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
707_D. Persistent Bookcase
Solve the following coding problem using the programming language python: Recently in school Alina has learned what are the persistent data structures: they are data structures that always preserves the previous version of itself and access to it when it is modified. After reaching home Alina decided to invent her ow...
```python def get_input(): return map(int, raw_input().strip().split()) n, m, q = get_input() inverted = [False] * (n + 1) nxt = [ [] for i in range(q + 1)] pre = [-1] * (q + 1) ops = [] p = [set() for i in range(n+1)] ans = [0] * (q+1) now_num = 0 for i in range(0, q): ops.append(get_input()) for i, now ...
vfc_56901
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 6\n3 2\n2 2 2\n3 3\n3 2\n2 2 2\n3 2\n", "output": "2\n1\n3\n3\n2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 3\n1 1 1\n3 2\n4 0\n", "output": "1\n4\n0\n", "type"...
code_contests
verifiable_code
72_E. Ali goes shopping
Solve the following coding problem using the programming language python: Ali Koochooloo is going to buy new clothes since we're reaching Noruz, the ancient Persian festival and the beginning of new Persian year. When Ali entered a shop, he saw that the shopkeeper was a programmer and since there is no money in progr...
vfc_56905
{ "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": "abab\n", "output": "ab\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abcd\n", "output": "abcd\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
750_B. New Year and North Pole
Solve the following coding problem using the programming language python: In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice ...
```python n = int(input()) x = 0 y = 0 fl = True for i in range(n): ar = input().split() d = int(ar[0]) if fl: if x == 0 and ar[1] != 'South': fl = False if x == 20000 and ar[1] != 'North': fl = False if ar[1][0] == 'S': if x + d > 20000: ...
vfc_56909
{ "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": "2\n15000 South\n4000 East\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
773_F. Test Data Generation
Solve the following coding problem using the programming language python: Test data generation is not an easy task! Often, generating big random test cases is not enough to ensure thorough testing of solutions for correctness. For example, consider a problem from an old Codeforces round. Its input format looks roughl...
vfc_56913
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 21 100129\n", "output": "154\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6 100000\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
798_E. Mike and code of a permutation
Solve the following coding problem using the programming language python: Mike has discovered a new way to encode permutations. If he has a permutation P = [p1, p2, ..., pn], he will encode it in the following way: Denote by A = [a1, a2, ..., an] a sequence of length n which will represent the code of the permutation...
vfc_56917
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n2 -1 4 -1 6 -1 8 -1\n", "output": "1 8 2 7 3 6 4 5 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 -1 1 5 -1 4\n", "output": "2 6 1 4 5 3 \n", "type": "stdin_stdout" ...
code_contests
verifiable_code
844_C. Sorting by Subsequences
Solve the following coding problem using the programming language python: You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence als...
```python n = int(input()) a = list(map(int, input().split())) a = sorted(range(n), key=lambda i: a[i]) s = [] for i in range(n): if a[i] + 1: l = [] s.append(l) while a[i] + 1: l.append(i + 1) a[i], i = -1, a[i] print(len(s)) for l in s: print(len(l)...
vfc_56925
{ "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": "6\n83 -75 -49 11 37 62\n", "output": "1\n6 1 2 3 4 5 6 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3 2 1 6 5 4\n", "output": "4\n2 1 3 \n1 2 \n2 4 6 \n1 5 \n", "type": ...
code_contests
verifiable_code
864_F. Cities Excursions
Solve the following coding problem using the programming language python: There are n cities in Berland. Some pairs of them are connected with m directed roads. One can use only these roads to move from one city to another. There are no roads that connect a city to itself. For each pair of cities (x, y) there is at mo...
vfc_56929
{ "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": "7 7 5\n1 2\n2 3\n1 3\n3 4\n4 5\n5 3\n4 6\n1 4 2\n2 6 1\n1 7 3\n1 3 2\n1 3 5\n", "output": "2\n-1\n-1\n2\n-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
88_E. Interesting Game
Solve the following coding problem using the programming language python: Two best friends Serozha and Gena play a game. Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of a1 > a2 > ... > ak > 0 stones. ...
```python from operator import __xor__ known = {1:0, 2:0} win = {1:-1, 2:-1} def split(stone, k): n = int( ( stone - (k*(k-1)/2)) / k) if n <= 0 or k*n + k*(k-1)/2 != stone: return [] return range(n, n+k) def mex(iterable): i = 0 while i in iterable: i += 1 return i def g(sto...
vfc_56933
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n", ...
code_contests
verifiable_code
913_C. Party Lemonade
Solve the following coding problem using the programming language python: A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at differe...
```python n = input().split() l = int(n[1]) n = int(n[0]) c = input().split() cperl = [] for i in range(n): c[i] = int(c[i]) cperl.append([(c[i])/2**i, 2**i, i]) cperl.sort() f = False nl = [0] nc = [0] i = 0 while not f: p = nl[i] nl[i] += cperl[i][1] * ((l-p)//cperl[i][1]) nc[i] += c[cperl[i][2]] ...
vfc_56937
{ "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": "4 12\n20 30 70 90\n", "output": "150\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 787787787\n123456789 234567890 345678901 456789012 987654321\n", "output": "44981600785557577\n...
code_contests
verifiable_code
935_C. Fifa and Fafa
Solve the following coding problem using the programming language python: Fifa and Fafa are sharing a flat. Fifa loves video games and wants to download a new soccer game. Unfortunately, Fafa heavily uses the internet which consumes the quota. Fifa can access the internet through his Wi-Fi access point. This access po...
```python import math i,x1,y1,x2,y2=input().split() R=int(i) x=int(x1) y=int(y1) xx=int(x2) yy=int(y2) a=(x-xx)*(x-xx) b=(y-yy)*(y-yy) d=math.sqrt(a+b) flag=0 if a+b >= R*R: print(x,end=" ") print(y,end=" ") print(R) flag=1 elif flag!=1 and d!=0: r=(d+R)/2 t=xx + r*(x-xx)/d u=yy + r*(y-yy)/d...
vfc_56941
{ "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": "10 5 5 5 15\n", "output": "5 5 10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3 3 1 1\n", "output": "3.767766952966369 3.767766952966369 3.914213562373095\n", "type": "st...
code_contests
verifiable_code
961_B. Lecture Sleep
Solve the following coding problem using the programming language python: Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells ai theorems during the i-th minute. Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are g...
```python from collections import Counter def main(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) t = list(map(int, input().split())) print(solve(n, k, a, t)) def solve(n, k, a, t): minsum = sum(ai for ai, ti in zip(a,t) if ti == 1) inc = sum(ai for ai, ti in zip...
vfc_56945
{ "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": "6 3\n1 3 5 2 5 4\n1 1 0 1 0 0\n", "output": "16\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
989_A. A Blend of Springtime
Solve the following coding problem using the programming language python: When the curtains are opened, a canvas unfolds outside. Kanno marvels at all the blonde colours along the riverside — not tangerines, but blossoms instead. "What a pity it's already late spring," sighs Mino with regret, "one more drizzling nigh...
```python s=input() f=False for i in range(len(s)-2): t=s[i:i+3] if 'A' in t and 'B' in t and 'C' in t: f=True if f: print('YES') else: print('NO') ```
vfc_56949
{ "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": "AA..CB\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": ".BAC.\n", "output": "YES", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
amit-and-cookies
Solve the following coding problem using the programming language python: Amit is very fond of cookies, so he wants to buy some. There are N different cookies lying in front of him, with their prices, but he has only K Rs. He wants to maximize the number of cookies he buys with this money. Now, you are Amit's best ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' n,m=map(int,raw_input().split()) l=[int(i) for i in raw_input().split()] l.sort() p=0 c=0 for i in l: p+=i if m>p: c+=1 print c ```
vfc_56953
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 50\n12 81 23 5 29\n\nSAMPLE", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
capture-castle
Solve the following coding problem using the programming language python: HackerMan loves playing Age of Empire. A few days ago, he discovered a variant of that game which is equally adventurous. Here, he has to capture a castle before his enemy. The map consists of several interconnected paths in a grid pattern. He ...
```python test=input() for n in range(0,test): size=map(int, raw_input().split()) x=size[0] y=size[1] G=[] for i in range(0,x): G.append(map(int, raw_input().split())) s=[0,0] e=map(int, raw_input().split()) G1=[] P=[] C=[] for i in range(0,x): G1.append([1000...
vfc_56957
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n35 30\n2 10 9 5 3 6 9 5 5 3 7 10 9 3 10 9 2 2 6 2 6 10 10 8 10 6 6 2 1 8\n5 7 3 4 2 3 6 8 5 10 10 9 7 2 5 1 3 8 5 4 7 2 5 7 9 5 8 7 6 5\n10 1 10 6 2 2 3 5 10 6 4 9 1 10 1 2 5 10 3 7 2 6 9 2 8 10 4 4 1 9\n8 2 3 8 9 8 5 9 10 7 1 4...
code_contests
verifiable_code
determine-the-truth
Solve the following coding problem using the programming language python: Anshu's father is a billionaire but he wants Anshu to learn the value of money. So, his father gives him his pocket money in a different manner. He gives 1Rs. on first day, 2 Rs. on second, 3 Rs. on third and so on. So, Anshu gets n Rs. on any ...
```python for t in range(input()): x=long(raw_input()) print x*(x+1)/2 ```
vfc_56961
{ "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\n6\n\nSAMPLE", "output": "6\n21\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
gcd-5
Solve the following coding problem using the programming language python: In this problem you will be given an integer array A of size N, your task is find whether given array is sorted or not (in ascending order) , if print "YES" else print "NO". Array a[n] is sorted if a[0] ≤ a[1] ≤ ... a[n - 1]. Input First li...
```python aa = int(raw_input()) outt=[] for x in range(aa): a=int(raw_input()) b=map(int,raw_input().split()) c=b s=sorted(c) if s==b: outt.append("YES") else: outt.append("NO") for k in outt: print k ```
vfc_56965
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 2 3 4\n3\n7 66 10 \n2 \n1 0\n\nSAMPLE", "output": "YES\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15\n16\n4 16 64 256 1024 4096 16384 65536 262144 1048576 5153632 1133...
code_contests
verifiable_code
monk-and-power-of-time
Solve the following coding problem using the programming language python: The Monk is trying to explain to its users that even a single unit of time can be extremely important and to demonstrate this particular fact he gives them a challenging task. There are N processes to be completed by you, the chosen one, sinc...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=int(raw_input()) c=raw_input().split() i=raw_input().split() x=0 z=0 while x<t: if c[x]==i[x]: x+=1 else: temp=c[x] for j in range(x+1,t): c[j-1]=c[j] c[t-1]=te...
vfc_56973
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 2 1\n1 3 2\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 2 1\n1 3 2\n\nSAMELP", "output": "5\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
people-circle
Solve the following coding problem using the programming language python: There are M males and F females arranged in a circle. Starting from a given point, you count clockwise and remove the K'th person from the circle (where K=1 is the person at the current point, K=2 is the next person in the clockwise direction, e...
```python def rate(p, m, f): return (p+1)%(m + f ); for _ in range(input()): m, f, k = map(int, raw_input().split()) ret = ["M"] * (m + f) pos = len(ret) - 1 for i in range(f): j = 0 while j < k: pos = (pos+1) % len(ret) if ret[pos] == 'M': j...
vfc_56977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 3 2\n1 0 245\n5 5 3\n\nSAMPLE", "output": "MFMFMFMM\nM\nMFFMMFFMFM", "type": "stdin_stdout" }, { "fn_name": null, "input": "35\n5 3 2\n7 3 1\n25 25 1000\n4 1 7\n3 2 7\n5 1 6\n20 25 45\n7 3 10\n0...
code_contests
verifiable_code
roy-and-leds-6
Solve the following coding problem using the programming language python: Its Diwali time and there are LED series lights everywhere. Little Roy got curious about how LED lights work. He noticed that in one single LED Bulb there are 3 LED lights, namely Red, Green and Blue. State of the bulb at any moment is the sum...
```python (T, Rs, Gs, Bs) = map(int, raw_input().split(' ')) R = 0 G = 0 B = 0 Y = 0 C = 0 M = 0 W = 0 Bk = 0 (tR, tG, tB) = (0, 0, 0) (rcount, gcount, bcount) = (Rs, Gs, Bs) for x in xrange(T): # set values of LEDs if rcount == 0: rcount = Rs tR = 1 if tR == 0 else 0 if gcount == 0: gcount = Gs tG =...
vfc_56981
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12 2 3 5\n\nSAMPLE", "output": "1 1 1 3 2 2 0 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000000 9000 8743 7562323", "output": "263477 265828 0 232523 0 0 0 238172", "ty...
code_contests
verifiable_code
string-weight
Solve the following coding problem using the programming language python: Prof. M went to unknown world where words are considered to be powerful according to their weights. But Prof. M doesn't know how to calculate weight of words. He will tell you a word and you have to tell its weight. You know that weight of a wo...
```python #!/usr/bin/env python import string t = int(raw_input()) letters = string.ascii_letters let_list = {} for x in range(26): let_list[letters[x]] = x + 1 for _ in range(t): text = raw_input() m = int(raw_input()) missed = raw_input().split() weight = 0 for i in range(len(text)): ...
vfc_56985
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nabcd\n2\na c\naaaa\n1\na\nababab\n2\na b\n\nSAMPLE", "output": "6\n0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\ngyyuyc\n22\nj m v p n x o g t q z s e w c l d f b r i h\nbqx...
code_contests
verifiable_code
v-vs-s
Solve the following coding problem using the programming language python: Siddharth is a math geek. His only work in free time is to think of a new math problem and keep working on that. Siddharth's latest problem is to sum up digits of a number till the result is a single digit. It goes this way.. Ex: for number 123...
```python k=input() for i in range(0,k): p=raw_input() a=int(p,3) a=list(str(a)) while(len(a)!=1): a=sum(map(int,a)) a=list(str(a)) print a[0] ```
vfc_56989
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n10\n0010\n\nSAMPLE", "output": "1\n3\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2\n10\n0010\n\nSAMPLE", "output": "2\n3\n3\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p03757 square869120Contest #4 - Get the Salary of Atcoder
Solve the following coding problem using the programming language python: Input Format Let the i-th query query_i, the input format is following: N Q p_0 a_0 p_1 a_1 : : p_{N - 1} a_{N - 1} query_0 query_1 : : query_{Q - 1} THe format of query_i is one of the three format: 1 v_i d_i x_i 2 v_i d_i 3 ...
vfc_57025
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 1073741824, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 7\n-1 6\n0 5\n0 4\n2 3\n2 2\n1 1\n2 0 1\n1 0 2 1\n2 2 1\n3 3 3\n2 0 3\n3 3 4\n2 1 1", "output": "15\n12\n30\n8", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7\n-1 6\n0 5\n0 4\n2 3\n2 2...
code_contests
verifiable_code
p00021 Parallelism
Solve the following coding problem using the programming language python: There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "YES" and i...
```python num=int(input()) for i in range (num): info=list(map(float,input().split())) info=list(map(lambda x:int(x*10**6),info)) if info[2]==info[0]: if info[6]==info[4]: print("YES") else: print("NO") elif info[6]==info[4]: if info[2]==info[0]: ...
vfc_57033
{ "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": "2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0", "output": "YES\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.680227...
code_contests
verifiable_code
p00473 Dividing Snacks
Solve the following coding problem using the programming language python: problem There is one bar-shaped candy with a length of N mm (where N is an even number). Two JOI officials decided to cut this candy into multiple pieces and divide them into a total of N / 2 mm. did. For unknown reasons, this candy has differ...
```python n = int(input()) dp = [float('inf')]*(n+1) dp[0] = 0 cost = [int(input()) for _ in range(n-1)] for i in range(1,n): for j in range(i): if dp[i-j]+cost[i-1] < dp[j]: dp[j] = dp[i-j]+cost[i-1]# = min(dp[j],dp[i-j]+cost[i-1]) if dp[j]+cost[i-1] < dp[i-j]: dp[i-j] = dp[j]+cost[i-1]# = min(dp[...
vfc_57045
{ "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\n1\n8\n12\n6\n2", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1\n4\n12\n6\n2", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p00665 Everything Starts With Your Vote
Solve the following coding problem using the programming language python: There is the word heuristics. It's a relatively simple approach that usually works, although there is no guarantee that it will work. The world is full of heuristics because it is simple and powerful. Some examples of heuristics include: In an ...
```python import sys input = sys.stdin.readline while True: n, m, k, l = map(int, input().split()) if n == 0: break ranking = [] for _ in range(n): name, x = input().split() x = int(x) ranking.append([x, name]) ranking.sort(key=lambda x:(-x[0], x[1])) favs = {input().strip() for _ in rang...
vfc_57049
{ "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 1 3 4\nyskwcnt 16\nakzakr 7\ntsnukk 12\nfnmyi 13\nakzakr\n4 1 3 5\nakzakr 7\ntsnukk 12\nfnmyi 13\nyskwcnt 16\nakzakr\n4 2 2 1\nakzakr 4\ntsnukk 6\nyskwcnt 6\nfnmyi 12\nakzakr\nfnmyi\n5 2 3 28\nknmmdk 6\nskrkyk 14\ntmemm 14\nakmhm...
code_contests
verifiable_code
p00808 Young
Solve the following coding problem using the programming language python: Ken and Keiko are young, poor and busy. Short explanation: they are students, and ridden with part-time jobs. To make things worse, Ken lives in Hakodate and Keiko in Tokyo. They want to meet, but since they have neither time nor money, they hav...
vfc_57053
{ "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": "5\nHakodate 08:15 Morioka 12:30 2500\nMorioka 14:05 Hakodate 17:30 2500\nMorioka 15:30 Hakodate 18:00 3000\nMorioka 14:30 Tokyo 17:50 3000\nTokyo 08:30 Morioka 13:35 3000\n4\nHakodate 08:15 Morioka 12:30 2500\nMorioka 14:04 Hakodat...
code_contests
verifiable_code
p00939 Bringing Order to Disorder
Solve the following coding problem using the programming language python: Example Input 20 Output 4 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 def solve(): D = input() N = len(D) *DI, = map(int, D) su = sum(DI) pd = 1 for d in D: pd *= int(d) + 1 memo = [{} for i in range(N)] def dfs0(i, s, p): key = (s, p) if i == N: return s > 0 or (s == 0 and p < pd) if key in memo[i]: ...
vfc_57057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01342 Dungeon Wall
Solve the following coding problem using the programming language python: In 2337, people are bored at daily life and have crazy desire of having extraordinary experience. These days,“Dungeon Adventure” is one of the hottest attractions, where brave adventurers risk their lives to kill the evil monsters and save the w...
vfc_57069
{ "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": "50 2 0\n0 0\n49 1", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "50 2 0\n0 0\n49 0", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01509 Play in Basic
Solve the following coding problem using the programming language python: One sunny day, Dick T. Mustang found an ancient personal computer in the closet. He brought it back to his room and turned it on with a sense of nostalgia, seeing a message coming on the screen: READY? Yes. BASIC. BASIC is a programming lan...
vfc_57073
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "C4C4G4G4A4A4G2F4F4E4E4D4D4C2\nO4C4.C8F4.F8G8F8E8D8C2\nB-8>C8<B-8V40R2R..R8.V100EV50L1CG\n*", "output": "Case 1: CCGGAAG2FFEEDDC2\nCase 2: C.C8F.L8FGFEDC2\nCase 3: L8B-B+B-RL1RE4V50CG", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01680 Everlasting -One-
Solve the following coding problem using the programming language python: Problem Statement "Everlasting -One-" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play. In this game, a character is characterized by attributes. There are ...
```python from collections import deque MOD = 10**9 + 7 while 1: N, M = map(int, input().split()) if N == M == 0: break G = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) que = deque() used = [0]*N ...
vfc_57077
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2\n2 3\n5 0\n100000 0\n0 0", "output": "3\n32\n607723520", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 2\n2 3\n2 0\n100000 0\n0 0", "output": "3\n4\n607723520\n", ...
code_contests
verifiable_code
p01824 Surface Area of Cubes
Solve the following coding problem using the programming language python: Example Input 2 2 2 1 0 0 0 Output 24 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 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_57081
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 2 1\n0 0 0", "output": "24", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2 0\n0 0 0", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01959 Revenge of the Broken Door
Solve the following coding problem using the programming language python: The JAG Kingdom consists of $N$ cities and $M$ bidirectional roads. The $i$-th road ($u_i, v_i, c_i$) connects the city $u_i$ and the city $v_i$ with the length $c_i$. One day, you, a citizen of the JAG Kingdom, decided to go to the city $T$ fro...
vfc_57085
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 1 3\n1 2 1\n2 3 5\n1 3 3", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4 1 4\n1 2 1\n2 4 1\n1 3 1\n3 4 1", "output": "4", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p02392 Range
Solve the following coding problem using the programming language python: Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No". Constraints * 0 ≤ a, b, c ≤ 100 Input Three integers a, b and c separated by a single space are given in a line. Output Print "Yes" or "N...
```python a,b,c = map(int,(input().split())) if(a < b and b < c): print("Yes") else: print("No") ```
vfc_57097
{ "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 3 8", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 8 1", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 6 8", ...
code_contests
verifiable_code
capple
Solve the following coding problem using the programming language python: Chef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so. Chef has N apple trees in his home garden. Each tree has a certain (non-zero) number of apples on...
```python t=int(raw_input()) for asd in range(t): n=int(raw_input()) a=map(int,raw_input().split()) a=sorted(a) c=1 for i in range(1,n): if a[i]!=a[i-1]: c+=1 print c ```
vfc_57101
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n3 3 3\n4\n1 2 3 3", "output": "1\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n3 3 3\n4\n1 4 3 3", "output": "1\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
craft05
Solve the following coding problem using the programming language python: Aman has a hardware store in Una. One day when he went down to the store room to fetch a box of nails. He found that the price tag had faded out. The first and the last digits of the price were not readable. Although, the number of nails in the ...
```python import sys test=int(input()) while(test>0): N=int(input()) xyz=sys.stdin.readline().split() i=99999 flag='true' while(flag=='true'): mid_3=int(i%100)/10 #print '1',mid_3 if(mid_3==int(xyz[2])): mid_3=int((i%1000)/100) #print '2', mid_3 if(mid_3==int(xyz[1])): mid_3=int((i%10000)/1000) ...
vfc_57105
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n72\n6 7 9\n5\n2 3 7\n78\n0 0 5", "output": "3 2 511\n9 5 18475\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n72\n6 7 9\n5\n2 3 7\n103\n0 0 5", "output": "3 2 511\n9 5 1847...
code_contests
verifiable_code
greedy
Solve the following coding problem using the programming language python: The Government of Greedistan has just found out that there is a lot of gold beneath some land area in their country. They quickly surveyed the land area and found that some people are living there, and surprisingly the houses are organized in a ...
```python t=int(raw_input()) while(t): t-=1 m,n=map(int,raw_input().split(" ")) if(m and n): print m/2+n/2+1 else: print 0 ```
vfc_57109
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 5\n3 4", "output": "3\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 5\n1 4", "output": "3\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
maxisum
Solve the following coding problem using the programming language python: You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make at m...
```python # /cc/2016/March/Long/MAXISUM for tc in xrange(input()): n_nums, n_ops = map(long, raw_input().strip().split()) nums1 = map(long, raw_input().strip().split()) nums2 = map(long, raw_input().strip().split()) print sum(num1 * num2 for num1, num2 in zip(nums1, nums2)) + (n_ops * max(map(abs, nums2))) ```
vfc_57113
{ "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 2\n-2 3\n3 5\n1 2 -3\n-2 3 -5", "output": "10\n44\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2\n1 2\n-2 3\n3 2\n1 2 -3\n-2 3 -5", "output": "10\n29\n", "typ...
code_contests
verifiable_code
rbx12r02
Solve the following coding problem using the programming language python: In a museum there is an empty wall. We can imagine this wall as a triangle on a coordinate plane with vertices (0; 0), (N; 0), (N; N * A / B), where N, A, B are some positive integers. The space has been allotted to a photographer who wants his...
```python from re import findall count = int(raw_input()) def test(p): x,y = p global m if eval(str(y)+".0")/x <= m: return True return False for i in range(count): n,a,b = [int(x) for x in findall("\d+",raw_input())] m,net = eval(str(a) + ".0")/b,0 xx,yr = xrange(1,n+1),int(eval(str...
vfc_57117
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 2 3\n4 5 4", "output": "5\n15", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tourmap
Solve the following coding problem using the programming language python: Sridhar was a seasoned traveler. He liked to visit new places. More than all he was a meticulous planner. This time he was planning to visit Europe. He wrote down his travel itinerary like as follows: If he wanted to visit Madrid, Paris, Munich...
```python from sys import stdin t=input() for i in range(0,t): d={} src=[] dest=[] n=input() for j in range(0,n-1): b = stdin.readline().split() d[b[0]]=b[1]+"%"+b[2] dest.append(b[1]) tmp=list(set(d)-set(dest)) s=tmp[0] cost=0 for j in range(0,n-1): ...
vfc_57121
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\nWarsaw Kiev 120$\nMadrid Paris 100$\nMunich Warsaw 150$\nParis Munich 200$", "output": "Madrid Paris 100$\nParis Munich 200$\nMunich Warsaw 150$\nWarsaw Kiev 120$\n570$\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1015_F. Bracket Substring
Solve the following coding problem using the programming language python: You are given a bracket sequence s (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'. A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expres...
```python def add(a,b): if a+b>=mod: return (a+b)%mod return a+b n=int(input())*2 s=input() d=[[0,0] for i in range(len(s)+1)] aux='' for i in range(len(s)): if s[i]=='(': d[i][1]=i+1 x=aux+')' for j in range(1,i+2): if x[j::] ==s[0:len(x)-j]: d[i]...
vfc_57125
{ "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": "2\n(((\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n(()\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5...
code_contests
verifiable_code
1039_E. Summer Oenothera Exhibition
Solve the following coding problem using the programming language python: While some people enjoy spending their time solving programming contests, Dina prefers taking beautiful pictures. As soon as Byteland Botanical Garden announced Summer Oenothera Exhibition she decided to test her new camera there. The exhibitio...
vfc_57129
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 4 3\n1 2 3 4 3 2\n1 2 3\n", "output": "0\n1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6 5\n2 4 0\n1 2 3 4 5\n", "output": "0\n0\n1\n1\n2\n", "type": "stdin_stdout"...
code_contests
verifiable_code
1062_A. A Prank
Solve the following coding problem using the programming language python: JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a_1, a_2, ..., a_n of integers, such that 1 ≤ a_1 < a_2 < … < a_n ≤ 10^3, and then went to the bathroom. JATC decided to p...
```python n = int(input()) l = [*map(int, input().split())] res = i = 0 while i < n: j = i + 1 while j < n and l[j] - l[j - 1] == 1: j += 1 res = max(res, j - i - 2 + int(l[i] == 1) + int(l[j - 1] == 1000)) # print(res, i, j) i = j print(min(res, n - 1)) ```
vfc_57133
{ "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\n998 999 1000\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1083_F. The Fair Nut and Amusing Xor
Solve the following coding problem using the programming language python: The Fair Nut has two arrays a and b, consisting of n numbers. He found them so long ago that no one knows when they came to him. The Fair Nut often changes numbers in his arrays. He also is interested in how similar a and b are after every modi...
vfc_57137
{ "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": "3 2 2\n1 3 2\n0 0 0\na 1 0\nb 1 1\n", "output": "2\n-1\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1103_B. Game with modulo
Solve the following coding problem using the programming language python: This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integer n...
```python import sys def ask(x, y): print("?", x, y) return input() == "y" while input() == "start": if not ask(0, 1): print("! 1") continue d = 1 while ask(d, d * 2): d *= 2 r = d l = d // 2 while l + 1 < r: m = (l + r) // 2 if ask(m, m * 2): ...
vfc_57141
{ "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": "start\nx\nx\nstart\nx\nx\ny\nstart\nx\nx\ny\ny\nend\n", "output": "? 0 1\n! 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1131_B. Draw!
Solve the following coding problem using the programming language python: You still have partial information about the score during the historic football match. You are given a set of pairs (a_i, b_i), indicating that at some point during the match the score was "a_i: b_i". It is known that if the current score is «x:...
```python n=int(input()) arr= [] arr.append((0,0)) ans = 1 for _ in range(n): a,b=map(int,input().split()) arr.append((a,b)) for i in range(1,n+1): preva = arr[i-1][0] prevb = arr[i-1][1] cura = arr[i][0] curb = arr[i][1] if preva == cura and prevb==curb: pass elif preva==prevb: ...
vfc_57145
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 0\n0 0\n0 0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5 4\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1151_D. Stas and the Queue at the Buffet
Solve the following coding problem using the programming language python: During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two numbers...
```python # Why do we fall ? So we can learn to pick ourselves up. t = int(input()) ss = [] for _ in range(0,t): a,b = map(int,input().split()) ss.append([b-a,a,b]) ss = sorted(ss) s = 0 for i in range(1,t+1): s += ss[i-1][1]*(i-1)+ss[i-1][2]*(t-i) print(s) ```
vfc_57149
{ "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": "10\n5 10\n12 4\n31 45\n20 55\n30 17\n29 30\n41 32\n7 1\n5 5\n3 15\n", "output": "1423", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 2\n2 3\n6 1\n", "output": "12", "type":...
code_contests
verifiable_code
1173_C. Nauuo and Cards
Solve the following coding problem using the programming language python: Nauuo is a girl who loves playing cards. One day she was playing cards but found that the cards were mixed with some empty ones. There are n cards numbered from 1 to n, and they were mixed with another n empty cards. She piled up the 2n cards ...
```python n=int(input()) arr1=list(map(int,input().split())) arr2=list(map(int,input().split())) arr3=[0] mini=n+1 for i in range(0,len(arr2)): if arr2[i]<mini and arr2[i]!=0: mini=arr2[i] if mini==n+1: print(len(arr1)) exit() q=n+1 a=0 b=0 m=0 for i in range(0,len(arr2)): if mini==arr2[i]: ...
vfc_57153
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 2 0\n1 0 3\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1190_F. Tokitsukaze and Powers
Solve the following coding problem using the programming language python: Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape. After a while, she realizes that the only way to run away is to open the digital door lock...
vfc_57157
{ "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": "4 9 8\n", "output": "2 4 5 7 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5 1\n", "output": "2 3 4 ", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
122_C. Lucky Sum
Solve the following coding problem using the programming language python: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let next(x) be the minimu...
```python li=set() def addi(n): if n>10**10+1: return li.add(n) addi(n*10+4) addi(n*10+7) addi(4) addi(7) li=list(set(li)) li.sort() #print(len(li)) l,r=map(int,input().split()) ans=0 for x in li: #print(x) if x>=r: #print("l",l) ans+=x*(r-l+1) #print("ans",ans) ...
vfc_57165
{ "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 7\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 7\n", "output": "33\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "369 85...
code_contests
verifiable_code
1251_B. Binary Palindromes
Solve the following coding problem using the programming language python: A palindrome is a string t which reads the same backward as forward (formally, t[i] = t[|t| + 1 - i] for all i ∈ [1, |t|]). Here |t| denotes the length of a string t. For example, the strings 010, 1001 and 0 are palindromes. You have n binary s...
```python Q = int(input()) for q in range(Q): n = int(input()) arr = [input() for i in range(n)] lens = [len(i) % 2 for i in arr] counts = [i.count('1') for i in arr] if sum(counts) % 2 == 0: print(n) else: if 1 in lens: print(n) else: print(n - 1...
vfc_57169
{ "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": "4\n1\n0\n3\n1110\n100110\n010101\n2\n11111\n000001\n2\n001\n11100111\n", "output": "1\n2\n2\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1270_I. Xor on Figures
Solve the following coding problem using the programming language python: There is given an integer k and a grid 2^k × 2^k with some numbers written in its cells, cell (i, j) initially contains number a_{ij}. Grid is considered to be a torus, that is, the cell to the right of (i, 2^k) is (i, 1), the cell below the (2^...
vfc_57173
{ "difficulty": "15", "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\n5 5 5 5\n2 6 2 3\n0 0 2 0\n0 0 0 0\n5\n1 1\n1 2\n1 3\n1 4\n2 4\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n657780854087801966 201152864179333045 2594770496449968...
code_contests
verifiable_code
1294_A. Collecting Coins
Solve the following coding problem using the programming language python: Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins. He wa...
```python import sys T = int(sys.stdin.readline()) for _ in range(T): a, b, c, n = map(int , sys.stdin.readline().split()) if not (a+b+c+n)%3 and max(a, b, c)<=(a+b+c+n)//3: print('YES') else: print('NO') ```
vfc_57177
{ "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": "5\n5 3 2 8\n100 101 102 105\n3 2 1 100000000\n10 20 15 14\n101 101 101 3\n", "output": "Yes\nYes\nNo\nNo\nYes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3 798 437 1804\n", "o...
code_contests
verifiable_code
1315_A. Dead Pixel
Solve the following coding problem using the programming language python: Screen resolution of Polycarp's monitor is a × b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 ≤ x < a, 0 ≤ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows — from 0 t...
```python t=int(input()) for _ in range(t): a,b,x,y=map(int,input().split()) print(max(max(a-1-x,x)*b,max(b-1-y,y)*a)) ```
vfc_57181
{ "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": "6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8\n", "output": "56\n6\n442\n1\n45\n80\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 2 0 ...
code_contests
verifiable_code
1336_D. Yui and Mahjong Set
Solve the following coding problem using the programming language python: This is an interactive problem. Yui is a girl who enjoys playing Mahjong. <image> She has a mysterious set which consists of tiles (this set can be empty). Each tile has an integer value between 1 and n, and at most n tiles in the set have th...
vfc_57185
{ "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": "5\n1 6\n2 9\n5 12\n5 24\n6 24\n", "output": "\n+ 1\n+ 1\n+ 2\n+ 5\n! 2 1 3 0 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 0 1\n", "output": "+ 3\n+ 1\n+ 2\n+ 1\n! 0 -1 0 ...
code_contests
verifiable_code
1379_C. Choosing flowers
Solve the following coding problem using the programming language python: Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly n flowers. Vladimir went to a flower shop, and he was amazed to see that there are m types of flowers being sold there, and there is ...
```python from sys import stdin import math from bisect import bisect_right input = stdin.readline for _ in range(int(input())): n, m = map(int, input().split(" ")) a = [] xs = [] ans = 0 for i in range(m): x, y = map(int, input().split(" ")) a.append((y, x)) xs.append(x) ...
vfc_57193
{ "difficulty": "9", "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\n4 3\n5 0\n1 4\n2 2\n\n5 3\n5 2\n4 2\n3 1\n", "output": "14\n16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n7 7\n875211518 78149272\n372527826 28528254\n777595365 608227558\n86158...
code_contests
verifiable_code
139_A. Petr and Book
Solve the following coding problem using the programming language python: One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages. Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day o...
```python n=int(input()) l=list(map(int,input().split())) i=0 while(n>0): if i==7: i=0 n -= l[i] if n>0: i+=1 print(i+1) ```
vfc_57197
{ "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": "100\n15 20 20 15 10 30 45\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 0 0 0 0 0 0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
1423_E. 5G Antenna Towers
Solve the following coding problem using the programming language python: After making a strategic plan with carriers for expansion of mobile network throughout the whole country, the government decided to cover rural areas with the last generation of 5G network. Since 5G antenna towers will be built in the area of m...
vfc_57201
{ "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": "10 10 3\n4 2 2 3 2 3 3 2 3\n3 3.5 2 4.5 2 4.5 3\n4 7 8 7.5 8.5 8 8 7.5 9\n5\n2 3.5 0.5\n3.3 2 0.4\n5 2.5 0.5\n7.5 8.5 0.5\n3 7 0.5\n", "output": "1 1 0\n1.5 2 0 1\n0.5 1 1\n0.25 1 2\n0 0\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
1442_D. Sum
Solve the following coding problem using the programming language python: You are given n non-decreasing arrays of non-negative numbers. Vasya repeats the following operation k times: * Selects a non-empty array. * Puts the first element of the selected array in his pocket. * Removes the first element from...
vfc_57205
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n2 5 10\n3 1 2 3\n2 1 20\n", "output": "26\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n3 1 1000 100000000\n2 1 100000000\n3 99999999 100000000 100000000\n", "output": "4...
code_contests
verifiable_code
16_E. Fish
Solve the following coding problem using the programming language python: n fish, numbered from 1 to n, live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability aij, an...
```python # Author : nitish420 -------------------------------------------------------------------- import os import sys from io import BytesIO, IOBase # sys.setrecursionlimit(10**4) def main(): n=int(input()) prob=[] for _ in range(n): prob.append(list(map(float,input().split()))) dp=[-1 for ...
vfc_57225
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 128000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n0 0.5\n0.5 0\n", "output": "0.500000 0.500000 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 1 1 1 1\n0 0 0.5 0.5 0.5\n0 0.5 0 0.5 0.5\n0 0.5 0.5 0 0.5\n0 0.5 0.5 0.5 0\n", "...
code_contests
verifiable_code
190_C. STL
Solve the following coding problem using the programming language python: Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer. We all know that programs often store sets of integers. For example, if we have a problem ab...
```python ###pyrival template for fast IO import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file....
vfc_57229
{ "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\npair pair int int int\n", "output": "pair<pair<int,int>,int>\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
214_C. Game
Solve the following coding problem using the programming language python: Furik and Rubik love playing computer games. Furik has recently found a new game that greatly interested Rubik. The game consists of n parts and to complete each part a player may probably need to complete some other ones. We know that the game ...
```python n = int(input()) h = [int(q) - 1 for q in input().split()] u = [set([int(q) - 1 for q in input().split()][1:]) for i in range(n)] t = 1e9 def g(): for i in p: if h[i] == k and not v[i]: return i for k in range(3): p = list(range(n)) d = -1 v = [q.copy() for q in u] w...
vfc_57233
{ "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": "1\n1\n0\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 2 1 1 3\n1 5\n2 5 1\n2 5 4\n1 5\n0\n", "output": "7", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
238_C. World Eater Brothers
Solve the following coding problem using the programming language python: You must have heard of the two brothers dreaming of ruling the world. With all their previous plans failed, this time they decided to cooperate with each other in order to rule the world. As you know there are n countries in the world. These c...
vfc_57237
{ "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\n2 1\n3 1\n4 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 1\n2 3\n4 3\n4 5\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
287_A. IQ Test
Solve the following coding problem using the programming language python: In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted wh...
```python # Description of the problem can be found at http://codeforces.com/problemset/problem/287/A l_l = list([input() for _ in range(4)]) dx = [ 0, 0, 1, 1] dy = [ 0, -1, -1, 0] for i in range(3): for j in range(3): t = 0 for z in range(4): t += (-1 if l_l[i + dy[z]][j + dx[z]...
vfc_57245
{ "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": "####\n....\n####\n....\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
312_A. Whose sentence is it?
Solve the following coding problem using the programming language python: One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the e...
```python import re n = int(input()) for i in range(n): s = input() rainbow = re.search(r"\Amiao\.", s) freda = re.search(r"lala\.\Z", s) if rainbow and not freda: print("Rainbow's") elif freda and not rainbow: print("Freda's") else: print("OMG>.< I don't know!") ```
vfc_57249
{ "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": "5\nI will go to play with you lala.\nwow, welcome.\nmiao.lala.\nmiao.\nmiao .\n", "output": "Freda's\nOMG>.< I don't know!\nOMG>.< I don't know!\nRainbow's\nOMG>.< I don't know!\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
334_D. Chips
Solve the following coding problem using the programming language python: Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute ...
```python #------------------------template--------------------------# import os import sys from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output....
vfc_57253
{ "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": "3 0\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n3 1\n3 2\n3 3\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
357_D. Xenia and Hamming
Solve the following coding problem using the programming language python: Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance. The Hamming distance between two strings s = s1s2... sn and t = t1t2... tn of equal length n is value <image>. Record [si ≠ ti] is the Iverson notati...
vfc_57257
{ "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 3\nrzr\naz\n", "output": " 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 10\na\naaaaaaaaaa\n", "output": " ...
code_contests
verifiable_code
380_C. Sereja and Brackets
Solve the following coding problem using the programming language python: Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")". Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to...
```python import sys input = sys.stdin.readline s = input() M = int(input()) def next_pow_2(n): p = 1 while p < n: p <<= 1 return p def represented_range(node, size): l = node r = node while l < size: l = 2*l r = 2*r + 1 return l-size, r-size class SegTree: ...
vfc_57261
{ "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": "())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10\n", "output": "0\n0\n2\n10\n4\n6\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "(()((((()(())((((((((()((((((()((((\n71\n15 29\n1...
code_contests
verifiable_code
401_B. Sereja and Contests
Solve the following coding problem using the programming language python: Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds. Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner co...
```python import math x,k=map(int,input().split(" ")) given=[0 for x in range(x-1)] for _ in range(k): a=list(map(int,input().split(" "))) if a[0]==2: given[a[1]-1]=1 else: given[a[2]-1]=1 given[a[1]-1]=1 cmax=0 for y in range(x-1): if given[y]==0: cmax=cmax+1 pp=0 t=0 ss...
vfc_57265
{ "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": "10 0\n", "output": "5 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n2 1\n2 2\n", "output": "0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
429_C. Guess the Tree
Solve the following coding problem using the programming language python: Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the foo...
```python def DFS(x): for i in range(x): if(Seen[i][x]): continue if(Rem[i]>=C[x]): if(Rem[i]==C[x] and len(Children[i])==0): continue Rem[i]-=C[x] Parent[x]=i Children[i].append(x) return True for i in range...
vfc_57269
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 1 5 2 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 1 4\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
451_A. Game With Sticks
Solve the following coding problem using the programming language python: After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks. An intersection point is any point on the grid which is formed by the interse...
```python n,m = map(int, input().strip().split()) print("Akshat" if min(n,m)%2!=0 else "Malvika") ```
vfc_57273
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n", "output": "Malvika\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n", "output": "Akshat\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
472_G. Design Tutorial: Increase the Constraints
Solve the following coding problem using the programming language python: There is a simple way to create hard tasks: take one simple problem as the query, and try to find an algorithm that can solve it faster than bruteforce. This kind of tasks usually appears in OI contest, and usually involves data structures. Let...
vfc_57277
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10001010101011001010100101010011010\n101010100101001010100100101010\n5\n0 0 12\n3 9 7\n6 4 15\n12 15 10\n13 3 20\n", "output": "5\n4\n3\n5\n13\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
497_C. Distributing Parts
Solve the following coding problem using the programming language python: You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the ...
vfc_57281
{ "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 4\n3 5\n2\n1 3 2\n2 5 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1\n", "output": "YES\n1 1 2 \n", "type": "st...
code_contests
verifiable_code
520_E. Pluses everywhere
Solve the following coding problem using the programming language python: Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses ("+") in the line between certain digits in the...
```python n, k = map(int, input().split()) t = list(map(int, input())) p, d = 1, 10**9 + 7 s = 0 f = [1] * n for i in range(2, n): f[i] = (i * f[i - 1]) % d c = lambda a, b: 0 if a > b else (f[b] * pow(f[a] * f[b -a], d - 2, d)) % d if k: u = [0] * (n + 1) p = [1] * (n + 1) for i in range(n): u[i] = (p[i] * ...
vfc_57285
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n108\n", "output": "27\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n108\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
574_D. Bear and Blocks
Solve the following coding problem using the programming language python: Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample. Limak will repeat the follo...
```python x=int(input()) mas = list(map(int,input().split(" "))) mas2=[0]*(x) mas2[0]=1 for i in range(1,x): mas2[i]=min(mas[i],mas2[i-1]+1) mas2[-1]=1 for i in range(2,x+1): mas2[-i]=min(mas[-i],mas2[-i+1]+1, mas2[-i]) print(max(mas2)) ```
vfc_57293
{ "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": "6\n2 1 4 6 2 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n3 3 3 1 3 3 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
596_B. Wilbur and Array
Solve the following coding problem using the programming language python: Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements ai, ai + 1, ... , an or subtract 1 from all elements ai, ai ...
```python # print("Input n") n = int(input()) # print("Input the integers") a = [int(x) for x in input().split()] answer = abs(a[0]) for i in range(1, n): answer += abs(a[i-1] - a[i]) print(answer) ```
vfc_57297
{ "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": "4\n1 2 2 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
617_D. Polyline
Solve the following coding problem using the programming language python: There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to...
```python """n=int(input()) x=list(map(int, input().split())) c=0 pro=1 for i in range(n): if x[i]==1: c+=1 if c==1: old=i elif c>1: new=i pro*=(new-old) old=new print(pro) """ a=list(map(int,input().split())) b=list(map(int,input().split())) c...
vfc_57301
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "-1 -1\n-1 3\n4 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 -1\n1 1\n1 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
638_A. Home Numbers
Solve the following coding problem using the programming language python: The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in t...
```python [n, x] = list(map(int, input().split(' '))) answer = int (x % 2 == 0 and (n / 2 - x / 2 + 1) or( (x + 1) / 2)) print(answer) ```
vfc_57305
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 5\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
665_E. Beautiful Subarrays
Solve the following coding problem using the programming language python: One day, ZS the Coder wrote down an array of integers a with elements a1, a2, ..., an. A subarray of the array a is a sequence al, al + 1, ..., ar for some integers (l, r) such that 1 ≤ l ≤ r ≤ n. ZS the Coder thinks that a subarray of a is bea...
```python import sys range = xrange input = raw_input L = [-1, -1] count = [0,0] def check(i): if L[i] == -1: L[i] = len(L) L.append(-1) L.append(-1) count.append(0) count.append(0) def add(x, i = 0, bits = 30): count[i] += 1 while bits >= 0: check(i) ...
vfc_57309
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2 3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n1 2 3\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
68_C. Synchrophasotron
Solve the following coding problem using the programming language python: For some experiments little Petya needs a synchrophasotron. He has already got the device, all that's left is to set the fuel supply. Fuel comes through a system of nodes numbered from 1 to n and connected by pipes. Pipes go from every node with...
vfc_57313
{ "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": "3\n1 2 1 2 3\n1 3 0 0 0\n2 3 3 4 5\n", "output": "-1 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2 1 2 3\n", "output": "1 4\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
712_A. Memory and Crow
Solve the following coding problem using the programming language python: There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure: * The crow sets ai initially 0. * The crow then adds bi to ai, subtracts bi + 1, adds the ...
```python n=int(input()) a=input().split() for i in range (n): a[i]=int(a[i]) a.reverse() b=[] b.append(a[0]) for i in range (n-1): b.append(a[i]+a[i+1]) b.reverse() print (" ".join(map(str, b))) ```
vfc_57317
{ "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": "5\n3 -2 -1 5 6\n", "output": "1 -3 4 11 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n6 -4 8 -2 3\n", "output": "2 4 6 1 3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
732_F. Tourist Reform
Solve the following coding problem using the programming language python: Berland is a tourist country! At least, it can become such — the government of Berland is confident about this. There are n cities in Berland, some pairs of which are connected by two-ways roads. Each road connects two different cities. In Ber...
vfc_57321
{ "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": "7 9\n4 3\n2 6\n7 1\n4 1\n7 3\n3 5\n7 4\n6 5\n2 5\n", "output": "4\n3 4\n6 2\n1 7\n4 1\n7 3\n5 3\n4 7\n5 6\n2 5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
757_A. Gotta Catch Em' All!
Solve the following coding problem using the programming language python: Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to g...
```python from collections import Counter k = Counter("Bulbasaur") r = Counter(input()) print(min([r[c] // k[c] for c in k])) ```
vfc_57325
{ "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": "Bulbbasaur\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "F\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aB...
code_contests
verifiable_code
778_C. Peterson Polyglot
Solve the following coding problem using the programming language python: Peterson loves to learn new languages, but his favorite hobby is making new ones. Language is a set of words, and word is a sequence of lowercase Latin letters. Peterson makes new language every morning. It is difficult task to store the whole ...
vfc_57329
{ "difficulty": "9", "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\n1 2 c\n2 3 a\n3 4 t\n2 5 t\n", "output": "3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "16\n1 2 o\n2 3 f\n1 4 p\n4 5 i\n5 6 e\n6 7 c\n7 8 e\n4 9 r\n9 10 e\n10 11 t\n11 12 t\n12 1...
code_contests
verifiable_code
825_B. Five-In-a-Row
Solve the following coding problem using the programming language python: Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match they have made some turns and now it's Alice's ...
```python mat=[] n=10 m=10 for i in range(n): s=input() s=list(s) mat.append(s) f=0 def check(mat): for i in range(10): for j in range(10): #horizontal for k in range(5): if (i+k)>=10 or mat[i+k][j]!='X': break else: ...
vfc_57337
{ "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": "XX.XX.....\n.....OOOO.\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "XX...
code_contests
verifiable_code
847_M. Weather Tomorrow
Solve the following coding problem using the programming language python: Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral. Vasya believes that if the average ...
```python n=int(input()) l=list(map(int,input().split())) f=0 for i in range (2,len(l)): if l[i]==l[i-1]+(l[1]-l[0]): pass else: f=1 print(l[n-1]) break if f==0: if (l[n-1])==(l[0]+(n-1)*(l[1]-l[0])): print(l[0]+(n*(l[1]-l[0]))) else: print(l[n-1]) ```
vfc_57341
{ "difficulty": "20", "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 1 1\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5 1 -5\n", "output": "-5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
896_B. Ithea Plays With Chtholly
Solve the following coding problem using the programming language python: This is an interactive problem. Refer to the Interaction section below for better understanding. Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight. <image> Initially, Ithea puts n clear sheets of pap...
```python import sys n, m, c=map(int, input().split()) a=[] for i in range(n+1): a.append(0) cnt=0 while cnt<n: i=0 x=int(input()) if x*2<=c: i=1 while a[i] and a[i]<=x: i+=1 else: i=n while a[i] and a[i]>=x: i-=1 if a[i]==0: cnt+=...
vfc_57349
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4 4\n2\n1\n3\n", "output": "1\n1\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
917_C. Pollywog
Solve the following coding problem using the programming language python: As we all know, Dart is some kind of creature from Upside Down world. For simplicity, we call their kind pollywogs. Dart and x - 1 other pollywogs are playing a game. There are n stones in a row, numbered from 1 through n from left to right. At ...
vfc_57353
{ "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": "2 3 10 2\n1 2 3\n5 -10\n6 1000\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 7 85 3\n17 5 28 4 52 46 6\n59 -76\n33 -69\n19 2018\n", "output": "135\n", "typ...
code_contests
verifiable_code
93_C. 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...
```python n=int(input()) mn=[float('inf')]*256 ans="" done=set() def gen(vals,st): global mn,ans #print(*vals) if('|'.join([str(x) for x in vals]) in done): return done.add('|'.join([str(x) for x in vals])) if(vals[-1]==n): if(len(vals)<mn[n]): mn[n]=len(vals) ...
vfc_57357
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "1\nlea ebx, [4*eax]\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "1\nlea ebx, [2*eax]", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
967_A. Mind the Gap
Solve the following coding problem using the programming language python: These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute. He was...
```python # -*- coding: utf-8 -*- # @Date : 2019-01-30 20:41:28 # @Author : raj lath (oorja.halt@gmail.com) # @Link : link # @Version : 1.0.0 from sys import stdin max_val=int(10e12) min_val=int(-10e12) def read_int() : return int(stdin.readline()) def read_ints() : return [int(x) for x in stdin.readl...
vfc_57361
{ "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 17\n0 30\n1 0\n12 0\n", "output": "0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "16 50\n0 30\n1 20\n3 0\n4 30\n6 10\n7 50\n9 30\n11 10\n12 50\n14 30\n16 10\n17 50\n19 30\n21 10\n22...
code_contests
verifiable_code
993_A. Two Squares
Solve the following coding problem using the programming language python: You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect. The interior of the square is considered to be part of the squar...
```python a=list(map(int,input().split())) b=list(map(int,input().split())) a1 = min(a[0::2]) b1 = max(a[0::2]) c1 = min(a[1::2]) d1 = max(a[1::2]) g = sum(b[0::2])/4 h = sum(b[1::2])/4 r = abs(b[0]-g) + abs(b[1]-h) for i in range(a1,b1+1) : for j in range (c1,d1+1) : if abs(i-g) + abs(j-h)<=r : ...
vfc_57365
{ "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": "6 0 6 6 0 6 0 0\n7 4 4 7 7 10 10 7\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0 6 0 6 6 0 6\n1 3 3 5 5 3 3 1\n", "output": "YES\n", "type": "stdin_std...
code_contests
verifiable_code
ashish-and-binary-matrix-1
Solve the following coding problem using the programming language python: Pulkit is really good at maths. Recently, he came to know about a problem on matrices. Amazed by the problem he got, he asked Ashish the same problem. Ashish also being good at maths solved the problem within 5 minutes. Now, its your time to sol...
```python for i in range(input()): l=[int(x) for x in raw_input().split()] l1=[] l2=[] for j in range(l[0]): a=input() l1.append(a) for k in range(0,len(l1)): if(l1[k] not in l2): l2.append(l1[k]) if(len(l1)==len(l2)): print('Yes') else: print('No') ```
vfc_57369
{ "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 3\n101\n000\n100\n2 2\n11\n11\n\nSAMPLE", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 3\n101\n000\n110\n2 2\n11\n11\n\nSAMPLE", "output": "Yes\nNo\n"...
code_contests
verifiable_code
chesters-revenge-4
Solve the following coding problem using the programming language python: Chester has been bullied enough all his life and now he seeks revenge. His first victim being Mike, obviously! He found this very interesting question from somewhere but he doesn't have the answers to it. Now without the answers he cannot know i...
```python for i in range(input()): a = raw_input().split() a1 = int(a[0]) a2 = int(a[1]) numb = str(a1**a2) count = 0 for i in numb: count+=int(i) print count ```
vfc_57373
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 10\n3 3\n5 2\n2 7\n100 1000\n\nSAMPLE", "output": "7\n9\n7\n11\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3000\n98 701\n59 853\n43 878\n62 839\n82 286\n3 371\n0 907\n23 614\n7...
code_contests
verifiable_code
dual-prime
Solve the following coding problem using the programming language python: a number can be said dual prime. if the number is prime and the sum of digits of the number is also a prime number. If a number is dual prime then print YES else print NO SAMPLE INPUT 2 13 11 SAMPLE OUTPUT NO YES The input will be given via s...
```python def prime(x): i=2 while i*i<=x: if x%i==0: return False i+=1 return True for _ in range(input()): n=input() if prime(n)==False: print 'NO' continue else: rev=0 while n: x=n%10 rev=rev+x n=n/10 # print rev if prime(rev)==True: print 'YES' else:print 'NO' ```
vfc_57377
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n13\n11\n\nSAMPLE", "output": "NO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n13\n4\n\nSAMPLE", "output": "NO\nNO\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
gudi-and-the-magical-orbs-july-easy
Solve the following coding problem using the programming language python: Moving ahead, Gudi now enters a room where the floor is divided into N x M square tiles, forming a grid with N rows and M columns. Each square in the grid contains a number of Magical Orbs that Gudi has to absorb if she steps on it. Each Orb in...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' T = int(raw_input()) for t in xrange(0, T): N, M, K = [int(x) for x in raw_input().split()] a = [] for i in xrange(0, N): a.append([int(x) for x in raw_inp...
vfc_57381
{ "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 3 7\n2 3 1\n6 1 9\n8 2 3\n3 4 9\n2 3 4 1\n6 5 5 3\n5 2 3 4\n\nSAMPLE", "output": "6\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n11 14 293\n16 7 10 14 6 17 11 16 5 11 7 10 ...
code_contests
verifiable_code
little-shino-and-coins-3
Solve the following coding problem using the programming language python: Little Shino loves to play with coins. In the city she lives, there are 26 different types of coins. Each coin is represented with a lowercase letter a, b, c, ... , y, z. Shino has some number of coins and she placed them in some random sequence...
```python k = int(raw_input()) line = raw_input() n = len(line) sets = 0 for l in range(n): count = 0 chars = "" for i, x in enumerate(line[l:]): if x not in chars: count += 1 chars += x if count < k: continue elif count > k: break sets += 1 # print line[l : l + i + 1] print sets ```
vfc_57385
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nabcaa\n\nSAMPLE", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "18\norfqxzjztvcgvzlcedwnezbwxmpobmrvxaskwvvwquudrnwhmmzheqxiwhfuxavlwftgyxxhpygspvwdnvmgnwnpkdrnznzvrkmjjmwi...
code_contests
verifiable_code
mystery
Solve the following coding problem using the programming language python: Problem Statement : Solve the Mystery. :) Input First line of input contains T – No of test cases.(1 ≤ T ≤ 21) Next T lines of input contains three integers a,b,c separated by spaces. (1 ≤ a,b ≤ 20) (1 ≤ c ≤ 100) Output T lines should conta...
```python T = input() for t in xrange(T): a,b,c = map(int, raw_input().split()) fibo = [a,b] if c == 0: print a elif c == 1: print b else: for i in range(2,c+1): fib = fibo[1] + fibo[0] fibo[0] = fibo[1] fibo[1] = fib print fibo[1] ```
vfc_57389
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3 2\n13 14 1\n14 5 9\n\nSAMPLE", "output": "5\n14\n464", "type": "stdin_stdout" }, { "fn_name": null, "input": "30\n1 1 50\n20 20 70\n10 12 40\n20 20 50\n2 3 2\n13 14 1\n14 5 9\n17 18 3\n1 1 1\n...
code_contests
verifiable_code
prime-sums
Solve the following coding problem using the programming language python: Problem Statement Given an integer N, find the sum of all primes < N. Input Format The only line of the input file contains a positive integer N. Output Format Output the sum of all primes < N. Constraints 1 ≤ N ≤ 4000000 You are guaranteed th...
```python from math import sqrt def checkPrime(num): limit = int(sqrt(num)) for i in range(2,limit+1): if num%i == 0: return False return True def primeUsingSieve(N): arr = [] i = 2 while(i<=N): arr.append(i) i += 1 limit = int(sqrt(N)) for i in rang...
vfc_57393
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n\nSAMPLE", "output": "76127\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4000000", "output": "544501644261", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
sansas-escape
Solve the following coding problem using the programming language python: As you all know, Sansa is trying to escape from the Boltons' specially from Ramsey! Winterfell is divided in an straight line of ice. In the line, each block has some thickness value. Ramsey would catch Sansa and Theon in an interval of ice if...
```python n=int(raw_input()) a=list(map(int,raw_input().split())) xor=[0]*n xor[0]=a[0] for i in range(1,n): xor[i]=a[i]^xor[i-1] #print(xor) for i in range(int(raw_input())): x,y=map(int,raw_input().split()) print( xor[x-1]^xor[y] if (x!=0) else xor[y]) ```
vfc_57397
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1 2 3 4 5 6 24 8 9 10\n2\n2 4\n0 2\n\nSAMPLE", "output": "2\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
sureshs-array-3
Solve the following coding problem using the programming language python: Suresh is a strange boy. He neither likes an array in ascending order nor in descending order. Then what does he like? He likes an array if and only if it is mixed i.e, both ascending and descending. He has got lots of arrays from his friends. B...
```python for _ in range(int(raw_input())): n=int(raw_input()) arr=map(int,raw_input().split()) arr=sorted(arr) arr1=[] k=0 j=0 for i in range(len(arr)): if i%2==0: arr1.append(arr[k]) k+=1 else: arr1.append(arr[n-1-j]) j+=1 #k+=1 for i in range(len(arr1)): print arr1[i], print ```
vfc_57401
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n9\n6 8 3 9 9 2 6 8 1 \n3\n3 8 2 \n8\n3 5 1 3 0 4 7 3\n\nSAMPLE", "output": "1 9 2 9 3 8 6 8 6 \n2 8 3 \n0 7 1 5 3 4 3 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n4\n4 9 7 5 \n...
code_contests
verifiable_code
where-have-the-vowels-gone-pledge-easy
Solve the following coding problem using the programming language python: In the world of Latin Alphabets, there seemed to be a catastrophe! All the vowels went missing. The other alphabets got disturbed and began the search operation. While searching they stumbled upon a garbage of letters. Can you help them find if ...
```python n=int(raw_input()) s=raw_input() vowels=[] check=[1,1,1,1,1] for i in range(n): ch=s[i] if ch=='a' and check[0]==1: vowels.append(ch) check[0]=0 elif ch=='e' and check[1]==1: vowels.append(ch) check[1]=0 elif ch=='i' and check[2]==1: vowels.append(ch) check[2]=0 elif ch=='o' and check[3...
vfc_57405
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\natuongih\n\nSAMPLE", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nholfz", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...