source
stringclasses
4 values
task_type
stringclasses
1 value
in_source_id
stringlengths
0
138
problem
stringlengths
219
13.2k
gold_standard_solution
stringlengths
0
413k
problem_id
stringlengths
5
10
metadata
dict
verification_info
dict
code_contests
verifiable_code
1060_A. Phone Numbers
Solve the following coding problem using the programming language python: Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You...
```python n = int(input()) s = input() k = s.count("8") l = n - k if k <= l//10: print(k) else: while k > l//10: k -= 1 l += 1 print(min(k, l//10)) ```
vfc_28389
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "22\n0011223344556677889988\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1081_G. Mergesort Strikes Back
Solve the following coding problem using the programming language python: Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the fol...
vfc_28393
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 998244353\n", "output": "665496236\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 3 998244353\n", "output": "449209967\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
1101_A. Minimum Integer
Solve the following coding problem using the programming language python: You are given q queries in the following form: Given three integers l_i, r_i and d_i, find minimum positive integer x_i such that it is divisible by d_i and it does not belong to the segment [l_i, r_i]. Can you answer all the queries? Recall ...
```python n = int(input()) A = [] for i in range(n): A = A+[input().split()] for a in A: if int(a[2]) < int(a[0]) or int(a[2]) > int(a[1]): print(a[2]) else: print(int(a[2])*(int(a[1])//int(a[2])+1)) ```
vfc_28397
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5\n", "output": "6\n4\n1\n3\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1...
code_contests
verifiable_code
1129_D. Isolation
Solve the following coding problem using the programming language python: Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo ...
vfc_28401
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n1 2 3 4 5\n", "output": "16", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n1 1 2\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
1149_E. Election Promises
Solve the following coding problem using the programming language python: In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, the...
vfc_28405
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "output": "LOSE\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "output": "WIN\n0 0 0 \n", "type": ...
code_contests
verifiable_code
1170_E. Sliding Doors
Solve the following coding problem using the programming language python: Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive company (such as JetBrains), your company has a dress code. That's why you have already allocated a spacious room for your employees where they can ch...
vfc_28409
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 10\n2 3 2\n6\n1 5\n2 1 10\n2 2 9\n2 5 6\n3 1 7 8\n4 1 2 3 4\n", "output": "\nYES\nYES\nNO\nNO\nYES\nNO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1189_D1. Add on a Tree
Solve the following coding problem using the programming language python: Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems. You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 d...
```python m = int(input()) l = [0 for _ in range(m + 1)] for _ in range(m - 1): a,b = map(int, input().split()) l[a] += 1 l[b] += 1 if 2 in l: print("NO") else: print("YES") ```
vfc_28413
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2\n2 3\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
1208_D. Restore Permutation
Solve the following coding problem using the programming language python: An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not perm...
```python from sys import stdin,stdout class Tree(object): def __init__(self,n): self.tree=[0]*(4*n+10) self.b=[0]*(n+10) self.a=list(map(int,stdin.readline().split())) self.n=n def update(self,L,C,l,r,rt): if l==r: self.tree[rt]+=C return ...
vfc_28417
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 0 0\n", "output": "3 2 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 1 1 1 10\n", "output": "1 4 3 2 5 ", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
1227_D1. Optimal Subsequences (Easy Version)
Solve the following coding problem using the programming language python: This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems. You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by ...
```python # class SegmentTree(): # adapted from https://www.geeksforgeeks.org/segment-tree-efficient-implementation/ # def __init__(self,arr,func,initialRes=0): # self.f=func # self.N=len(arr) # self.tree=[0 for _ in range(2*self.N)] # self.initialRes=initialRes # for i in r...
vfc_28421
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10 20 10\n6\n1 1\n2 1\n2 2\n3 1\n3 2\n3 3\n", "output": "20\n10\n20\n10\n20\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 2 1 3 1 2 1\n9\n2 1\n2 2\n3 1\n3 2\n3 3\n1 1\n7 1\n7...
code_contests
verifiable_code
1269_E. K Integers
Solve the following coding problem using the programming language python: You are given a permutation p_1, p_2, …, p_n. In one move you can swap two adjacent values. You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be a...
```python n = int(input()) a = [0] + list(map(int, input().split())) pos, pb, ps = [[0] * (n + 1) for x in range(3)] def add(bit, i, val): while i <= n: bit[i] += val i += i & -i def sum(bit, i): res = 0 while i > 0: res += bit[i] i -= i & -i return res def find(bi...
vfc_28429
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "0 0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 4 3 2 1\n", "output": "0 1 3 6 10\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
1311_F. Moving Points
Solve the following coding problem using the programming language python: There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the ...
```python import bisect def getsum(tree , i): s = 0 i += 1 while i>0: s += tree[i] i -= i & (-i) return s def updatebit(tree , n , i , v): i+= 1 while i <= n: tree[i] += v i += i & (-i) n = int(input()) x = list(map(int , input().split())) v = list(map(int , in...
vfc_28437
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3 2\n-100 2 3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 1\n-3 0\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
1334_D. Minimum Euler Cycle
Solve the following coding problem using the programming language python: You are given a complete directed graph K_n with n vertices: each pair of vertices u ≠ v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly onc...
```python # -*- coding:utf-8 -*- """ created by shuangquan.huang at 2020/7/1 """ import collections import time import os import sys import bisect import heapq from typing import List def solve(n, l, r): # 1, 2, 1, 3, ..., 1, n # 2, 3, 2, 4, ..., 2, n # ... # n-1, n # 1 lo, hi = 1, n...
vfc_28441
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n", "output": "1 2 1 \n1 3 2 3 \n1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 2 3\n", "output": "2 1 \n", "type": "stdin...
code_contests
verifiable_code
1354_F. Summoning Minions
Solve the following coding problem using the programming language python: Polycarp plays a computer game. In this game, the players summon armies of magical minions, which then fight each other. Polycarp can summon n different minions. The initial power level of the i-th minion is a_i, and when it is summoned, all pr...
```python from sys import stdin, gettrace from heapq import nlargest if not gettrace(): def input(): return next(stdin)[:-1] # def input(): # return stdin.buffer.readline() INF = int(10E10) def main(): def solve(): n, k = map(int, input().split()) mm = [] for i in range(1...
vfc_28445
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 2\n5 3\n7 0\n5 0\n4 0\n10 0\n2 1\n10 100\n50 10\n5 5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "output": "8\n2 3 -3 4 -4 1 -1 5\n3\n1 -1 2\n5\n5 4 3 2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1374_E1. Reading Books (easy version)
Solve the following coding problem using the programming language python: Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have ...
```python import sys input=sys.stdin.readline f=lambda :list(map(int, input().strip('\n').split())) n, k=f() _11=[] _01=[] _10=[] for _ in range(n): t, a, b=f() if a and b: _11.append(t) elif a: _10.append(t) elif b: _01.append(t) _01.sort(); _10.sort(); _11.sort() for i in range(1, len(_01)): _01[i]+=_01[i...
vfc_28449
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 4\n7 1 1\n2 1 1\n4 0 1\n8 1 1\n1 0 1\n1 1 1\n1 0 1\n3 0 0\n", "output": "18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n6 0 0\n9 0 0\n1 0 1\n2 1 1\n5 1 0\n", "output": "8\...
code_contests
verifiable_code
1421_B. Putting Bricks in the Wall
Solve the following coding problem using the programming language python: Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roge...
```python l=[] for _ in range(int(input())): n=int(input()) a=[] for i in range(n): a.append(list(input())) if a[0][1]==a[1][0]: if a[n-1][n-2]==a[n-2][n-1]: if a[n-1][n-2]==a[0][1]: l.append("2") l.append("1 2") l.append("2 1")...
vfc_28457
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n", "output": "1\n3 4\n2\n1 2\n2 1\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\nS01\n111\n0...
code_contests
verifiable_code
143_A. Help Vasilisa the Wise 2
Solve the following coding problem using the programming language python: Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she ca...
```python inn = list(map(int, input().split(" "))) r1 = inn[0] r2 = inn[1] inn = list(map(int, input().split(" "))) c1 = inn[0] c2 = inn[1] inn = list(map(int, input().split(" "))) d1 = inn[0] d2 = inn[1] x = int((d1+c1-r2)/2) y = int(((2*r1)-d1-c1+r2)/2) a = int(((2*c1)-d1-c1+r2)/2) b = int((r2-(2*c1)+d1+c1)/2) if x ...
vfc_28461
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n3 4\n5 6\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11 10\n13 8\n5 16\n", "output": "4 7\n9 1\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
1466_F. Euclid's nightmare
Solve the following coding problem using the programming language python: You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. In his bad dream Euclid has a set S of n m-dimensional vectors o...
```python import sys input = sys.stdin.buffer.readline def _find(s, u): p = [] while s[u] != u: p.append(u) u = s[u] for v in p: s[v] = u return u def _union(s, u, v): su, sv = _find(s, u), _find(s, v) if su != sv: s[su] = sv return su != sv n, m = map(int, input().split()...
vfc_28465
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 1\n1 2\n2 2 1\n", "output": "\n4 2\n1 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n2 1 2\n1 3\n1 4\n", "output": "\n8 3\n1 2 3 \n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1490_G. Old Floppy Drive
Solve the following coding problem using the programming language python: Polycarp was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with n integers written on it. Polycarp wrote the numbers from the disk into the a array. It turned out that the drive works accord...
```python def findIndexGE(prefixSumsMax,startSum,query): n=len(prefixSumsMax) b=n i=-1 while b>0: while i+b<n and startSum+prefixSumsMax[i+b]<query: i+=b b//=2 i+=1 return i def main(): t=int(input()) allans=[] for _ in range(t): n,m=readInt...
vfc_28469
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3\n1 -3 4\n1 5 2\n2 2\n-2 0\n1 2\n2 2\n0 1\n1 2\n", "output": "\n0 6 2 \n-1 -1 \n1 3 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1513_C. Add One
Solve the following coding problem using the programming language python: You are given an integer n. You have to apply m operations to it. In a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 after applying the operation...
```python from os import path import sys,time from math import ceil, floor,gcd,log,log2 ,factorial from collections import defaultdict ,Counter , OrderedDict , deque from heapq import heapify , heappush , heappop from bisect import * # from functools import reduce from operator import mul from itertools import permutat...
vfc_28473
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1912 1\n5 6\n999 1\n88 2\n12 100\n", "output": "\n5\n2\n6\n4\n2115\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n90 94\n26 25\n64 84\n14 6\n20 96\n", "output": "1842\n12\n101...
code_contests
verifiable_code
1540_C1. Converging Array (Easy Version)
Solve the following coding problem using the programming language python: This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved. There is a process that takes place on arrays a and b of length n and length n-1 res...
```python def putin(): return map(int, input().split()) def sol(): n = int(input()) C = list(putin()) B = list(putin()) q = int(input()) x = int(input()) min_arr = [x] min_part_sums = [x] part_sums = [C[0]] for i in range(1, n): part_sums.append(part_sums[-1] + C[i]) ...
vfc_28477
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3 4\n2 1\n1\n-1\n", "output": "56\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n95 54 23 27 51 58 94 34 29 95 53 53 8 5 64 32 17 62 14 37 26 95 27 85 94 37 85 72 88 69 43 9 60 ...
code_contests
verifiable_code
168_A. Wizards and Demonstration
Solve the following coding problem using the programming language python: Some country is populated by wizards. They want to organize a demonstration. There are n people living in the city, x of them are the wizards who will surely go to the demonstration. Other city people (n - x people) do not support the wizards a...
```python num,wiz,per = map(int,input().split()) k = 0 while (k+wiz)/num*100 < per: k += 1 print(k) ```
vfc_28481
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000 352 146\n", "output": "1108\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 1 14\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
260_B. Ancient Prophesy
Solve the following coding problem using the programming language python: A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the P...
```python s=input() n=len(s) l=list("0987654321") cnt={} for i in range(n-9): t=s[i:i+10] if t[0] in l and t[1] in l and t[2]=="-" and t[3] in l and t[4] in l and t[5]=="-" and t[6] in l and t[7] in l and t[8] in l and t[9] in l: if 2013<=int(t[6:11])<=2015 and 1<=int(t[3:5])<=12: if int(t[3:5]) in [1,3,...
vfc_28497
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "777-444---21-12-2013-12-2013-12-2013---444-777\n", "output": "13-12-2013\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12-12-201312-12-201312-12-201313--12-201313--12-201313--12-201313--...
code_contests
verifiable_code
284_B. Cows and Poker Game
Solve the following coding problem using the programming language python: There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED...
```python #!/bin/python # -*- coding: utf-8 -*- n = int(input()) s = input() print(int(s.count('I') == 1) if 'I' in s else s.count('A')) ```
vfc_28501
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nAFI\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\nAFFAAA\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\...
code_contests
verifiable_code
309_B. Context Advertising
Solve the following coding problem using the programming language python: Advertising has become part of our routine. And now, in the era of progressive technologies, we need your ideas to make advertising better! In this problem we'll look at a simplified version of context advertising. You've got a text, consisting...
vfc_28505
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 4 12\nthis is a sample text for croc final round\n", "output": "this is a\nsample text\nfor croc\nfinal round\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 1 9\nthis is a sample text...
code_contests
verifiable_code
331_E2. Deja Vu
Solve the following coding problem using the programming language python: Everybody knows that we have been living in the Matrix for a long time. And in the new seventh Matrix the world is ruled by beavers. So let's take beaver Neo. Neo has so-called "deja vu" outbursts when he gets visions of events in some places h...
vfc_28509
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 6\n1 2 2 1 2\n2 3 1 3\n3 4 2 4 5\n4 5 0\n5 3 1 3\n6 1 1 6\n", "output": "1\n2\n1\n1\n2\n1\n1\n2\n1\n1\n2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 6\n1 2 2 1 2\n2 3 1 3\n3 4 2...
code_contests
verifiable_code
354_E. Lucky Number Representation
Solve the following coding problem using the programming language python: We know that lucky digits are digits 4 and 7, however Vasya's got another favorite digit 0 and he assumes it also is lucky! Lucky numbers are such non-negative integers whose decimal record only contains lucky digits. For example, numbers 0, 47,...
vfc_28513
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n42\n17\n444\n7\n51\n", "output": " 7 7 ...
code_contests
verifiable_code
379_A. New Year Candles
Solve the following coding problem using the programming language python: Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went o...
```python a, b = map(int, input().split()) c, s = a, 0 while a >= b: s += a // b a = (a // b) + (a % b) print(s + c) ```
vfc_28517
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n",...
code_contests
verifiable_code
425_D. Sereja and Squares
Solve the following coding problem using the programming language python: Sereja has painted n distinct points on the plane. The coordinates of each point are integers. Now he is wondering: how many squares are there with sides parallel to the coordinate axes and with points painted in all its four vertexes? Help him,...
vfc_28525
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 0\n0 2\n2 0\n2 2\n1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n0 0\n1 1\n2 2\n0 1\n1 0\n0 2\n2 0\n1 2\n2 1\n", "output": "5\n", "type": "stdin_s...
code_contests
verifiable_code
44_B. Cola
Solve the following coding problem using the programming language python: To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, ...
```python def nik(rudy,x,y,z,cot): for i in range(z+1): for j in range(y+1): t = rudy - i*2 -j if t>=0 and x*0.5 >= t: cot+=1 return cot rudy, x, y, z = list(map(int,input().split())) cot = 0 print(nik(rudy,x,y,z,cot)) ```
vfc_28529
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 5 5 5\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 0 0 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
470_F. Pairwise Sums
Solve the following coding problem using the programming language python: You are given an array of n integers. For each element output the sum of itself and the previous element. For the first element, output the sum of the first and the last elements of the array. Input The input consists of a single line of space...
vfc_28533
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 2 3 4\n", "output": "5 3 5 7 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
494_D. Birthday
Solve the following coding problem using the programming language python: Ali is Hamed's little brother and tomorrow is his birthday. Hamed wants his brother to earn his gift so he gave him a hard programming problem and told him if he can successfully solve it, he'll get him a brand new laptop. Ali is not yet a very ...
vfc_28537
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 2 100\n1 3 20\n2 4 2\n2 5 1\n3 6 1\n3 7 2\n6 8 5\n6\n1 8\n2 3\n5 8\n2 6\n4 7\n6 1\n", "output": "999968753\n49796\n999961271\n999991235\n999958569\n45130\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
519_B. A and B and Compilation Errors
Solve the following coding problem using the programming language python: A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them ...
```python n = int(input()) a_sum = sum(map(int, input().split())) b_sum = sum(map(int, input().split())) c_sum = sum(map(int, input().split())) print(a_sum - b_sum) print(b_sum - c_sum) ```
vfc_28541
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5\n", "output": "1\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 5 8 123 7\n123 7 5 1\n5 1 7\n", "output": "8\n123\n", "type": "stdin...
code_contests
verifiable_code
545_C. Woodcutters
Solve the following coding problem using the programming language python: Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below. There are n tre...
```python ll=lambda:map(int,input().split()) t=lambda:int(input()) ss=lambda:input() #from math import log10 ,log2,ceil,factorial as f,gcd #from itertools import combinations_with_replacement as cs #from functools import reduce #from bisect import bisect_right as br #from collections import Counter n=t() x,h=[],[] fo...
vfc_28545
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2\n2 1\n5 10\n10 9\n20 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2\n2 1\n5 10\n10 9\n19 1\n", "output": "3\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
571_E. Geometric Progressions
Solve the following coding problem using the programming language python: Geometric progression with the first element a and common ratio b is a sequence of numbers a, ab, ab2, ab3, .... You are given n integer geometric progressions. Your task is to find the smallest integer x, that is the element of all the given p...
```python def primes(n): size = n/3 + (n%6==2) plist = size * [True] plist[0] = False for i in xrange(int(n**0.5)/3+1): if plist[i]: k=3*i+1|1 for j in xrange((k*k)/3,size,2*k): plist[j] = False for j in xrange((k*k+4*k-2*k*(i&1))/3,size,2*k): plist[j] = False ans = [2,3] for i in xrange(size)...
vfc_28549
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n3 3\n", "output": " -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2\n4 1\n", "output": " ...
code_contests
verifiable_code
593_C. Beautiful Function
Solve the following coding problem using the programming language python: Every day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of points, such that there ...
```python def f(x): if x == n: return "0" if x == 0: return "(" + str(X[0]) + "+" + f(1) + ")" ss = "(abs((t-" + str(x-1) + "))-abs((t-" + str(x) + ")))" tmp = (X[x] - X[x - 1]) // 2 re = (X[x] - X[x - 1]) - 2 * tmp X[x] -= re ...
vfc_28553
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 10 4\n10 0 4\n20 10 4\n", "output": "(((0*((1-abs((t-0)))+abs((abs((t-0))-1))))+(5*((1-abs((t-1)))+abs((abs((t-1))-1)))))+(10*((1-abs((t-2)))+abs((abs((t-2))-1)))))\n(((5*((1-abs((t-0)))+abs((abs((t-0))-1))))+(0*((1-abs(...
code_contests
verifiable_code
615_A. Bulbs
Solve the following coding problem using the programming language python: Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns o...
```python import math nm = input().split() n = int(nm[0]) m = int(nm[1]) lis = [ 0 for i in range(m+1)] for _ in range(n) : inp = list(map(int, input().split())) inp.pop(0) for i in inp: lis[i]=1 prev = i if sum(lis)==m: print("YES") else: print("NO") ```
vfc_28557
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n2 1 4\n3 1 3 1\n1 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 1\n1 2\n1 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
663_A. Rebus
Solve the following coding problem using the programming language python: You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n,...
```python s = input().split() plus = 1 minus = 0 for ch in s: if (ch == '+') : plus += 1 if (ch == '-') : minus += 1 n = int(s[len(s) - 1]) maxx = plus * n - 1 * minus minn = plus - n * minus now = n - (plus - minus) if (n>maxx or n<minn): print("Impossible") else: pre = '+' print("Possible") for ...
vfc_28565
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "? - ? = 1\n", "output": "Impossible\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "? + ? - ? + ? + ? = 42\n", "output": "Possible\n40 + 1 - 1 + 1 + 1 = 42\n", "type": "stdin_s...
code_contests
verifiable_code
687_D. Dividing Kingdom II
Solve the following coding problem using the programming language python: Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. The great kingdom con...
vfc_28569
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 6 5\n5 4 86\n5 1 0\n1 3 38\n2 1 33\n2 4 28\n2 3 40\n3 5\n2 6\n1 3\n2 3\n1 6\n", "output": "-1\n33\n-1\n-1\n33\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 9 4\n4 1 46\n1 3 29\n3 2 5...
code_contests
verifiable_code
70_C. Lucky Tickets
Solve the following coding problem using the programming language python: In Walrusland public transport tickets are characterized by two integers: by the number of the series and by the number of the ticket in the series. Let the series number be represented by a and the ticket number — by b, then a ticket is describ...
```python from collections import defaultdict from fractions import gcd (max_x, max_y, w) = map( int, raw_input().split() ) def Pair(x): inv_x = 0 val = x while val: inv_x = inv_x * 10 + val % 10 val /= 10 uc = gcd( x, inv_x ) return ( x/uc, inv_x/uc ) def Reverse(P): return (...
vfc_28573
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 18 1000\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "132 10 35\n", "output": "5 7\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
730_J. Bottles
Solve the following coding problem using the programming language python: Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≤ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has ...
```python f = lambda: list(map(int, input().split())) n = int(input()) a, b = f(), f() d = [[None] * 10001 for i in range(n)] def g(i, s): if s <= 0: return (0, s) if i == n: return (1e7, 0) if not d[i][s]: x, y = g(i + 1, s - b[i]) d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i])) ...
vfc_28577
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1\n100 100\n", "output": "1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10 30 5 6 24\n10 41 7 8 24\n", "output": "3 11\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
754_E. Dasha and cyclic table
Solve the following coding problem using the programming language python: Dasha is fond of challenging puzzles: Rubik's Cube 3 × 3 × 3, 4 × 4 × 4, 5 × 5 × 5 and so on. This time she has a cyclic table of size n × m, and each cell of the table contains a lowercase English letter. Each cell has coordinates (i, j) (0 ≤ i...
vfc_28581
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 7\nqcezchs\nhhedywq\nwikywqy\nqckrqzt\nbqexcxz\n3 2\n??\nyw\n?q\n", "output": "0000100\n0001001\n0000000\n0000000\n0000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 6\nibrgxl\nxq...
code_contests
verifiable_code
776_A. A Serial Killer
Solve the following coding problem using the programming language python: Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two po...
```python def main(): l = input().split() print(*l) for _ in range(int(input())): a, b = input().split() l[a == l[1]] = b print(*l) if __name__ == '__main__': main() ```
vfc_28585
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "icm codeforces\n1\ncodeforces technex\n", "output": "icm codeforces\nicm technex\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ross rachel\n4\nross joey\nrachel phoebe\nphoebe monica\nmo...
code_contests
verifiable_code
7_B. Memory Manager
Solve the following coding problem using the programming language python: There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manage...
```python t, m = map(int, input().split()) disk = [False] * m req = 0 for i in range(t): inp = input().split() if inp[0][0] == "a": c = 0 inp[1] = int(inp[1]) for j in range(m): if disk[j]: c = 0 else: c += 1 if c == inp...
vfc_28589
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 10\nalloc 5\nalloc 3\nerase 1\nalloc 6\ndefragment\nalloc 6\n", "output": "1\n2\nNULL\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\nerase -1\nerase 0\nerase -2147483648\n", ...
code_contests
verifiable_code
820_D. Mister B and PR Shifts
Solve the following coding problem using the programming language python: Some time ago Mister B detected a strange signal from the space, which he started to study. After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some ...
```python from sys import stdin def main(): n = int(stdin.readline()) a = list(map(int, stdin.readline().split())) inf = [0] * (n + 1) curr = 0 d = 0 for i in range(n): curr += abs(i + 1 - a[i]) if a[i] > i + 1: d += 1 inf[a[i] - i - 1] += 1 elif a...
vfc_28593
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 2 1\n", "output": "2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n", "output": "0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
868_A. Bark to Unlock
Solve the following coding problem using the programming language python: As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lo...
```python one=input() num=int(input()) twos=[] for i in range(num): twos.append(input()) if (one in twos) or (one[::-1] in twos): print("YES") else: flag1,flag2=False,False for i in range(num): if twos[i][0]==one[1]: flag1=True if twos[i][1]==one[0]: flag2=True if(flag1 and flag2): p...
vfc_28601
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ah\n1\nha\n", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "ya\n4\nah\noy\nto\nha\n", "output": "YES", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
893_D. Credit Card
Solve the following coding problem using the programming language python: Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of i-th day a transaction ai occurs. If ai > 0, then ai bourles are deposited t...
```python #Bhargey Mehta (Sophomore) #DA-IICT, Gandhinagar import sys, math, queue, bisect #sys.stdin = open("input.txt", "r") MOD = 10**9+7 sys.setrecursionlimit(1000000) n, d = map(int, input().split()) a = list(map(int, input().split())) p = [0 for i in range(n)] for i in range(n): p[i] = p[i-1]+a[i] mx = [-1 f...
vfc_28605
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 10\n-5 0 10 -11 0\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 10\n-1 5 0 -5 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
915_A. Garden
Solve the following coding problem using the programming language python: Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any ...
```python def is_prime(a): return all(a % i for i in range(2, a)) n, k = map(int, input().split()) l = [int(x) for x in input().split()] if is_prime(k): if k in l: print(1) else: print(k) else: ll = [] for i in range(len(l)): if k % l[i] == 0: ll.append(l[i]) ...
vfc_28609
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6\n2 3 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7\n1 2 3 4 5 6\n", "output": "7\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
938_B. Run For Your Prize
Solve the following coding problem using the programming language python: You and your friend are participating in a TV show "Run For Your Prize". At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your...
```python input() a=list(map(int,input().split())) ans=0 for x in a: z=min(x-1,1000000-x) ans=max(z,ans) print(ans) ```
vfc_28613
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 999995\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 3 9\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
963_B. Destruction of a Tree
Solve the following coding problem using the programming language python: You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges). A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges c...
```python from collections import defaultdict,deque import sys import bisect import math input=sys.stdin.readline mod=1000000007 def bfs(root,count): q=deque([root]) vis.add(root) while q: vertex=q.popleft() for child in graph[vertex]: if ans[child]==0: ans[child...
vfc_28617
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 1 2 1 2\n", "output": "YES\n1\n2\n3\n5\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 1 2 3\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
990_E. Post Lamps
Solve the following coding problem using the programming language python: Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer num...
```python import sys from array import array n, m, k = map(int, input().split()) block = list(map(int, input().split())) a = [0] + list(map(int, input().split())) if block and block[0] == 0: print(-1) exit() prev = array('i', list(range(n))) for x in block: prev[x] = -1 for i in range(1, n): if prev...
vfc_28621
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 1 5\n0\n3 3 3 3 3\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
appu-and-sugarcane-farm
Solve the following coding problem using the programming language python: As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu s...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' num_of_sugarcanes = int(raw_input()) list_of_sugarcanes = map(int,raw_input().split()) max_of_sugarcanes = max(list_of_sugarcanes) def xyz (list_of_sugarcanes, max_sugar): ...
vfc_28625
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 23\n\nSAMPLE", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "47\n169884146 730277703 8645016 732791141 331583052 25104065 895622218 478600214 924154067 813310590 38984...
code_contests
verifiable_code
chandu-and-his-girlfriend-returns
Solve the following coding problem using the programming language python: In the previous problem Chandu bought some unsorted arrays and sorted them (in non-increasing order). Now, he has many sorted arrays to give to his girlfriend. But, the number of sorted arrays are very large so Chandu decided to merge two sorted...
```python def merge(a,b): c=[] l1=len(a) l2=len(b) i=0 j=0 while i<l1 and j<l2: if a[i]>b[j]: c.append(a[i]) i+=1 else: c.append(b[j]) j+=1 while i<l1: c.append(a[i]) i+=1 while j<l2: c.append(b[j]) ...
vfc_28629
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 5\n9 7 5 3\n8 6 4 2 0\n\nSAMPLE", "output": "9 8 7 6 5 4 3 2 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n439 79\n991800654 985952720 985538124 983840231 983710443 982377023 9...
code_contests
verifiable_code
discover-the-monk
Solve the following coding problem using the programming language python: You are given an array A of size N, and Q queries to deal with. For each query, you are given an integer X, and you're supposed to find out if X is present in the array A or not. Input: The first line contains two integers, N and Q, denoting th...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' line1 = raw_input() arr_inp=[] for j in line1.split(' '): arr_inp.append(int(j)) line2 = raw_input() elemnt_array = {} for i in line2.split(' '): elemnt_array[int(i)] = 1 #...
vfc_28633
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 10\n50 40 30 20 10\n10\n20\n30\n40\n50\n60\n70\n80\n90\n100\n\nSAMPLE", "output": "YES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 10000\n...
code_contests
verifiable_code
golu-and-coins-1
Solve the following coding problem using the programming language python: Golu is given a task of clearing coins fallen down on floor. Naughty being his modus operandi, he thought of playing a game while clearing coins. He arranges the coins like an M X N matrix with random heads (1) and tails (0). In every move, he...
```python M,N=map(int,raw_input().split()) L=[] for i in range(M): L.append(map(int,raw_input().split())) if M+N==4 and (L==[[0,1],[1,1]] or L==[[1,0],[1,1]] or L==[[1,1],[1,0]] or L==[[1,1],[0,1]]) or L==[[1,0],[0,0]] or L==[[0,1],[0,0]] or L==[[0,0],[1,0]] or L==[[0,0],[0,1]]: print "-1" else: List=[...
vfc_28637
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n0 0 1 1\n0 0 1 1\n\nSAMPLE", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n1 1 1\n0 1 0", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
list-sort
Solve the following coding problem using the programming language python: A certain business maintains a list of all its customers' names. The list is arranged in order of importance, with the last customer in the list being the most important. Now, he want to create a new list sorted alphabetically according to custo...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' def fun(l): a=[] b=l[::-1] for j in range(len(b)): s=b[j].split(" ") if(len(s)>=2): a.append([s[-1].lower(),j]) else: a.append([s[0].lower(),j]) a.sort(ke...
vfc_28641
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\nTom Jones\nADAMS\nBOB ADAMS\nTom Jones\nSTEVE jONeS\n3\nTrudy\nTrudy\nTRUDY\n\nSAMPLE", "output": "BOB ADAMS\nADAMS\nSTEVE jONeS\nTom Jones\nTom Jones\nTRUDY\nTrudy\nTrudy\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
monks-choice-of-numbers-1
Solve the following coding problem using the programming language python: Monk loves cakes! He visits the Binary Bakery to buy some of his favorite cheesecakes. The owner of the bakery, Bob, is a clever man. He does not want Monk to finish all his cheesecakes. Hence, he plays a game. The Monk is given N numbers and ...
```python def count(num): tmp=num cnt=0 while(tmp!=0): ...
vfc_28645
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2\n6 1 2 0\n\nSAMPLE", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1000 910\n94625 95469 92038 95916 93405 95533 97004 92469 99853 94992 90361 99819 93294 97195 9...
code_contests
verifiable_code
roys-life-cycle
Solve the following coding problem using the programming language python: Roy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing but eat, sleep and code. ...
```python def main(): n = int(raw_input()) strings = [] string_streak = 0 total_streak = 0 for i in range(n): temp_string = raw_input() strings.append(temp_string) for string in strings: temp_string_streak = 0 temp_streak = 0 for char in string: if char == "E" or char == "S": if temp_streak > te...
vfc_28653
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nSSSSEEEECCCCEECCCC\nCCCCCSSSSEEECCCCSS\nSSSSSEEESSCCCCCCCS\nEESSSSCCCCCCSSEEEESAMPLE", "output": "7 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nSSSSEEEECCCCEECCCC\nCCCCCSSSSEEE...
code_contests
verifiable_code
subtraction-game-theory-1
Solve the following coding problem using the programming language python: Problem: Rani and Nandu decide to play a number game. Both play alternately, Rani playing the first move. In each of their moves, they can subtract a maximum of k and a minimun of 1 from n ( ie.each of them must subtract from n, any natural n...
```python for _ in xrange(input()): flag=True n,k=map(int,raw_input().split()) print "Nandu" if not (n-1)%(k+1) else "Rani" ```
vfc_28657
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 1\n3 2\n\nSAMPLE", "output": "Rani\nRani\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "72\n909 34\n420 51\n621 76\n65 48\n82 41\n665 53\n43 33\n309 21\n942 51\n156 13\n997 11\n753 2...
code_contests
verifiable_code
vowel
Solve the following coding problem using the programming language python: Rakesh have learn about vowel in school and is given an assignment by his teacher in which he has to list all vowel together from the word's given to him,but he is busy in watching cricket match and want your help to solve the assignment. 5 vow...
```python b="AEIOUaeiou" t=input() while t: t-=1 c="" a=raw_input() for x in a: if x in b: c+=x if (c==""): print "No" else: print c ```
vfc_28661
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nSdfgAe\nOut\nGet\n\nSAMPLE", "output": "Ae\nOu\ne\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nfdSgAe\nOut\nGet\n\nSAMPLE", "output": "Ae\nOu\ne\n", "type": "stdin_std...
code_contests
verifiable_code
p00035 Is it Convex?
Solve the following coding problem using the programming language python: 4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coor...
```python def gai(a,b,c,d): S = a*d - b*c return(S) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,input().split(",")) A1,A2,B1,B2,C1,C2,D1,D2 = x1,y1,x2,y2,x3,y3,xp,yp if gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) < 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) < 0 and gai(x3...
vfc_28705
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0", "output": "YES\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.1\n0.0,0.0,3.0,0.0,1.0,1.0...
code_contests
verifiable_code
p00167 Bubble Sort
Solve the following coding problem using the programming language python: Sorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of "sorting the elements of an array of integer values ​​in ascending order" is alignment. <ima...
```python def bubble_sort(n): arr = [int(input()) for _ in range(n)] cnt = 0 for i in range(n): for j in range(n-1, i, -1): if arr[j] < arr[j-1]: arr[j], arr[j-1] = arr[j-1], arr[j] cnt += 1 return cnt while True: n = int(input()) if n == 0: b...
vfc_28709
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5\n3\n2\n1\n4\n6\n1\n2\n3\n4\n5\n6\n3\n3\n2\n1\n0", "output": "7\n0\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5\n3\n2\n1\n7\n6\n1\n2\n3\n4\n5\n6\n3\n3\n2\n1\n0", "output...
code_contests
verifiable_code
p00493 Zig-Zag Numbers
Solve the following coding problem using the programming language python: problem If you write a positive integer in decimal notation (without leading 0) and look at the digit numbers in order, when the number increases and decreases alternately, the number is "zigza". Let's call it. For example, 2947 is a zigzag num...
vfc_28717
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n200\n5", "output": "13", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n303\n5", "output": "26\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
p00680 KND Factory
Solve the following coding problem using the programming language python: Problem KND is a student programmer at the University of Aizu. There are N towns around his town. He loves cream so he built a factory in a town to eat cream every day. The factory produces F liters of fresh cream daily. Every time you carry th...
vfc_28721
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 0 2 5\n1 1 1 6\n3 2 1 10\n1 -2 3 6\n2\n1 2\n3 3\n1\n2\n3\n0\n3 0 2 5\n1 1 1 6\n3 2 1 10\n1 -2 3 6\n2\n1 2\n2 2\n1\n2\n2\n0\n10 2 7 20\n8 9 -5 6 -9 5 1 0 4 9 4\n3 -1 -8 0 -5 4 3 0 -3 2 4\n-4 5 8 -4 1 -8 -6 3 3 5 -7\n-7 0 2 5 8 ...
code_contests
verifiable_code
p00953 Animal Companion in Maze
Solve the following coding problem using the programming language python: Example Input 2 1 1 2 2 Output 1 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_28729
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n1 2 2", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01086 Short Phrase
Solve the following coding problem using the programming language python: Short Phrase A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition: > (The Condition for ...
```python tanku = [5, 7, 5, 7, 7] while True: n = int(input()) if n==0: break w = [len(input()) for i in range(n)] ans = 0 for i in range(n): sum = 0 k = 0 for j in range(i, n): sum += w[j] if sum == tanku[k]: sum = 0 k += 1 if k==5: ans = i+1 ...
vfc_28733
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\ndo\nthe\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz...
code_contests
verifiable_code
p01356 Nearest Station
Solve the following coding problem using the programming language python: I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n − 1, and you can use the k ticket to go to p⋅ak + q⋅bk station. Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current ...
```python def solve(): n,m,a,b,p,q = map(int,input().split()) if a==1 and b==1: if (p+q)*n <= m: return m - (p+q)*n else: k = m//(p+q) return min(m-k*(p+q),(k+1)*(p+q)-m) else: ans = m for i in range(min(n-1,40),-1,-1): f = p*(a...
vfc_28741
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 1 2 3 4 5", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 200 2 3 4 5", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
p01538 Kakezan
Solve the following coding problem using the programming language python: Taro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or equal to 0. (Processing ...
```python "かけざん" "最大のものを取得して、一桁になるまでに操作を行う回数を答える" def kakezan(n): ret = 0 str_n = str(n) digit_amount = len(str_n) for i in range(digit_amount-1): # print(str_n[:i+1]) # print(str_n[i+1:]) # print("") ret = max(ret, int(str_n[:i+1])*int(str_n[i+1:])) return ret Q...
vfc_28745
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n999999\n1000000", "output": "12\n1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01694 Step Aerobics
Solve the following coding problem using the programming language python: Step up and down Kazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and requires a high degree of a...
```python while True: N = int(input()) if N == 0: break a = input() b = a.split() x = 0 for i in range(N//2): if b[2 * i] == 'lu' and b[(2 * i)+1] == 'ru': x += 1 if b[2 * i] == 'ru' and b[(2 * i)+1] == 'lu': x += 1 if b[2 * i] == 'ld' a...
vfc_28749
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nlu ru ld rd\n4\nlu ld lu ru\n1\nlu\n10\nru lu ld rd ru rd ru lu rd ld\n0", "output": "2\n1\n0\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nlu ru ld rd\n4\nlu ld lu ru\n0\nlu\n10\...
code_contests
verifiable_code
p01838 Optimal Tournament
Solve the following coding problem using the programming language python: Example Input 4 3 1 3 4 7 Output 6 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_28753
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n1 3 4 7", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n1 3 2 7", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
p01974 Pigeonhole principle
Solve the following coding problem using the programming language python: problem Given $ N $ different natural numbers $ a_i $. I decided to make a pair by choosing a different natural number from the given natural numbers. Output one pair that can be created with a value difference that is a multiple of $ N -1 $. ...
```python N = int(input()) a = [int(x) for x in input().split()] x, y = -1, -1 for i in range(N) : for j in range(N) : if i != j and abs(a[i] - a[j]) % (N - 1) == 0 : x, y = i, j print(a[x], a[y]) ```
vfc_28757
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 4 7 10", "output": "2 10", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02260 Selection Sort
Solve the following coding problem using the programming language python: Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 ...
```python n = int(input()) s = list(map(int, input().split())) indexMin = 0 count = 0 for start in range(n): indexMin = s[start:].index(min(s[start:])) + start s[start], s[indexMin] = s[indexMin], s[start] if start != indexMin: count+=1 print(*s) print(count) ```
vfc_28765
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5 2 4 6 1 3", "output": "1 2 3 4 5 6\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n5 6 4 2 1 3", "output": "1 2 3 4 5 6\n4", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p02408 Finding Missing Cards
Solve the following coding problem using the programming language python: Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond. Note 解説 Input In the fi...
```python n=int(input()) cs = [ (s,k) for s in ['S','H','C','D'] for k in range(1,14) ] for _ in range(n): s,k=input().split() cs.remove((s,int(k))) for (s, k) in cs: print(s, k) ```
vfc_28769
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD...
code_contests
verifiable_code
cdva1502
Solve the following coding problem using the programming language python: Your task is very simple. Given K numbers A1, A2, ..., AK. You need to find f(N) mod max(A1, A2, ..., AK) . f(N)=N! Input First line contains single integer T denoting the number of test cases.. First line of each test case contains two integ...
```python from math import* for i in range (input()): num ,k = map(int,raw_input().split()) a = factorial(num) arr = map(int,raw_input().split()) maxi = max(arr) print a%maxi ```
vfc_28773
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 3\n200 6 9", "output": "120", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5 3\n200 12 9", "output": "120\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
dbyz15t
Solve the following coding problem using the programming language python: Problem Desrcription Shil likes to play with trees a lot.He is playing with an undirected tree containing N nodes.He wants to find out total number of unordered triplets (A,B,C) such that A is not connected to B, B is not connected to C and A i...
```python N=int(input()) D=[0]*N for i in range(N-1): a,b=map(int,raw_input().split()) a-=1;b-=1; D[a]+=1 D[b]+=1 ans=N*(N-1)*(N-2) ans/=6 ans-=(N-1)*(N-2) for i in D: if i>=2: ans+=(i*(i-1))/2 print ans ```
vfc_28777
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2\n1 3\n3 4\n2 5", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
ig01
Solve the following coding problem using the programming language python: This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A'...
```python testcase = raw_input(); tc = int(testcase) while (tc > 0): flames = "FLAMES" #flames[0] = 'X' name1=list((raw_input()).replace(' ','')) name2=list((raw_input()).replace(' ','')) #ht = {} count =0 count1 = 0 i=0 while(i < len(name1)): j=0 while(j < len(name2)): if(name1[i] == nam...
vfc_28781
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nSHILPA\nAAMIR\nMATT\nDENISE", "output": "ENEMIES\nLOVE", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
muffins3
Solve the following coding problem using the programming language python: Now that Chef has finished baking and frosting his cupcakes, it's time to package them. Chef has N cupcakes, and needs to decide how many cupcakes to place in each package. Each package must contain the same number of cupcakes. Chef will choose ...
```python t = int(raw_input()) for ii in range(t): i = int(raw_input()) if i == 1 : print 1 elif i == 2 : print 2 elif i%2 == 0 : print (i/2 +1) else : print ( (i+1)/2) ```
vfc_28785
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n5", "output": "2\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n7", "output": "2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
rrcode
Solve the following coding problem using the programming language python: You are given a simple code of a function and you would like to know what it will return. F(N, K, Answer, Operator, A[N]) returns int; begin for iK do for jN do AnswerAnswer operator Aj) return Answer end...
```python for q in range(int(raw_input())): n,k,ans=[int(u) for u in raw_input().split()] arr=[int(u) for u in raw_input().split()] op=raw_input().strip() if(k==0): print ans continue if(op=='OR'): for i in arr: ans=ans|i elif(op=='AND'): f...
vfc_28789
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 1 0\n1 2 3\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n1 2 3\nOR", "output": "0\n0\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 1 0\n1 2 6\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n1 2 3\nOR", ...
code_contests
verifiable_code
walk
Solve the following coding problem using the programming language python: Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve...
```python for _ in range(input()): n= int(raw_input()) att = map(int,raw_input().split()) ans = [] for i in range(n): ans.append(att[i]+i) print max(ans) ```
vfc_28793
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n6 5 4 3 2\n5\n3 4 3 1 1", "output": "6\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n6 5 4 3 2\n5\n3 4 6 1 1", "output": "6\n8\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
101_C. Vectors
Solve the following coding problem using the programming language python: At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А: * Turn the vector by 90 degrees clockwise. * Add to the vector a certain ve...
```python import math def ok(xa, ya): x, y = xb - xa, yb - ya d = math.gcd(abs(xc), abs(yc)) if xc == 0 and yc == 0: return x == 0 and y == 0 if xc == 0: return x % yc == 0 and y % yc == 0 if yc == 0: return x % xc == 0 and y % xc == 0 if (x % d != 0) or (y % d != 0): ...
vfc_28797
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n1 1\n1 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0\n1 1\n0 1\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1043_A. Elections
Solve the following coding problem using the programming language python: Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person ...
```python import math n = int(input()) l= list(map(int,input().split())) s = 2*sum(l) z= s/n p = max(l) an = int(z+1) print(max(p,an)) ```
vfc_28801
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 2 3 2 2\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 1 5 1\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1065_F. Up and Down the Tree
Solve the following coding problem using the programming language python: You are given a tree with n vertices; its root is vertex 1. Also there is a token, initially placed in the root. You can move the token to other vertices. Let's assume current vertex of token is v, then you make any of the following two possible...
vfc_28805
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 2\n1 1 2 3 4 5 5\n", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1088_D. Ehab and another another xor problem
Solve the following coding problem using the programming language python: This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with: * 1 if a ⊕ c>b ⊕ d. * 0 if a ⊕ c=b ⊕ d. * -1 if a ⊕ c<b ⊕ d. Operation...
vfc_28809
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n-1\n0", "output": "? 0 0\n? 536870912 0\n? 0 536870912\n? 805306368 536870912\n? 536870912 805306368\n? 939524096 536870912\n? 805306368 671088640\n? 872415232 671088640\n? 805306368 738197504\n? 838860800 738197504\n? 805...
code_contests
verifiable_code
1107_D. Compression
Solve the following coding problem using the programming language python: You are given a binary matrix A of size n × n. Let's denote an x-compression of the given matrix as a matrix B of size n/x × n/x such that for every i ∈ [1, n], j ∈ [1, n] the condition A[i][j] = B[⌈ i/x ⌉][⌈ j/x ⌉] is met. Obviously, x-compres...
```python # ---------------------------iye ha aam zindegi--------------------------------------------- import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction mod = 10 ** 9 + 7 mod1 = 998244353 # ------------------------------warmup------------------------...
vfc_28813
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\nE7\nE7\nE7\n00\n00\nE7\nE7\nE7\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n7\nF\nF\nF\n", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1136_D. Nastya Is Buying Lunch
Solve the following coding problem using the programming language python: At the big break Nastya came to the school dining room. There are n pupils in the school, numbered from 1 to n. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the que...
```python import sys import math import bisect from math import sqrt def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) mod = int(1e9)+...
vfc_28817
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n3 1 5 4 2\n5 2\n5 4\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1176_F. Destroy it!
Solve the following coding problem using the programming language python: You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game. The boss battle consists of n turns. During each turn, you will get several cards. Each card has two parameters: its ...
```python import sys import math import cProfile DEBUG = False def log(s): if DEBUG and False: print(s) def calc_dmg(num, arr): maximum = 0 if num - len(arr) < 0: maximum = max(arr) return sum(arr) + maximum if DEBUG: sys.stdin = open('input.txt') pr = cProfile.Profile...
vfc_28825
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3\n1 6\n1 7\n1 5\n2\n1 4\n1 3\n3\n1 10\n3 5\n2 3\n3\n1 15\n2 4\n1 10\n1\n1 100\n", "output": "263\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n...
code_contests
verifiable_code
1195_D2. Submarine in the Rybinsk Sea (hard edition)
Solve the following coding problem using the programming language python: This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers a_1, a_2, ..., a_n. A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunk...
```python from collections import Counter n = int(input()) a = list(map(int, input().split())) l = [len(str(i)) for i in a] c = Counter(l) cl = [c[i] for i in range(1,11)] M = 998244353 pad = lambda a, d: a%d + (a - a%d) * 10 #print(a, l, c, cl) ans = 0 for i in a: il = len(str(i)) # let's calculate it again t...
vfc_28829
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n12 3 45\n", "output": "12330\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n123 456\n", "output": "1115598\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1236_A. Stones
Solve the following coding problem using the programming language python: Alice is playing with some stones. Now there are three numbered heaps of stones. The first of them contains a stones, the second of them contains b stones and the third of them contains c stones. Each time she can do one of two operations: ...
```python t = int(input()) while t>0: x, y, z = [int(i) for i in input().split()] s = 0 f = -1 z = z//2 if y >= z: y = y - z s = z*2 + z else: s = y*2 + y f = 1 if f == -1: y = y//2 if x >= y: s = s + 2*y + y ...
vfc_28837
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 4 5\n1 0 5\n5 3 2\n", "output": "9\n0\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n9 4 8\n10 6 7\n4 6 0\n7 7 6\n3 3 10\n4 2 1\n4 4 0\n2 0 0\n8 8 7\n3 1 7\n3 10 7\n1 7 3\n7 9...
code_contests
verifiable_code
1253_F. Cheap Robot
Solve the following coding problem using the programming language python: You're given a simple, undirected, connected, weighted graph with n nodes and m edges. Nodes are numbered from 1 to n. There are exactly k centrals (recharge points), which are nodes 1, 2, …, k. We consider a robot moving into this graph, with...
vfc_28841
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 9 3 1\n10 9 11\n9 2 37\n2 4 4\n4 1 8\n1 5 2\n5 7 3\n7 3 2\n3 8 4\n8 6 13\n2 3\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 11 3 2\n1 3 99\n1 4 5\n4 5 3\n5 6 3\n6 ...
code_contests
verifiable_code
133_D. Piet
Solve the following coding problem using the programming language python: Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet language with s...
```python class Piet: inc = [{'x':0,'y':-1},{'x':1,'y':0},{'x':0,'y':1},{'x':-1,'y':0}] def __init__(self): self.BP = {'x':0,'y':0} self.DP = 1 self.CP = 0 self.getdata() self.go() def getdata(self): in_line = raw_input().split() self.m = int(in_line[0...
vfc_28857
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 9\n10345\n23456\n34567\n45678\n56789\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 10\n12\n43\n", "output": "1", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1382_A. Common Subsequence
Solve the following coding problem using the programming language python: You are given two arrays of integers a_1,…,a_n and b_1,…,b_m. Your task is to find a non-empty array c_1,…,c_k that is a subsequence of a_1,…,a_n, and also a subsequence of b_1,…,b_m. If there are multiple answers, find one of the smallest poss...
```python #!/usr/bin/env python3 import io import os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def get_str(): return input().decode().strip() def rint(): return map(int, input().split()) def oint(): return int(input()) t = oint() for _ in range(t): n, m = rint() a = set(rint(...
vfc_28865
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 5\n10 8 6 4\n1 2 3 4 5\n1 1\n3\n3\n1 1\n3\n2\n5 3\n1000 2 2 2 3\n3 1 5\n5 5\n1 2 3 4 5\n1 2 3 4 5\n", "output": "YES\n1 4\nYES\n1 3\nNO\nYES\n1 3\nYES\n1 1\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
1402_A. Fancy Fence
Solve the following coding problem using the programming language python: Everybody knows that Balázs has the fanciest fence in the whole town. It's built up from N fancy sections. The sections are rectangles standing closely next to each other on the ground. The ith section has integer height h_i and integer width w_...
vfc_28869
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n1 2\n", "output": "\n12\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1497_D. Genius
Solve the following coding problem using the programming language python: Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if ...
```python def nr():return int(input()) def nrs():return [int(i) for i in input().split()] def f(n,t,s): d=[0]*n for i in range(1,n): for j in range(i-1,-1,-1): if t[i]==t[j]:continue sc=abs(s[i]-s[j]) d[i],d[j]=max(d[i],d[j]+sc),max(d[j],d[i]+sc) return max(d) for _ in range(nr()): n=nr() t=nrs() s=nrs...
vfc_28885
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 32000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4\n1 2 3 4\n5 10 15 20\n4\n1 2 1 2\n5 10 15 20\n4\n2 2 4 1\n2 8 19 1\n2\n1 1\n6 9\n1\n1\n666\n", "output": "\n35\n30\n42\n0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4\n1 2 ...
code_contests
verifiable_code
151_C. Win or Freeze
Solve the following coding problem using the programming language python: You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial ...
```python import sys line = sys.stdin.readline() N = int(line) tmp = N factor = [] i = 2 while i**2 <= tmp: if tmp % i == 0: tmp //= i factor.append(i) else: i += 1 if tmp != 1: factor.append(i) if len(factor) == 2: print(2) else: print(1) if len(factor) <= 1: print(0) else: print(fa...
vfc_28889
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "1\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1547_C. Pair Programming
Solve the following coding problem using the programming language python: Monocarp and Polycarp are learning new programming techniques. Now they decided to try pair programming. It's known that they have worked together on the same file for n + m minutes. Every minute exactly one of them made one change to the file....
```python # -*- coding: utf-8 -*- """ Created on Sat Jul 10 23:15:34 2021 @author: Kevin Chang Project: Codeforces Problem 1547C """ t = int(input()) for i in range(t): shit = input() k, n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ...
vfc_28893
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n\n3 2 2\n2 0\n0 5\n\n4 3 2\n2 0 5\n0 6\n\n0 2 2\n1 0\n2 3\n\n5 4 4\n6 0 8 0\n0 7 0 9\n\n5 4 1\n8 7 8 0\n0\n", "output": "0 2 0 5\n0 2 0 5 6\n-1\n0 6 0 7 0 8 0 9\n-1\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
174_E. Ancient Berland Hieroglyphs
Solve the following coding problem using the programming language python: Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hieroglyphs. We know that no hieroglyph occurs twice in either the first or the second circle (but in ...
vfc_28897
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4\n1 2 3 4 5\n1 3 5 6\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
195_A. Let's Watch Football
Solve the following coding problem using the programming language python: Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will...
```python from math import ceil a,b,c = map(int,input().split()) t = (a*c - c*b)/b print(ceil(t)) ```
vfc_28901
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3 2\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 12 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
219_A. k-String
Solve the following coding problem using the programming language python: A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string...
```python from collections import Counter import string import math import sys def array_int(): return [int(i) for i in sys.stdin.readline().split()] def vary(number_of_variables): if number_of_variables==1: return int(sys.stdin.readline()) if number_of_variables>=2: return map(int,sys.stdin...
vfc_28905
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\naazz\n", "output": "azaz", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nabcabcabz\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
242_C. King's Path
Solve the following coding problem using the programming language python: The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 109 fr...
```python from collections import deque x0,y0,x1,y1=list(map(int, input().split())) n=int(input()) allowed={} for i in range(n): r,a,b=list(map(int,input().split())) for j in range(a,b+1): allowed[(r,j)]=True visited={} q=deque() q.append((x0,y0)) visited[(x0,y0)]=0 dire=[(-1,0),(1,0),(0,-1),(0,1),(-1,...
vfc_28909
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4 3 10\n3\n3 1 4\n4 5 9\n3 10 10\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 2 10\n2\n1 1 3\n2 6 10\n", "output": "-1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
268_A. Games
Solve the following coding problem using the programming language python: Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays...
```python n=int(input()) mat=[] for i in range(n): mat.append(list(map(int, input().rstrip().split()))) b=0 for i in range (n): for j in range (n): if mat[i][0]==mat[j][1]: b=b+1 print(b) ```
vfc_28913
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n1 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n100 42\n42 100\n5 42\n100 5\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
290_D. Orange
Solve the following coding problem using the programming language python: <image> Input The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inc...
```python text = input().lower() caps = int(input())+97 for letter in text: print(letter.upper(), end='')if letter < chr(caps) else print(letter, end='') print() ```
vfc_28917
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "AprilFool\n14\n", "output": "AprILFooL", "type": "stdin_stdout" } ] }