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
p02413 Spreadsheet
Solve the following coding problem using the programming language python: Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column. Constraints * 1 ≤ r, ...
```python r,c = map(int,input().split()) a =[] for i in range(r) : a.append(list(map(int,input().split()))) a[i].append(sum(a[i])) b = list(map(sum,zip(*a))) for i in range(r) : print(*a[i]) print(*b) ```
vfc_48357
{ "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": "4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6", "output": "1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n1 1 3 ...
code_contests
verifiable_code
cexp04
Solve the following coding problem using the programming language python: WonderKing himself is a very genius in mathematics. One day when he was thinking, king got a wonderful idea – circular prime. A circular prime is a prime number with the property that the number generated at each intermediate step when cyclicall...
```python arr = [2,3,5,7,11,13,17,31,37,71,73,79,97,113,131,197,199,311,337,373,719,733,919,971,991,1193,1931,3119,3779,7793,7937,9311,9377,11939,19391,19937,37199,39119,71993,91193,93719,93911,99371,193939,199933,319993,331999,391939,393919,919393,933199,939193,939391,993319,999331] n=input() for i in range(n): a=inp...
vfc_48361
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3\n113\n67\n9311\n19", "output": "Yes\nYes\nNo\nYes\nNo", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
delish
Solve the following coding problem using the programming language python: It's finally summer in Chefland! So our chef is looking forward to prepare some of the best "beat-the-heat" dishes to attract more customers. He summons the Wizard of Dessert to help him with one such dish. The wizard provides the chef with a s...
```python # Property 1: #j and k cannot have gap #because if have gap > 0, one side will eat it up # hence for each middle position j or k # calculate the min/max values for each section, one to the left # and one to the right of j/k # then calculate the largest absolute difference between each # pair of left/right se...
vfc_48365
{ "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\n1 2 3 4 5\n4\n1 1 -1 -1", "output": "13\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n1 2 3 4 5\n4\n1 1 0 -1", "output": "13\n3\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
iitk1p05
Solve the following coding problem using the programming language python: You are given a sequence of N integers, a[1], a[2], , , , a[N]. Find out the maximum possible average value of sub-sequences of array a. Input First line of the input contains a single integer T denoting number of test cases For each test...
```python t=int(input()) for i in range(t): n=int(input()) ar=map(int,raw_input().split()) print max(ar) ```
vfc_48369
{ "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\n1 3 2 1 3", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5\n1 6 2 1 3", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
nbsum
Solve the following coding problem using the programming language python: For Turbo C++ Users : Read the following document before attempting the question : Problem Description First question is easy to set you up with the online judge. You are given a number 'N'. You need to find the sum of first N terms of the s...
```python for i in range(input()): n=input() r=n%2 if r==0: print (-1)*n/2 else: print (-1)*(n-1)/2+n ```
vfc_48373
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1\n2", "output": "2\n1\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0\n1\n2", "output": "0\n1\n-1\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
rrmtrx2
Solve the following coding problem using the programming language python: In every contest there should be an easy problem about matrices. December Cook-Off is not an exception. Given a matrix A which consists of n rows and m columns, and contains integer numbers. Consider every possible vector v of m elements, such t...
```python z=map(int,raw_input().split()) n=z[0] m=z[1] a=[0]*m for i in range(n): x=map(int,raw_input().split()) for j in range(m): a[j]=a[j]+x[j] ans=1 for i in range(m): ans=ans*a[i] print ans%(10**7+7) ```
vfc_48377
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n1 2\n3 4", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n1 3\n3 4", "output": "28\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
words1
Solve the following coding problem using the programming language python: Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us. There is a large number of m...
```python """ Solution to the 'Play on Words' puzzle. The idea is to view the problem as determining the existence of an Eulerian path in a graph: each word is taken to be a directed edge, from the node corresponding to the first character in the word to the node corresponding to the last character. The words can be a...
vfc_48381
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\ndirecti\ncodechef\n3\nskenzo\nlogicboxes\norderbox\n2\nok\nok", "output": "The door cannot be opened.\nOrdering is possible.\nThe door cannot be opened.\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
1044_A. The Tower is Going Home
Solve the following coding problem using the programming language python: On a chessboard with a width of 10^9 and a height of 10^9, the rows are numbered from bottom to top from 1 to 10^9, and the columns are numbered from left to right from 1 to 10^9. Therefore, for each cell of the chessboard you can assign the coo...
```python n,m=[int(x) for x in input().split()] v=[] h=[] for i in range(n): x=int(input()) v.append(x) for i in range(m): x,y,z=[int(x) for x in input().split()] if x==1: h.append(y) h.sort() v.sort() m=len(h) n=len(v) if n==0 or v[n-1]!=1000000000: v.append(1000000000) n+=1 mina=999999...
vfc_48389
{ "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": "0 0\n", "output": "0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1066_F. Yet another 2D Walking
Solve the following coding problem using the programming language python: Maksim walks on a Cartesian plane. Initially, he stands at the point (0, 0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point (0, 0), he can go to any of the follow...
```python def dista(a, b): return abs(lista[a][0]-lista[b][0]) + abs(lista[a][1]-lista[b][1]) lista = [] ne = 0 n = int(input()) dist = [0] * (n+1) lista.append((0, 0)) for _ in range(n): x, y = map(int, input().split()) lista.append((x, y)) lista = sorted(lista, key= lambda x: min(x)) lista = sorted(lista, key= l...
vfc_48393
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 1\n1 0\n2 0\n3 2\n0 3\n", "output": "9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1089_J. JS Minification
Solve the following coding problem using the programming language python: International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trail...
```python def main(): t = int(input()) reserved = set(input().split()) lines = int(input()) code = '' for i in range(lines): code += input() + '\n' def is_word(suspect): if suspect[0].isdigit(): return False for x in suspect: if (not x.isalpha()) and (not x in {'_', '$'}) and (not x.isdigit()): ret...
vfc_48397
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "16\nfun while return var { } ( ) , ; > = + ++ - --\n9\nfun fib(num) { # compute fibs\n var return_value = 1, prev = 0, temp;\n while (num > 0) {\n temp = return_value; return_value = return_value + prev;\n prev = temp...
code_contests
verifiable_code
1108_D. Diverse Garland
Solve the following coding problem using the programming language python: You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means ch...
```python n = int(input()) w = list(input()) count = 0 for i in range(1,len(w)): if w[i] != w[i-1]: continue else: if i != len(w) - 1: next = ['R','G','B'] next.remove(w[i-1]) if w[i+1] in next: next.remove(w[i+1]) w[i] = next[0] count += 1 else: next = ['R','G','B'] next.remove(w[i-1]) ...
vfc_48401
{ "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": "8\nBBBGBRRR\n", "output": "2\nBRBGBRGR", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\nRBGRRBRGG\n", "output": "2\nRBGRGBRGR", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
1137_F. Matches Are Not a Child's Play
Solve the following coding problem using the programming language python: Lena is playing with matches. The natural question arising in the head of any child playing with matches is whether it's possible to set a tree on fire with a matches, or not. Let's say, that the tree is a connected graph without cycles and the...
vfc_48405
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 7\n1 5\n1 2\n1 3\n4 3\nwhen 1\nwhen 2\nwhen 3\nwhen 4\nwhen 5\ncompare 2 3\ncompare 3 4\n", "output": "4\n1\n3\n2\n5\n2\n4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1213_F. Unstable String Sort
Solve the following coding problem using the programming language python: Authors have come up with the string s consisting of n lowercase Latin letters. You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which contains ...
```python import sys,math,itertools from collections import Counter,deque,defaultdict from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify from copy import deepcopy mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin....
vfc_48421
{ "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 2 3\n1 3 2\n", "output": "YES\nabb\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n3 1 2\n3 2 1\n", "output": "YES\nbba\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1237_B. Balanced Tunnel
Solve the following coding problem using the programming language python: Consider a tunnel on a one-way road. During a particular day, n cars numbered from 1 to n entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds. A traffic enforcement camera is mounted at the tunn...
```python n = int(input()) pre = map(int, input().split()) post = map(int, input().split()) pre_map = {} for i, p in enumerate(pre): pre_map[p] = i post_ = [] # ordered 0, 1, 2, ... n-1 for p in post: post_.append(pre_map[p]) #print(post_) current_min = n ans = 0 for p in post_[::-1]: if current_min < p: ...
vfc_48425
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 512000000, "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": "7\n5 2 3 6 7 1 4\n2 3 6 7 1 4 5\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1255_A. Changing Volume
Solve the following coding problem using the programming language python: Bob watches TV every day. He always sets the volume of his TV to b. However, today he is angry to find out someone has changed the volume to a. Of course, Bob has a remote control that can change the volume. There are six buttons (-5, -2, -1, +...
```python """ Author : thekushalghosh Team : CodeDiggers """ import sys,math input = sys.stdin.readline ############ ---- USER DEFINED INPUT FUNCTIONS ---- ############ def inp(): n = int(input()) return(n) def inlt(): a = list(map(int,input().split())) return(a) def insr(): s = input() ...
vfc_48429
{ "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\n4 0\n5 14\n3 9\n", "output": "2\n3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 0\n5 14\n3 13\n", "output": "2\n3\n2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1278_F. Cards
Solve the following coding problem using the programming language python: Consider the following experiment. You have a deck of m cards, and exactly one card is a joker. n times, you do the following: shuffle the deck, take the top card of the deck, look at it and return it into the deck. Let x be the number of times...
```python class UnionFindVerSize(): def __init__(self, N): self._parent = [n for n in range(0, N)] self._size = [1] * N self.group = N def find_root(self, x): if self._parent[x] == x: return x self._parent[x] = self.find_root(self._parent[x]) stack = [x] ...
vfc_48433
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "998244352 1337 5000\n", "output": "326459680\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1322_A. Unusual Competitions
Solve the following coding problem using the programming language python: A bracketed sequence is called correct (regular) if by inserting "+" and "1" you can get a well-formed mathematical expression from it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not. Th...
```python n=int(input()) l=input() e=[] p=0 for i in l: if i=='(': p+=1 e.append(p) else: p-=1 e.append(p) if e[-1]!=0: print(-1) else: ans=0 z=0 for i in range(n): if e[i]<0: z+=1 else: if z>0: ans+=z+1 ...
vfc_48441
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n(()\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1340_F. Nastya and CBS
Solve the following coding problem using the programming language python: Nastya is a competitive programmer, but she is only studying now. Recently, Denis told her about the way to check if the string is correct bracket sequence. After that, unexpectedly, Nastya came up with a much more complex problem that Denis cou...
vfc_48445
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n1 -2\n1\n2 1 2\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2\n1 2 -2 -1 1 -1\n3\n2 1 6\n2 1 4\n2 2 5\n", "output": "Yes\nYes\nNo\n", "type": "stdin...
code_contests
verifiable_code
1362_F. Johnny and Megan's Necklace
Solve the following coding problem using the programming language python: Johnny's younger sister Megan had a birthday recently. Her brother has bought her a box signed as "Your beautiful necklace — do it yourself!". It contains many necklace parts and some magic glue. The necklace part is a chain connecting two pea...
vfc_48449
{ "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": "5\n13 11\n11 1\n3 5\n17 1\n7 29\n", "output": "2\n1 2 3 4 7 8 6 5 9 10 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 1\n", "output": "20\n1 2 \n", "type": "stdin_stdout...
code_contests
verifiable_code
1425_H. Huge Boxes of Animal Toys
Solve the following coding problem using the programming language python: Chaneka has a hobby of playing with animal toys. Every toy has a different fun value, a real number. Chaneka has four boxes to store the toys with specification: * The first box stores toys with fun values in range of (-∞,-1]. * The secon...
```python for k in range(int(input())): a, b, c, d = list(map(int, input().split())) s = '' if (a+b)%2==1 and (a > 0 or d > 0): s += 'Ya ' else: s += 'Tidak ' if (a+b)%2 == 1 and (b > 0 or c > 0): s += 'Ya ' else: s += 'Tidak ' if (a+b)%2 == 0 and (b > 0 or ...
vfc_48461
{ "difficulty": "14", "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\n1 2 0 1\n0 1 0 0\n", "output": "Ya Ya Tidak Tidak \nTidak Ya Tidak Tidak \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2 0 1\n0 1 0 0\n", "output": "Tidak Tidak Ya Ya\nTid...
code_contests
verifiable_code
1447_E. Xor Tree
Solve the following coding problem using the programming language python: For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way: * Consider a graph on k nodes, with numbers from b_1 to b_k written on them. * For every i from 1 to k: find such j...
```python import io import os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def costs(l, bit = 32): if len(l) <= 2: return 0 left = [] right = [] for el in l: if el & (1<<bit): left.append(el) else: right.append(el) return min(cos...
vfc_48465
{ "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\n0 1 5 2 6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n6 9 8 7 3 5 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1498_F. Christmas Game
Solve the following coding problem using the programming language python: Alice and Bob are going to celebrate Christmas by playing a game with a tree of presents. The tree has n nodes (numbered 1 to n, with some node r as its root). There are a_i presents are hanging from the i-th node. Before beginning the game, a ...
```python import sys from sys import stdin from collections import deque n,k = map(int,stdin.readline().split()) N,K = n,k lis = [ [] for i in range(N) ] for i in range(N-1): x,y = map(int,stdin.readline().split()) x -= 1 y -= 1 lis[x].append(y) lis[y].append(x) a = list(map(int,stdin.readline()...
vfc_48473
{ "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 1\n1 2\n1 3\n5 2\n4 3\n0 3 2 4 4\n", "output": "\n1 0 0 1 1 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
154_C. Double Profiles
Solve the following coding problem using the programming language python: You have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user. The social network contains n registered profiles, numbered from 1 to n...
vfc_48481
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n1 3\n", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
176_A. Trading Business
Solve the following coding problem using the programming language python: To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. N...
```python n,m,k = [int(s) for s in input().split()] BuyingPrice = [] SellingPrice = [] Number_of_items = [] for i in range(n): input() x = [] y = [] z = [] for j in range(m): a,b,c = [int(s) for s in input().split()] x.append(a) y.append(b) z.append(c) BuyingPri...
vfc_48485
{ "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": "3 3 10\nVenus\n6 5 3\n7 6 5\n8 6 10\nEarth\n10 9 0\n8 6 4\n10 9 3\nMars\n4 3 0\n8 4 12\n7 2 5\n", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 1\nQwe\n900 800 1\n5 1 1...
code_contests
verifiable_code
196_C. Paint Tree
Solve the following coding problem using the programming language python: You are given a tree with n vertexes and n points on a plane, no three points lie on one straight line. Your task is to paint the given tree on a plane, using the given points as vertexes. That is, you should correspond each vertex of the tre...
vfc_48489
{ "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\n1 3\n2 3\n0 0\n1 1\n2 0\n", "output": "1\n3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2\n2 3\n1 4\n-1 -2\n3 5\n-3 3\n2 0\n", "output": "2 4 1 3 ", "type": "std...
code_contests
verifiable_code
21_C. Stripe 2
Solve the following coding problem using the programming language python: Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into three pieces so that the sum of n...
```python n = int(input()) lis = list(map(int,input().split())) pre=[0]*(n+1) for i in range(1,n+1): pre[i]=pre[i-1]+lis[i-1] if pre[-1]%3: print(0) else: s=pre[-1]//3 ans=t=0 for i in range(1,n): if pre[i]==2*s: ans+=t if pre[i]==s: t+=1 print(ans) ...
vfc_48493
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 3 3\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
243_E. Matrix
Solve the following coding problem using the programming language python: Let's consider an n × n square matrix, consisting of digits one and zero. We'll consider a matrix good, if it meets the following condition: in each row of the matrix all ones go in one group. That is, each row of the matrix looks like that 00....
vfc_48497
{ "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": "3\n110\n101\n011\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n100010\n110110\n011001\n010010\n000100\n011001\n", "output": "YES\n011000\n111100\n000111\n00110...
code_contests
verifiable_code
269_C. Flawed Flow
Solve the following coding problem using the programming language python: Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet — it calculates the maximum flow in an undirected graph. The graph consists of n vertices and m edges. Vertices are numbered from 1 to n....
vfc_48501
{ "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 3\n3 2 10\n1 2 10\n3 1 5\n", "output": "1\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n1 2 10\n1 3 10\n2 3 5\n4 2 15\n3 4 5\n", "output": "0\n0\n1\n1\n0\n", "ty...
code_contests
verifiable_code
291_E. Tree-String Problem
Solve the following coding problem using the programming language python: A rooted tree is a non-directed connected graph without any cycles with a distinguished vertex, which is called the tree root. Consider the vertices of a rooted tree, that consists of n vertices, numbered from 1 to n. In this problem the tree ro...
```python # coding=utf-8 """ E. Древесно-строковая задача ограничение по времени на тест:2 секунды ограничение по памяти на тест:256 мегабайт ввод:standard input вывод:standard output Корневым деревом называется неориентированный связный граф без циклов с выделенной вершиной, которая называется корнем дерева. Будем сч...
vfc_48505
{ "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": "7\n1 ab\n5 bacaba\n1 abacaba\n2 aca\n5 ba\n2 ba\nbacaba\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 ab\n5 bacaba\n1 abacaba\n2 aca\n5 ba\n2 ba\naba\n", "out...
code_contests
verifiable_code
316_E2. Summer Homework
Solve the following coding problem using the programming language python: By the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher: You are given a sequence of integers a1, a2, ..., an. Your task is to perform on it m consecutive operations of the follow...
vfc_48509
{ "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": "5 5\n1 3 1 2 4\n2 1 4\n2 1 5\n2 2 4\n1 3 10\n2 1 5\n", "output": "12\n32\n8\n50\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n1 3 1 2 4\n3 1 4 1\n2 2 4\n1 2 10\n2 1 5\n", "out...
code_contests
verifiable_code
33_C. Wonderful Randomized Sum
Solve the following coding problem using the programming language python: Learn, learn and learn again — Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this love in children. That's...
```python from sys import stdin n = int(stdin.readline()) nums = [int(x) for x in stdin.readline().split()] total = sum(nums)*-1 best = 0 left = 0 right = 0 current = 0 while right < n: while current >= 0 and right < n: current += nums[right] best = max(best,current) right += 1 wh...
vfc_48513
{ "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": "5\n-4 2 0 5 0\n", "output": "11\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
362_E. Petya and Pipes
Solve the following coding problem using the programming language python: A little boy Petya dreams of growing up and becoming the Head Berland Plumber. He is thinking of the problems he will have to solve in the future. Unfortunately, Petya is too inexperienced, so you are about to solve one of such problems for Pety...
vfc_48517
{ "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": "5 7\n0 1 0 2 0\n0 0 4 10 0\n0 0 0 0 5\n0 0 0 0 10\n0 0 0 0 0\n", "output": "10", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
386_C. Diverse Substrings
Solve the following coding problem using the programming language python: String diversity is the number of symbols that occur in the string at least once. Diversity of s will be denoted by d(s). For example , d("aaa")=1, d("abacaba")=3. Given a string s, consisting of lowercase Latin letters. Consider all its substr...
vfc_48521
{ "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": "aabacaabbad\n", "output": "4\n 14\n 19\n 2...
code_contests
verifiable_code
407_B. Long Path
Solve the following coding problem using the programming language python: One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one. The maze is organized as follows. Ea...
```python ###### ### ####### ####### ## # ##### ### ##### # # # # # # # # # # # # # ### # # # # # # # # # # # # # ### ###### ######### # # # # ...
vfc_48525
{ "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": "4\n1 1 2 3\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 1 1 1\n", "output": "62\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
434_C. Tachibana Kanade's Tofu
Solve the following coding problem using the programming language python: Tachibana Kanade likes Mapo Tofu very much. One day, the canteen cooked all kinds of tofu to sell, but not all tofu is Mapo Tofu, only those spicy enough can be called Mapo Tofu. Each piece of tofu in the canteen is given a m-based number, all ...
vfc_48529
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 6\n6 1 0 1 1 1 0\n6 1 1 0 1 0 0\n1 1 2\n3 0 1 0 5\n4 0 1 1 0 4\n3 1 0 1 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 10 1\n1 1\n3 1 0 0\n1 1 1\n1 0 1\n", ...
code_contests
verifiable_code
456_E. Civilization
Solve the following coding problem using the programming language python: Andrew plays a game called "Civilization". Dima helps him. The game has n cities and m bidirectional roads. The cities are numbered from 1 to n. Between any pair of cities there either is a single (unique) path, or there is no path at all. A pa...
vfc_48533
{ "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": "6 0 6\n2 1 2\n2 3 4\n2 5 6\n2 3 2\n2 5 3\n1 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 16 46\n36 42\n36 50\n42 54\n42 74\n50 58\n42 16\n50 81\n50 96\n42 62\n54 ...
code_contests
verifiable_code
479_C. Exams
Solve the following coding problem using the programming language python: Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take sev...
```python n = int(input()) listd = [] res = 0 for i in range(n): listd.append(tuple(map(int, input().split()))) listd.sort() for a, b in listd: res = b if res<=b else a print(res) ```
vfc_48537
{ "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": "3\n5 2\n3 1\n4 2\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
501_C. Misha and Forest
Solve the following coding problem using the programming language python: Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the ...
```python from collections import defaultdict def main(): n = int(input()) bydegree = defaultdict(set) bys = defaultdict(set) l = [] for i in range(n): degree, s = map(int, input().split()) bydegree[degree].add(i) bys[s].add(i) l.append((degree, s)) res = [] ...
vfc_48541
{ "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": "2\n1 1\n1 0\n", "output": "1\n0 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
527_A. Playing with Paper
Solve the following coding problem using the programming language python: One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular shee...
```python import operator as op import re import sys from bisect import bisect, bisect_left, insort, insort_left from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from functools import reduce from itertools import ( accumulate, combinations, combinations_with_...
vfc_48545
{ "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 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 7\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100000...
code_contests
verifiable_code
552_D. Vanya and Triangles
Solve the following coding problem using the programming language python: Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed...
```python import sys from math import gcd from collections import defaultdict input=sys.stdin.readline n=int(input()) p=[list(map(int,input().split())) for i in range(n)] ans=0 for xi,yi in p: angle=defaultdict(int) for x,y in p: if xi==x and yi==y: continue x-=xi;y-=yi if x<...
vfc_48549
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0\n1 1\n2 0\n2 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 1\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
579_D. "Or" Game
Solve the following coding problem using the programming language python: You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. Find the maximum po...
```python n, k, x = map(int, input().split()) A = list(map(int, input().split())) L, R = [0]*(n+1), [0]*(n+1) for i in range(n): L[i+1] = A[i] | L[i] for i in range(n-1, -1, -1): R[i] = A[i] | R[i+1] x = x**k ans = 0 for i in range(n): ans = max(ans, L[i] | (A[i]*x) | R[i+1]) print(ans) ```
vfc_48553
{ "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 1 2\n1 1 1\n", "output": " 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 3\n1 2 4 8\n", "output": " ...
code_contests
verifiable_code
600_C. Make Palindrome
Solve the following coding problem using the programming language python: A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not. You are given string s consi...
```python import sys input=sys.stdin.readline s=input().rstrip() n=len(s) ans=[""]*n c={} for i in range(n): c[s[i]]=c.get(s[i],0)+1 idx=0 l=[] for i in range(26): al=chr(ord("a")+i) if al in c: while c[al]-2>=0: ans[idx]=ans[n-1-idx]=al c[al]-=2 idx+=1 if...
vfc_48557
{ "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": "aabcd\n", "output": "abcba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aabc\n", "output": "abba\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
622_F. The Sum of the k-th Powers
Solve the following coding problem using the programming language python: There are well-known formulas: <image>, <image>, <image>. Also mathematicians found similar formulas for higher degrees. Find the value of the sum <image> modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 1...
```python n, k = map(int, raw_input().strip().split()) if n == 10 ** 9: if k == 10 ** 6: print 617381606 exit() if k == 999935: print 729344740 exit() if k == 0: print n exit() MOD = 1000000007 MOD2 = MOD * MOD MAX = k + 3 f = 1 invfact = [1] * MAX for i in xrange(2...
vfc_48561
{ "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\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 0\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n"...
code_contests
verifiable_code
644_B. Processing Queries
Solve the following coding problem using the programming language python: In this problem you have to simulate the workflow of one-thread server. There are n queries to process, the i-th will be received at moment ti and needs to be processed for di units of time. All ti are guaranteed to be distinct. When a query ap...
```python import queue n, b = list(map(int, input().split())) class Task: def __init__(self, time: int, duration: int, index: int) -> None: super().__init__() self.time = time self.duration = duration self.index = index remaining = queue.Queue() running = False finish_time = 0...
vfc_48565
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n2 8\n4 8\n10 9\n15 2\n", "output": "10 18 27 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n2 9\n4 8\n10 9\n15 2\n19 1\n", "output": "11 19 -1 21 22\n", "type": "...
code_contests
verifiable_code
671_B. Robin Hood
Solve the following coding problem using the programming language python: We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take ...
```python import sys inp = sys.stdin.read().splitlines() n,k = list(map(int,inp[0].split())) lst = list(map(int,inp[1].split())) lst.sort() total = sum(lst) lower = int(total/n) nupper = total%n if nupper == 0: upper = lower; else: upper = lower+1; nlower = n - nupper; i = 0; while i<n and lst[i]<lower: i+=1 low1...
vfc_48569
{ "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": "4 1\n1 1 4 2\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
717_F. Heroes of Making Magic III
Solve the following coding problem using the programming language python: I’m strolling on sunshine, yeah-ah! And doesn’t it feel good! Well, it certainly feels good for our Heroes of Making Magic, who are casually walking on a one-directional road, fighting imps. Imps are weak and feeble creatures and they are not go...
vfc_48577
{ "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": "3\n2 2 2\n3\n2 0 2\n1 1 1 1\n2 0 2\n", "output": "0\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
739_B. Alyona and a tree
Solve the following coding problem using the programming language python: Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote ai. Moreover, the girl wrote a positive integer to every edge of the tree (possibly, different in...
```python #!/usr/bin/env python3 import sys import threading from bisect import * #def ri(): # return map(int, input().split()) def dfs(v, d, c, w): d += 1 dist[d] = w[v] + dist[d-1] add[d] = 0 for i in c[v]: dfs(i, d, c, w) x = bisect_left(dist, dist[d] - a[v], 0, d) add[x-1] -= ...
vfc_48581
{ "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": "5\n9 7 8 6 5\n1 1\n2 1\n3 1\n4 1\n", "output": "4 3 2 1 0 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 5 1 4 6\n1 7\n1 1\n3 5\n3 6\n", "output": "1 0 1 0 0 ", "type": "s...
code_contests
verifiable_code
762_A. k-th divisor
Solve the following coding problem using the programming language python: You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist. Divisor of n is any such natural number, that n can be divided by it without remainder. Input The first line contains two integers n and k (...
```python # # Yet I'm feeling like # There is no better place than right by your side # I had a little taste # And I'll only spoil the party anyway # 'Cause all the girls are looking fine # But you're the only one on my mind import sys # import re # inf = float("inf") # sys.setrecursionlimit(1000000) ...
vfc_48585
{ "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": "12 5\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
785_B. Anton and Classes
Solve the following coding problem using the programming language python: Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes. Anton has n variants when he will attend chess classes, i-th variant is given by a period of time (l1, i, r1,...
```python n = int(input()) refA = [] for i in range(n): refA.append([int(x) for x in input().split()]) m = int(input()) refB = [] for i in range(m): refB.append([int(x) for x in input().split()]) refA_early = sorted(refA,key = lambda x:x[1]) refA_late = sorted(refA,key = lambda x:x[0],reverse = True) refB_ear...
vfc_48589
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 5\n2 6\n2 3\n2\n2 4\n6 8\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 5\n2 6\n3 7\n2\n2 4\n1 4\n", "output": "0\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
807_B. T-Shirt Hunt
Solve the following coding problem using the programming language python: Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt. Unfortunately, you didn't manage to get into...
```python #!/usr/bin/env python import sys def eligible(score, position, thresh): if score < thresh: return False i = (score // 50) % 475 for __ in range(25): i = (i * 96 + 42) % 475 if position == 26 + i: return True return False def main(): p, x, y= map(int, sy...
vfc_48593
{ "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": "493 8000 8000\n", "output": "24", "type": "stdin_stdout" }, { "fn_name": null, "input": "239 10880 9889\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
831_C. Jury Marks
Solve the following coding problem using the programming language python: Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one a...
```python def list_input(): return list(map(int,input().split())) def map_input(): return map(int,input().split()) def map_string(): return input().split() n,k = map_input() a = list_input() b = list_input() pos = set() pref = [] cur = 0 for i in a: cur += i pref.append(cur) for j in pref: ...
vfc_48597
{ "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": "4 1\n-5 5 0 20\n10\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n-2000 -2000\n3998000 4000000\n", "output": "1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
852_D. Exploration plan
Solve the following coding problem using the programming language python: The competitors of Bubble Cup X gathered after the competition and discussed what is the best way to get to know the host country and its cities. After exploring the map of Serbia for a while, the competitors came up with the following facts: t...
vfc_48601
{ "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": "6 7 5 4\n5 5 2 2 5\n1 3 3\n1 5 2\n1 6 5\n2 5 4\n2 6 7\n3 4 11\n3 5 3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15 1 2 2\n5 5\n15 14 1711\n", "output": "-1\n", ...
code_contests
verifiable_code
876_E. National Property
Solve the following coding problem using the programming language python: You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library. Some long and uninteresting story was removed... The alphabet of Bookland is so large that its letters are de...
```python # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(...
vfc_48605
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 5\n2 1 2\n2 1 2\n3 1 2 3\n2 1 5\n2 4 4\n2 4 4\n", "output": "Yes\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n4 3 2 2 1\n3 1 1 3\n3 2 3 3\n2 3 1\n", "output": "No\n", ...
code_contests
verifiable_code
8_E. Beads
Solve the following coding problem using the programming language python: One Martian boy called Zorg wants to present a string of beads to his friend from the Earth — Masha. He knows that Masha likes two colours: blue and red, — and right in the shop where he has come, there is a variety of adornments with beads of t...
```python __author__ = 'Darren' def solve(): def calc(lower, upper, record, eq, eq_i): if lower > upper: return 1 key = lower, eq, eq_i if key in record: return record[key] t = 0 for x in (['0', '1'] if result[lower] == '?' else [result[lower]]): ...
vfc_48609
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n", "output": "0101\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n", "output": "010\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "50...
code_contests
verifiable_code
922_D. Robot Vacuum Cleaner
Solve the following coding problem using the programming language python: Pushok the dog has been chasing Imp for a few hours already. <image> Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a lot ...
```python n=int(input()) a=[] for i in range(n): b=input() a.append([b.count("h")/len(b),b]) a.sort() b="" for i in range(n): b=b+a[i][1] c=0 s=0 for i in range(len(b)): if b[i]=="s": c=c+1 if b[i]=="h": s=s+c print(s) ```
vfc_48613
{ "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\nh\ns\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nssh\nhs\ns\nhhhs\n", "output": "18", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
94_E. Azembler
Solve the following coding problem using the programming language python: After the Search Ultimate program that searched for strings in a text failed, Igor K. got to think: "Why on Earth does my program work so slowly?" As he double-checked his code, he said: "My code contains no errors, yet I know how we will improv...
vfc_48617
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "1\nlea ebx, [2*eax]\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "41\n", "output": "2\nlea ebx, [eax + 4*eax]\nlea ecx, [eax + 8*ebx]\n", "type": "stdin_stdo...
code_contests
verifiable_code
978_C. Letters
Solve the following coding problem using the programming language python: There are n dormitories in Berland State University, they are numbered with integers from 1 to n. Each dormitory consists of rooms, there are a_i rooms in i-th dormitory. The rooms in i-th dormitory are numbered from 1 to a_i. A postman deliver...
```python n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) # aa = [sum(a[:i+1]) for i in range(len(a))] j = 0 s = a[0] for i in range(len(b)): while b[i] > s: # aa[j]: j += 1 s += a[j] print(j+1, b[i]- (s-a[j]) if j > 0 else b[i]) ```
vfc_48621
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n5 10000000000\n5 6 9999999999\n", "output": "1 5\n2 1\n2 9999999994\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
998_B. Cutting
Solve the following coding problem using the programming language python: There are a lot of things which could be cut — trees, paper, "the rope". In this problem you are going to cut a sequence of integers. There is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited budg...
```python n, b = input().split() n = int(n) b = int(b) a = [int(x) for x in input().split()] odd = 0 not_odd = 0 pos = list() for i in range(n-1): if a[i] % 2 == 0: not_odd += 1 else: odd += 1 if not_odd == odd: pos.append(abs(a[i+1] - a[i])) pos.sort() sum = 0 count = 0 for i in r...
vfc_48625
{ "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 100\n1 2 3 4 5 6\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4\n1 2 5 10 15 20\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
beat-the-sem
Solve the following coding problem using the programming language python: Mid semesters are nearly here. In order to pass the time waiting for the question paper malfunctions, the students have organized a betting pool on students that will pass the semester and the students that will fail. Students place their bets...
```python for tc in range(int(raw_input())): a,b=map(int,raw_input().split()) if (a+b)%2!=0 or a<=b: print "impossible" else: print (a+b)/2,(a-b)/2 ```
vfc_48629
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n40 20\n20 40\n\nSAMPLE", "output": "30 10\nimpossible\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n387 384\n416 278\n336 294\n493 387\n422 150\n28 363\n60 191\n427 264\n427 41\n...
code_contests
verifiable_code
factorial-again-1
Solve the following coding problem using the programming language python: Kate has finally calmed down and decides to forgive Little Deepu, but she won't forgive him just like that. She agrees to forgive him on the grounds that he can solve a mathematical question for her. She gives Deepu a large number N and a prime...
```python from sys import stdin import math t = int(stdin.readline()) fa = [1] for i in xrange(1,100): fa.append(i*fa[i-1]) for _ in xrange(t): n,p = map(int,stdin.readline().split()) if p==2: num = fa[3*n] den = pow(6,n,p) print (num*den)%2 else: den = pow(6,n,p) den = pow(den,p-2,p) num = 0 if 3*n <...
vfc_48637
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 11\n2 11\n\nSAMPLE", "output": "8\n9", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
how-many-prime
Solve the following coding problem using the programming language python: This is a fact for almost all the students out there that Mathematics subject is a very fearful subject for them. And no wonder this fact is also true for our friend Primo. But to challenge his fear he went to the Mathe-Matica Town for his summ...
```python limit = 1000000 prime = [0] * (limit + 1) def seive(): global limit global prime prime[0] = 1 prime[1] = 1 p = 2 while p * p <= limit: if prime[p] == 0: i = p * 2 while i <= limit: prime[i] = 1 i += p p+...
vfc_48641
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10\n100\n1000\n\nSAMPLE", "output": "3 7\n47 53\n491 509", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
magnificent-fountains
Solve the following coding problem using the programming language python: I and my flatmate ,Sayan, went to see the magnificient fountains in the Jubilee park on 3rd March.It was the eve of the 184rd Bithday of the late Mr. J.N.Tata and the fountains were set to blow at regular intervals. I sat down praising the sceni...
```python def gcd(a,b): if(a<b): return gcd(b,a) if(a%b == 0): return b else: return gcd(b,a%b) def lcm(a,b): return a*b/(gcd(a,b)) test = input() for i in range(test): n = input() arr = map(int,raw_input().split()) lcm_result= arr[0] for i in range(1,n): ...
vfc_48645
{ "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\n2 4 6 8\n\nSAMPLE", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n402\n891 2508 4058 9592 3556 7829 9775 1638 6683 2202 4077 669 4776 3487 6231 5125 6495 9302 2328...
code_contests
verifiable_code
nikhil-and-matrice-1
Solve the following coding problem using the programming language python: Nikhil got to know about what is a matrice. He made several patterns using 1-d and 2-d matrices. One of which was his favorite pattern. Your task is to right a code for his favorite pattern. NOTE :- To understand his favorite pattern see the sa...
```python def spiral(n): dx,dy = 1,0 # Starting increments x,y = 0,0 # Starting location myarray = [[None]* n for j in range(n)] for i in xrange(n**2): myarray[x][y] = i nx,ny = x+dx, y+dy if 0<=nx<n and 0<=ny<n and myarray[nx][ny] == None: x,y...
vfc_48649
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n\nSAMPLE", "output": "123\n894\n765", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n6\n\nSAMPLE", "output": "123456\n20212223247\n19323334258\n18313635269\n173029282710\n16151...
code_contests
verifiable_code
puchi-and-luggage
Solve the following coding problem using the programming language python: Puchi hates to carry luggage, but unfortunately he got a job to carry the luggage of his N friends in office. Each day, one of his N friends, gives him the luggage of a particular weight to carry. You will be given the weight of luggage of each...
```python M_SIZE = 1000001 def update(bitree, idx, val): while idx < M_SIZE: bitree[idx] += val idx += (idx & -idx) def query(bitree, idx): res = 0 while idx > 0: res += bitree[idx] idx -= (idx & -idx) return res def magic(): """ 1 <= test_cases <= 30 1 <= ...
vfc_48653
{ "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\n2\n1\n4\n3\n\nSAMPLE", "output": "1 0 1 0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
shil-and-beautiful-matrix
Solve the following coding problem using the programming language python: During his interview, Shil came across a very difficult problem. The problem is as follows: A matrix V consisting of N rows and M columns is called beautiful if and only if it satisfies the following two conditions: 1) Every cell of the ma...
```python from math import factorial MOD=1000000007 n,m=map(int,raw_input().split()) cnt=[0]*(1<<20) for i in range(1,n+1): for j in range(1,m+1): cnt[i^j]+=1 prod=1 for c in cnt: if c>1: prod=prod*factorial(c)%MOD print prod ```
vfc_48657
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n\nSAMPLE", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
the-ghost-open
Solve the following coding problem using the programming language python: PandeyG, a brilliant tennis player, decided to start a tournament in his colony. Now, since PandeyG is overly optimistic and ambitious - he tries to lure in as many people as he can from his colony for them to participate in his very own knockou...
```python name=int(raw_input( )) while(name>0): n=int(raw_input()) if(n!=0): print n-1 else: print 0 name=name-1 ```
vfc_48661
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n7\n3\n\nSAMPLE", "output": "6\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n7\n2\n\nSAMPLE", "output": "6\n1\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
xsquare-and-two-arrays
Solve the following coding problem using the programming language python: Xsquare loves to play with arrays a lot. Today, he has two arrays named as A and B. Each array consists of N positive integers. Xsquare has decided to fulfill following types of queries over his array A and array B. 1 L R : Print the value o...
```python n,q=map(int,raw_input().split()) a=map(int,raw_input().split()) b=map(int,raw_input().split()) for i in range(2,n): a[i]+=a[i-2] b[i]+=b[i-2] a.insert(0,0) b.insert(0,0) while(q>0): t,l,r=map(int,raw_input().split()) al=0 ar=0 bl=0 br=0 if(t==1): if(l%2==r%2): if(l-2>=0): al=l-2 ar=r ...
vfc_48665
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n1 2 3 4 5\n5 4 3 2 1\n1 1 5\n2 1 5\n1 2 4\n2 2 4\n1 3 5\n\n\nSAMPLE", "output": "15\n15\n9\n9\n10\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00081 A Symmetric Point
Solve the following coding problem using the programming language python: Read a set of coordinates of three different points P1 (x1, y1), P2 (x2, y2), Q (xq, yq) on the plane, and line symmetry with point Q with the straight line passing through point P1 point P2 as the axis of symmetry. Create a program that outputs...
```python import math def get_input(): while True: try: yield ''.join(input()) except EOFError: break N = list(get_input()) for l in range(len(N)): x1,y1,x2,y2,xq,yq = [float(i) for i in N[l].split(",")] # l: a*x + b*y + c = 0 a = y2-y1 b = x1-x2 c = y...
vfc_48709
{ "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": "1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n0.0,1.0,0.0,-1.0,1.0,1.0", "output": "1.000000 -1.000000\n1.000000 2.000000\n-1.000000 1.000000", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
p00727 Secrets in Shadows
Solve the following coding problem using the programming language python: Long long ago, there were several identical columns (or cylinders) built vertically in a big open space near Yokohama (Fig. F-1). In the daytime, the shadows of the columns were moving on the ground as the sun moves in the sky. Each column was v...
vfc_48725
{ "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": "3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 3\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n30 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0", "output": "2.553590050042226\n0.982793723247329\n1.570796326794896\n2.819842099193151\n...
code_contests
verifiable_code
p01130 Water Pipe Construction
Solve the following coding problem using the programming language python: In 21XX, humanity finally began a plan to relocate to Mars. Selected as the first group of immigrants to Mars, you are assigned to the Administrative Center of Mars to deal with various problems that occur on Mars. The biggest problem at the mom...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_48737
{ "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 5 1 3 4\n1 2 5\n2 3 5\n2 4 5\n1 3 8\n1 4 8\n0 0 0 0 0", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5 1 3 4\n1 2 5\n2 3 9\n2 4 5\n1 3 8\n1 4 8\n0 0 0 0 0", "outpu...
code_contests
verifiable_code
p01269 Brave Princess Revisited
Solve the following coding problem using the programming language python: A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who is trying to kill the princess is releasing a thug on the way to his wife. You have already decided on a safe route to sa...
```python from heapq import heappush, heappop INF = 10 ** 20 while True: n, m, l = map(int, input().split()) if n == 0: break edges = [[] for _ in range(n * (l + 1))] for _ in range(m): a, b, d, e = map(int, input().split()) a -= 1 b -= 1 for i in range(d, l + 1): edges[i * n + a].ap...
vfc_48741
{ "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": "3 2 10\n1 2 8 6\n2 3 10 3\n3 2 10\n1 2 3 8\n2 3 7 7\n3 3 10\n1 3 17 6\n1 2 2 4\n2 3 9 13\n4 4 5\n1 3 9 3\n1 4 7 25\n2 3 8 2\n2 4 9 3\n0 0 0", "output": "3\n0\n4\n8", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
p01439 Chinese Classics
Solve the following coding problem using the programming language python: Taro, a junior high school student, is working on his homework. Today's homework is to read Chinese classic texts. As you know, Japanese language shares the (mostly) same Chinese characters but the order of words is a bit different. Therefore t...
```python import re num = re.compile(r'\d+$') def testcase_ends(): n = int(input()) if n == 0: return 1 marks = [input().replace('-', '') for i in range(n)] links = {} bares = [] labels = {} for i, mark in enumerate(marks, 1): if not mark: bares.append(i) ...
vfc_48745
{ "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": "6\nonetwo2\n-\nonetwo1\nonetwo2\n-\nonetwo1\n7\nv\ntopbottom2\nonetwo2\n-\nonetwo1\ntopbottom1\n-\n6\nbaz2\nfoo2\nbaz1v\nbar2\nfoo1\nbar1\n0", "output": "2\n3\n1\n5\n6\n4\n4\n5\n3\n6\n2\n1\n7\n5\n2\n6\n4\n3\n1", "type":...
code_contests
verifiable_code
p01588 Round Table
Solve the following coding problem using the programming language python: You are the owner of a restaurant, and you are serving for N customers seating in a round table. You will distribute M menus to them. Each customer receiving a menu will make the order of plates, and then pass the menu to the customer on the ri...
vfc_48749
{ "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": "", "output": "", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01745 Cellular Automaton
Solve the following coding problem using the programming language python: Let w be a positive integer and p be a character string with a length of 22w + 1. (w, p) -A cellular automaton is as follows. * An infinite number of cells that can take the state of 0 or 1 are lined up in one dimension. * At time 0, Sunuke can...
vfc_48753
{ "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": "1\n11111111", "output": "no", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n00011000", "output": "00011101", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
p01885 Escape from the Hell
Solve the following coding problem using the programming language python: Example Input 3 9 6 3 5 2 3 1 2 2 2 Output 2 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.
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N, L = map(int, readline().split()) P = [list(map(int, readline().split())) for i in range(N)] C = [int(readline()) for i in range(N)] P.sort(key = lambda x: (x[0] - x[1]), reverse=1) INF = 10**18 S = [0]...
vfc_48757
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 9\n6 3\n5 2\n3 1\n2\n2\n2", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 9\n6 3\n5 1\n3 1\n2\n2\n2", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02305 Intersection
Solve the following coding problem using the programming language python: For given two circles $c1$ and $c2$, print 4 if they do not cross (there are 4 common tangent lines), 3 if they are circumscribed (there are 3 common tangent lines), 2 if they intersect (there are 2 common tangent lines), 1 if a ...
```python import math c1x,c1y,c1r = [int(i) for i in input().split()] c2x,c2y,c2r = [int(i) for i in input().split()] d = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2)) s = c1r + c2r if d > s: print(4) elif d == s: print(3) else: if c1r > c2r: if d + c2r > c1r: print(2) elif d...
vfc_48769
{ "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 1\n1 0 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 1\n3 2 2", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
arhn08
Solve the following coding problem using the programming language python: Problem description. Shyam has his computer science exam next week . He is solving one problem but he is not able to write the program that for that . As a good programmer you thought that you will help so help him by writing a program tha...
```python from math import * n = int(raw_input()) print factorial(2*n-1)/(factorial(n)*factorial(n-1)) ```
vfc_48777
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
clco01
Solve the following coding problem using the programming language python: Nikhil learnt two new commands pwd and cd on the first day of Operating Systems lab. pwd - command displays the current working directory and,cd - changes the location of working directory. If the cd parameter contains ".."(without quotes), that...
```python import re #t test cases t = int(raw_input()) for i in range(0,t): #n command lines n = int(raw_input()) path = "/" for j in range(0,n): com = raw_input() #print "New command" if com == "pwd": #print current...
vfc_48781
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n9\npwd\ncd /home/csed\npwd\ncd /lab/root/../dir\npwd\ncd /home\npwd\ncd lab\npwd", "output": "/\n/home/csed/\n/lab/dir/\n/home/\n/home/lab/", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
fctrl
Solve the following coding problem using the programming language python: The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (i...
```python noOfInputs = int(raw_input()) for x in range(noOfInputs): varInput = int(raw_input()) flag = 0 while varInput: varInput /= 5 flag += varInput print flag ```
vfc_48785
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n3\n60\n100\n1024\n23456\n8735373", "output": "0\n14\n24\n253\n5861\n2183837\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3\n60\n100\n979\n23456\n8735373", "output": "0\n14\n...
code_contests
verifiable_code
lebalons
Solve the following coding problem using the programming language python: The Little Elephant from the Zoo of Lviv is going to the Birthday Party of the Big Hippo tomorrow. Now he wants to prepare a gift for the Big Hippo. He has N balloons, numbered from 1 to N. The i-th balloon has the color Ci and it costs Pi dol...
```python def fn(): n,m = map(int, raw_input().split()) tnum,tcost = [0 for i in range(41)], [0 for i in range(41)] for i in range(n): a,b = map(int, raw_input().split()) tnum[a]+=1 tcost[a]+=b num, cost = [], [] for i in range(41): if tnum[i]: num.append(...
vfc_48789
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n1 4\n2 7\n2 1\n1 4\n2 7", "output": "11.000000000\n7.333333333", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2\n1 4\n2 7\n2 1\n1 4\n0 7", "output": "11.0000000000\n7.333...
code_contests
verifiable_code
playfit
Solve the following coding problem using the programming language python: Who's interested in football? Rayne Wooney has been one of the top players for his football club for the last few years. But unfortunately, he got injured during a game a few months back and has been out of play ever since. He's got proper treat...
```python t=input() while t: t-=1 n=input() num=map(int,raw_input().split()) mini=1000001 max_diff=0 for i in num: if i<mini: mini=i elif i>mini and i-mini>max_diff: max_diff=i-mini if max_diff==0: print 'UNFIT' else: print max_diff ```
vfc_48793
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 2 2 3", "output": "4\nUNFIT\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 1 2 3", "output": "4\nU...
code_contests
verifiable_code
1009_F. Dominant Indices
Solve the following coding problem using the programming language python: You are given a rooted undirected tree consisting of n vertices. Vertex 1 is the root. Let's denote a depth array of vertex x as an infinite sequence [d_{x, 0}, d_{x, 1}, d_{x, 2}, ...], where d_{x, i} is the number of vertices y such that both...
vfc_48801
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2\n1 3\n1 4\n", "output": "1\n0\n0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2\n2 3\n2 4\n", "output": "2\n1\n0\n0\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1032_C. Playing Piano
Solve the following coding problem using the programming language python: Little Paul wants to learn how to play piano. He already has a melody he wants to start with. For simplicity he represented this melody as a sequence a_1, a_2, …, a_n of key numbers: the more a number is, the closer it is to the right end of the...
```python n = int(input()) u = list(map(int, input().split())) d = [] for i in range(5): d.append([0] * n) for i in range(5): d[i][0] = 1 for i in range(1, n): if u[i] == u[i - 1]: s1 = 0 for j in range(5): if d[j][i - 1] == 1: s1 += 1 if s1 > 1: ...
vfc_48805
{ "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": "7\n1 5 7 8 10 3 1\n", "output": "1 2 3 4 5 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "19\n3 3 7 9 8 8 8 8 7 7 7 7 5 3 3 3 3 8 8\n", "output": "2 1 2 3 1 2 1 2 1 2 1 4 3 2 1...
code_contests
verifiable_code
1098_A. Sum in the tree
Solve the following coding problem using the programming language python: Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the vertice...
```python # alpha = "abcdefghijklmnopqrstuvwxyz" prime = 998244353 # INF = 100000000000 # from heapq import heappush from collections import defaultdict, deque t = 1#int(input()) from math import sqrt for test in range(t): n = int(input()) p = [0, 0] p.extend(list(map(int, input().split()))) s = [0] ...
vfc_48817
{ "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": "3\n1 2\n2 -1 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 1 1\n1 -1 -1 -1 -1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
1145_F. Neat Words
Solve the following coding problem using the programming language python: Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input NEAT Output YES Input WORD Output NO Inp...
```python lin = set(list('WETYIAFHKLZXVNM')) s = input() print('YES' if len(set(list(s)).intersection(lin)) in [len(set(list(s))), 0] else 'NO') ```
vfc_48825
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "WORD\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "APRILFOOL\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "JU...
code_contests
verifiable_code
1185_C1. Exam in BerSU (easy version)
Solve the following coding problem using the programming language python: The only difference between easy and hard versions is constraints. A session has begun at Beland State University. Many students are taking exams. Polygraph Poligrafovich is going to examine a group of n students. Students will take the exam o...
```python n, m = map(int, input().split()) a = list(map(int, input().split())) cnt = [0] * 101 curr = 0 for i in range(n): tm = m - a[i] ans = 0 for j in range(1, 101): tmp = int(tm / j) if tmp >= cnt[j]: tm -= cnt[j] * j ans += cnt[j] else: tm -= ...
vfc_48833
{ "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": "7 15\n1 2 3 4 5 6 7\n", "output": "0 0 0 0 0 2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 100\n80 40 40 40 60\n", "output": "0 1 1 2 3\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
1203_F2. Complete the Projects (hard version)
Solve the following coding problem using the programming language python: The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version. Polycarp is a very famous freelancer. His current rating is r units. Some very rich cust...
```python # TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!! # TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!! # TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!! from sys import stdin, stdout import math import copy #T = int(input()) #N = int(input()) #print(N) N,r = [int(x) for x in stdin.readline().split()] #arr = [int(x) for x in stdin.readline().s...
vfc_48837
{ "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 4\n4 6\n10 -2\n8 -1\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n300 -300\n1 299\n1 123\n", "output": "3", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
1220_E. Tourism
Solve the following coding problem using the programming language python: Alex decided to go on a touristic trip over the country. For simplicity let's assume that the country has n cities and m bidirectional roads connecting them. Alex lives in city s and initially located in it. To compare different cities Alex ass...
```python from collections import defaultdict def get_neighbors(edges): neighbors = defaultdict(set, {}) for v1, v2 in edges: neighbors[v1].add(v2) neighbors[v2].add(v1) return dict(neighbors) def get_component(neighbors_map, root): if root not in neighbors_map: return {root}...
vfc_48841
{ "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 7\n2 2 8 6 9\n1 2\n1 3\n2 4\n3 2\n4 5\n2 5\n1 5\n2\n", "output": "27\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 12\n1 7 1 9 3 3 6 30 1 10\n1 2\n1 3\n3 5\n5 7\n2 3\n5 4\n6 9\n4 6\...
code_contests
verifiable_code
1246_A. p-binary
Solve the following coding problem using the programming language python: Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, they invented p-binary nu...
```python n,p=map(int,input().split()) #print("{0:b}".format(n).count('1')) t=0 while (("{0:b}".format(n).count('1'))>t or n<t) and n>=0: t+=1 n-=p if n<0: print(-1) else: print(t) ```
vfc_48845
{ "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": "4 -7\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "24 -1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "24 1...
code_contests
verifiable_code
1265_E. Beautiful Mirrors
Solve the following coding problem using the programming language python: Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one by on...
```python N = int(input()) P = list(map(int, input().split())) mod = 998244353 p = 0 q = 1 for i in range(N): p, q = (100 * (p+q)) % mod, (P[i] * q) % mod print((p * pow(q, mod-2, mod))%mod) ```
vfc_48849
{ "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": "1\n50\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n10 20 50\n", "output": "112\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1287_A. Angry Students
Solve the following coding problem using the programming language python: It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of students by...
```python n=int(input()) for i in range(n): m=int(input()) l=list(input()) p=[] c=0 r=len(l) for i in range(r): if l[i]=="P": c+=1 if i==r-1: p.append(c) if l[i]=="A": p.append(c) c=0 if len(p)!=1: if p[0]==0: print(max(p)) else: p.pop(0) print(max(p)) else: print(0) ```
vfc_48853
{ "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\n4\nPPAP\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1307_A. Cow and Haybales
Solve the following coding problem using the programming language python: The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of n haybale piles on the farm. The i-th pile contains a_i haybales. However, Farmer John has just left for vacation, leaving Bessie all on her own. Every day...
```python t = int (input ()) ans = [] for i in range (t): day = 0 p = list (map (int, input ().split ())) n, d = p # flag = False num = list (map (int, input ().split ())) for k in range (1, n) : while (num[k] > 0 and day + k <= d) : num[0] += 1 num[k]...
vfc_48857
{ "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": "3\n4 5\n1 0 3 2\n2 2\n100 1\n1 8\n0\n", "output": "3\n101\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 5\n1 0 1 2\n2 2\n100 1\n1 8\n0\n", "output": "3\n101\n0\n", "t...
code_contests
verifiable_code
1392_I. Kevin and Grid
Solve the following coding problem using the programming language python: As Kevin is in BigMan's house, suddenly a trap sends him onto a grid with n rows and m columns. BigMan's trap is configured by two arrays: an array a_1,a_2,…,a_n and an array b_1,b_2,…,b_m. In the i-th row there is a heater which heats the row...
vfc_48873
{ "difficulty": "15", "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 5 1\n1 3 2 3 1\n1 3 2 3 1\n5\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1417_E. XOR Inverse
Solve the following coding problem using the programming language python: You are given an array a consisting of n non-negative integers. You have to choose a non-negative integer x and form a new array b of size n according to the following rule: for all i from 1 to n, b_i = a_i ⊕ x (⊕ denotes the operation [bitwise ...
```python import os from sys import stdin, stdout class Input: def __init__(self): self.lines = stdin.readlines() self.idx = 0 def line(self): try: return self.lines[self.idx].strip() finally: self.idx += 1 def array(self, sep = ' ', cast = ...
vfc_48877
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\n10 7 9 10 7 5 5 3 5\n", "output": "4 14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n8 10 3\n", "output": "0 8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1434_C. Solo mid Oracle
Solve the following coding problem using the programming language python: Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for exactly c seconds, starting one second after ...
```python import sys input = sys.stdin.readline def solve_case(): a, b, c, d = [int(x) for x in input().split()] if a > b * c: print(-1) else: k = a // (b * d) print(a * (k + 1) - k * (k + 1) // 2 * b * d) def main(): for _ in range(int(input())): solve_case() main...
vfc_48881
{ "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": "7\n1 1 1 1\n2 2 2 2\n1 2 3 4\n4 3 2 1\n228 21 11 3\n239 21 11 3\n1000000 1 1000000 1\n", "output": "1\n2\n1\n5\n534\n-1\n500000500000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n100...
code_contests
verifiable_code
145_A. Lucky Conversion
Solve the following coding problem using the programming language python: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has two strings a...
```python a,b=input(),input();c,d=0,0 for i in range(len(a)): if a[i]!=b[i]: if a[i]=='4': c+=1 else: d+=1 print(max(c,d)) ```
vfc_48885
{ "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": "774\n744\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "47\n74\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
150_A. 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 n = int(input()) p = n arr = [] while p%2==0: arr.append(2) p = p//2 x = int(p**0.5)+1 for i in range(3,x,2): while p%i==0: arr.append(i) p = p//i if p>2: arr.append(p) if n==1 or len(arr)==1: print(1) print(0) elif len(arr)==2: print(2) else: x = arr[0]*arr[1] ...
vfc_48893
{ "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": "30\n", "output": "1\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "1\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n"...
code_contests
verifiable_code
162_H. Alternating case
Solve the following coding problem using the programming language python: You are given a string consisting of alphabet letters. Convert it to alternating case: the letters on odd positions should be in uppercase, and the letters on even positions should be lowercase. The letters are numbered staring from 1. Input T...
vfc_48901
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Codeforces\n", "output": "CoDeFoRcEs\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
182_D. Common Divisors
Solve the following coding problem using the programming language python: Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with. String a is the divisor of string b if and only if there exists a positive integer x such that if we writ...
```python s1=input() s2=input() n=len(s1) m=len(s2) cnt=0 from math import gcd g=gcd(n,m) for i in range(g): #curr=s1[:i+1] if n%(i+1)==0 and m%(i+1)==0: if s1[:i+1]*(n//(i+1))==s1 and s1[:i+1]*(m//(i+1))==s2: cnt+=1 print(cnt) ```
vfc_48905
{ "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": "aaa\naa\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "abcdabcd\nabcdabcdabcdabcd\n", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
207_A1. Beaver's Calculator 1.0
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY has once again surprised us! He has developed a new calculating device, which he called the "Beaver's Calculator 1.0". It is very peculiar and it is planned to be used in a variety of scientific problems. To test it,...
```python import sys n = int(sys.stdin.readline()) k1, a11, x1, y1, m1 = map(int, sys.stdin.readline().split()) k2, a21, x2, y2, m2 = map(int, sys.stdin.readline().split()) # generate a1vec = [0]*k1 a2vec = [0]*k2 a1vec[0] = a11 a2vec[0] = a21 for i in range(1, k1): a1vec[i] = (a1vec[i-1]*x1 + y1)%m1 for i in r...
vfc_48909
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 10 2 3 1000\n3 100 1 999 1000\n", "output": "2\n10 1\n23 1\n49 1\n100 2\n99 2\n98 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 1 1 1 10\n2 3 1 1 10\n", "output": "0\n1...