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
codeforces
verifiable_code
758
Solve the following coding problem using the programming language python: In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are *n* citizens, the welfare of each of them ...
n = int(input()) l = list(map(int,input().split())) p = max(l) v=0 r=0 for i in l: v = p-i r+=v print(r)
vfc_82049
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 1 2 3 4", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 0 1 1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input...
codeforces
verifiable_code
996
Solve the following coding problem using the programming language python: Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum numb...
t=int(input()) x=[100,20,10,5,1] count=0 for i in x: count+=t//i t%=i print(count)
vfc_82053
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "125", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "43", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000000000", ...
codeforces
verifiable_code
834
Solve the following coding problem using the programming language python: It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclo...
n, k = map(int, input().split()) s = input() d = {} op = set() for i in range(len(s)): d[s[i]] = i ans = 0 doors = 0 for i in range(len(s)): if s[i] not in op: doors += 1 op.add(s[i]) ans = max(ans, doors) if i == d[s[i]]: doors -= 1 print(('YES','NO')[ans <= k])
vfc_82057
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 1\nAABBB", "output": "NO", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
78
Solve the following coding problem using the programming language python: Haiku is a genre of Japanese traditional poetry. A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should cont...
a = input() damn = 0 damn += a.count('a') damn += a.count('e') damn += a.count('i') damn += a.count('o') damn += a.count('u') if damn != 5: print('NO') exit() damn = 0 b = input() damn += b.count('a') damn += b.count('e') damn += b.count('i') damn += b.count('o') damn += b.count('u') if damn !=...
vfc_82065
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "on codeforces \nbeta round is running\n a rustling of keys ", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "how many gallons\nof edo s rain did you drink\n ...
codeforces
verifiable_code
81
Solve the following coding problem using the programming language python: Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed only once. Fo...
n = input() st = [] for i in range(len(n)): st.append(n[i]) while len(st) > 1 and st[-1] == st[-2]: st.pop() st.pop() print(''.join(st))
vfc_82069
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "hhoowaaaareyyoouu", "output": "wre", "type": "stdin_stdout" }, { "fn_name": null, "input": "reallazy", "output": "rezy", "type": "stdin_stdout" }, { "fn_name": null, "...
codeforces
verifiable_code
917
Solve the following coding problem using the programming language python: As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Ups...
st=input() le=len(st) ans=0 for i in range(le): l=0 w=0 for j in range(i,le): if(st[j]=="("): l+=1 elif(st[j]==")"): l-=1 else: w+=1 if(l+w<0): break elif(w>l): xx=l l=w ...
vfc_82073
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "((?))", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "??()??", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "?????)(???...
codeforces
verifiable_code
749
Solve the following coding problem using the programming language python: Bachgold problem is very easy to formulate. Given a positive integer *n* represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1. Recall that integer *k* is...
def main(): a = int(input()) b = [2] * (a // 2) print(a // 2) if a % 2 != 0: b[-1] = 3 print(*b) main()
vfc_82077
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "2\n2 3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
573
Solve the following coding problem using the programming language python: Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are *n* players (including Limak himself) and right now all of them have bids on the table. *i*-th of them has bid with size *a**i* dollars. E...
n = int(input()) m=list(map(int,input().split())) for i in range(n): while(m[i]%2==0): m[i]//=2 while(m[i]%3==0): m[i]//=3 if(len(set(m))==1): print('Yes') else: print('No')
vfc_82081
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n75 150 75 50", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n100 150 250", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
998
Solve the following coding problem using the programming language python: There are a lot of things which could be cut — trees, paper, "the rope". In this problem you are going to cut a sequence of integers. There is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited budg...
n,b=map(int,input().split()) a=list(map(int,input().split())) q,w,l,m=0,0,[],0 for i in range(n-1): if a[i]&1:q+=1 else:w+=1 if q==w:l.append(abs(a[i]-a[i+1])) l.sort() for i in l: if i<=b:m+=1;b-=i else:break print(m)
vfc_82085
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 4\n1 2 5 10 15 20", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 10\n1 3 2 4", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
215
Solve the following coding problem using the programming language python: Vasya's bicycle chain drive consists of two parts: *n* stars are attached to the pedal axle, *m* stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation. We know that the *i*-th sta...
import math n=int(input()) arr=[int(x) for x in input().split()] m=int(input()) brr=[int(x) for x in input().split()] mx=0 for i in range(n): for j in range(m): if int(math.ceil(brr[j]/arr[i]))==brr[j]//arr[i]: if brr[j]//arr[i]>mx: mx=brr[j]//arr[i] c=0 for i in rang...
vfc_82089
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 5\n3\n12 13 15", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 3 4\n5\n10 11 12 13 14", "output": "1", "type": "stdin_stdout" }, { "fn_na...
codeforces
verifiable_code
617
Solve the following coding problem using the programming language python: An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point *x*(*x*<=&gt;<=0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positio...
n = int(input()) moves = 0 while n >0 : if n >=5: n-=5 elif n>=4: n-=4 elif n>=3: n-=3 elif n>=2: n-=2 elif n>= 1: n-=1 moves+=1 print(moves)
vfc_82093
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "12", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "999999", "ou...
codeforces
verifiable_code
964
Solve the following coding problem using the programming language python: There are *n* incoming messages for Vasya. The *i*-th message is going to be received after *t**i* minutes. Each message has a cost, which equals to *A* initially. After being received, the cost of a message decreases by *B* each minute (it can ...
n,a,b,c,t=[int(i) for i in (input().split(" "))] ans=0 lis=[int(i) for i in input().split(" ")] if(b>=c): ans=n*a else: for i in lis: ans+=(c*(t-i)+a-b*(t-i)) print(ans)
vfc_82105
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5 5 3 5\n1 5 5 4", "output": "20", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3 1 1 3\n2 2 2 1 1", "output": "15", "type": "stdin_stdout" }, { "fn_name": nul...
codeforces
verifiable_code
514
Solve the following coding problem using the programming language python: Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*. Help Chewbacca to transform the initial number *x* to the ...
s=input() ss="" for i in range(len(s)): if i==0 and s[i]=='9': ss+=s[i] continue if int(s[i])>9-int(s[i]): ss+=str(9-int(s[i])) else: ss+=s[i] print(ss)
vfc_82109
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "27", "output": "22", "type": "stdin_stdout" }, { "fn_name": null, "input": "4545", "output": "4444", "type": "stdin_stdout" }, { "fn_name": null, "input": "1", "...
codeforces
verifiable_code
467
Solve the following coding problem using the programming language python: George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want to live in the same room. The dormi...
n = int(input()) accomodation = [] available = 0 for i in range(n): inhabitants, capacity = list(map(int, input().split())) accomodation.append((inhabitants, capacity)) if capacity - inhabitants >= 2: available += 1 else: continue print(available)
vfc_82113
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n2 2\n3 3", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 10\n0 10\n10 10", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
268
Solve the following coding problem using the programming language python: Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays...
n = int(input()) ho = [] gst = [] for i in range(n): team = input().split() ho.append(team[0]) gst.append(team[1]) count = 0 for c in ho: count += gst.count(c) print(count)
vfc_82117
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n2 4\n3 4", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n100 42\n42 100\n5 42\n100 5", "output": "5", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
777
Solve the following coding problem using the programming language python: Of course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the rings for this wonderful game? Once upon a time, the ruler of the ancient Egypt ordered the workers of Hanoi Factory to c...
read = input n = int(read()) c = [] for i in range(n): a, b, h = map(int, read().split()) c.append((b, a, h)) c.append((1e18, 0, 0)) c.sort() c.reverse() s, p = [0], [0] * (n + 1) for i in range(1, n + 1): while c[s[-1]][1] >= c[i][0]: s.pop() p[i] = p[s[-1]] + c[i][2] s.append(i) print(max(p)) ...
vfc_82125
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 5 1\n2 6 2\n3 7 3", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 1\n1 3 3\n4 6 2\n5 7 1", "output": "4", "type": "stdin_stdout" }, { "fn...
codeforces
verifiable_code
551
Solve the following coding problem using the programming language python: Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. In total, *n* students will attend, and before the start, every one of them has som...
wwe=int(input()) s=list(map(int,input().split())) p=sorted(s,reverse=True) k={} for i in s: if i in k: print(k[i],end=' ') else: for j in range(len(p)): if p[j]==i: print(j+1,end=' ') k[i]=j+1 ...
vfc_82129
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3 3", "output": "3 1 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n3 ...
codeforces
verifiable_code
981
Solve the following coding problem using the programming language python: A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not. A substring $s[l ...
def is_pal(S): for i in range(0, len(S)): if S[i] != S[-(i+1)]: return False return True while True: S = input() if not is_pal(S): print(len(S)) else: if S.count(S[0]) == len(S): print(0) else: print(len(S)-1) ...
vfc_82133
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "mew", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "wuffuw", "output": "5", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
581
Solve the following coding problem using the programming language python: One day Vasya the Hipster decided to count how many socks he had. It turned out that he had *a* red socks and *b* blue socks. According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu...
def main(): (red_socks, blue_socks) = input().split() count = 0 (red_socks, blue_socks) = int(red_socks), int(blue_socks) while int(red_socks) > 0 and int(blue_socks) > 0: count += 1 (red_socks, blue_socks) = red_socks - 1, blue_socks - 1 print(count, red_socks // 2 + blue_soc...
vfc_82137
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1", "output": "1 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3", "output": "2 0", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
886
Solve the following coding problem using the programming language python: Vlad likes to eat in cafes very much. During his life, he has visited cafes *n* times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research. First of all, Vlad ass...
n = input() stol = input() stol = stol.split(' ') nums = {} for i in range(0,len(stol)): nums[stol[i]] = [i, len(stol)-i] dif = [] max = -1 imax = 0 fl = 0 for num in nums: if max<nums[num][1]: max = nums[num][1] imax = num print(imax)
vfc_82141
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 2 1 2", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 1 2 2 4 1", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
859
Solve the following coding problem using the programming language python: You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie,...
import math from random import random def getInt(): return(int(input())) def getInts(): line = input().split() return [int(l) for l in line] def getFloat(): return(float(input())) def getFloats(): line = input().split() return [float(l) for l in line] def getStrings(): ...
vfc_82145
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n141 592 653", "output": "653 733", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10 21 10 21 10", "output": "31 41", "type": "stdin_stdout" }, { "fn_name": nu...
codeforces
verifiable_code
811
Solve the following coding problem using the programming language python: At regular competition Vladik and Valera won *a* and *b* candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 can...
import math while True: try: a,b=map(int,input().split()) except: break n=math.sqrt(a) n=int(n) bt=(n+1)*n if b>=bt: print("Vladik") else: print("Valera")
vfc_82149
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1", "output": "Valera", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 6", "output": "Vladik", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
545
Solve the following coding problem using the programming language python: Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are *n* people in the queue. For each person we know time *t**i* needed to serve him. A person will be disappointed if the time he waits is mor...
n = int(input()) tlist = list(map(int, input().split())) tlist.sort() count = 0 sum1 = tlist[0] for i in range(1,n): if sum1 <= tlist[i]: count += 1 sum1 += tlist[i] print(count+1)
vfc_82153
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n15 2 1 5 3", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "15\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "output": "2", "type": "stdin_stdout" }, { "fn_name...
codeforces
verifiable_code
490
Solve the following coding problem using the programming language python: The School №0 of the capital of Berland has *n* children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child ...
n = int(input()) x = list(map(int, input().split())) a = [i + 1 for i, j in enumerate(x) if j == 1] b = [i + 1 for i, j in enumerate(x) if j == 2] c = [i + 1 for i, j in enumerate(x) if j == 3] if not a or not b or not c: print(0) else: print(min(len(a), len(b), len(c))) for i, j, k in zip(a, b, c)...
vfc_82157
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 3 1 3 2 1 2", "output": "2\n3 5 2\n6 7 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 1 1 2", "output": "0", "type": "stdin_stdout" }, { "fn_name": nul...
codeforces
verifiable_code
222
Solve the following coding problem using the programming language python: One day shooshuns found a sequence of *n* integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: 1. Find the number that goes *k*-th in the current sequence and add the same num...
n,k=map(int,input().split()) a=list(map(int,input().split())) while n and a[n-1]==a[-1]: n-=1 if k>n: print(n) else: print(-1)
vfc_82161
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "3000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n3 1 1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n3 1 1", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
codeforces
verifiable_code
746
Solve the following coding problem using the programming language python: Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters...
n = int(input()) a=input() if (n-1)%2==0: c = '' i = n - 2 while i % 2 != 0 and i > 0: c = c + a[i] i = i - 2 i = 0 while i % 2 == 0 and i < n: c = c + a[i] i = i + 2 else: c = '' i = n - 2 while i % 2 == 0 and i >= 0: c = c + a[i] ...
vfc_82165
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nlogva", "output": "volga", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nno", "output": "no", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n...
codeforces
verifiable_code
Solve the following coding problem using the programming language python: Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1<=×<=*n*. Each cell contains the direction for the next jump and the length of that jump. Grasshopper sta...
n = int(input()) s = str(input()) L = list(map(int, input().split())) D = [0 for _ in range(n)] r = 0 ok = 1 while r >= 0 and r < n: if D[r]: ok = 0 break else: D[r] = 1 if s[r] == "<": r = r - L[r] else: r = r + L[r] if ok: print("FINITE") else: print("IN...
vfc_82169
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n><\n1 2", "output": "FINITE", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n>><\n2 1 1", "output": "INFINITE", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
114
Solve the following coding problem using the programming language python: When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word "tma" (which now means "too much to be counted") used to stand for a thousand and "tma tmysc...
import math k=int(input()) l=int(input()) n=0 tmp=k while(l>tmp and l!=tmp): tmp=tmp*k n+=1 if(l==tmp): print("YES") print(n) else: print("NO")
vfc_82173
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n25", "output": "YES\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n8", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "123\n1...
codeforces
verifiable_code
4
Solve the following coding problem using the programming language python: One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and...
weight = input() w = int(weight) a = 0 b = w - a while True: a += 1 b = w - a if a % 2 == 0 and b % 2 == 0 and b != 0: print('YES') break elif a > w: print('NO') break else: continue
vfc_82177
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "5000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "5", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "4", "outpu...
codeforces
verifiable_code
49
Solve the following coding problem using the programming language python: Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever th...
n=input() n=list(n) n=n[::-1] l=['A','E','I','O','U','Y','a','e','i','o','u','y'] i=1 while(n[i]==' '): i=i+1 continue #print(n,i) if(n[i] not in l): print("NO") else: print("YES")
vfc_82181
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Is it a melon?", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "Is it an apple?", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
939
Solve the following coding problem using the programming language python: As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are *n* planes on Earth, numbered from 1 to *n*, and the plane with number *i* likes the plane with number *f**i*, where 1<=...
n = int(input()) f = [int(i) for i in input().split()] D = {} for i in range(1, n + 1): D[i] = f[i - 1] res = 'NO' for ver in D.keys(): chel = ver for _ in range(3): ver = D[ver] if ver == chel: res = 'YES' print(res)
vfc_82185
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 4 5 1 3", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 5 5 5 1", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "inp...
codeforces
verifiable_code
38
Solve the following coding problem using the programming language python: The Berland Armed Forces System consists of *n* ranks that are numbered using natural numbers from 1 to *n*, where 1 is the lowest rank and *n* is the highest rank. One needs exactly *d**i* years to rise from rank *i* to rank *i*<=+<=1. Reachin...
a = int(input()) b = list(map(int,input().split())) c , d = list(map(int,input().split())) count = 0 for i in range(c,d): count += b[i-1] print(count)
vfc_82189
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 6\n1 2", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5 6\n1 3", "output": "11", "type": "stdin_stdout" }, { "fn_name": null, "input":...
codeforces
verifiable_code
208
Solve the following coding problem using the programming language python: Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them. Let's assume that a song consists of some number o...
s = input() for x in s.split('WUB'): if ((x != ' ') and (x != '')): print(x,end=' ')
vfc_82193
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "WUBWUBABCWUB", "output": "ABC ", "type": "stdin_stdout" }, { "fn_name": null, "input": "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB", "output": "WE ARE THE CHAMPIONS MY FRIEND ", "t...
codeforces
verifiable_code
224
Solve the following coding problem using the programming language python: You've got an array *a*, consisting of *n* integers: *a*1,<=*a*2,<=...,<=*a**n*. Your task is to find a minimal by inclusion segment [*l*,<=*r*] (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) such, that among numbers *a**l*,<= *a**l*<=+<=1,<= ...,<= *a**r* there a...
import sys import os.path if(os.path.exists('input.txt')) : sys.stdin = open("input.txt", "r") sys.stdout = open("output.txt", "w") sys.stderr = open("error.txt", "w") depth = 1000005 mod = 1000000007 lim = mod * mod sys.setrecursionlimit(depth) linp = lambda: list(minp()) minp = la...
vfc_82197
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 2 2 3", "output": "1 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 3\n1 1 2 2 3 3 4 5", "output": "2 5", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
440
Solve the following coding problem using the programming language python: Polycarpus adores TV series. Right now he is ready to finish watching a season of a popular sitcom "Graph Theory". In total, the season has *n* episodes, numbered with integers from 1 to *n*. Polycarpus watches episodes not one by one but in a ...
n = int(input()) s = n * (n + 1) // 2 for x in input().split(): s -= int(x) print(s)
vfc_82201
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "500" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n3 8 10 1 7 9 6 5 2", "output": "4", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
554
Solve the following coding problem using the programming language python: Ohana Matsumae is trying to clean a room, which is divided up into an *n* by *n* grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a...
n = int(input()) p = [] for i in range(n): p.append(list(input())) max = 0 for i in range(n): q = p for t in range(n): if q[i][t] == '0': for k in range(n): if q[k][t] == '0': q[k][t] = '1' else: q[k][t] = '0...
vfc_82205
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0101\n1000\n1111\n0101", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n111\n111\n111", "output": "3", "type": "stdin_stdout" }, { "fn_name": nu...
codeforces
verifiable_code
43
Solve the following coding problem using the programming language python: One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole ...
n = int(input()) scores = {} for i in range(n): team = input() scores[team] = scores.get(team, 0) + 1 print(max(scores.items(), key=lambda x: x[1])[0])
vfc_82209
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nABC", "output": "ABC", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nA\nABA\nABA\nA\nA", "output": "A", "type": "stdin_stdout" }, { "fn_name": null, "in...
codeforces
verifiable_code
515
Solve the following coding problem using the programming language python: Drazil is playing a math game with Varda. Let's define for positive integer *x* as a product of factorials of its digits. For example, . First, they choose a decimal number *a* consisting of *n* digits that contains at least one digit larger ...
answer = { "7": [7], "8": [7, 2, 2, 2], "9": [7, 3, 3, 2], "6": [5, 3], "5": [5], "4": [3, 2, 2], "3": [3], "2": [2], "1": [], "0": [] } def main(): _ = input() inp = str(input()) ans = [] for i in inp: ans += answer[i] ans.sort() for i in reverse...
vfc_82213
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1234", "output": "33222", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n555", "output": "555", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
499
Solve the following coding problem using the programming language python: You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes. You know two languages, and the professor is giving the lecture in the first one. The words in ...
a,b = (map(int,input().split())) dic = {} for i in range(b): a = input().split(' ') if(len(a[0])>len(a[1])): dic[a[0]] = a[1] dic[a[1]] = a[1] else: dic[a[0]] = a[0] dic[a[1]] = a[0] t = input().split() for i in range(len(t)): print(dic[t[i]],end = ' ')
vfc_82217
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest", "output": "codeforces round letter round", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\nj...
codeforces
verifiable_code
1008
Solve the following coding problem using the programming language python: Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant. In Berlanese, there has to be a vowel after every consonant, but...
s=input() answer='yes' if s[-1] not in "naeiou": answer='no' for i in range(len(s)-1): if s[i] not in "naeiou" and s[i+1] not in "aeiou": answer='no' print(answer)
vfc_82221
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "sumimasen", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "ninja", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
255
Solve the following coding problem using the programming language python: Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg should repeat the *i*-th ...
n = int(input()) l_n = list(map(int, input().split())) a_t = [0]*3 for i in range(n): a_t[i % 3] += l_n[i] if a_t[0] > a_t[1] and a_t[0] > a_t[2]: print("chest") elif a_t[1] > a_t[2]: print("biceps") else: print("back")
vfc_82225
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 8", "output": "biceps", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5 1 10", "output": "back", "type": "stdin_stdout" }, { "fn_name": null, "input":...
codeforces
verifiable_code
664
Solve the following coding problem using the programming language python: Greatest common divisor *GCD*(*a*,<=*b*) of two positive integers *a* and *b* is equal to the biggest integer *d* such that both integers *a* and *b* are divisible by *d*. There are many efficient algorithms to find greatest common divisor *GCD*...
a, b = list(input().split()) if a == b: print(a) else: print("1")
vfc_82229
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576", "output": "61...
codeforces
verifiable_code
148
Solve the following coding problem using the programming language python: «One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine. However, just counting dragons was boring as well, so she entertained herself at best sh...
a=int(input()) b=int(input()) c=int(input()) d=int(input()) y=int(input()) if a==1 or b==1 or d==1 or c==1: print(y) else: h=set() for i in range(1,y+1): if i%a!=0 and i%b!=0 and i%c!=0 and i%d!=0 : h.add(i) print(y-len(h))
vfc_82233
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n3\n4\n12", "output": "12", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
18
Solve the following coding problem using the programming language python: Last year Bob earned by selling memory sticks. During each of *n* days of his work one of the two following events took place: - A customer came to Bob and asked to sell him a 2*x* MB memory stick. If Bob had such a stick, he sold it and got ...
max_x = 2001 n = int(input()) income = [0]*n win = {} for i in range(n): s, a = input().split() a = int(a) if (i > 0): income[i] = income[i-1] if (s[0] == 'w'): win[a] = i; elif (win.get(a) != None): income[i] = max(income[i], income[win.get(a)] + 2**a) print...
vfc_82237
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\nwin 10\nwin 5\nwin 3\nsell 5\nsell 3\nwin 10\nsell 10", "output": "1056", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nwin 5\nsell 6\nsell 4", "output": "0", "type": "stdi...
codeforces
verifiable_code
254
Solve the following coding problem using the programming language python: Petya has got 2*n* cards, each card contains some integer. The numbers on the cards can be the same. Let's index all cards by consecutive integers from 1 to 2*n*. We'll denote the number that is written on a card with number *i*, as *a**i*. In o...
import sys sys.stdin = open("input.txt", "r") sys.stdout = open("output.txt", "w") n=int(input()) d={} for x,y in enumerate(input().split(),1): d.setdefault(y,[]).append(x) if any(len(d[i])%2!=0 for i in d): print(-1) exit(0) for i in d: print("\n".join("{0} {1}".format(*k) for k in zip(d[i][::2],d[i][1...
vfc_82241
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n20 30 10 30 20 10", "output": "4 2\n1 5\n6 3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
784
Solve the following coding problem using the programming language python: In this problem you will write a simple generator of Brainfuck ([https://en.wikipedia.org/wiki/Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)) calculators. You are given an arithmetic expression consisting of integers from 0 to 255 and add...
a = input() b = int(eval(a)) res = '+' * 48; if b >= 200: res += "++.--"; b -= 200; elif b >= 100: res += "+.-"; b -= 100; k = b // 10 b %= 10 if k > 0: res += ("+" * k + '.' + '-' * k) res += ('+' * b + '.') print(res)
vfc_82245
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2+3", "output": "+++++++++++++++++++++++++++++++++++++++++++++++++++++.>", "type": "stdin_stdout" }, { "fn_name": null, "input": "9-7", "output": "++++++++++++++++++++++++++++++++++++++++++++++...
codeforces
verifiable_code
460
Solve the following coding problem using the programming language python: Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th day (at days with numbers...
a,b=map(int,input().split()) c=0 d=0 while a>0: d+=1 c+=1 if c==b: a+=1 c=0 a-=1 print(d)
vfc_82249
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 3", "output": "13", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2", "o...
codeforces
verifiable_code
282
Solve the following coding problem using the programming language python: The classic programming language of Bitland is Bit++. This language is so peculiar and complicated. The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations: - Operation ++ increases the value o...
x = int(input()) resultaat = 0 for y in range(0,x,1): z = input() if z == "++X" or z == "X++": resultaat += 1 if z == "--X" or z == "X--": resultaat -= 1 print(resultaat)
vfc_82253
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n++X", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nX++\n--X", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n+...
codeforces
verifiable_code
507
Solve the following coding problem using the programming language python: Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has *n* instruments, it takes *a**i* days to learn *i*-th instrument. Being busy, Amr dedicated *k* days to le...
n,m=map(int,input().split()) a=list(map(int,input().split())) #a.sort() l=[] for i in range(n): l.append((a[i],i+1)) l.sort() cnt=0 p=[] s=0 k=0 #print(l) for i in range(n): s=s+l[i][0] if s<=m: cnt+=1 p.append(l[i][1]) else: print(cnt) print(*p) ...
vfc_82257
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 10\n4 3 1 2", "output": "4\n1 2 3 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6\n4 3 1 1 2", "output": "3\n3 4 5", "type": "stdin_stdout" }, { "fn_name": ...
codeforces
verifiable_code
703
Solve the following coding problem using the programming language python: Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game. R...
n=int(input()) x=0 y=0 z=0 for i in range(n): a,b=map(int,input().split()) if(a>b): x=x+1 elif(a<b): y=y+1 elif(a==b): z=z+1 if(x>y): print("Mishka") elif(x<y): print("Chris") elif(x==y or z>0): print("Friendship is magic!^^")
vfc_82261
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 5\n2 1\n4 2", "output": "Mishka", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
863
Solve the following coding problem using the programming language python: Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks....
inf = float('inf') def solve(A, N): A.sort() N *= 2 ans = inf for i in range(N): for j in range(i + 1, N): B = [] for k in range(N): if k != i and k != j: B.append(A[k]) total = sum(B[i + 1] - B[i] for i in range(0, N - 2...
vfc_82265
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2 3 4", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 3 4 6 3 4 100 200", "output": "5", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
810
Solve the following coding problem using the programming language python: Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one. In school, where Noora is...
n, k = map(int, input().split()) marks = list(map(int, input().split())) s = sum(marks) q = 0 while s < n * (k - 0.5): q += 1 s += k n += 1 print(q)
vfc_82269
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 10\n8 9", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n4 4 4", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 ...
codeforces
verifiable_code
588
Solve the following coding problem using the programming language python: Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat. There is a big shop uptown and Malek wants to buy meat for her from there. In *i*-th da...
from math import inf min_p = inf ans = 0 for _ in range(int(input())): ai, pi = map(int, input().split()) min_p = min(min_p, pi) ans += ai * min_p print(ans)
vfc_82273
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3\n2 2\n3 1", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3\n2 1\n3 2", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
814
Solve the following coding problem using the programming language python: A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed. To get rid of the oddity and recover her weight, a special...
n,k= map(int,input().split()) arr = list(map(int,input().split())) b = list(map(int,input().split())) if k >= 2: print("Yes") else: if k == 1: arr[arr.index(0)] = b[0] x = [i for i in arr] x.sort() if x == arr: print("No") else: print(...
vfc_82277
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n11 0 0 14\n5 4", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1\n2 3 0 8 9 10\n5", "output": "No", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
231
Solve the following coding problem using the programming language python: One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they wi...
n = int(input()) k = 0 for i in range(n): arr = [int(i) for i in input().split()] if arr.count(1) > 1: k += 1 print(k)
vfc_82281
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 0\n1 1 1\n1 0 0", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 0 0\n0 1 1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
757
Solve the following coding problem using the programming language python: The gym leaders were fascinated by the evolutions which took place at Felicity camp. So, they were curious to know about the secret behind evolving Pokemon. The organizers of the camp gave the gym leaders a PokeBlock, a sequence of *n* ingredi...
mo = 10**9+7 def calc(l, r, si): res = 0 for i in range(l, r + 1): res = res * 2 + int(si[i]) return res def main(): n, si = int(input()), input() si = chr(0)+si f = [[0]*(1<<20) for i in range(6)] res, r, f[0][0]= 0, 0, 1 for i in range(1, n+1): r=(r+1)%6 ...
vfc_82285
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1011", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n10", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n01100...
codeforces
verifiable_code
128
Solve the following coding problem using the programming language python: In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8<=×<=8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has sev...
r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9 for i in range(0, 72, 9): t = set() for x in r: for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8): if s[y] == 'T': continue if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t...
vfc_82289
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": ".SSSSSSA\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\nMSSSSSSS", "output": "WIN", "type": "stdin_stdout" }, { "fn_name": null, "input": "SSSSSSSA\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSS...
codeforces
verifiable_code
910
Solve the following coding problem using the programming language python: A frog lives on the axis *Ox* and needs to reach home which is in the point *n*. She starts from the point 1. The frog can jump to the right at a distance not more than *d*. So, after she jumped from the point *x* she can reach the point *x*<=+<...
#10010101 n,e = map(int,input().split()) s = input() i = 0 d = e ans = -1 flag = 0 while(i<n-1): if(n-i-1 < e): e = n - i - 1 d = e if(d==0): flag = 1 print("-1") break if(s[i+d]=='1'): i = i + d ans+=1 d = e else: ...
vfc_82293
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 4\n10010101", "output": "2", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
433
Solve the following coding problem using the programming language python: Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of qu...
import sys import threading from sys import stdin, stdout from itertools import accumulate input = stdin.readline print = stdout.write if __name__ == "__main__": n = int(input().strip()) arr = list(map(int, input().strip().split())) arr_sort = sorted(arr) #this is the t = O(nlogn) step ...
vfc_82297
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6", "output": "24\n9\n28", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1...
codeforces
verifiable_code
82
Solve the following coding problem using the programming language python: Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go ...
n=int(input()) a=["Sheldon","Leonard","Penny","Rajesh","Howard"] R=1 while(R*5<n): n-=R*5 R*=2 print(a[(n-1)//R])
vfc_82301
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": "Sheldon", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
608
Solve the following coding problem using the programming language python: Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacit...
n,s=(map(int,input().split())) x=[] for i in range(n): a,b=(map(int,input().split())) x.append([a,b]) x.sort(key=lambda i:i[0],reverse=True) c=0 p=s for i in x: c=max(i[1],c+p-i[0]) p=i[0] c+=i[0] print(c)
vfc_82305
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 7\n2 1\n3 8\n5 2", "output": "11", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
876
Solve the following coding problem using the programming language python: You are given a multiset of *n* integers. You should select exactly *k* of them in a such way that the difference between any two of them is divisible by *m*, or tell that it is impossible. Numbers can be repeated in the original multiset and i...
n,k,m=map(int,input().split()) a=list(map(int,input().split())) mods=[0]*m mod=0 for i in range(n): mod=a[i]%m mods[mod]+=1 if mods[mod]==k: break else: print('No') exit() print('Yes') results=[None]*k count=0 for i in range(n): cur=a[i] if cur%m==mod: results[count]=cur count+=1 if...
vfc_82309
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 3\n1 8 4", "output": "Yes\n1 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 3\n1 8 4", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
715
Solve the following coding problem using the programming language python: ZS the Coder has drawn an undirected graph of *n* vertices numbered from 0 to *n*<=-<=1 and *m* edges between them. Each edge of the graph is weighted, each weight is a positive integer. The next day, ZS the Coder realized that some of the weig...
import heapq import random import sys from math import inf from types import GeneratorType RANDOM = random.randint(1, 10 ** 9) class FastIO: def __init__(self): return @staticmethod def read_str(): return sys.stdin.readline() def read_int(self): return int(...
vfc_82317
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "4000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5 13 0 4\n0 1 5\n2 1 2\n3 2 3\n1 4 0\n4 3 4", "output": "YES\n0 1 5\n2 1 2\n3 2 3\n1 4 8\n4 3 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1 123456789 0 1\n0 1 0", "output": "...
codeforces
verifiable_code
667
Solve the following coding problem using the programming language python: A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you,...
from math import pi X = list(map(int, input().split())) RainPouring = X[-1] * (X[0] / 2) ** 2 * pi if RainPouring >= X[-2]: print("NO");exit() X[-2] -= RainPouring Volume = X[1] * (X[0] / 2) ** 2 * pi print("YES", Volume / X[-2], sep='\n') # Caption: With the help of ARPA
vfc_82321
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 3 100", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1 1", "output": "YES\n3.659792366325", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
991
Solve the following coding problem using the programming language python: Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system. The term is coming to an end and students s...
from sys import * def main(): n = int(stdin.readline()) target = 4.5*n currentTotal = 0 minimumRetakes = 0 listOfScores = [int(x) for x in stdin.readline().split()] for x in listOfScores: currentTotal+=x listOfScores.sort() while(currentTotal < target): curre...
vfc_82325
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 4 4", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 4 5 5", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n...
codeforces
verifiable_code
30
Solve the following coding problem using the programming language python: A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself. The total income *A* of his kingdom during 0-th year is known, as well as the total income *B...
import sys q,w,num = map(int,input().split()) for p in range(-1000,1001): if q*(p**num)== w: print(p) sys.exit() print("No solution")
vfc_82329
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 18 2", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
285
Solve the following coding problem using the programming language python: Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* th...
a, b = map(int, input().split()) m = [] j = 0 for i in range(a, 1, -1): if j != b: m.append(i) j += 1 if j == b: break print(*m, end = ' ') v = [] for i in range(1, a-b+1): v.append(i) print(*v)
vfc_82333
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2", "output": "1 5 2 4 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 0", "output": "1 2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2...
codeforces
verifiable_code
653
Solve the following coding problem using the programming language python: Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*. Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy: - No two friends ...
#http://codeforces.com/contest/653/problem/A import sys len_input = input() seq_input = input().split() #seq_input = '18 55 16 17'.split() # seq_input = '40 41 43 44 44 44'.split() # seq_input = '5 972 3 4 1 4 970 971'.split() # seq_input = ''.split() # seq_input = '998 30 384 289 505 340 872 223 663 31 929 6...
vfc_82337
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n18 55 16 17", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
471
Solve the following coding problem using the programming language python: Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from ...
sticks = input().split() four = False two = False for stick in sticks: if sticks.count(stick) >= 4: four = True if sticks.count(stick) == 2 or sticks.count(stick) == 6: two = True if four: if two: print("Elephant") else: print("Bear") else: print("Alien")
vfc_82341
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 5 4 4 4", "output": "Bear", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
801
Solve the following coding problem using the programming language python: You found a mysterious function *f*. The function takes two strings *s*1 and *s*2. These strings must consist only of lowercase English letters, and must be the same length. The output of the function *f* is another string of the same length. T...
x = [i for i in input()] y = [i for i in input()] z = [] possible = True for i in range(len(x)): if x[i] == y[i]: z.append('z') elif x[i] > y[i]: z.append(y[i]) else: possible = False break if possible: print("".join(z)) else: print(-1)
vfc_82345
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ab\naa", "output": "ba", "type": "stdin_stdout" }, { "fn_name": null, "input": "nzwzl\nniwel", "output": "xiyez", "type": "stdin_stdout" }, { "fn_name": null, "input":...
codeforces
verifiable_code
698
Solve the following coding problem using the programming language python: Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Internet on that day. F...
n=int(input()) dp=[[0 for i in range(3)]for j in range(n+1)] ar=tuple(map(str,input().split())) for i in range(1,n+1): x=ar[i-1] dp[i][0]=min(dp[i-1])+1 if(x=='1' or x=='3'): dp[i][1]=min(dp[i-1][0],dp[i-1][2]) else: dp[i][1]=dp[i-1][1]+1 if(x=='2' or x=='3'): dp...
vfc_82353
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 2 0", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 3 3 2 1 2 3", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
codeforces
verifiable_code
182
Solve the following coding problem using the programming language python: Vasya has recently bought some land and decided to surround it with a wooden fence. He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products that the company has at its disposal *n...
import sys, os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def f(u, v): return 2 * n * u + v n, l = map(int, input().split()) mod = pow(10, 9) + 7 a, b = [], [] for _ in range(n): a0, b0 = map(int, input().split()) a.append(a0) b.append(b0) if a0 == b0: a...
vfc_82361
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n1 2\n2 3", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n2 2", "output": "1", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
895
Solve the following coding problem using the programming language python: Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into *n* pieces. The *i*-th p...
n=int(input()) a=[int (i) for i in input().split()] min=361 for i in range(n): for j in range(i, n): if -min<sum(a[0:i])+sum(a[j:])-sum(a[i:j])<min: min=sum(a[0:i])+sum(a[j:])-sum(a[i:j]) if min<0: min*=-1 print(min)
vfc_82365
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "4000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n90 90 90 90", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n100 100 160", "output": "40", "type": "stdin_stdout" }, { "fn_name": null, "i...
codeforces
verifiable_code
855
Solve the following coding problem using the programming language python: Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its ...
def main(): n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) ans = -float('inf') mx = -float('inf') mx1 = -float('inf') for i in range(n): mx = max(mx, a[i] * p) mx1 = max(mx1, mx + a[i] * q) ans = max(ans, mx1 + a[i] * r) print(ans...
vfc_82369
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 1 2 3\n1 2 3 4 5", "output": "30", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 2 -3\n-1 -2 -3 -4 -5", "output": "12", "type": "stdin_stdout" }, { "fn_name":...
codeforces
verifiable_code
785
Solve the following coding problem using the programming language python: Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: - Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahedron. Octahedron has 8 triangula...
lists=[] for _ in range(int(input())): lists.append(input()) s=0 for i in lists: if i=='Tetrahedron': s+=4 elif i=='Cube': s+=6 elif i=='Octahedron': s+=8 elif i=='Dodecahedron': s+=12 elif i=='Icosahedron': s+=20 print(s)
vfc_82377
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "output": "42", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nDodecahedron\nOctahedron\nOctahedron", "output": "28", "type": ...
codeforces
verifiable_code
699
Solve the following coding problem using the programming language python: There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. *n* particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles locate...
n = int(input()) s = input() arr = list(map(int, input().split())) ans = [] for i in range(n): if(i == n-1): break if((s[i] == "R" and s[i+1] == "L")): ans.append(arr[i+1]-arr[i]) for i in range(len(ans)): ans[i] = int(ans[i]/2) if not ans: print(-1) else: print(min(ans...
vfc_82381
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nRLRL\n2 4 6 10", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nLLR\n40 50 60", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
729
Solve the following coding problem using the programming language python: Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string *s* consisting of *n* lowercase English letters. There is a filler word ogo in Oleg's speech...
import sys, io, os import math import bisect import heapq import string from collections import defaultdict,Counter,deque input = sys.stdin.readline def I(): return input() def II(): return int(input()) def MII(): return map(int, input().split()) def LI(): return list(input().s...
vfc_82385
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\naogogob", "output": "a***b", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
34
Solve the following coding problem using the programming language python: Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any ...
n, m = [int(x) for x in input().split(' ')] a = [int(x) for x in input().split(' ') if int(x) < 0] a.sort() print(-sum(a[:min(len(a), m)]))
vfc_82389
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n-6 0 35 -2 4", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n7 0 0 -7", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "...
codeforces
verifiable_code
331
Solve the following coding problem using the programming language python: Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar. The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaveri...
n=int(input()) l=list(str(n)) n=int(n) c=0 while n!=0: m=max(list(str(n))) n-=int(m) c+=1 print(c)
vfc_82393
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "24", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "0", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "3", "output"...
codeforces
verifiable_code
16
Solve the following coding problem using the programming language python: A burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are *m* containers, in the *i*-th container there are *a**i* matchboxes, and each matchbox contains *b**i* matches. All the matchboxes ...
n,m=map(int,input().split()) l=[] for i in range(m): a,b=map(int,input().split()) l.append([b,a]) l.sort(reverse=True) i=c=0 while n>0 and i<len(l): if l[i][1]<n: n-=l[i][1] c+=l[i][0]*l[i][1] i+=1 else: # print(n) d=n n-=d c+=l[i][0]*d print(c)
vfc_82397
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "500" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 3\n5 10\n2 5\n3 6", "output": "62", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 3\n2 2\n3 1", "output": "7", "type": "stdin_stdout" }, { "fn_name": null,...
codeforces
verifiable_code
413
Solve the following coding problem using the programming language python: Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors. The testing goes in *n* steps, at each step the processor gets ...
a,b,c,d=map(int,input().split()) z=list(map(int,input().split())) k=z.copy() if c in k:k.remove(c) if d in k:k.remove(d) if (max(z)>d or min(z)<c or len(k)+2>a ):print("Incorrect") else:print("Correct")
vfc_82405
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1 1 2\n1", "output": "Correct", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 1 3\n2", "output": "Correct", "type": "stdin_stdout" }, { "fn_name": null, ...
codeforces
verifiable_code
401
Solve the following coding problem using the programming language python: Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed *x* i...
n,x=map(int,input().split()) l=list(map(int,input().split())) import math as m print(m.ceil(abs(sum(l))/x))
vfc_82413
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n-1 1 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n-2 -2", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
codeforces
verifiable_code
181
Solve the following coding problem using the programming language python: The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang. The Berland capital's map is represented by an *n*<=×<=*m* rectangular table. Each cell of the table on the map represents some districts...
r,c = map(int,input().split()) ind_c =[] ind = None for i in range(r): s = input() if s.count('*') == 1: ind = [i,s.index('*')] elif s.count('*')>1: for j in range(c): if s[j] == '*': ind_c.append(j) if ind[1] == ind_c[1]: print(...
vfc_82417
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n.*\n..\n**", "output": "1 1", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
548
Solve the following coding problem using the programming language python: While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string *s*. He is not sure if this is his own back...
string = input() partskitnekarnehai = int(input()) if len(string)%partskitnekarnehai!=0: print('NO') exit() nayalength = len(string) // partskitnekarnehai # o is length of part for j in range(partskitnekarnehai): seedha_part = string[ j*nayalength : (j + 1)*nayalength] # print(seedha_part) ...
vfc_82421
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "saba\n2", "output": "NO", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
937
Solve the following coding problem using the programming language python: The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points. As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respe...
n=int(input()) a=list(map(int,input().split())) sa=set(a) arr=list(sa) count=0 for i in sa: if i!=0: count+=1 print(count)
vfc_82425
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 3 2", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
990
Solve the following coding problem using the programming language python: You have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them. You know that you have $n$ bacteria in the Petri dish and size of t...
n, K = map(int, input().split()) a = sorted(list(map(int, input().split()))) num = 0 for i in a: while a[num] < i: if i <= K+a[num]: n-=1 num += 1 print(n)
vfc_82429
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 1\n101 53 42 102 101 55 54", "output": "3", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
265
Solve the following coding problem using the programming language python: There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string *s*. The *i*-th (1-based) character of *s* represents the color of the *i*-th stone. If the character is "R", "G", or "B", the ...
#A. Colorful Stones from tkinter import S s = input() t = input() i = 0 j = 0 counter = 1 while j < len(t): if s[i] != t[j]: j += 1 elif s[i] == t[j]: i += 1 j += 1 counter += 1 print(counter)
vfc_82433
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "RGB\nRRR", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "RRRBGBRBBB\nBBBRR", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input...
codeforces
verifiable_code
616
Solve the following coding problem using the programming language python: You are given a rectangular field of *n*<=×<=*m* cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a si...
# n=int(input()) # n,k=map(int,input().split()) # arr=list(map(int,input().split())) #ls=list(map(int,input().split())) #for i in range(m): # for _ in range(int(input())): from collections import Counter #from fractions import Fraction #n=int(input()) #arr=list(map(int,input().split())) #ls = [list(map(int, i...
vfc_82437
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n*.*\n.*.\n*.*", "output": "3.3\n.5.\n3.3", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n**..*\n..***\n.*.*.\n*.*.*", "output": "46..3\n..732\n.6.4.\n5.4.3", "type": "s...
codeforces
verifiable_code
361
Solve the following coding problem using the programming language python: Levko loves tables that consist of *n* rows and *n* columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals *k*. Unfortunately, he doesn't know any...
n, k = map(int, input().split()); a = list(range(n)); for i in range (0, n): a[i] = list(range(n)); for j in range (0, n): if j == i: a[i][j] = k; else: a[i][j] = 0; print(*a[i], sep=" ")
vfc_82445
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4", "output": "4 0 \n0 4 ", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
582
Solve the following coding problem using the programming language python: The GCD table *G* of size *n*<=×<=*n* for an array of positive integers *a* of length *n* is defined by formula Let us remind you that the greatest common divisor (GCD) of two positive integers *x* and *y* is the greatest integer that is divis...
import math as ma import sys input=sys.stdin.readline def fu(b): for i in b: if b[i]!=0: return i return -1 def gcd(a,b): if a%b==0: return b else: return gcd(b,a%b) n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) b={} for i...
vfc_82449
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 1 2 3 4 3 2 6 1 1 2 2 1 2 3 2", "output": "2 3 4 6 ", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
102
Solve the following coding problem using the programming language python: Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number *n*...
s=input() c=0 while(len(s)>1): sum=0 for i in s: sum+=int(i) s=str(sum) c+=1 print(c)
vfc_82453
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "10", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "991", "outpu...
codeforces
verifiable_code
764
Solve the following coding problem using the programming language python: Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist. Ilia-alpinist calls every *n* minutes, i.e. in minutes *n*, 2*n*, 3*n* and so on. Artists come to the comrade every *m* minut...
n, m, z = (int(i) for i in input().split()) calls = set(i for i in range(0, z + 1, n)) art = set(i for i in range(0, z + 1, m)) print(len(calls & art) - 1)
vfc_82457
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 10", "output": "10", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
96
Solve the following coding problem using the programming language python: Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero correspon...
line = input() ans = "NO" for i in range(len(line) - 6): if line[i: i + 7].count('0') == 7 or line[i: i + 7].count('1') == 7: ans = "YES" break print(ans)
vfc_82461
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "001001", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000000001", "output": "YES", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
560
Solve the following coding problem using the programming language python: A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with ...
n = int(input()) num = map(int, input().rstrip().split()) if 1 in num: print(-1) else: print(1)
vfc_82465
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n...
codeforces
verifiable_code
186
Solve the following coding problem using the programming language python: Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is re...
a = input() b = input() d = 0 f = [] if not len(a) == len(b): print('NO') else: for i in range(len(a)): if not a[i] == b[i]: d += 1 if d == 3: break f.append([a[i], b[i]]) if d == 2: print('YES' if f[0][0] == f[1][1] and f...
vfc_82469
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ab\nba", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "aa\nab", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "a\nza"...
codeforces
verifiable_code
358
Solve the following coding problem using the programming language python: Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to ...
s = [] for i in range(int(input())): s.append(input()) s = "<3" + '<3'.join(s) + "<3" cur = 0 t = input() for i in t: if i == s[cur]: cur += 1 if cur == len(s): break print('yes' if cur == len(s) else 'no')
vfc_82473
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "2000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ni\nlove\nyou\n<3i<3love<23you<3", "output": "yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\ni\nam\nnot\nmain\nin\nthe\nfamily\n<3i<>3am<3the<3<main<3in<3the<3><3family<3", "...
codeforces
verifiable_code
250
Solve the following coding problem using the programming language python: Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as *n* days. Right now his task is to make a series of reports about the company's performance for the last *n* days. We know that the main informatio...
days = int(input()) sequence = input().split() folder = 1 bad_rep = 0 rep = 0 ans = "" for profit in sequence: rep += 1 if int(profit) < 0: bad_rep += 1 if bad_rep == 3: folder += 1 ans = ans + str(rep - 1) + " " bad_rep = 1 rep = 1 ans += str(rep) print(folder) prin...
vfc_82477
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6", "output": "3\n5 3 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 -1 100 -1 0", "output": "1\n5 ", "type": "stdin_stdout" }, { ...
codeforces
verifiable_code
394
Solve the following coding problem using the programming language python: When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us...
n = input() lth = len(n) a = n.find('+') b = n.find('=') - a - 1 c = len(n) - n.find('=') - 1 if a + b == c: print(n) elif a + b == c - 2: print('|',n[:lth-1],sep="") elif a + b == c + 2: if a >= 2: print(n[1:],'|',sep="") else: print(n[:a+1],n[a+2:],'|',sep="") else: ...
vfc_82481
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "||+|=|||||", "output": "|||+|=||||", "type": "stdin_stdout" } ] }
codeforces
verifiable_code
912
Solve the following coding problem using the programming language python: During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals. Grisha needs to obtain some yellow, green and...
a, b = map(int, input().split()) x, y, z = map(int, input().split()) need_yellow = x * 2 + y need_blue = y + z * 3 yellow_diff = max(0, need_yellow - a) blue_diff = max(0, need_blue - b) total_diff = yellow_diff + blue_diff print(total_diff)
vfc_82485
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n2 1 1", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 9\n1 1 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1...
codeforces
verifiable_code
501
Solve the following coding problem using the programming language python: Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at some ...
n=int(input()) a=[] for i in range(n): b=input().split() if b[0] in a: ind=a.index(b[0]) a.insert(ind,b[1]) a.pop(ind+1) else: a.append(b[0]) a.append(b[1]) print(len(a)//2) for i in range(len(a)//2): print(*a[:2]) a=a[2:]
vfc_82489
{ "difficulty": "N/A", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "1000" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nMisha ILoveCodeforces\nVasya Petrov\nPetrov VasyaPetrov123\nILoveCodeforces MikeMirzayanov\nPetya Ivanov", "output": "3\nPetya Ivanov\nMisha MikeMirzayanov\nVasya VasyaPetrov123", "type": "stdin_stdout" }, { ...