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
898_B. Proper Nutrition
Solve the following coding problem using the programming language python: Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars. Find out if it's possible to buy some...
```python n = int(input()) a = int(input()) b = int(input()) for i in range(n//a+1): if (n - i * a) % b == 0: print("YES") print(i, (n - i * a) // b) break else: print("NO") ```
vfc_73593
{ "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\n2\n3\n", "output": "YES\n2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9960594\n2551\n2557\n", "output": "YES\n1951 1949\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
946_B. Weird Subtraction Process
Solve the following coding problem using the programming language python: You have two variables a and b. Consider the following sequence of actions performed with these variables: 1. If a = 0 or b = 0, end the process. Otherwise, go to step 2; 2. If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1....
```python a, b = map(int, input().split()) while a != 0 and b != 0: if a >= 2 * b: a = a % (2 * b) elif b >= 2 * a: b = b % (2 * a) else: print(a, b) exit(0) print(a, b) ```
vfc_73601
{ "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": "12 5\n", "output": "0 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "31 12\n", "output": "7 12", "type": "stdin_stdout" }, { "fn_name": null, "input": "100...
code_contests
verifiable_code
96_E. Horse Races
Solve the following coding problem using the programming language python: Petya likes horse racing very much. Horses numbered from l to r take part in the races. Petya wants to evaluate the probability of victory; for some reason, to do that he needs to know the amount of nearly lucky horses' numbers. A nearly lucky n...
vfc_73605
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n70 77\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 20\n80 100\n", "output": "0\n0\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
994_E. Careful Maneuvering
Solve the following coding problem using the programming language python: There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coo...
```python from collections import defaultdict import itertools as it def main(): n, m = map(int, input().split()) l = tuple(map(int, input().split())) r = tuple(map(int, input().split())) p2d = defaultdict(lambda :set()) for i, ll in enumerate(l): for j, rr in enumerate(r, len(l)): pd = p2d[(ll+rr)/2] ...
vfc_73609
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 9\n1 2 3\n1 2 3 7 8 9 11 12 13\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n1 2 3 4 5\n1 2 3 4 5\n", "output": "10\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
chotu-and-hug-day
Solve the following coding problem using the programming language python: "Too close Yet too far" It is well known that our chotu is chotu (Height-wise :P). On Hug day his short height is creating problems for him as most of the girls are taller than him so he can't hug them properly. To overcome the problem he has ...
```python import math t = int(raw_input()) while t>0: a = raw_input().split(' ') a = [int(x) for x in a if x!=''] b = raw_input().split(' ') b = [int(x) for x in b if x!=''] for i in range(0, len(b)): b[i]=abs(b[i]-a[1]) b.sort() print b[0] t=t-1 ```
vfc_73617
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 4\n10 1 2 3 6 \n4 8\n8 8 8 8\n\nSAMPLE", "output": "1\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
easy-factorial-a-1
Solve the following coding problem using the programming language python: Sorry folks,, admin has no time to create a story for this problem... You have two integers n and m and you have to print value of factorial(n)%m. OUTPUT a single integer containing answer of problem. Input 23 14567 NOTE You do not need to c...
```python from math import factorial a,b=map(int,raw_input().split()) j=factorial(a) p=j%b print p ```
vfc_73621
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "23 14567", "output": "12404\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
hanuman-language
Solve the following coding problem using the programming language python: Hanuman has been a great admirer of Ram. However, there is one thing that Hanuman finds really difficult when talking to Ram. Hanuman can only understand sentences in reverse order but Ram,though an incarnation of God,is somehow unable to speak ...
```python noOfSentences = int(raw_input()) def reverseString(s): strings = s.split(" ") strings = strings[::-1] return ' '.join(strings) for caseNo in range(1, noOfSentences + 1): print reverseString(raw_input()) ```
vfc_73625
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nI have always been fond of you, Hanuman\nSpacelessSentence\nA B C D 5\n\nSAMPLE", "output": "Hanuman you, of fond been always have I \nSpacelessSentence \n5 D C B A \n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
love-encoded
Solve the following coding problem using the programming language python: There was girl named Julia in their neighbourhood. Both of them liked her and were trying to impress her. Now that Tim and Bob are done with daddy’s game. Julia thought that Tim solved the game on his own and was deeply impressed. After few days...
```python for i in range(input()): k=input() st=[] s=raw_input() for j in range(len(s)): l=ord(s[j])-k if l<ord('A'): l=l+26 st.append(chr(l)) print "".join(st) ```
vfc_73629
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\nKOKUUW\n4\nALEXCSYIEX\n9\nFQHJANHXDXOOURWN\n1\nXIPXBTTIF\n\nSAMPLE", "output": "IMISSU\nWHATYOUEAT\nWHYAREYOUOFFLINE\nWHOWASSHE\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2\n...
code_contests
verifiable_code
mystery-8
Solve the following coding problem using the programming language python: Solve the mystery. Input: String which consists of words(all the characters of any word are lower case letters) and punctuation marks(consists of {'.' , ',' , '?' , '!'}). Also every input string consists of one '*' in it. It is guaranteed tha...
```python N=input(); for k in range(0,N): st=raw_input() str="" ct=0; for i in range(0,len(st)): if(st[i].isalnum()==1)or st[i]=='*': str=str+st[i]; #print str ct=len(str)-1; c="" for i in range(0,len(str)): if(str[i]=='*'): c=str[ct]; ...
vfc_73633
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\nk! cats s*ack.\nah, s*tan sees natasha!\naibohphobi*\nal lets della call ed ste*la.\namy, must i jujitsu *y ma?\naerata pat a*ea.\nlollipop i * lol.\n\nSAMPLE", "output": "t\na\na\nl\nm\nr\nl\n", "type": "stdin_stdou...
code_contests
verifiable_code
problem-2-2
Solve the following coding problem using the programming language python: Julia has a sack full of red and yellow balls and wants to arrange them in a particular order as defined below. Let us consider two definitions - Chroma-regularity - maximum number of objects of the same color that appear consecutively. Mi...
```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!' r=input() s=input() m=min(r,s) n=max(r,s) if m==n or s==1: print "1" else: while m>0: n=n/2+1 m-=1 print n ```
vfc_73637
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n10\n\nSAMPLE", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "253\n356", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
selection-3
Solve the following coding problem using the programming language python: Bob gives you a list of N strings and a task to solve. The task is to remove all the duplicate strings from the list and print the resulting list of strings in a sorted order. Input: The first line contains an integer N. Then next N lines con...
```python n=input() a=set() for i in range(n): str=raw_input() a.add(str) for i in sorted(a): print i ```
vfc_73641
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "16\nnandu \nkanth\nkalyan\ndhiraj\nkanth\nkalyan\nbaala\nkt\nbaala\njayanth\nsampu\nbaala\nkanth\nkalyan\nbaala\nkt\n\nSAMPLE", "output": "baala\ndhiraj\njayanth\nkalyan\nkanth\nkt\nnandu \nsampu\n", "type": "stdin_stdo...
code_contests
verifiable_code
testcop
Solve the following coding problem using the programming language python: Mr. Osama is a maths enthusiast. Numbers and equations never fails to amaze him. Recently he started exploring a weird problem. The explanation of the problem he is working on, is given below. He takes the equation, ax1+bx2+cx3+.... = 1, for som...
```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!' from fractions import gcd t=input() while t>0: t-=1 n=input() l=[int(i) for i in raw_input().split()] if reduce(gcd,l)==1: print "YES" else: pr...
vfc_73645
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10...
code_contests
verifiable_code
x-game
Solve the following coding problem using the programming language python: Rohan is programmer. He designed a game called X-Game. In this game, there are N number of soldiers, represented in terms of their powers. The algorithm of this game arranges all soldiers in all possible different groups. Every group will figh...
```python mod = 10**9+7 for _ in xrange(input()): n = input() lst = map(int, raw_input().split()) ans = 0 for i in lst: ans |= i print (((2**(n-1)) % mod) * (ans % mod)) % mod ```
vfc_73649
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n1 2 3\n\nSAMPLE", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\n1 2 3\n\nSAMPME", "output": "12\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p03972 CODE FESTIVAL 2016 qual B - Gr-idian MST
Solve the following coding problem using the programming language python: On an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers. There are unpaved roads between every pair of points for which either the x coordinates are equal and the di...
```python #!/usr/bin/env python3 import sys try: from typing import Any, Union, List, Tuple, Dict except ImportError: pass sys.setrecursionlimit(10**6) def debug(*args): print(*args, file=sys.stderr) def exit(): sys.exit(0) W, H = map(int, input().split()) p = [] for i in range(W): p.append(int(input())) q = [] f...
vfc_73689
{ "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": "4 3\n2\n4\n8\n1\n2\n9\n3", "output": "60", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n3\n5\n2\n7", "output": "29", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
p00061 Rank Checker
Solve the following coding problem using the programming language python: The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers...
```python def get_input(): while True: try: yield ''.join(input()) except EOFError: break teams = [0 for i in range(101)] points = [False for i in range(31)] while True: a,b = [int(i) for i in input().split(",")] if a == 0 and b == 0: break teams[a] = b ...
vfc_73693
{ "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,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n5", "output": "2\n2\n3\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n1", "outpu...
code_contests
verifiable_code
p00192 Multistory Parking Lot
Solve the following coding problem using the programming language python: There are various parking lots such as three-dimensional type and tower type in the city to improve the utilization efficiency of the parking lot. In some parking lots, a "two-stage parking device" as shown in the figure is installed in one park...
```python from collections import deque def out(time, parking): x = len(parking) outs = [] for i in range(x): for j in range(2): if parking[i][j] != None: parking[i][j][0] -= time for i in range(x): c1 = parking[i][0] c2 = parking[i][1] if c1 != None and c2 != None: if c1...
vfc_73697
{ "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 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0", "output": "2 5 1 4 3\n1 2 4 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n123\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0", "...
code_contests
verifiable_code
p00543 Swapping Bibs
Solve the following coding problem using the programming language python: problem N students from JOI High School are lined up in a row from east to west. The i-th student from the western end of the column is student i. Each student has a bib with one integer. Initially, the integer Ai is written on the number of st...
```python n,m=map(int,input().split()) a=[int(input()) for _ in range(n)] for i in range(1,m+1): for j in range(n-1): if a[j]%i>a[j+1]%i:a[j],a[j+1]=a[j+1],a[j] for i in a:print(i) ```
vfc_73705
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 4\n3\n2\n8\n3\n1\n5", "output": "2\n3\n1\n8\n5\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4\n3\n2\n11\n3\n1\n5", "output": "2\n3\n1\n3\n5\n11\n", "type": "stdin_stdou...
code_contests
verifiable_code
p00707 The Secret Number
Solve the following coding problem using the programming language python: Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1. <image> Figure 1: A Matrix The secret number and other non-secret ones ...
```python from collections import defaultdict def main(w, h): field = [list(input()) for i in range(h)] d = defaultdict(str) for y in range(h - 1, -1, -1): for x in range(w - 1, -1, -1): if "0" <= field[y][x] <= "9": d[(x, y)] = field[y][x] for y in range(h - 1, -1, -...
vfc_73709
{ "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": "7 4\n9R2A993\n0E314A0\n8A900DE\n820R037\n6 7\nJH03HE\nID7722\n0DA1AH\n30C9G5\n99971A\nCA7EAI\nAHLBEM\n20 2\nA1234567891234CBDEGH\nBDEDF908034265091499\n0 0", "output": "23900037\n771971\n12345908034265091499", "type": "...
code_contests
verifiable_code
p00846 How I Mathematician Wonder What You Are!
Solve the following coding problem using the programming language python: After counting so many stars in the sky in his childhood, Isaac, now an astronomer and a mathematician, uses a big astronomical telescope and lets his image processing program count stars. The hardest part of the program is to judge if a shining...
vfc_73713
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n66 13\n96 61\n76 98\n13 94\n4 0\n45 68\n8\n27 21\n55 14\n93 12\n56 95\n15 48\n38 46\n51 65\n64 31\n0", "output": "1\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01248 Text Justification
Solve the following coding problem using the programming language python: You are hired by the ∀I¶אΞ℘, an extraterrestrial intelligence, as a programmer of their typesetting system. Your task today is to design an algorithm for text justification. Text justification is to equalize the line widths as much as possible ...
vfc_73725
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 10\n8\n6\n9\n1\n4 7\n1\n2\n3\n4\n0 0", "output": "Case 1: 4\nCase 2: 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 10\n8\n6\n9\n1\n4 7\n1\n2\n6\n4\n0 0", "output": "Case 1: 4\n...
code_contests
verifiable_code
p01409 Common Palindromes
Solve the following coding problem using the programming language python: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's practice is to improve the ability to read messages hidden from sentences by searching for palindromes i...
vfc_73729
{ "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": "ICPC\nCPCPC", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "MYON\nUSAGI", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
p01563 Connect
Solve the following coding problem using the programming language python: You are playing a solitaire puzzle called "Connect", which uses several letter tiles. There are R × C empty cells. For each i (1 ≤ i ≤ R), you must put a string si (1 ≤ |si| ≤ C) in the i-th row of the table, without changing the letter order. ...
```python # seishin.py import sys readline = sys.stdin.readline write = sys.stdout.write def gen(N, K): if K == 0: yield 0 return v = (1 << K) - 1 N2 = (1 << N) while v < N2: yield v x = v & -v; y = v + x v = ((v & ~y) // x >> 1) | y def solve(): R, C = map(...
vfc_73733
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 16\nINTERNATIONAL\nCOLLEGIATE\nPROGRAMMING\nCONTEST", "output": "18", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4\nACM\nICPC", "output": "2", "type": "stdin_stdout" }...
code_contests
verifiable_code
p01863 Miko Mi String
Solve the following coding problem using the programming language python: F: Miko Mi String- story Mikko Mikkomi ~! Everyone's idol, Miko Miko Tazawa! Today ~, with Mikoto ~, practice the string algorithm, let's do it ☆ Miko's special ~~ character making ~~ The slogan "MikoMikomi" becomes "MikoMikoMi" in Roman lett...
```python s = input() length = len(s) BASE = 100 MOD1 = 1000000007 MOD2 = 2147483647 acc1 = 0 acc2 = 0 hlst1 = [0] hlst2 = [0] for c in s: i = ord(c) acc1 = (acc1 * BASE + i) % MOD1 acc2 = (acc2 * BASE + i) % MOD2 hlst1.append(acc1) hlst2.append(acc2) def calc_hash(left, right, xlen): return ((hlst1[right]...
vfc_73741
{ "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": "NicoNicoNi", "output": "Love Nico!", "type": "stdin_stdout" }, { "fn_name": null, "input": "iNociNociN", "output": "Love iNoc!\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
p01998 Prime Number
Solve the following coding problem using the programming language python: problem One day, Sosusa, who loves prime numbers, was playing with the pair $ (p, q) $, where $ p + q $ is a prime number. Suddenly, Sosusa wondered how many of these pairs were prime numbers with $ p $ and $ q $ both less than or equal to $ N ...
```python import math N = int(input()) P = [True for x in range(N + 3)] P[0] = False P[1] = False for i in range(2, int(math.sqrt(N + 3)) + 1): if P[i]: for j in range(i * 2, N + 3, i): P[j] = False count = 0 for q in range(3, N + 1): if P[q] and P[2 + q]: count += 2 print(coun...
vfc_73745
{ "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", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1", "output...
code_contests
verifiable_code
p02144 Loss
Solve the following coding problem using the programming language python: Problem You were asked by a company to create a program. The company has $ N $ jobs, and each job is numbered from $ 1 $ to $ N $. There are $ M_i $ prerequisite jobs $ X_ {i, j} $ in job $ i $, and work $ X_ {i, j} $ is performed before job $ ...
vfc_73749
{ "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": "5\n1 2\n1 3\n2 1 2\n3 1 3 5\n0", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1\n0", "output": "1", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
p02285 Binary Search Tree III
Solve the following coding problem using the programming language python: Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node c...
```python class Node: def __init__(self,key,left=None,right=None,parent=None): self.key = key self.left = left self.right = right self.parent = parent root=None #前序排序 def PreorderTreeWalk(u): if u == None: return print(" %d"%u.key,end='') PreorderTreeWalk(u.left...
vfc_73753
{ "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": "18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint", "output": "yes\nyes\nyes\nno\nno\nno\nyes\nyes\n 1 2 3 7 8 22...
code_contests
verifiable_code
acugray
Solve the following coding problem using the programming language python: Problem Description Two mathematicians Mr.X and Mr.Y are discussing about a problem. Mr.X says that the ans is a and Mr.Y says the ans is b(where a and b being string containing 0's and 1's). After arguing for a long time they find that Mr.X was...
```python for _ in range(input()): s=raw_input() g='' g+=s[0] for i in range(1,len(s)): g+=str(int(s[i-1])^int(s[i])) print g ```
vfc_73761
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n100\n011\n10001", "output": "110\n010\n11001", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n000\n011\n10001", "output": "000\n010\n11001\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
chefsock
Solve the following coding problem using the programming language python: Today, Chef woke up to find that he had no clean socks. Doing laundry is such a turn-off for Chef, that in such a situation, he always buys new socks instead of cleaning the old dirty ones. He arrived at the fashion store with money rupees in hi...
```python jacketCost, sockCost, money = map(int,raw_input().split()) if((money-jacketCost)//sockCost)%2==0: print('Lucky Chef') else: print('Unlucky Chef') ```
vfc_73765
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 3", "output": "Unlucky Chef\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 6", "output": "Lucky Chef\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
double
Solve the following coding problem using the programming language python: The palindrome is a string that can be read the same way from left to right and from right to left. For example, strings "aaaaa", "1221", "bbaabb" are palindromes, however the string "chef" is not a palindrome because if we read it from right to...
```python T = int(raw_input()) for i in range(T): N = int(raw_input()) if N%2 == 0: print N else: print N-1 ```
vfc_73769
{ "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\n4", "output": "2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n0", "output": "2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
jeryfibo
Solve the following coding problem using the programming language python: Today, as usual, Jerry comes up with a new puzzle for Tom. Jerry knows very well that Tom is well aware of the concepts of fibonacci series. So he intends to present the problem with a twist. By choosing any random integer Jerry asks Tom to tell...
```python a = [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,1771128657,46368,75025, 121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169, 63245986,102334155,165580141,267914296,433494437,701408733] t = int(raw_input()) while t: t-=1 n ...
vfc_73773
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n3\n7", "output": "is fibo\nis fibo\nnot fibo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n5\n7", "output": "is fibo\nis fibo\nnot fibo\n", "type": "stdin_stdout"...
code_contests
verifiable_code
noways
Solve the following coding problem using the programming language python: John wanted to buy gifts for some k children in his apartments on christmas. He goes to the shop and the shopkeeper shows him n gifts. How many ways John can choose k gifts from n total gifts ?. Since answer could be large print the answer mod 1...
```python def C(n, r): if(n<r): return 0 if(r==0): return 1 if(r==1): return n if(r>n/2): return C(n, n-r) else: res = 1 for i in xrange(0, r): res*=(n-i) res/=(i+1) return res%1000000007 li=list() for _ in xrange(int(r...
vfc_73777
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 1", "output": "5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
sgarden
Solve the following coding problem using the programming language python: All bandits are afraid of Sheriff. Sheriff constantly fights crime, but when bandits lay low, he gets bored and starts to entertain himself. This time Sheriff gathered all the bandits in his garden and ordered them to line up. After the whistle...
```python def gcd(a, b): """ Compute the GCD of 2 numbers. """ while b: a, b = b, a % b return a def _lcm(a, b): """ Compute the LCM of 2 numbers. """ return (a * b) / gcd(a, b) def lcm(*args): """ Compute the LCM of arbitrary amount of numbers. """ return reduce(_lcm, args) def garden_game(): # Get ...
vfc_73781
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 2 3\n5\n2 3 1 5 4", "output": "1\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n1 2 3\n5\n2 3 1 5 4", "output": "1\n6\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1003_F. Abbreviation
Solve the following coding problem using the programming language python: You are given a text consisting of n space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of...
```python # import time N = 303 eq = [] dp = [] for i in range(N): eq.append([False] * N) for i in range(N): dp.append([0] * N) n = int(input()) s = input() # t = time.time() allsum = len(s) s = s.split() for i in range(n): eq[i][i] = True for j in range(i): eq[i][j] = eq[j][i] = s[i] == s[j] fo...
vfc_73785
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\na ab a a b ab a a b c\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\naa bb aa aa bb bb\n", "output": "11\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1027_G. X-mouse in the Campus
Solve the following coding problem using the programming language python: The campus has m rooms numbered from 0 to m - 1. Also the x-mouse lives in the campus. The x-mouse is not just a mouse: each second x-mouse moves from room i to the room i ⋅ x mod{m} (in fact, it teleports from one room to another since it doesn...
```python from math import gcd def powmod(a,b,m): a%=m r=1 while b: if b&1:r=r*a%m a=a*a%m b>>=1 return r def f(n): r=[] if (n&1)==0: e=0 while (n&1)==0:n>>=1;e+=1 yield (2,e) p=3 while n>1: if p*p>n:p=n if n%p: p+=2 continue e=1;n//=p while n%p==0:n//=p;e+=1 yield (p,e) p+=2 ret...
vfc_73789
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n",...
code_contests
verifiable_code
1046_F. Splitting money
Solve the following coding problem using the programming language python: After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency. These were the great news for Alice, wh...
```python n = int(input()) a = list(map(int, input().split())) max, fee = map(int, input().split()) total = 0 a.sort(reverse=True) for i in range(n): if a[i]> max: num = -(-(a[i]-max)//(max+fee)) total = total + fee*num else: break print(total) ```
vfc_73793
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n13 7 6\n6 2\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n999999999\n499999999 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
1070_E. Getting Deals Done
Solve the following coding problem using the programming language python: Polycarp has a lot of work to do. Recently he has learned a new time management rule: "if a task takes five minutes or less, do it immediately". Polycarp likes the new rule, however he is not sure that five minutes is the optimal value. He suppo...
```python import io, os input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) out = [] for _ in range(ii()): n, m, t = mi() p = li() def check(d): cur = tim = tot = totim = 0 for i in...
vfc_73797
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n11 1 29\n6 4 3 7 5 3 4 7 3 5 3\n7 1 5\n1 1 1 1 1 1 1\n5 2 18\n2 3 3 7 5\n", "output": "4 3\n3 1\n4 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 2 16\n5 6 1 4 7\n5 3 30\n5 6 1 ...
code_contests
verifiable_code
1092_A. Uniform String
Solve the following coding problem using the programming language python: You are given two integers n and k. Your task is to construct such a string s of length n that for each i from 1 to k there is at least one i-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) ...
```python t=int(input()) for _ in range(t): n,k=map(int,input().split()) s='' for i in range(97,97+k): s+=chr(i) s=s*(n//k)+s[:n%k] print(s) ```
vfc_73801
{ "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\n7 3\n4 4\n6 2\n", "output": "abcabca\nabcd\nababab\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "66\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 ...
code_contests
verifiable_code
1140_D. Minimum Triangulation
Solve the following coding problem using the programming language python: You are given a regular polygon with n vertices labeled from 1 to n in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pai...
```python n=int(input()) print((n*(n+1)*(n+2))//3-2-n*(n+1)) ```
vfc_73809
{ "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\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "137\n", ...
code_contests
verifiable_code
1159_B. Expansion coefficient of the array
Solve the following coding problem using the programming language python: Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i, a_j) is satisfied. The expansion coefficient of t...
```python from sys import stdin,stdout a=int(stdin.readline()) z=list(map(int,stdin.readline().split())) k=min(z);r=int(1e9);i=0;j=a-1 while i<=j:r=min(r,z[i]//max(i,a-i-1),z[j]//max(j,a-j-1));i+=1;j-=1 stdout.write(str(r)) ```
vfc_73813
{ "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\n6 4 5 5\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 1 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1181_B. Split a Number
Solve the following coding problem using the programming language python: Dima worked all day and wrote down on a long paper strip his favorite number n consisting of l digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the s...
```python n = int(input()) s = input() mid = n//2; ans = int(s) for i in range(mid, 0, -1): if s[i] != '0': val = int(s[:i]) + int(s[i:]) ans = min(ans, val) break for i in range(mid+1, n): if s[i] != '0': val = int(s[:i]) + int(s[i:]) ans = min(ans, val) break ...
vfc_73817
{ "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": "3\n101\n", "output": "11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1234567\n", "output": "1801\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
119_A. Epic Game
Solve the following coding problem using the programming language python: Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turn...
```python def gcd(a, b): if a == 0: return b return gcd(b % a, a) a, b,n = map(int,input().split(" ")) while True: n -= gcd(a, n) if n < 0: print("1") break n -= gcd(b,n) if n < 0: print("0") break ```
vfc_73821
{ "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 5 9\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 100\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1...
code_contests
verifiable_code
1216_E2. Numerical Sequence (hard version)
Solve the following coding problem using the programming language python: The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. The fi...
```python q = int(input()) def f(n): take = 0 ret = 0 while True: if n - take <= 0: break ret += (n - take) * (n - take + 1) // 2 take = take * 10 + 9 return ret def g(n): take = 0 ret = 0 while True: if n - take <= 0: break ret += n - take take = take * 10 + 9 return ret ...
vfc_73825
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n3\n20\n38\n56\n", "output": "1\n2\n5\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2132\n506\n999999999999999999\n1000000000000000000\n", "output": "8\n2\n4\n1\n", ...
code_contests
verifiable_code
125_B. Simple XML
Solve the following coding problem using the programming language python: Let's define a string <x> as an opening tag, where x is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type </x>, where x is the same letter. Tegs can be nested into each other: in this case one opening an...
```python # vars s = input() h = 0 # end_vars # main.sys l = s.split('>') for _ in range(len(l)): l[_] += '>' l = l[:-1] for i in range(len(l)): if '/' in l[i]: h -= 2 print(h * ' ' + l[i]) if '/' not in l[i]: h += 2 # end_main.sys ```
vfc_73833
{ "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": "&lt;a&gt;&lt;b&gt;&lt;c&gt;&lt;/c&gt;&lt;/b&gt;&lt;/a&gt;\n", "output": "&lt\n ;a&\n gt;\n &lt\n ;b&\n gt;\n &lt\n ;c&\n gt;\n &lt\n ...
code_contests
verifiable_code
1281_D. Beingawesomeism
Solve the following coding problem using the programming language python: You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant religion. There are onl...
```python # ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase 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...
vfc_73837
{ "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": "4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP\n", "output": "2\n1\nMORTAL\n4\n", "type": ...
code_contests
verifiable_code
1301_D. Time to Run
Solve the following coding problem using the programming language python: Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going to quit programming after the national ...
```python import sys import math from collections import defaultdict,Counter # input=sys.stdin.readline # def print(x): # sys.stdout.write(str(x)+"\n") # sys.stdout=open("CP1/output.txt",'w') # sys.stdin=open("CP1/input.txt",'r') # m=pow(10,9)+7 n,m,k=map(int,input().split()) if k>(4*m*n-2*n-2*m): print("NO"...
vfc_73841
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 4\n", "output": "YES\n2\n2 R\n2 L\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 8\n", "output": "YES\n4\n2 R\n2 L\n1 D\n1 RUD\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1325_D. Ehab the Xorcist
Solve the following coding problem using the programming language python: Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v ≤ 1...
```python u, v = list(map(int, input().split())) if u > v: print(-1) elif u == 0 and v == 0: print(0) elif u == v: print(1) print(u) else: a, b, c = u, (v - u) // 2, (v - u) // 2 d, e = (v - u) // 2 + u, (v - u) // 2 if d + e == v and d ^ e == u: print(2) print(d, e) elif...
vfc_73845
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n", "output": "2 3 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n", "output": "3 1 1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
1344_C. Quantifier Question
Solve the following coding problem using the programming language python: Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universa...
```python import sys from collections import deque input=sys.stdin.readline n,m=map(int,input().split()) edge=[[] for i in range(n)] revedge=[[] for i in range(n)] for i in range(m): j,k=map(int,input().split()) edge[j-1].append(k-1) revedge[k-1].append(j-1) deg=[len(revedge[i]) for i in range(n)] ans =...
vfc_73849
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n1 2\n", "output": "1\nAE\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 3\n2 3\n", "output": "2\nAAE\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
1386_C. Joker
Solve the following coding problem using the programming language python: Joker returns to Gotham City to execute another evil plan. In Gotham City, there are N street junctions (numbered from 1 to N) and M streets (numbered from 1 to M). Each street connects two distinct junctions, and two junctions are connected by ...
vfc_73857
{ "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 8 2\n1 3\n1 5\n1 6\n2 5\n2 6\n3 4\n3 5\n5 6\n4 8\n4 7\n", "output": "NO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 6\n1 2\n2 3\n3 1\n1 1\n1 2\n1 3\n2 2\n2 3\n3 3\n", ...
code_contests
verifiable_code
1408_C. Discrete Acceleration
Solve the following coding problem using the programming language python: There is a road with length l meters. The start of the road has coordinate 0, the end of the road has coordinate l. There are two cars, the first standing at the start of the road and the second standing at the end of the road. They will start ...
```python from sys import stdin, stdout from bisect import * def calc(T,arr): M={} # arr.insert(0,0) D,S,T=[0],[1],[0] M[0]=(0,1) c=0 t=0 for i in range(1,len(arr)): d=arr[i]-arr[i-1] c+=1 t+=d/c M[t]=(d,c) D.append(arr[i]) T.append(t) ...
vfc_73861
{ "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": "5\n2 10\n1 9\n1 10\n1\n5 7\n1 2 3 4 6\n2 1000000000\n413470354 982876160\n9 478\n1 10 25 33 239 445 453 468 477\n", "output": "3\n3.666666666666667\n2.047619047619048\n329737645.75\n53.7\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
1428_F. Fruit Sequences
Solve the following coding problem using the programming language python: Zookeeper is buying a carton of fruit to feed his pet wabbit. The fruits are a sequence of apples and oranges, which is represented by a binary string s_1s_2… s_n of length n. 1 represents an apple and 0 represents an orange. Since wabbit is al...
```python hist = [0]*1000005 def solve(n,s): cnt = 0 tot = 0 i = 0 while i < n: if s[i] == '0': tot += cnt else: l = i r = i while r+1 < n and s[r+1] == '1': r+=1 #print(r) for x in range(r-l...
vfc_73865
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1101001\n", "output": "30\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n011100011100\n", "output": "156\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1452_A. Robot Program
Solve the following coding problem using the programming language python: There is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute: * move north from cell (i, j) to (i, j + 1); * move east from cell (i, j) t...
```python for _ in range(int(input())): n,m=[int(x) for x in input().split()] print(n+m+max(0,abs(m-n)-1)) ```
vfc_73869
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 5\n3 4\n7 1\n0 0\n2 0\n", "output": "\n10\n7\n13\n0\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "output": "0\n0\n0\n0\n0\n0\n0\n"...
code_contests
verifiable_code
157_C. Message
Solve the following coding problem using the programming language python: Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "...
```python aa = input() bb = input() if len(aa) >= len(bb): p = aa q = bb else: p = aa q = bb maxc = 0 for i in range(1,len(p)+len(q)): k1 = max(0,i-len(q)) k2 = min(i,len(p)) a = p[k1:k2] if i < len(q): b = q[-i:] elif i > len(p): b = q[:-(i-len(p))] else: ...
vfc_73885
{ "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": "abcabc\nbcd\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aaaaa\naaa\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
19_D. Points
Solve the following coding problem using the programming language python: Pete and Bob invented a new interesting game. Bob takes a sheet of paper and locates a Cartesian coordinate system on it as follows: point (0, 0) is located in the bottom-left corner, Ox axis is directed right, Oy axis is directed up. Pete gives...
vfc_73893
{ "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": "7\nadd 1 1\nadd 3 4\nfind 0 0\nremove 1 1\nfind 0 0\nadd 1 1\nfind 0 0\n", "output": "1 1\n3 4\n1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\nadd 5 5\nadd 5 6\nadd 5 7\nadd 6 5\n...
code_contests
verifiable_code
248_C. Robo-Footballer
Solve the following coding problem using the programming language python: It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guy...
```python from math import hypot y1, y2, yw, xb, yb, r = map(int, input().split()) yw -= r y1, y2 = yw * 2 - y2, yw * 2 - y1 def xww(y): return (y - yw) * xb / (y - yb) def dd(y): xw = xww(y) return (y - y1) / hypot(1, (yw - y) / xw) def binary_search(): a, b = y1 + r, 1e10 for i in range(200): m = ...
vfc_73901
{ "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 10 13 10 3 1\n", "output": "4.3750000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 4 6 2 2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
272_D. Dima and Two Sequences
Solve the following coding problem using the programming language python: Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can be ...
```python from math import sqrt,ceil,gcd from collections import defaultdict def modInverse(b,m): g = gcd(b, m) if (g != 1): # print("Inverse doesn't exist") return -1 else: # If b and m are relatively prime, # then modulo inverse is b^(m-2) mode m return pow(b, m...
vfc_73905
{ "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": "1\n1\n2\n7\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n2 3\n11\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
296_A. Yaroslav and Permutations
Solve the following coding problem using the programming language python: Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. Help Y...
```python import math nums=eval(input()) list=input().split() max1=0 for i in list: if max1<list.count(i): max1=list.count(i) if max1>math.ceil((len(list)/2)): print("NO") else :print("YES") ```
vfc_73909
{ "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\n7 7 7 7\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
319_D. Have You Ever Heard About the Word?
Solve the following coding problem using the programming language python: A substring of a string is a contiguous subsequence of that string. So, string bca is substring of string abcabc, but string cc is not. A repeating block is a string formed by concatenating some string with itself. So, string abcabc is a repeat...
vfc_73913
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abccabc\n", "output": "abc\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "birdbirdbirdistheword\n", "output": "birdistheword\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
343_D. Water Tree
Solve the following coding problem using the programming language python: Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water. The vertices of the tree are numbered from 1 to n with the root at vertex 1. For each ver...
vfc_73917
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2\n5 1\n2 3\n4 2\n12\n1 1\n2 3\n3 1\n3 2\n3 3\n3 4\n1 2\n2 4\n3 1\n3 3\n3 4\n3 5\n", "output": "0\n0\n0\n1\n0\n1\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n13\n1 1\...
code_contests
verifiable_code
367_A. Sereja and Algorithm
Solve the following coding problem using the programming language python: Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q1q2... qk. The algorithm consists of two steps: 1. Find any con...
```python import sys # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') input = sys.stdin.readline s = input().strip() x_c, y_c, z_c = [0], [0], [0] for el in s: x_c.append(x_c[-1]+int(el=="x")) y_c.append(y_c[-1]+int(el=="y")) z_c.append(z_c[-1]+int(el=="z")) for _ in range(...
vfc_73921
{ "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": "zyxxxxxxyyz\n5\n5 5\n1 3\n1 11\n1 4\n3 6\n", "output": "YES\nYES\nNO\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "zxyzxyzyyzxzzxyzxyzx\n15\n7 10\n17 17\n6 7\n8 14\n4 7\n11 18\n...
code_contests
verifiable_code
38_E. Let's Go Rolling!
Solve the following coding problem using the programming language python: On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. Yo...
```python import os import sys from io import BytesIO, IOBase 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.buffer.write i...
vfc_73925
{ "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\n1 7\n3 1\n5 10\n6 1\n", "output": "11", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 3\n3 4\n1 2\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
40_D. Interesting Sequence
Solve the following coding problem using the programming language python: Berland scientists noticed long ago that the world around them depends on Berland population. Due to persistent research in this area the scientists managed to find out that the Berland chronology starts from the moment when the first two people...
```python from fractions import Fraction import sys sys.setrecursionlimit(1000*100) A=int(input()) p=[] c=1 for _ in range(600): p.append(c) c*=12 r=[] for i in range(600): for j in range(i+1): if p[j]+p[i-j]==A: r.append(i+1) break s=set() for i in r: for j in range(i...
vfc_73929
{ "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": "13\n", "output": "YES\n1\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1729\n", "output": "YES\n1\n4\n1\n156\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
438_C. The Child and Polygon
Solve the following coding problem using the programming language python: This time our child has a simple polygon. He has to find the number of ways to split the polygon into non-degenerate triangles, each way must satisfy the following requirements: * each vertex of each triangle is one of the polygon vertex; ...
vfc_73933
{ "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\n0 0\n1 0\n0 1\n-1 0\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
45_J. Planting Trees
Solve the following coding problem using the programming language python: Vasya is a Greencode wildlife preservation society proponent. One day he found an empty field nobody owned, divided it into n × m squares and decided to plant a forest there. Vasya will plant nm trees of all different heights from 1 to nm. For h...
```python # by the authority of GOD author: manhar singh sachdev # def some_random_function(): """due to the fast IO template, my code gets caught in plag check for no reason. That is why, I am making random functions""" x = 10 x *= 100 i_dont_know = x why_am_i_writing_this = x*x ...
vfc_73937
{ "difficulty": "16", "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\n", "output": "3 6 2 \n5 1 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
483_D. Interesting Array
Solve the following coding problem using the programming language python: We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. ...
```python # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def main(): n,m = map(int,input().split()) dp = [[0]*30 for _ in range(n+2)] op = [] for _ in range(m): op.append(tuple(map(int,input().split()))) l,r,q = op[-1] ...
vfc_73941
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 3 3\n1 3 2\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n1 3 3\n", "output": "YES\n3 3 3\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
507_D. The Maths Lecture
Solve the following coding problem using the programming language python: Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't. First he gave Amr two positive integers n and k...
```python def get_input(): hahaha=input() (n,k,m)=hahaha.split(sep=None, maxsplit=1000) return (int(n),int(k),int(m)) (n,k,m)=get_input() f=[0 for i in range(k)] s=0 for v in range(n): tens = 10**v%k f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)] for...
vfc_73945
{ "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 2 1000\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
530_E. Sum and product
Solve the following coding problem using the programming language python: You are given integers N and D. Find N positive integers x1...xN such that the difference of their product and their sum equals D. Input The only line of input contains integers N (2 ≤ N ≤ 1000) and D (0 ≤ D ≤ 1000). Output Output N integers...
vfc_73949
{ "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 1\n", "output": "2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n", "output": "1 2 8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
582_C. Superior Periodic Subarrays
Solve the following coding problem using the programming language python: You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≤ l < n, 1 ≤ s < n) of array a is an infinite periodic array with a period of length s that is a subs...
vfc_73957
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 1\n", "output": " 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n7 1 2 3\n", "output": " ...
code_contests
verifiable_code
604_C. Alternative Thinking
Solve the following coding problem using the programming language python: Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad...
```python if __name__ == "__main__": n = int( input().strip() ) s = input().strip() segs = [] start = 0 i = 1 while i <= n: if i == n or s[i] != s[start]: segs.append( i - start ) start = i i = start + 1 else: i += 1 res = l...
vfc_73961
{ "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": "8\n10000011\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n01\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
626_F. Group Projects
Solve the following coding problem using the programming language python: There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their independent pieces, and then discuss the results together. It takes the i-th student ai minutes...
vfc_73965
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n2 4 5\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
650_D. Zip-line
Solve the following coding problem using the programming language python: Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in the forest. He is sure that he remembers correct heights of all trees exce...
vfc_73969
{ "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": "4 2\n1 3 2 6\n3 5\n2 4\n", "output": "4\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 2 3 4\n1 1\n1 4\n4 3\n4 5\n", "output": "4\n3\n3\n4\n", "type": "stdin_stdout"...
code_contests
verifiable_code
676_B. Pyramid of Glasses
Solve the following coding problem using the programming language python: Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is n. The top level...
```python n, t = map(int, input().split()) g = [0] * n for i in range(n): g[i] = [0]*(i+1) for i in range(t): g[0][0] += 1 for j in range(n): for k in range(j+1): if g[j][k] > 1 and j < n - 1: u = g[j][k] - 1 g[j][k] = 1 g[j+1][k] += u/2 ...
vfc_73973
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 8\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 10\n"...
code_contests
verifiable_code
69_B. Bets
Solve the following coding problem using the programming language python: In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allows to place ...
```python import os import sys from io import BytesIO, IOBase from types import GeneratorType from bisect import * from collections import defaultdict, deque, Counter import math import string from heapq import * from operator import add from itertools import accumulate BUFSIZE = 8192 sys.setrecursionlimit(10 ** 5) ...
vfc_73977
{ "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": "8 4\n1 5 24 10\n2 4 6 15\n4 6 30 50\n6 7 4 20\n", "output": "105\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 4 20 5\n1 3 21 10\n3 3 4 30\n3 4 4 20\n", "output": "60\n", ...
code_contests
verifiable_code
720_E. Cipher
Solve the following coding problem using the programming language python: Borya has recently found a big electronic display. The computer that manages the display stores some integer number. The number has n decimal digits, the display shows the encoded version of the number, where each digit is shown using some lower...
vfc_73981
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n42\nabcdefghij\njihgfedcba\n2\n42\naaaaaaaaaa\naaaaaaaaaa\n1\n2\nabcdabcdff\n", "output": "0\n58\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
742_B. Arpa’s obvious problem and Mehrdad’s terrible solution
Solve the following coding problem using the programming language python: There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came up with an obvious problem: Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that <image>, where <image> is bitwise ...
```python n,x = map(int, input().split(' ')) a = list(map(int, input().split(' '))) cs = {} for v in a: cs[v] = cs.get(v, 0) + 1 t = 0 if x == 0: for c in cs.values(): t += c * (c - 1) // 2 print (t) else: for v in a: t += cs.get(x ^ v, 0) print(t // 2) ```
vfc_73985
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n1 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1\n5 1 2 3 4 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
789_C. Functions again
Solve the following coding problem using the programming language python: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried a...
```python n = int(input()) arr = list(map(int,input().split(' '))) arr.insert(0,0) diff_arr = [] end_so_far = 0 max_so_far = 0 l = 1 for i in range(2,len(arr)-1): temp = abs(arr[i]-arr[i+1]) diff_arr.append(temp*(pow((-1),i))) end_so_far = end_so_far + diff_arr[-1] if end_so_far < 0: if i%2 == 0...
vfc_73993
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 4 2 3 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 5 4 7\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
80_E. Beavermuncher-0xFF
Solve the following coding problem using the programming language python: "Eat a beaver, save a tree!" — That will be the motto of ecologists' urgent meeting in Beaverley Hills. And the whole point is that the population of beavers on the Earth has reached incredible sizes! Each day their number increases in several ...
```python import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') n = int(input()) beaver = list(map(int, input().split())) adj = [[] for _ in range(n)] deg = [0] * n for u, v in (map(int, input().split()) for _ in range(n - 1)): adj[u - 1].append(v ...
vfc_73997
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 1 3 2\n2 5\n3 4\n4 5\n1 5\n4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 1 1\n3 2\n1 2\n3\n", "output": "2\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
835_C. Star sky
Solve the following coding problem using the programming language python: The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c). Over time the stars twinkle. At moment 0 th...
```python import sys from bisect import bisect_left, bisect_right n, q, c = list(map(int, input().split())) values = [[[0 for _ in range(11)] for _ in range(0, 101)] for _ in range(0, 101)] # print(dp) for i in range(n): x, y, s = list(map(int, sys.stdin.readline().split())) values[x][y][s] += 1 dp = [[[-1...
vfc_74001
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 50 50 51 51\n", "output": "3\n3\n5\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 3\n1 1 1\n3 2 0\n2 1 1 2 2\n0 2...
code_contests
verifiable_code
855_F. Nagini
Solve the following coding problem using the programming language python: Nagini, being a horcrux You-know-who created with the murder of Bertha Jorkins, has accumulated its army of snakes and is launching an attack on Hogwarts school. Hogwarts' entrance can be imagined as a straight line (x-axis) from 1 to 105. Nag...
vfc_74005
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 2 3 5\n1 1 10 10\n1 4 5 -5\n2 4 8\n1 1 10 -10\n2 4 8\n2 1 10\n", "output": "15\n75\n170\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 10 10\n1 2 4 -7\n2 1 10\n", "outpu...
code_contests
verifiable_code
87_D. Beautiful Road
Solve the following coding problem using the programming language python: A long time ago in some country in Asia were civil wars. Each of n cities wanted to seize power. That's why sometimes one city gathered an army and sent it to campaign against another city. Road making was difficult, so the country had few roa...
vfc_74009
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 1 5\n", "output": " 2 1\n1 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
903_F. Clear The Matrix
Solve the following coding problem using the programming language python: You are given a matrix f with 4 rows and n columns. Each element of the matrix is either an asterisk (*) or a dot (.). You may perform the following operation arbitrary number of times: choose a square submatrix of f with size k × k (where 1 ≤ ...
```python import sys n = int(sys.stdin.buffer.readline().decode('utf-8')) cost = [0] + \ list(map(int, sys.stdin.buffer.readline().decode('utf-8').split())) a = [line.decode('utf-8').rstrip() for line in sys.stdin.buffer] mask = [0, 1, 51, 1911] inf, bs_size, full_bit = 10**9, 1 << 12, (1 << 12) - 1 dp = [[inf]*b...
vfc_74013
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10 10 1 10\n***.\n*..*\n*..*\n.***\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 10 8 20\n***.\n***.\n***.\n...*\n", "output": "9", "type": "stdin_stdo...
code_contests
verifiable_code
926_A. 2-3-numbers
Solve the following coding problem using the programming language python: A positive integer is called a 2-3-integer, if it is equal to 2x·3y for some non-negative integers x and y. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, 16 and...
```python import sys from math import * from fractions import gcd readints=lambda:map(int, input().strip('\n').split()) l,r=readints() maxn=2*(10**9) twos=set() i=2 while i<=maxn: twos.add(i) i*=2 threes=set() i=3 while i<=maxn: threes.add(i) i*=3 nums=set() nums.add(1) for x in twos: for y in t...
vfc_74017
{ "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 2000000000\n", "output": "326\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 200\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
954_H. Path Counting
Solve the following coding problem using the programming language python: You are given a rooted tree. Let's denote d(x) as depth of node x: depth of the root is 1, depth of any other node x is d(y) + 1, where y is a parent of x. The tree has the following property: every node x with d(x) = i has exactly ai children....
vfc_74021
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3\n", "output": "8 13 6 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 2 2\n", "output": "14 19 20 20 16 16\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
981_A. Antipalindrome
Solve the following coding problem using the programming language python: A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not. A substring s[l …...
```python a=input() b=a[::-1] c=0 if a!=b: print(len(a)) while a==b: a=a[:0]+a[(0+1):] b=a[::-1] if a!=b: print(len(a)) else: print(c) break ```
vfc_74025
{ "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": "qqqqqqqq\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "wuffuw\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
189
Solve the following coding problem using the programming language python: The fraction 1/89 can be described as sum of n floating point numbers, where n tends to infinity. 1/89 = 0.0 + 0.01 + ....... If we consider these numbers as elements in a float array named “Numbers” (index starting from 0) then kth number in...
```python l = [ ] l.append(0) l.append(1) a = 0 b = 1 cnt = 2 while cnt<=100: c = a+b l.append(c) a = b b = c cnt += 1 t = input() for i in range(t): n = input() n += 1 print "0."+"0"*(n-1)+str(l[n-1]) ```
vfc_74029
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n4\n1\n10\n\nSAMPLE", "output": "0.001\n0.00003\n0.01\n0.000000000055", "type": "stdin_stdout" }, { "fn_name": null, "input": "858\n21\n51\n62\n58\n51\n32\n59\n69\n58\n53\n56\n41\n56\n9\n75\n4\n...
code_contests
verifiable_code
bholu-the-pandit-1
Solve the following coding problem using the programming language python: Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes. But he loves uniformity so he asks you to divide it such a way that all the cubes are of same size and volume of individual cube is as large as possible....
```python def gcd(a, b): if b == 0: return a else: return gcd(b, a%b) def main(): test_cases = int(raw_input()) for _ in xrange(test_cases): L, B, H = raw_input().split() l, b, h = int(L), int(B), int(H) Volume = l*b*h possible_dim = gcd(l,gcd(b,h)) number = Volume/(possible_dim**3) print int(po...
vfc_74033
{ "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 4 6\n1 2 3\n\nSAMPLE", "output": "2 6\n1 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 3 6\n1 2 3\n\nSAMPLE", "output": "1 36\n1 6\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
count-carry-problem-1
Solve the following coding problem using the programming language python: Poornimites are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job is to co...
```python n=input() for i in range(0,n): x,y=(i for i in raw_input().split()) l=len(x) carry=0 count=0 for j in range(0,l): if(int(x[j])+int(y[j])+carry>=10): count+=1 carry=int((int(x[j])+int(y[j])+carry)/10) if count==0: print "No carry operation" elif count==1: print "1 carry operation" else: p...
vfc_74037
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n123 456\n555 555\n123 594\n\nSAMPLE", "output": "No carry operation\n3 carry operations\n1 carry operation\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n123 456\n555 555\n123 594",...
code_contests
verifiable_code
find-the-students-2
Solve the following coding problem using the programming language python: Subodh is having N branches, where each branches have positive integral student. A minimize operation is performed on the branch such that all of them are reduced by the minimum number student in a branch. Suppose we have 5 branches and all of ...
```python n=int(raw_input()) a=sorted(map(int,raw_input().split())) print n v=a[0] i=1 while (i<n): while (i<n and a[i]==v): i+=1 if (i<n): v=a[i] i+=1 print n-i+1 ```
vfc_74041
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5 4 4 2 2 8\n\nSAMPLE", "output": "6\n4\n2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n5 4 4 2 2 8", "output": "6\n4\n2\n1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
integration-1
Solve the following coding problem using the programming language python: Bitoholic is an inhabitant of the planet Neo in a galaxy far far away. Their civilization is studies an advanced form of mathematics. However, rules of calculus are a bit different there. On his planet, integration and differentiation techniques...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=int(raw_input()) for i in range(1,t+1): n,p,u,r,s=map(int,raw_input().split()) for j in range(0,n): if p+r<=u: p=p+r elif p-s>=0: p=p-s else: p=p print...
vfc_74045
{ "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 6 10 11 5 \n2 2 4 2 1\n\nSAMPLE", "output": "Case #1: 1\nCase #2: 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 \n1 6 14 11 5 \n2 2 4 2 1\n\nSAMPLE", "output": "Case #1: ...
code_contests
verifiable_code
maximum-and
Solve the following coding problem using the programming language python: Given two numbers A and B. Find the value of pair (P,Q) such that A ≤ P < Q ≤ B value of P AND Q is maximum where AND is a binary operator. Refer to this link for more information about AND operator : http://en.wikipedia.org/wiki/Bitwise_operati...
```python for _ in xrange(input()): a,b=map(int,raw_input().split()) if b-a+1<3: print a&b elif b&1: print b&(b-1) else: print (b-1)&(b-2) ```
vfc_74049
{ "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 3\n4 8\nSAMPLE", "output": "2\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n4 5\n4 6\n5 7\n5 8\n1 1200\n1 1199\n2 1199\n2 1198\n3 1198\n3 1197\n4 1197\n4 1196\n5 1196\n5 11...
code_contests
verifiable_code
one-in-zillion-2
Solve the following coding problem using the programming language python: The time is 1st January 20000014 Gazu is depressed with his life as he thinks there is nothing unique about him. One day he meets a travelling coder, Gazu tells him why he is depressed, to which coder replies “Everyone is one in a zillion my br...
```python import math t = input() for i in range(t): n = input() val = 1+n/30 print int(2**val) ```
vfc_74053
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n140\n310\n30\n\nSAMPLE", "output": "32\n2048\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n245\n310\n30\n\nSAMPLE", "output": "512\n2048\n4\n", "type": "stdin_stdout...
code_contests
verifiable_code
random-generator
Solve the following coding problem using the programming language python: Aparna recently created a random number generator and now she wants Harsh to check if it works fine. She gives Harsh an array containing N numbers generated from this random number generator of hers, and two integers K and P. If the given array...
```python T = int(raw_input()) for t in range(T): (N, K, P) = map (int, str(raw_input()).split()) nums = sorted (map (int, str(raw_input()).split())) for I in range(N-K+1): fail = False if nums[I+K-1] - nums[I] <= 2 * P: fail = True break if fail: print "NO" else: print "YES" ```
vfc_74057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 2 2\n2 9 6 8 4\n\nSAMPLE", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5 2 2\n4 9 6 8 4\n\nSAMPLE", "output": "NO\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
skipping-stones
Solve the following coding problem using the programming language python: My flatmate, Sayan, went to the game show called Takeshi's castle.It is a game show in which you need to pass different game challenges to enter the final. Now the most famous round of all of them is the "skipping stones".In the game you need t...
```python n, L, D = [int(i) for i in raw_input().split(" ")] p = [float(x) for x in raw_input().split(" ")] p.append(1) p.insert(0, 1) d = [int(x) for x in raw_input().split(" ")] d.insert(0,0) last = d[len(d) - 1] d.append(D) pthen = [0]*len(d) pthen[0] = 1 for x in range(0, len(d)): for y in range(x+1, len(d)): ...
vfc_74061
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 10\n0.5 0.4 0.6 0.8 1.0\n2 3 5 6 8\n\nSAMPLE", "output": "0.320000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "486 7835 730\n0.567444596044 0.982519196406 0.922789966077 0.80656874...
code_contests
verifiable_code
the-tiled-footpath-on-marine-drive
Solve the following coding problem using the programming language python: X and Y are sitting beside a footpath on a bench on Marine Drive having a look at the beautiful sea. (Anyone from Mumbai here ?). X is a top coder who studies at DA-IICT. His friend Y studies at some local college from Mumbai. X always wants to...
```python def mul(A,B): a,b,c,d,e,f,g,h=A[0][0],A[0][1],A[1][0],A[1][1],B[0][0],B[0][1],B[1][0],B[1][1] return [[(a*e+b*g)%mod,(a*f+b*h)%mod],[(e*c+d*g)%mod,(c*f+d*h)%mod]] def findNthPower(M ,n): if( n == 1 ): return M; R = findNthPower ( M , n/2 ); #a,b,c,d=R[0][0],R[0][1],R[1][0],R[1][1] R = ...
vfc_74065
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 2\n\nSAMPLE", "output": "0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00102 Matrix-like Computation
Solve the following coding problem using the programming language python: Your task is to develop a tiny little part of spreadsheet software. Write a program which adds up columns and rows of given table as shown in the following figure: <image> Input The input consists of several datasets. Each dataset consists...
```python while True: n = int(input()) if not n: break mat = [] for _ in range(n): lst = list(map(int, input().split())) lst.append(sum(lst)) mat.append(lst) sum_lst = [] for i in range(len(mat[0])): s = 0 for j in range(n): s += mat[j][i] sum_lst.append(s) mat.append...
vfc_74113
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0", "output": "52 96 15 20 183\n 86 22 35 45 188\n 45 78 54 36 213\n 16 86 74 55 ...
code_contests
verifiable_code
p00235 Sergeant Rian
Solve the following coding problem using the programming language python: Under the command "Save Sergeant Ryan," Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio...
```python while 1: N = int(input()) if N == 0:break R = [[0 for i in range(N+1)] for i in range(N+1)] def dfs_max(cur, pre): _max = -R[cur][pre] for i in range(N+1): if R[cur][i] > 0 and i != pre: _max = max(_max, dfs_max(i, cur) + R[cur][i]) # print('...
vfc_74117
{ "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": "7\n1 2 5\n2 3 2\n3 4 3\n2 5 3\n5 6 3\n5 7 8\n0", "output": "12", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 2 5\n2 3 2\n3 4 3\n2 5 3\n5 6 5\n5 7 8\n0", "output": "12\n", ...
code_contests
verifiable_code
p00612 Hedro's Hexahedron
Solve the following coding problem using the programming language python: Dr. Hedro is astonished. According to his theory, we can make sludge that can dissolve almost everything on the earth. Now he's trying to produce the sludge to verify his theory. The sludge is produced in a rectangular solid shaped tank whose s...
```python while 1: n=int(input()) if n==0:break a=0;i=1;b=n//2 while i*i<b:a+=((b-1)//i+1)-i-1;i+=1 a=(a+b-1)*2+i print(8*(a+n)) ```
vfc_74125
{ "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\n4\n0", "output": "24\n64", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n8\n0", "output": "24\n160\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
p00750 The Most Powerful Spell
Solve the following coding problem using the programming language python: Long long ago, there lived a wizard who invented a lot of "magical patterns." In a room where one of his magical patterns is drawn on the floor, anyone can use magic by casting magic spells! The set of spells usable in the room depends on the dr...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_74129
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0", "output": "abracadabra\nNO\nopqr\nNO", ...
code_contests
verifiable_code
p00888 The Two Men of the Japanese Alps
Solve the following coding problem using the programming language python: Two experienced climbers are planning a first-ever attempt: they start at two points of the equal altitudes on a mountain range, move back and forth on a single route keeping their altitudes equal, and finally meet with each other at a point on ...
```python from heapq import heappush, heappop import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) if N == 0: return False P = [tuple(map(int, readline().split())) for i in range(N)] YS = set(y for x, y in P) Q = P[:] for i in range(N-1): ...
vfc_74133
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n0 0\n3 4\n9 12\n17 6\n21 9\n33 0\n5\n0 0\n10 0\n20 0\n30 0\n40 0\n10\n0 0\n1 2\n3 0\n6 3\n9 0\n11 2\n13 0\n15 2\n16 2\n18 0\n7\n0 0\n150 997\n300 1\n450 999\n600 2\n750 998\n900 0\n0", "output": "52.5\n40.0\n30.33562093046...
code_contests
verifiable_code
p01019 Cheat Case
Solve the following coding problem using the programming language python: Hint * One grid may be filled more than once * Even if it can be represented by one line segment such as '1', it may be represented by two or more line segments. Sample Input 1 Formula for Sample Input 1. Sample Input 2 Sample Input 2 formu...
```python dic = {((0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)):"0", ((0, 0), (0, 1), (0, 2), (0, 3), (0, 4)):"1", ((0, 0), (0, 2), (0, 3), (0, 4), (1, 0), (1, 2), (1, 4), (2, 0), (2, 1), (2, 2), (2, 4)):"2", ((0, ...
vfc_74137
{ "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": "4\n1 1 1 5\n3 3 5 3\n4 2 4 4\n7 1 7 5", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "23\n1 1 3 1\n3 1 3 3\n3 3 1 3\n1 3 1 5\n1 5 3 5\n5 2 7 2\n7 2 7 4\n7 4 5 4\n5 4 5 6\n5 6 ...
code_contests
verifiable_code
p01152 Reading a Chord
Solve the following coding problem using the programming language python: In this problem, you are required to write a program that enumerates all chord names for given tones. We suppose an ordinary scale that consists of the following 12 tones: C, C# , D, D# , E, F, F# , G, G# , A, A# , B Two adjacent tones are di...
vfc_74141
{ "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\n3 C E G\n3 C E G#\n4 C A G E\n5 F A C E D\n3 C D E", "output": "C Em(+5)\nC(+5) E(+5) G#(+5)\nC(13) Am7 Am(+13)\nDm7(9) FM7(13)\nUNKNOWN", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\...