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
p01243 Castle Wall
Solve the following coding problem using the programming language python: A new lord assumed the position by the death of the previous lord in a Far Eastern province. The new greedy lord hates concave polygons, because he believes they need much wasted area to be drawn on paper. He always wants to modify them to conv...
vfc_62893
{ "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 4\n0 0\n4 0\n4 4\n2 2\n0 4\n8 80\n45 41\n70 31\n86 61\n72 64\n80 79\n40 80\n8 94\n28 22\n0 0", "output": "case 1: 16.0\ncase 2: 3375.0", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n...
code_contests
verifiable_code
p01404 Water Clock
Solve the following coding problem using the programming language python: Problem G: Water clock An unusually shaped water clock was discovered from the bottom of Lake Biwa. The water clock is placed on a wide horizontal plane and consists of a cubic aquarium with one or more sides of 30 cm. The aquariums are placed...
vfc_62897
{ "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": "3 3\n1 1 900\n0 10 0\n10 45 10\n10 0 0\n3\n5 1 1\n50 1 0\n100 0 1\n5 5\n2 0 9000\n0 0 4 0 0\n0 3 3 3 0\n2 2 2 2 2\n0 0 1 0 0\n0 0 1 0 0\n4\n5 2 0\n10 2 1\n100 2 2\n250 2 3\n0 0", "output": "5\n5\n8\n30\n5\n13\n4", "type...
code_contests
verifiable_code
p01558 Substring
Solve the following coding problem using the programming language python: Given a string of length n s = s1, s2,…, sn and m queries. Each query qk (1 ≤ k ≤ m) is one of four types, "L ++", "L-", "R ++", "R-", and l [for the kth query qk. k] and r [k] are defined below. * L ++: l [k] = l [k-1] + 1, r [k] = r [k-1] * ...
```python def main(): n, m = map(int, input().split()) s = input() mem = set() base = ord("a") - 1 mod1 = 1000000007 mod2 = 2147483647 h1 = [0] h2 = [0] for c in s: h1.append((h1[-1] * 27 + ord(c) - base) % mod1) h2.append((h2[-1] * 27 + ord(c) - base) % mod2) pow_mem1 = {0:1} pow_mem2 = {...
vfc_62901
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4\nabcde\nR++\nR++\nL++\nL--", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 13\naacacbabac\nR++\nR++\nL++\nR++\nR++\nL++\nL++\nR++\nR++\nL--\nL--\nR--\nR--", "outp...
code_contests
verifiable_code
p01858 Sendame
Solve the following coding problem using the programming language python: A: Isono, let's do that! --Sendame - story Nakajima "Isono ~, let's do that!" Isono "What is that, Nakajima" Nakajima "Look, that's that. It's hard to explain because I have to express it in letters for some reason." Isono "No, it seems tha...
```python K = int(input()) Is = [input() for i in range(K)] Ns = [input() for i in range(K)] atk_I = 0 atk_N = 0 #"mamoru", "tameru", "kougekida" #"Isono-kun", "Nakajima-kun", "Hikiwake-kun" for i, n in zip(Is, Ns): i_n = [i, n] if (i_n.count("mamoru") == 2): pass elif (i_n.count("mamoru") == 1): if (i_n.count("...
vfc_62909
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ntameru\ntameru\ntameru\ntameru\nkougekida\ntameru", "output": "Nakajima-kun", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\ntameru\ntameru\nuremat\ntameru\nkougekida\ntameru", "o...
code_contests
verifiable_code
p02280 Binary Trees
Solve the following coding problem using the programming language python: A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T: * node ID of u * parent...
```python class Node: def __init__(self, parent, left, right): self.parent = parent self.left = left self.right = right d = {} def get_all_depth(t, u, p): d[u] = p if t[u].right is not None: get_all_depth(t, t[u].right, p+1) if t[u].left is not None: get_all_dept...
vfc_62921
{ "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": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1", "output": "node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, heigh...
code_contests
verifiable_code
arrange
Solve the following coding problem using the programming language python: The Chef has prepared the appetizers in the shapes of letters to spell a special message for the guests. There are n appetizers numbered from 0 to n-1 such that if the appetizers are arrayed in this order, they will display the message. The Chef...
```python for _ in range(input()): k,s = raw_input().strip().split() k = int(k) out = ['']*2**k for n in range(2**k): r = int(bin(n)[2:].zfill(k)[::-1],2) out[n] = s[r] print "".join(out) ```
vfc_62929
{ "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 chef\n4 enjoyourapplepie", "output": "cehf\neayejpuinpopolre\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 chef\n4 eipelpparuoyojne", "output": "cehf\nerlopopniupjeyae\n"...
code_contests
verifiable_code
clco04
Solve the following coding problem using the programming language python: After getting bored of the monotonous routine of college, Chahak wants go back to the golden days of her life ‘Her Childhood’ when she used to enjoy playing games and one such game is "Stapu" (Hopscotch). Chahak wants to play the game differentl...
```python # cook your code here for _ in range(input()): n,fff = map(int,raw_input().split()) s = map(int,raw_input().split()) if min(s) == 1 or max(s) == n: print 'NO' else: f = True s = sorted(s) for i in range(len(s)-2): if s[i+2]-s[i] == 2: ...
vfc_62933
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 6\n2 4 8 3 6 7\n10 5\n2 4 5 7 9", "output": "NO\nYES", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
fdivgame
Solve the following coding problem using the programming language python: Henry and Derek are waiting on a room, eager to join the Snackdown 2016 Qualifier Round. They decide to pass the time by playing a game. In this game's setup, they write N positive integers on a blackboard. Then the players take turns, startin...
```python grunds = [0,1,2,2,3,3,0,0,0,0,0,0] def grundy(n): return grunds[n] if n < 12 else grundy(n/12) for cas in xrange(input()): n = input() a = map(int, raw_input().strip().split()) x = 0 for v in a: x ^= grundy(v) print 'Henry' if x else 'Derek' ```
vfc_62937
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n3 4\n3\n1 3 5", "output": "Henry\nDerek\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n3 4\n3\n1 3 10", "output": "Henry\nHenry\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
lebinary
Solve the following coding problem using the programming language python: Asmany strings are strings of '0's and '1's that have as many 00 as 11. A string such as 00110001 consists of 3 "00" and 1 "11". Of course this is not an Asmany string. 0011, 1100, 000111000111 are Asmany strings. An L'th Asmany number is the nu...
```python import sys dp = set(); dp.add(2) dp.add(4) prev = 2 max=10**1000 i=2 while i: cur=prev*4-(prev*2)/i i=i+1 dp.add(cur) dp.add(cur*2) prev=cur if cur>max: break t=int(input()); while t: t=t-1 n=int(input()); if n in dp: print ('YES') else: print ('NO') ```
vfc_62941
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n4", "output": "NO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n4", "output": "NO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
plzlykme
Solve the following coding problem using the programming language python: In a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least L number of likes before D days pass. Peop...
```python t=input() while t>0: l,d,s,c=map(int,raw_input().split()) x=l*1.0/s if d==1: if s>=l: x=1 else: x=0 else: x=pow(x,1.0/(d-1.0)) if (1+c)>=x: x=1 else: x=0 if x==1: print "ALIVE AND KICKING" ...
vfc_62945
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 1 5 1\n10 2 2 2", "output": "ALIVE AND KICKING\nDEAD AND ROTTING\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 2 5 1\n10 2 2 2", "output": "ALIVE AND KICKING\nDEAD AND RO...
code_contests
verifiable_code
subanagr
Solve the following coding problem using the programming language python: Let's start from some definitions. Strings A and B are called anagrams if it's possible to rearrange the letters of string A using all the original letters exactly once and achieve string B; in other words A and B are permutations of each other...
```python import sys from collections import Counter num = int(sys.stdin.readline().rstrip()) text = sys.stdin.readline().rstrip() common_dict = Counter(text) while num != 1: text = sys.stdin.readline().rstrip() count = Counter(text) tmp = {} for key,val in common_dict.items(): if key in count: tmp[key] = mi...
vfc_62949
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nhope\nelephant\npath", "output": "hp\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
100_A. Carpeting the Room
Solve the following coding problem using the programming language python: Soroush's room is a square with side length n. Before this contest he bought k fine Persian carpets to carpet his room for celebrating the 100th contest on his favorite site. Each Persian carpet is a square of side length n1. Soroush wants to c...
vfc_62953
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4 6\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 2 5\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1032_E. The Unbearable Lightness of Weights
Solve the following coding problem using the programming language python: You have a set of n weights. You know that their masses are a_1, a_2, ..., a_n grams, but you don't know which of them has which mass. You can't distinguish the weights. However, your friend does know the mass of each weight. You can ask your f...
vfc_62957
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 2 4 4 4 9\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 4 2 2\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1055_C. Lucky Days
Solve the following coding problem using the programming language python: Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, for ...
```python def gcd(a, b): return b if a == 0 else gcd(b % a, a) l1, r1, t1 = map(int, input().split()) l2, r2, t2 = map(int, input().split()) g = gcd(t1, t2) d = l2 - l1 s = d % g #print(g, d, s) ans1 = min(r1 - l1 - s, r2 - l2) + 1 s = (g - s) % g #print(s) ans2 = min(r1 - l1, r2 - l2 - s) + 1 print(max(ans1, an...
vfc_62961
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 2 5\n1 3 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 1 3\n2 3 6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1077_D. Cutting Out
Solve the following coding problem using the programming language python: You are given an array s consisting of n integers. You have to find any array t of length k such that you can cut out maximum number of copies of array t from array s. Cutting out the copy of t means that for each element t_i of array t you ha...
```python def check(d,h): temp=0 for i in d.values(): temp+=i//mid if temp>=k: return True return False n,k=map(int,input().split()) arr=list(map(int,input().split())) d={} for i in arr: if i in d:d[i]+=1 else:d[i]=1 l=1 r=n ans=0 while l<=r: mid=(l+r)//2 if check(d,mid): ans=max...
vfc_62965
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 3\n1 2 3 2 4 3 1\n", "output": "1 2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15 2\n1 2 1 1 1 2 1 1 2 1 2 1 1 1 1\n", "output": "1 1\n", "type": "stdin_stdout" },...
code_contests
verifiable_code
1098_C. Construct a tree
Solve the following coding problem using the programming language python: Misha walked through the snowy forest and he was so fascinated by the trees to decide to draw his own tree! Misha would like to construct a rooted tree with n vertices, indexed from 1 to n, where the root has index 1. Every other vertex has a p...
```python def clc(mid): sm , i , cp = 0 , 1 , n cur = 1 while(cp + 1 > cur): sm = sm + i * cur i+= 1 cp -= cur cur = cur * mid return sm + i * cp n , s = map(int,input().split()) sm = n * (n + 1) // 2 dp = [0] * 100005 x = [0] * 100005 y = [0] * 100005 x[0] = 1 if s + 1...
vfc_62969
{ "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 15\n", "output": "Yes\n1 1 2 2 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n", "output": "Yes\n1 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1119_D. Frets On Fire
Solve the following coding problem using the programming language python: Miyako came to the flea kingdom with a ukulele. She became good friends with local flea residents and played beautiful music for them every day. In return, the fleas made a bigger ukulele for her: it has n strings, and each string has (10^{18} ...
```python import sys import math def lower(num,arr): ans=-1 low,high=0,len(arr)-1 while (low<=high): mid=(low+high)//2 if arr[mid]<=num: ans=max(ans,mid) low=mid+1 else: high=mid-1 return ans n=int(sys.stdin.readline()) arr=list(map(int,sys.std...
vfc_62973
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n3 1 4 1 5 9\n3\n7 7\n0 2\n8 17\n", "output": "5 10 18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 500000000000000000\n2\n1000000000000000000 1000000000000000000\n0 100000000000...
code_contests
verifiable_code
1146_A. Love "A"
Solve the following coding problem using the programming language python: Alice has a string s. She really likes the letter "a". She calls a string good if strictly more than half of the characters in that string are "a"s. For example "aaabb", "axaa" are good strings, and "baca", "awwwa", "" (empty string) are not. A...
```python lita=input() a=lita.count('a') b=len(lita) if a>(b/2): print(b) else: print(2*a-1) ```
vfc_62977
{ "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": "aaabaa\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "xaxxxxa\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
1204_B. Mislove Has Lost an Array
Solve the following coding problem using the programming language python: Mislove had an array a_1, a_2, ⋅⋅⋅, a_n of n positive integers, but he has lost it. He only remembers the following facts about it: * The number of different numbers in the array is not less than l and is not greater than r; * For each arra...
```python from sys import stdin def count(N, l, r): resultmin, resultmax = 0, 0 fmax, smax = 1, 1 for n in range(N): if l: resultmin += fmax fmax *= 2 l -= 1 else: resultmin += 1 if r: resultmax += smax smax *= ...
vfc_62989
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 2\n", "output": "5 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 5\n", "output": "5 31\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
1220_G. Geolocation
Solve the following coding problem using the programming language python: You are working for the Gryzzl company, headquartered in Pawnee, Indiana. The new national park has been opened near Pawnee recently and you are to implement a geolocation system, so people won't get lost. The concept you developed is innovativ...
```python import sys import math n = int(input()) x = [0]*n y = [0]*n for i in range(n): x[i], y[i] = map(int, input().split()) sx = sum(x) sy = sum(y) for i in range(n): x[i] = n * x[i] - sx y[i] = n * y[i] - sy m = int(input()) d = [0]*n e = [0]*n HD = 0 def check(a, b): global HD HE ...
vfc_62993
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 0\n0 1\n1 0\n1\n1 1 2\n", "output": "1 1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 0\n0 1\n1 0\n1 1\n2\n0 1 1 2\n2 5 5 8\n", "output": "4 0 0 0 1 1 0 1 1\n4 -1 -1 -...
code_contests
verifiable_code
1246_C. Rock Is Push
Solve the following coding problem using the programming language python: You are at the top left cell (1, 1) of an n × m labyrinth. Your goal is to get to the bottom right cell (n, m). You can only move right or down, one cell per step. Moving right from a cell (x, y) takes you to the cell (x, y + 1), while moving do...
vfc_62997
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n.\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1266_A. Competitive Programmer
Solve the following coding problem using the programming language python: Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked n of them how much effort they needed to reach red. "Oh, I just spent x_i hours sol...
```python T = int(input()) for t in range(T): a = [int(x) for x in list(input())] if sum(a)%3==0 and a.count(0)>0 and (a.count(0)+a.count(2)+a.count(4)+a.count(6)+a.count(8)>1): print("red") else: print("cyan") ```
vfc_63001
{ "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\n603\n006\n205\n228\n1053\n0000000000000000000000000000000000000000000000\n", "output": "red\nred\ncyan\ncyan\ncyan\nred\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n900\n", ...
code_contests
verifiable_code
1287_C. Garland
Solve the following coding problem using the programming language python: Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was...
```python import sys n = int(input()) if n == 1: print(0) sys.exit() arr = list(map(int, input().split())) arr = [i % 2 if i != 0 else -1 for i in arr] skipped = sum([i == -1 for i in arr]) if skipped == n: print(1) sys.exit() ans = 0 for i in range(n - 1): if (arr[i] == 0) and (arr[i + 1] ==...
vfc_63005
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 0 0 5 0 0 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 5 0 2 3\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1307_C. Cow and Message
Solve the following coding problem using the programming language python: Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string s of lowercase Latin letters. She considers a string t as hidden in str...
```python import os import sys def main(): s=input() dp=[[0]*(27) for i in range(27)] d=[0]*27 for i in range(len(s)): k=ord(s[i])-97 for j in range(27): dp[k][j]+=d[j] d[k]+=1 ans=0 for i in range(27): for j in range(27): ans=max(ans, dp[i][j]) for i in d: ans=max(ans , i) print(ans) if __name_...
vfc_63009
{ "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": "aaabb\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "lol\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "usaco...
code_contests
verifiable_code
1330_C. Dreamoon Likes Coloring
Solve the following coding problem using the programming language python: Dreamoon likes coloring cells very much. There is a row of n cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 1 to n. You are given an integer m and m integers l_1, l_2, …, l_m (1 ≤ l_i ≤ n) Dreamoon wi...
```python import sys input = sys.stdin.readline n, m = map(int, input().split()) l = list(map(int, input().split())) sum_l = sum(l) if sum_l < n: print(-1) exit() diff = sum_l - n prev = 1 ans = [0] for i in range(m): ans.append(max(prev + ans[-1] - diff, ans[-1] + 1)) diff -= prev - (ans[-1] - ...
vfc_63013
{ "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": "10 1\n1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n3 2 2\n", "output": "1 2 4 \n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1350_C. Orac and LCM
Solve the following coding problem using the programming language python: For the multiset of positive integers s=\\{s_1,s_2,...,s_k\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow: * \gcd(s) is the maximum positive integer x, such that all integers in s are divisible on x...
```python #x,y = map(int,input().split()) #arr = [int(i) for i in input().split()] #x,y = map(int,input().split()) from collections import Counter import math mod = 10**9+7 n = int(input()) arr = [int(i) for i in input().split()] suffix = [arr[-1]] for i in range(n-1): x = suffix[0] y = math.gcd(x,arr[n-i-2]) suff...
vfc_63017
{ "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": "10\n540 648 810 648 720 540 594 864 972 648\n", "output": "54\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n10 24 40 80\n", "output": "40\n", "type": "stdin_stdout" },...
code_contests
verifiable_code
1370_F1. The Hidden Pair (Easy Version)
Solve the following coding problem using the programming language python: Note that the only difference between the easy and hard version is the constraint on the number of queries. You can make hacks only if all versions of the problem are solved. This is an interactive problem. You are given a tree consisting of n...
vfc_63021
{ "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": "1\n3\n1 2\n1 3\n\n1 1\n\n2 3\n\n3 1\n\n3 1\n\nCorrect", "output": "? 3 1 2 3\n? 2 2 3\n? 2 2 3\n! 1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n3\n2 3\n2 3\n1 3\n6\n1 4\n3 4\n2 5...
code_contests
verifiable_code
1393_B. Applejack and Storages
Solve the following coding problem using the programming language python: This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another o...
```python import sys input = sys.stdin.readline n = int(input()) a = list(map(int,input().split())) u = [0]*int(1e5+1) for i in a: u[i] += 1 can1 = 0 can2 = 0 for i in u: can1 += i//4 can2 += i%4//2 q = int(input()) for i in range(q): p, x = map(str,input().split()) x = int(x) if p == "+": ...
vfc_63025
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2\n", "output": "NO\nYES\nNO\nNO\nNO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n1 1 1 1 2 2 2 2 3 3 3 3\n1\n+ 10\n", "outp...
code_contests
verifiable_code
1418_A. Buying Torches
Solve the following coding problem using the programming language python: You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft k torches. One torch can be crafted using one stick and one coal. Hopefully, you've met a very handsome wandering trader who has two trade off...
```python """ - math - from math import factorial from math import gcd from math import pi large_p = 10**9 + 7 from itertools import accumulate # 累積和 from operator import mul - other - from collections import Counter from itertools import combinations from itertools import combinations_with_replacement from itertools i...
vfc_63029
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000\n", "output": "14\n33\n25\n2000000003\n1000000001999999999\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
145_C. Lucky Subsequence
Solve the following coding problem using the programming language python: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence a co...
```python import sys input = sys.stdin.readline def solve(): n, k = map(int, input().split()) a = [4,7] d = dict() idx = 0 for p in range(1,10): for m in range(1<<p): v = 0 for i in range(p): v = v*10+a[(m >> i)&1] d[v] = idx idx += 1 #print(d) c = [0]*idx b = 0 for v in map(int, input().sp...
vfc_63037
{ "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 2\n10 10 10\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n4 4 7 7\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1485_E. Move and Swap
Solve the following coding problem using the programming language python: You are given n - 1 integers a_2, ..., a_n and a tree with n vertices rooted at vertex 1. The leaves are all at the same distance d from the root. Recall that a tree is a connected undirected graph without cycles. The distance between two vert...
```python from collections import deque T = int(input()) def solve(E, W): nodes = {idx: (w, []) for idx, w in weights.items()} for u, v in E: nodes[u][1].append(v) nodes[v][1].append(u) layers = [] visited = set([1]) parents = {idx: None for idx in weights.keys()} Q = deque([1...
vfc_63041
{ "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": "4\n14\n1 1 1 2 3 4 4 5 5 6 7 8 8\n2 3 7 7 6 9 5 9 7 3 6 6 5\n6\n1 2 2 3 4\n32 78 69 5 41\n15\n1 15 1 10 4 9 11 2 4 1 8 6 10 11\n62 13 12 43 39 65 42 86 25 38 19 19 43 62\n15\n11 2 7 6 9 8 10 1 1 1 5 3 15 2\n50 19 30 35 9 45 13 24 8...
code_contests
verifiable_code
1536_A. Omkar and Bad Story
Solve the following coding problem using the programming language python: Omkar has received a message from Anton saying "Your story for problem A is confusing. Just make a formal statement." Because of this, Omkar gives you an array a = [a_1, a_2, …, a_n] of n distinct integers. An array b = [b_1, b_2, …, b_k] is cal...
```python from sys import stdin input = stdin.readline def solve(): n = int(input()) a = [int(x) for x in input().split()] for i in a: if i < 0: print("NO") return ans = list(range(0, 101)) print("YES") print(len(ans)) print(*ans) t = int(input()) for _ in r...
vfc_63049
{ "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": "4\n3\n3 0 9\n2\n3 4\n5\n-7 3 13 -2 8\n4\n4 8 12 6\n", "output": "\nyes\n4\n6 0 3 9\nyEs\n5\n5 3 1 2 4\nNO\nYes\n6\n8 12 6 2 4 10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n7\n-28 -...
code_contests
verifiable_code
162_J. Brackets
Solve the following coding problem using the programming language python: A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters "+" and "1". For example, sequences "(())()", "()" and "(()(()))" are balanced, while ")(", "(()" and "(()))(" are not. You are given...
vfc_63053
{ "difficulty": "16", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "(()(()))()\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
183_A. Headquarters
Solve the following coding problem using the programming language python: Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he ...
```python n = int(input()) r = 1; c = 1 for i in range(n): s = input() if (len(s) == 4): r += 1; c += 1 elif(s == "UL" or s == "DR"): r += 1 else: c += 1 print(r * c) ```
vfc_63057
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nDR\nDL\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nUR\nUL\nULDR\n", "output": "9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
207_A3. Beaver's Calculator 1.0
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY has once again surprised us! He has developed a new calculating device, which he called the "Beaver's Calculator 1.0". It is very peculiar and it is planned to be used in a variety of scientific problems. To test it,...
vfc_63061
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 10 2 3 1000\n3 100 1 999 1000\n", "output": "2\n10 1\n23 1\n49 1\n100 2\n99 2\n98 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 1 1 1 10\n2 3 1 1 10\n", "output": "0\n1...
code_contests
verifiable_code
230_B. T-primes
Solve the following coding problem using the programming language python: We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors. You are given an array of n positive integ...
```python N=1000000 a=[1]*N a[0]=a[1]=0 s=set() for i,x in enumerate(a): if x: s.add(i*i) for j in range(i+i,N,i): a[j] = 0 n= int(input()) lis = list(map(int,input().split())) for i in lis: print("YES" if i in s else "NO") ```
vfc_63065
{ "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\n4 5 6\n", "output": "YES\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n10\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
256_A. Almost Arithmetical Progression
Solve the following coding problem using the programming language python: Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented as: * a1 = p, where ...
```python R = lambda: map(int, input().split()) n = int(input()) arr = list(R()) dp = [[0] * (n + 1) for i in range(n + 1)] for i in range(n): p = -1 for j in range(i): dp[i][j] = max(dp[i][j], dp[j][p] + 1) p = j if arr[j] == arr[i] else p print(max(max(dp[i]) for i in range(n)) + 1) ```
vfc_63069
{ "difficulty": "7", "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\n3 5\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n10 20 10 30\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
27_A. Next Test
Solve the following coding problem using the programming language python: «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will ...
```python def main(): MAX = 3005 n = int(input()) nums = list(map(int, input().split(' '))) a = [False] * MAX for i in nums: a[i] = True for i in range(1, MAX): if not a[i]: return i return -1 print(main()) ```
vfc_63073
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 7 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4...
code_contests
verifiable_code
301_E. Yaroslav and Arrangements
Solve the following coding problem using the programming language python: Yaroslav calls an array of r integers a1, a2, ..., ar good, if it meets the following conditions: |a1 - a2| = 1, |a2 - a3| = 1, ..., |ar - 1 - ar| = 1, |ar - a1| = 1, at that <image>. An array of integers b1, b2, ..., br is called great, if it...
vfc_63077
{ "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": "1 1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5...
code_contests
verifiable_code
329_A. Purification
Solve the following coding problem using the programming language python: You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the col...
```python a = [] n = int(input()) for i in range(0, n): a.append(input()) l = [0 for i in range(0, n)] c = [0 for i in range(0, n)] for i in range(0, n): for j in range(0, n): if a[i][j] == 'E': l[i] += 1 c[j] += 1 if n in l and n in c: print('-1') exit() if n in l: ...
vfc_63081
{ "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\nEEE\nE..\nE.E\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n.E.\nE.E\n.E.\n", "output": "1 1\n2 2\n3 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
34_D. Road Map
Solve the following coding problem using the programming language python: There are n cities in Berland. Each city has its index — an integer number from 1 to n. The capital has index r1. All the roads in Berland are two-way. The road system is such that there is exactly one path from the capital to each city, i.e. th...
```python import sys sys.setrecursionlimit(100000) n, r1, r2 = map(int, input().split()) a = list(map(int, input().split())) g = {} num = 0 for k, v in enumerate(a): num += 1 if num == r1: num += 1 # print(k, num, v) if num not in g: g[num] = [] g[num].append(v) if v not in g:...
vfc_63085
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 3\n2 2\n", "output": "2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2 4\n6 1 2 4 2\n", "output": "6 4 1 4 2\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
373_E. Watching Fireworks is Fun
Solve the following coding problem using the programming language python: A festival will be held in a town's main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance between each adjacent sections is 1. In the festival m fireworks will be launched. ...
vfc_63089
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "50 3 1\n49 1 1\n26 1 4\n6 1 10\n", "output": "-31\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 2 1\n1 1000 4\n9 1000 4\n", "output": "1992\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
396_B. On Sum of Fractions
Solve the following coding problem using the programming language python: Let's assume that * v(n) is the largest prime number, that does not exceed n; * u(n) is the smallest prime number strictly greater than n. Find <image>. Input The first line contains integer t (1 ≤ t ≤ 500) — the number of testscases...
```python T = int( input() ) MAX = 33000 bePrime = [0] * MAX; primNum = [] for j in range(2, MAX): if bePrime[j] == 0: primNum.append( j ) i = j while i < MAX: bePrime[i] = 1 i = i + j def isPrime( a ): for j in primNum: if j >= a: return ...
vfc_63093
{ "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\n2\n3\n", "output": "1/6\n7/30\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1000000000\n", "output": "999999941999999673/1999999887999999118\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
418_C. Square Table
Solve the following coding problem using the programming language python: While resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of size n × m, consisting of positive intege...
```python """ Codeforces Round 241 Div 1 Problem E Author : chaotic_iak Language: Python 3.3.4 """ class InputHandlerObject(object): inputs = [] def getInput(self, n = 0): res = "" inputs = self.inputs if not inputs: inputs.extend(input().split(" ")) if n == 0: re...
vfc_63097
{ "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 1\n", "output": "1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n", "output": "3 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2...
code_contests
verifiable_code
445_A. DZY Loves Chessboard
Solve the following coding problem using the programming language python: DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or bl...
```python n,m = map(int,input().split()) for i in range(n): s = list(input()) for j in range(m): if s[j]==".": if (i+j)%2==0: s[j]="W" else:s[j]="B" k="".join(s) print(k) ```
vfc_63101
{ "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 3\n.-.\n---\n--.", "output": "B-B\n---\n--B\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n.\n", "output": "B\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
467_B. Fedor and New Game
Solve the following coding problem using the programming language python: After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are number...
```python def dif(a, b): cont = 0 for i in range(0, len(a)): if a[i]!=b[i]: cont+=1 return cont n, m, k = [int(x) for x in input().split()] lista = [] string = '' for i in range (0, m+1): string = bin(int(input()))[2:] string = ('0'*(n-len(string)))+string if i<m: ...
vfc_63105
{ "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": "7 3 1\n8\n5\n111\n17\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 3\n1\n2\n3\n4\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
48_E. Ivan the Fool VS Gorynych the Dragon
Solve the following coding problem using the programming language python: Once upon a time in a kingdom far, far away… Okay, let’s start at the point where Ivan the Fool met Gorynych the Dragon. Ivan took out his magic sword and the battle began. First Gorynych had h heads and t tails. With each strike of the sword Iv...
vfc_63109
{ "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": "2 2 4\n2\n1 0\n0 1\n3\n0 1\n0 1\n0 0\n", "output": "Ivan\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 4\n1\n0 1\n1\n1 0\n", "output": "Draw\n", "type": "stdin_stdout"...
code_contests
verifiable_code
53_C. Little Frog
Solve the following coding problem using the programming language python: Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are n mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mou...
```python from itertools import zip_longest n = int(input()) z = (n+1)//2 for p,q in zip_longest(range(1,z+1),range(n,z,-1)): if q: print(p, q, end=' ') else: print(p) ```
vfc_63117
{ "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\n", "output": "1 3 2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
589_a
Solve the following coding problem using the programming language python: Polycarp has quite recently learned about email aliases. Of course, he used to suspect that the case of the letters doesn't matter in email addresses. He also learned that a popular mail server in Berland bmail.com ignores dots (characters '.') ...
```python from sys import stdin line = stdin.readline() n = int(line) d = {} for i in xrange(0, n): line = stdin.readline().strip() ad = line.lower().split("@") if ad[1] == "bmail.com": ad[0] = ad[0].replace(".", "") ad[0] = ad[0].split("+") ad[0] = ad[0][0] ad = str(ad) if not ad in d: d[ad] = [] d[ad...
vfc_63125
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nICPC.@bmail.com\np+con+test@BMAIL.COM\nP@bmail.com\na@bmail.com.ru\nI.cpc@Bmail.Com\na+b@bmail.com.ru", "output": "4\n2 ICPC.@bmail.com I.cpc@Bmail.Com\n2 p+con+test@BMAIL.COM P@bmail.com\n1 a@bmail.com.ru\n1 a+b@bmail.com...
code_contests
verifiable_code
630_N. Forecast
Solve the following coding problem using the programming language python: The Department of economic development of IT City created a model of city development till year 2100. To prepare report about growth perspectives it is required to get growth estimates from the model. To get the growth estimates it is required...
```python a,b,c=map(float,input().split()) q=((b*b-4*a*c)**0.5) x=((-b+q)/(2*a)) y=((-b-q)/(2*a)) print(max(x,y)) print(min(x,y)) ```
vfc_63133
{ "difficulty": "21", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 30 200\n", "output": "-10.000000000\n-20.000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 0\n", "output": "0.000000000\n-1.000000000\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
659_F. Polycarp and Hay
Solve the following coding problem using the programming language python: The farmer Polycarp has a warehouse with hay, which can be represented as an n × m rectangular table, where n is the number of rows, and m is the number of columns in the table. Each cell of the table contains a haystack. The height in meters of...
vfc_63137
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4 12\n1 1 3 1\n1 6 2 4\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 35\n10 4 9\n9 9 7\n", "output": "YES\n7 0 7 \n7 7 7 \n", "type": "stdin_stdout" ...
code_contests
verifiable_code
682_C. Alyona and the Tree
Solve the following coding problem using the programming language python: Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on. The girl noticed that some of th...
```python n=int(input()) a=[0]+list(map(int,input().split())) E=[[] for _ in range(n+1)] for i in range(n-1): p,c=map(int,input().split()) E[i+2]+=[(p,c)] E[p]+=[(i+2,c)] ans=0 ch=[(1,0,0)] while ch: nom,pre,l=ch.pop() if l>a[nom]: continue ans+=1 for x,c in E[nom]: if x!=pre: ch+=[...
vfc_63141
{ "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": "9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n60 89 33 64 92 75\n4 50\n1 32\n5 21\n3 77\n1...
code_contests
verifiable_code
727_E. Games on a CD
Solve the following coding problem using the programming language python: Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length...
```python n, k = map(int, raw_input().split()) s = raw_input() g = int(raw_input()) games = [raw_input() for i in range(g)] MOD_1 = 1000000007 BASE_1 = 31 MOD_2 = 1000000409 BASE_2 = 29 hashes_1 = [] hashes_2 = [] hash_inv = {} game_inv = {} for i, game in enumerate(games): h_1 = 0 h_2 = 0 for c in game:...
vfc_63149
{ "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": "3 1\nabc\n4\nb\na\nc\nd\n", "output": "YES\n2 1 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\naabbccdd\n4\ndd\nab\nbc\ncd\n", "output": "NO\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
771_E. Bear and Rectangle Strips
Solve the following coding problem using the programming language python: Limak has a grid that consists of 2 rows and n columns. The j-th cell in the i-th row contains an integer ti, j which can be positive, negative or zero. A non-empty rectangle of cells is called nice if and only if the sum of numbers in its cell...
vfc_63157
{ "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": "6\n70 70 70 70 70 -15\n90 -60 -30 30 -30 15\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1000000000 999999999 -1000000000\n999999999 -1000000000 -999999998\n", ...
code_contests
verifiable_code
796_E. Exam Cheating
Solve the following coding problem using the programming language python: Zane and Zane's crush have just decided to date! However, the girl is having a problem with her Physics final exam, and needs your help. There are n questions, numbered from 1 to n. Question i comes before question i + 1 (1 ≤ i < n). Each of th...
vfc_63161
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 3 3\n4 1 3 5 6\n5 2 4 6 7 8\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2 3\n3 1 3 6\n4 1 2 5 6\n", "output": "4\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
817_A. Treasure Hunt
Solve the following coding problem using the programming language python: Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure. Bottle with potion has two values x...
```python a, b, c, d = map(int, input().split()) x, y = map(int, input().split()) if abs(c - a) % abs(x) == 0 and abs(c - a) / abs(x) % 2 == abs(d - b) / abs(y) % 2 and abs(d - b) % abs(y) == 0: print("YES") else: print("NO") ```
vfc_63165
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 3 6\n1 5\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0 0 6\n2 3\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
842_A. Kirill And The Game
Solve the following coding problem using the programming language python: Kirill plays a new computer game. He came to the potion store where he can buy any potion. Each potion is characterized by two integers — amount of experience and cost. The efficiency of a potion is the ratio of the amount of experience to the c...
```python IL = lambda: list(map(int, input().split())) IS = lambda: input().split() I = lambda: int(input()) S = lambda: input() l, r, x, y, k = IL() for i in range(max(l, x*k), min(r, y*k) + 1): if i%k == 0: print("YES") quit() print("NO") ```
vfc_63169
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 10 1 10 1\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
863_A. Quasi-palindrome
Solve the following coding problem using the programming language python: Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, numb...
```python s=input() if s==s[::-1]: print("YES") else: news="" c=0 start=0 end=len(s) for i in range(len(s)): if s[i]!="0": start=i break for i in range(len(s)-1,-1,-1): if s[i]!="0": end=i+1 break news=s[start:end] if ne...
vfc_63173
{ "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": "2010200\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "320\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
888_E. Maximum Subsequence
Solve the following coding problem using the programming language python: You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≤ b1 < b2 < ... < bk ≤ n) in such a way that the value of <image> is maximized. Chosen sequence can ...
```python import bisect import array n,m=list(map(int,input().split())) a=list(map(int,input().split())) a1,a2=array.array('L'),array.array('L') n1=n//2 def sums1(i,sum=0): if i==n1: a1.append(sum) else: sums1(i+1,(sum+a[i])%m) sums1(i+1,sum) def sums2(i,sum=0): if i==n: ...
vfc_63177
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 20\n199 41 299\n", "output": "19", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n5 2 4 1\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
911_C. Three Garlands
Solve the following coding problem using the programming language python: Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on. When a garland is switched on, it periodically changes its state — sometimes it is lit...
```python k1, k2, k3 = map(int, input().split()) ans = 'NO' if [k1, k2, k3].count(2) >= 2: ans = 'YES' if 1 in [k1, k2, k3]: ans = 'YES' if [k1, k2, k3].count(3) >= 3: ans = 'YES' if 2 in [k1, k2, k3] and [k1, k2, k3].count(4) == 2: ans = 'YES' print(ans) ```
vfc_63181
{ "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 2 3\n", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 3\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4 ...
code_contests
verifiable_code
95_C. Volleyball
Solve the following coding problem using the programming language python: Petya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The city has n junctions, some of which are connected by two-way roads. The length of ea...
```python 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.mode self.write = self...
vfc_63189
{ "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 4\n1 3\n1 2 3\n1 4 1\n2 4 1\n2 3 5\n2 7\n7 2\n1 2\n7 7\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15 29\n6 6\n7 12 7\n11 3 7\n4 5 18\n13 9 18\n3 8 12\n6 1 7\n4 1 4\...
code_contests
verifiable_code
987_A. Infinity Gauntlet
Solve the following coding problem using the programming language python: You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems: * the Power Gem of purple color, * the Time Gem of green color, * the Space Gem of blue color, * the Soul Gem of orange colo...
```python stone = {'purple': 'Power', 'green': 'Time', 'blue': 'Space','orange': 'Soul','red': 'Reality','yellow': 'Mind'} color = {} n = int(input()) for _ in range(0, n): c = input() if c in stone: del stone[c] print(6-n) print('\n'.join(stone.values())) ```
vfc_63193
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0\n", "output": "6\nPower\nTime\nSpace\nSoul\nReality\nMind\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nred\npurple\nyellow\norange\n", "output": "2\nTime\nSpace\n", "ty...
code_contests
verifiable_code
aldrin-justice
Solve the following coding problem using the programming language python: Lily Aldrin, as the slap bet commissioner, needs to resolve issues regarding slap bets due with Barney and Marshall. She has mandated that there be a fixed period of time in which the slaps may be used. So, she draws two lines representing the...
```python test=input() for i in range(test): b1,b2,m1,m2=map(int,raw_input().split(" ")) left=min(max(b1,b2),max(m1,m2)) right=max(min(b1,b2),min(m1,m2)) if (left>right): print "Nothing" elif (left < right): print "Line" else: print "Point" ```
vfc_63197
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 1 4 5\n1 2 -1 5\n1 2 2 3\n\nSAMPLE", "output": "Line\nNothing\nPoint\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
bulbasaur-and-roses
Solve the following coding problem using the programming language python: DG (Departmental Gathering) is coming…. As one of the most famous girls in the college everybody is smitten with Harshada and wants to give her roses. But Harshada is only into coders , therefore she sends out word that she would accept ros...
```python def fun(n): if n <= 2: return n if(n%2==1): return fun(n-2) * fun(n-1) elif(n%2==0): return fun(n-2) + fun(n-1) t=int(input()) while(t): x=int(input()) val=fun(x) print(val) t=t-1 ```
vfc_63201
{ "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\n5\n10\n\nSAMPLE", "output": "1\n8\n10476\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
day-4-basic-mathematics
Solve the following coding problem using the programming language python: Problem : The Starks(S),Lannisters(L) and the Baratheons(B) are fighting for the Iron Throne. These three houses are fighting from ages to capture the throne. The N th battle goes on for N days before a winner emerges. Interestingly,the battle...
```python __author__ = 'apritam' import math no_of_test=int(raw_input()) while no_of_test > 0: t_range = raw_input() t= long(t_range) n = long(math.ceil((-1+(math.ceil(math.sqrt(8*t-1))))/2)) if n % 3 == 0: print 'SL' elif n % 3 == 1: print 'LB' else: print 'BS' no_...
vfc_63205
{ "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\n6\n12\n\nSAMPLE", "output": "LB\nSL\nBS\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
game-of-numbers-16
Solve the following coding problem using the programming language python: "IT can do almost everything using codes", a Arjun(a CS Student) says to his mathematics' teacher. Mathematics teacher gives a very simple problem to solve using codes but Arjun got stuck. The problem was find out all those pairs of two numbers ...
```python t=input() for i in range(0,t): x=input() c=0 for j in range(1,x): for k in range(j+1,x+1): if((j*k)%(j+k)==0): c=c+1 print c ```
vfc_63209
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n15\n\nSAMPLE", "output": "0\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n15\n\nPAMSLE", "output": "0\n4\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
karan-and-trees
Solve the following coding problem using the programming language python: Karan performed poorly in the Capillary Java Hiring Challenge because he did not know the concept of trees. After the contest, he asks you to help him out in the questions. Given two nodes of a binary tree, you need to tell the lowest common an...
```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!' t = int(raw_input()) for i in range(t): a,b = map(int,raw_input().split()) while(a != b): if a > b: if a % 2==0: ...
vfc_63213
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 3\n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n18227 11193\n11541 11674\n7869 16134\n161 10985\n4348 23603\n1667 17178\n10755 3433\n27021 4675\n6745 ...
code_contests
verifiable_code
mixing-strings-1
Solve the following coding problem using the programming language python: Heisenberg is very fond of mixing various strings together. But he has storage problem. He wants that his strings use as less space as possible. He has N strings right now. He wants to store them together. To reduce space he can use this pro...
```python def suture(s1, s2): for n in xrange(len(s2), 0, -1): if s1.endswith(s2[:n]): return s1 + s2[n:] return s1 + s2 import itertools strings = [] for _ in xrange(input()): strings.append(raw_input()) best = 10**100 for perm in itertools.permutations(strings): line = '' for ...
vfc_63217
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nabcdef\nfghi\n\nSAMPLE", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nfedcba\nfghi\n\nSAMPLE", "output": "10\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
panda-and-his-lazy-number
Solve the following coding problem using the programming language python: It is vacation time and Panda is in his hometown Pandaland. Panda is very bored so he started studying some interesting properties of natural numbers. Some days later he meet his friend Agham, who is pretty good in mathematics and tells him abou...
```python from sys import stdin import math def get(n): return int(math.sqrt(n)) a = stdin.readlines() for i in a[1:]: l,r = map(int,i.strip().split()) if r < 11: while True: x = 3 else: print get(r)-get(l-1) ```
vfc_63221
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 3\n6 10\n\nSAMPLE", "output": "1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n846930886 1804289383\n1681692777 1714636915\n424238335 1957747793\n719885386 1649760492\n5965166...
code_contests
verifiable_code
rooms-1
Solve the following coding problem using the programming language python: Harsh is thinking of starting his own business.He has decided to start with the hotel business. He has been given a list which contains the arrival time and the duration of stay of each guest at his hotel. He can give 1 room to only 1 guest.Sinc...
```python T = input() while(T>0): n = input() A = map(int,raw_input().split()) D = map(int,raw_input().split()) E = [] l = len(A) for i in range(l): E.append(A[i]+D[i]) A.sort() E.sort() i = 0 j = 0 m = 0 g = 0 while((i<n) and (j<n)): if(A[i] < E[j]): g = g+1 if(g>m): m = g i = i+1 else...
vfc_63225
{ "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 \n1 2 3 \n3 3 3 \n5 \n1 2 3 4 5 \n2 3 4 5 6 \n\nSAMPLE", "output": "3\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 \n3 \n1 2 3 \n3 6 3 \n5 \n1 2 3 4 5 \n2 3 4 5 6 \n\nSAMPLE"...
code_contests
verifiable_code
stickers
Solve the following coding problem using the programming language python: Karan has decided to give stickers to all the attendees of the last day of Google Week. The stickers will be given such that the last person to enter the hall gets a single sticker. The second last person entering the hall gets two stickers and ...
```python from sys import stdin a = stdin.readlines() for i in a[1:]: n = int(i) print ((n*(n+1))/2 % 2**32) ```
vfc_63229
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n\nSAMPLE", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
unify-numbers
Solve the following coding problem using the programming language python: Today Omar has assignment problems from his math professor. Yes, Omar has infinite number of questions that he must solve today. The first problem went something like this. Given N integers in the form of A_i where 1 ≤ i ≤ N, Omar wants to ma...
```python import math t=int(raw_input()) while t: t=t-1 n = int(raw_input()) a = map(int,raw_input().split()) a.sort() m = 0 x=n/2 if n%2==0: m = int(math.ceil((a[x-1]+a[x])/float(2))) else: m = a[x] cost = 0 for i in a: cost+=abs(m-i) print cost ```
vfc_63233
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n1 2 4 5\n\nSAMPLE", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n4\n0 2 4 5\n\nSAMPLE", "output": "7\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
p00008 Sum of 4 Integers
Solve the following coding problem using the programming language python: Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c...
```python import sys answer = [0] * 51 for a in range(10): for b in range(10): for c in range(10): for d in range(10): answer[a + b + c + d] += 1 for line in sys.stdin: try: print(answer[int(line)]) except: break ```
vfc_63277
{ "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": "35\n1", "output": "4\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "35\n2", "output": "4\n10\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00140 Bus Line
Solve the following coding problem using the programming language python: There is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 → 6 → 7 → 8 → 9 → 5 as shown in the figure. <image> ...
```python # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0140 """ import sys from sys import stdin input = stdin.readline def solve(start, goal): path = [] # ?????????n??????????????????????????????????????? # ????????????????????¨????????´?????¨?????...
vfc_63281
{ "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\n2 4\n4 2", "output": "2 3 4\n4 3 2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00461 IOIOI
Solve the following coding problem using the programming language python: problem For the integer n (1 ≤ n), let Pn be a string of n + 1 I's and n O's starting with I and alternating, where I and O are the uppercase Ai and O, respectively. is there. P1 | IOI --- | --- P2 | IOIOI P3 | IOIOIOI |. | |. | |. | Pn | IOI...
```python # -*- coding: utf-8 -*- """ IOIOI http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0538 """ import sys import re def solve(n, s): ans = 0 p = '(I(?:OI){' + str(n) + ',})' for f in re.findall(p, s): repeat = len(f) // 2 if repeat >= n: ans += (repeat - n + 1) ...
vfc_63289
{ "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\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0", "output": "4\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n13\nOIIOIOIOIIOIO\n2\n13\nOOIOIOIOIIOII\n0", "output": "4\n2\n", ...
code_contests
verifiable_code
p00651 Legend of Storia
Solve the following coding problem using the programming language python: In Storia Kingdom, there is an artifact called "Perfect Sphere" made by a great meister Es. This is handed down for generations in the royal palace as a treasure. Es left a memo and filled mysterious values in it. Within achievements of research...
vfc_63293
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 10 8\n0 -10\n3 -7\n0 -4\n-3 -7\n0 0 0", "output": "-4.146082488326 -9.100000000000\n-7.545870128753 -6.562000000000\n-9.587401146004 -2.842840000000\n-9.903199956975 1.388031200000\n-8.436422775690 5.369056784000\n-5.451089...
code_contests
verifiable_code
p00796 Lost in Space
Solve the following coding problem using the programming language python: William Robinson was completely puzzled in the music room; he could not find his triangle in his bag. He was sure that he had prepared it the night before. He remembered its clank when he had stepped on the school bus early that morning. No, not...
vfc_63297
{ "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": "2\n50.36493 81.61338 79.96592\n5\n-10293.83 -4800.033 -5296.238\n14936.30 6964.826 7684.818\n-4516.069 25748.41 -27016.06\n18301.59 -11946.25 5380.309\n27115.20 43415.93 -71607.81\n11.51547 13.35555 14.57307\n5\n-56292.27 ...
code_contests
verifiable_code
p00927 Space Golf
Solve the following coding problem using the programming language python: Example Input 100 1 0 50 100 Output 14.57738 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 d, n, b = map(int, input().split()) O = [list(map(int, input().split())) for i in range(n)] def solve(b): l = d / (b+1) idx = 0 vx2 = 10**9 for i in range(b+1): while idx < n and O[idx][0]*(b+1) <= d*(i+1): p, h = O[idx] p -= l*i vx2 = m...
vfc_63301
{ "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": "100 1 0\n50 100", "output": "14.57738", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 1 0\n28 100", "output": "16.065362523637\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
p01192 Greedy
Solve the following coding problem using the programming language python: Once upon a time, there lived a dumb king. He always messes things up based on his whimsical ideas. This time, he decided to renew the kingdom’s coin system. Currently the kingdom has three types of coins of values 1, 5, and 25. He is thinking o...
vfc_63309
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 5 25\n3 7 77 777\n4 1 8 27 64\n0", "output": "Case #1: OK\nCase #2: Cannot pay some amount\nCase #3: Cannot use greedy algorithm", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 5 25\...
code_contests
verifiable_code
p01667 Everlasting Zero
Solve the following coding problem using the programming language python: A - Everlasting Zero Problem Statement You are very absorbed in a famous role-playing game (RPG), "Everlasting -Zero-". An RPG is a game in which players assume the roles of characters in a fictional setting. While you play the game, you can f...
vfc_63321
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n2\n1 >= 3\n2", "output": "Yes", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01945 Star in Parentheses
Solve the following coding problem using the programming language python: You are given a string $S$, which is balanced parentheses with a star symbol '*' inserted. Any balanced parentheses can be constructed using the following rules: * An empty string is balanced. * Concatenation of two balanced parentheses is bal...
```python S = list(input()) S_l = len(S) n=0 l = [] r = [] f_l, f_r = 0,0 for n in range(S.index('*')): if S[n]== '(': f_l += 1 elif S[n]== ')': f_l -= 1 for n in range(S_l - S.index('*')): if S[S_l-n-1] == ')': f_r += 1 elif S[S_l-n-1]== '(': f_r -= 1 print(min(f_r, f_l)...
vfc_63329
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "*", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "((((((((((*))))))))))", "output": "10", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02227 Test
Solve the following coding problem using the programming language python: UnionFind(ランダム生成) Example Input Output The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_63337
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 1073741824, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "", "output": "", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02378 Bipartite Matching
Solve the following coding problem using the programming language python: A bipartite graph G = (V, E) is a graph in which the vertex set V can be divided into two disjoint subsets X and Y such that every edge e ∈ E has one end point in X and the other end point in Y. A matching M is a subset of edges such that each ...
```python #!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 3 4 6 0 0 0 2 0 3 1 1 2 1 2 3 output: 3 """ import sys def generate_adj_table(_edges): for edge in _edges: vx, vy = map(int, edge) init_adj_table[vx].add(vy) return init_adj_table def graph_dfs(current, matching, visited)...
vfc_63341
{ "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": "3 4 6\n0 0\n0 2\n0 3\n1 1\n2 1\n2 3", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 6\n0 0\n0 0\n0 3\n1 1\n2 1\n2 3", "output": "3\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
cakedoom
Solve the following coding problem using the programming language python: From the FAQ: What am I allowed to post as a comment for a problem? Do NOT post code. Do NOT post a comment asking why your solution is wrong. Do NOT post a comment asking if you can be given the test case your program fails on. Do NOT post ...
```python a=int(raw_input()) ans=[] for i in range(0,a): q=0 b=int(raw_input()) c=raw_input() if b==2 and c[0]=='?': if c.find('0')>0 and c.find('1')>0: if c.find('1') < c.find('0') and c.find('1')%2==0: c='1'+c[1:] elif c.find('1') > c.find('0') and c.fin...
vfc_63345
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1\n?\n2\n?0\n10\n79259?087\n2\n??\n3\n0?1\n4\n?????\n3\n012", "output": "0\n10\nNO\n01\n021\n01012\n012", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cr02
Solve the following coding problem using the programming language python: POINTS - 30   Given an integer N, output the number of zeroes at the end of N! (factorial).   Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of...
```python import sys t=int(sys.stdin.readline()) while t!=0: n=int(sys.stdin.readline()) f=1 for i in range (1,n+1): f=f*i f=str(f) c=0 l=len(f)-1 while l>=0: if f[l]=='0': c+=1 l-=1 else: break print c t-=1 ```
vfc_63349
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n60\n3\n100", "output": "14\n0\n24", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
gpyrd
Solve the following coding problem using the programming language python: Problem Description: A pyramid has been constructed using bricks. All these bricks are made of gold. However the quality of gold varies from brick to brick. The value of the bricks has been marked equivalent to nCr. Where n is the nth row of the...
```python from math import sqrt def disp(A): j = 0 for i in A: print j, i j += 1 print def Asum(A): s = 0L for i in A: s += sum(i) return long(s) def solve(N): N = sqrt(1 + 8*N) - 1 N /= 2 N = int(N) # print N A = [[0] * (i + 1) for i in xrange...
vfc_63353
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10\n21", "output": "5\n43", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
maxcomp
Solve the following coding problem using the programming language python: Chef Po has given an online advertisement to provide Event organizing services. Chef got a huge response for his advertisement. He got various orders to conduct the events from different organizations. In turn, Chef will receive a compensation d...
```python from sys import stdin from collections import defaultdict class Event(object): def __init__(self, start, end, value): self.start = start self.end = end self.value = value T = int(stdin.readline()) for _ in range(T): number_of_events = int(stdin.readline()) events = defaultdict(list) for _ in rang...
vfc_63357
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 2 100\n2 3 200\n3 4 1600\n1 3 2100\n3\n1 10 2000\n2 5 100\n6 9 400", "output": "3700\n2000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
rainbowb
Solve the following coding problem using the programming language python: Chef loves arrays. But he really loves a specific kind of them - Rainbow Arrays. The array is a Rainbow Array if it has such a structure: The first a1 elements equal to 1. The next a2 elements equal to 2. The next a3 elements equal to 3. ...
```python import sys f=sys.stdin mod=1000000007 n=int(f.readline()) if n<13: print 0 else : n+=1 n/=2 n-=1 ans=n*(n-1)*(n-2)*(n-3)*(n-4)*(n-5) ans/=720 ans%=mod print ans ```
vfc_63361
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "14", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13", "o...
code_contests
verifiable_code
tos01
Solve the following coding problem using the programming language python: Damon was captured by almighty Ni’klaus. Ni’klaus was 1000 years old and have spent his life hunting innocents, so he didn’t had time to study math. Damon, a sharp minded vampire, came across a very interesting idea. He wanted to tell his frien...
```python t=input() for x in range(0,t): n=input() s=bin(n) cnt=s.count('1') print cnt ```
vfc_63365
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n15", "output": "1\n4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1015_D. Walking Between Houses
Solve the following coding problem using the programming language python: There are n houses in a row. They are numbered from 1 to n in order from left to right. Initially you are in the house 1. You have to perform k moves to other house. In one move you go from your current house to some other house. You can't stay...
```python import math def main(): n, k, s = [int(x) for x in input().split()] if (n - 1) * k < s: print('NO') return if k > s: print('NO') return curr = 1 print('YES') while s > 0: d = min(n - 1, s - k + 1) s -= d k -= 1 if cur...
vfc_63369
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 2 15\n", "output": "YES\n10 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 9 82\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1039_B. Subway Pursuit
Solve the following coding problem using the programming language python: This is an interactive problem. In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictio...
```python import sys,random n,k=map(int,input().split()) l=1 r=n count=0 while True: if l+200<r: try1=(l+r)//2 print(l,try1,flush=True) s=input() if s=='Yes': r=min(try1+10,n) l=max(1,l-10) else: l=max(1,try1-10) r=min(n,r+10) else: guess=random.randint(l,r) print...
vfc_63373
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 2\n\nYes\n\nNo\n\nYes\n\nYes\n", "output": "10 10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n\nYes\n\nNo\n\nYes\n\nseY\n", "output": "1 1\n", "type": "stdin_stdout...
code_contests
verifiable_code
1061_D. TV Shows
Solve the following coding problem using the programming language python: There are n TV shows you want to watch. Suppose the whole time is split into equal parts called "minutes". The i-th of the shows is going from l_i-th to r_i-th minute, both ends inclusive. You need a TV to watch a TV show and you can't watch tw...
```python from bisect import bisect_right n, x, y = map(int, input().split(' ')) s=[0]*n e=[0]*n v=[0]*n c=0 for i in range(n): s[i],e[i]=map(int, input().split(' ')) c+=x+(e[i]-s[i])*y s.sort() e.sort() for i in range(n-2,-1,-1): k=bisect_right(s,e[i]) while (k < n) and (v[k]==1) and (s[k]-e[i]) * y <...
vfc_63377
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3 2\n8 20\n6 22\n4 15\n20 28\n17 25\n20 27\n", "output": "142\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4 3\n1 2\n4 10\n2 4\n10 11\n5 9\n", "output": "60\n", "type": ...
code_contests
verifiable_code
1083_C. Max Mex
Solve the following coding problem using the programming language python: Once Grisha found a tree (connected graph without cycles) with a root in node 1. But this tree was not just a tree. A permutation p of integers from 0 to n - 1 is written in nodes, a number p_i is written in node i. As Grisha likes to invent s...
vfc_63381
{ "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": "6\n2 5 0 3 1 4\n1 1 3 3 3\n3\n2\n1 6 3\n2\n", "output": "3\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n5 2 1 4 3 0\n1 1 1 3 3\n9\n2\n1 5 3\n2\n1 6 1\n2\n1 4 2\n2\n1 1 6\n2\n", ...
code_contests
verifiable_code
1130_D2. Toy Train
Solve the following coding problem using the programming language python: Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circular m...
```python n, m = map(int, input().split()) def dist(a, b): return (n + b - a) % n def main(): inp1 = [0] * (n + 1) inp2 = [n] * (n + 1) for _ in range(m): a, b = map(int, input().split()) inp1[a] += 1 inp2[a] = min(inp2[a], dist(a, b)) inp = tuple((((r1 - 1) * n + r2) for...
vfc_63389
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n1 2\n1 2\n1 2\n", "output": "5 6 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n2 4\n5 1\n2 3\n3 4\n4 1\n5 3\n3 5\n", "output": "10 9 10 10 9 ", "type": "stdin_stdout...
code_contests
verifiable_code
1151_A. Maxim and Biology
Solve the following coding problem using the programming language python: Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a task f...
```python Answer = 'ACTG' MIN = 10 ** 6 input() X = input() for i in range(0, len(X) - 3): Temp = X[i:i + 4] Index, Count = 0, 0 for j in Temp: tmp = 0 if ord(j) > ord(Answer[Index]): tmp += 26 + ord(Answer[Index]) - ord(j) else: tmp += 26 + ord(j) - ord(Answe...
vfc_63393
{ "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\nZCTH\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nZDATG\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
1172_F. Nauuo and Bug
Solve the following coding problem using the programming language python: Nauuo is a girl who loves coding. One day she was solving a problem which requires to calculate a sum of some numbers modulo p. She wrote the following code and got the verdict "Wrong answer". <image> She soon discovered the bug — the ModAdd...
vfc_63397
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5 6\n7 2 -3 17\n2 3\n1 3\n1 2\n2 4\n4 4\n", "output": "-1\n0\n3\n10\n11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\n1\n1 1\n", "output": "0\n", "type": "stdin_stdo...
code_contests
verifiable_code
1190_C. Tokitsukaze and Duel
Solve the following coding problem using the programming language python: "Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started. There are n cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and ...
```python n, k = map(int,input().split()) s= input() fir0 = -1 last0 = -1 fir1 = -1 last1 = -1 for i in range(n): if(s[i] == '0'): if(fir0 == -1): fir0 = i last0 = i else: if(fir1 == -1): fir1 = i last1 = i d0 = last0 - fir0 d1 = last1 - fir1 if(min(d...
vfc_63401
{ "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 1\n010101\n", "output": "once again\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n0011\n", "output": "once again\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
1250_M. SmartGarden
Solve the following coding problem using the programming language python: Berland Gardeners United Inc. hired you for the project called "SmartGarden". The main feature of this project is automatic garden watering. Formally the garden can be represented as a square of n × n cells with rows numbered 1 to n from top to...
vfc_63413
{ "difficulty": "20", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2", "output": "\n2\n1 1\n1 2\n1 1\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4", "output": "\n4\n2 1 4\n1 2\n2 1 2\n2 3 4\n1 3\n2 1 4\n1 4\n1 1\n", "type": "stdin_std...
code_contests
verifiable_code
1270_F. Awesome Substrings
Solve the following coding problem using the programming language python: Let's call a binary string s awesome, if it has at least 1 symbol 1 and length of the string is divisible by the number of 1 in it. In particular, 1, 1010, 111 are awesome, but 0, 110, 01010 aren't. You are given a binary string s. Count the nu...
```python import sys range = xrange input = raw_input A = [+(c == '1') for c in sys.stdin.read()] A.pop() n = len(A) cumA = [0] cumA += (cumA[-1] + a for a in A) frac_limit = 200 # Calculate number of intervals with 1/frac ones, 1 <= frac < frac_limit big = n + n counter = [0]*big combs = 0.0 for frac in range(1, ...
vfc_63417
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1111100000\n", "output": " 25", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1293_D. Aroma's Search
Solve the following coding problem using the programming language python: [THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover h...
```python x,y,a,b,c,d,xs,ys,t,maxx = [0]*10 arr = [] #must run now def abs(x): if x < 0: return 0 - x return x def max(x,y): if x > y: return x return y def dfs(idx,left,currx,curry,dir,cnt): global arr,maxx if dir == 0: if idx < 0: maxx = max(maxx,cnt) return else: if abs(currx - arr[...
vfc_63421
{ "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 2 3 1 0\n2 4 20\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 2 3 1 0\n2 2 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name"...