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
763_B. Timofey and rectangles
Solve the following coding problem using the programming language python: One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they...
```python n = int(input()) coordinates = [] for i in range(n): coordinates.append([int(x) % 2 for x in input().split()]) print('YES') for coordinate in coordinates: x1, y1, x2, y2 = coordinate print(2*x2 + y2 + 1) ```
vfc_38589
{ "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\n0 0 5 3\n2 -1 5 0\n-3 -4 2 -1\n-1 -1 2 0\n-3 0 0 5\n5 2 10 3\n7 -3 10 2\n4 -2 7 -1\n", "output": "YES\n1\n2\n3\n4\n3\n3\n4\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "25\n0 0 7 7...
code_contests
verifiable_code
808_C. Tea Party
Solve the following coding problem using the programming language python: Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes a1, a2, ..., an. His teapot stores w milliliters of tea (w ≤ a1 + a2 + ... + an). Polycarp wants to pour tea i...
```python import math import re n, w = map(int, input().split()) a = list(map(int, input().split())) a1 = [math.ceil(el/2) for el in a] s = w - sum(a1) if s < 0: print(-1) elif s == 0: print(' '.join(map(str, a1))) else: for i in range(n): if a[i] == 1: a1[i] = 0 a[i] = 0...
vfc_38597
{ "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 10\n8 7\n", "output": "6 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10\n9 8 10\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
832_D. Misha, Grisha and Underground
Solve the following coding problem using the programming language python: Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other. The boys decide...
```python import os import sys from io import BytesIO, IOBase from types import GeneratorType from collections import defaultdict BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mo...
vfc_38601
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 1\n1 2 3\n2 3 3\n", "output": "2\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n1 2 3\n1 2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
853_B. Jury Meeting
Solve the following coding problem using the programming language python: Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutive...
```python from bisect import * from sys import * n,m,k=[int(i) for i in input().split()] pln=[] if m==0: print(-1) exit(0) for i in range(m): pln.append([int(i) for i in input().split()]) pln.sort() grp=[[pln[0]]];gt=0; for i in range(1,m): if pln[i][0]!=pln[i-1][0]: gt=gt+1 grp.append(...
vfc_38605
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4 5\n1 2 0 5000\n2 1 0 4500\n2 1 0 3000\n8 0 1 6000\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 6 5\n1 1 0 5000\n3 2 0 5500\n2 2 0 6000\n15 0 2 9000\n9 0 1 7000\n8 ...
code_contests
verifiable_code
877_F. Ann and Books
Solve the following coding problem using the programming language python: In Ann's favorite book shop are as many as n books on math and economics. Books are numbered from 1 to n. Each of them contains non-negative number of problems. Today there is a sale: any subsegment of a segment from l to r can be bought at a f...
```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" no...
vfc_38609
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n1 1 1 2\n1 1 1 1\n4\n1 2\n1 3\n1 4\n3 4\n", "output": "2\n3\n4\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 0\n1 2 1 2\n0 0 0 0\n1\n1 4\n", "output": "10\n", "type...
code_contests
verifiable_code
901_B. GCD of Polynomials
Solve the following coding problem using the programming language python: Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <imag...
```python """ NTC here """ import sys inp= sys.stdin.readline input = lambda : inp().strip() flush= sys.stdout.flush # import threading # sys.setrecursionlimit(10**6) # threading.stack_size(2**25) def iin(): return int(input()) def lin(): return list(map(int, input().split())) # range = xrange # input = raw_input d...
vfc_38613
{ "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": "1\n", "output": "1\n0 1\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "2\n1 0 1\n1\n0 1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
923_E. Perpetual Subtraction
Solve the following coding problem using the programming language python: There is a number x initially written on a blackboard. You repeat the following action a fixed amount of times: 1. take the number x currently written on a blackboard and erase it 2. select an integer uniformly at random from the range [0...
vfc_38617
{ "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": "9 350\n3 31 314 3141 31415 314159 3141592 31415926 314159265 649178508\n", "output": "822986014 12998613 84959018 728107923 939229297 935516344 27254497 413831286 583600448 442738326 ", "type": "stdin_stdout" } ] ...
code_contests
verifiable_code
952_A. Quirky Quantifiers
Solve the following coding problem using the programming language python: Input The input contains a single integer a (10 ≤ a ≤ 999). Output Output 0 or 1. Examples Input 13 Output 1 Input 927 Output 1 Input 48 Output 0 The input will be given via stdin and the output should be printed to stdou...
```python b=int(input()) if b%2==0: print(0) else: print(1) ```
vfc_38621
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "13\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
979_C. Kuro and Walking Route
Solve the following coding problem using the programming language python: Kuro is living in a country called Uberland, consisting of n towns, numbered from 1 to n, and n - 1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns a and b. Kuro loves wa...
```python def calculate_max_paths(edges, node, dest, par, cnt): ans = 1 for child in edges.get(node, []): if child != par: ans += calculate_max_paths(edges, child, dest, node, cnt) if dest == node: cnt[0] = ans return ans def main(): from collections import defaul...
vfc_38625
{ "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 1 3\n1 2\n2 3\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 3\n1 2\n1 3\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
999_D. Equalize the Remainders
Solve the following coding problem using the programming language python: You are given an array consisting of n integers a_1, a_2, ..., a_n, and a positive integer m. It is guaranteed that m is a divisor of n. In a single move, you can choose any position i between 1 and n and increase a_i by 1. Let's calculate c_r...
```python from collections import deque import sys input = sys.stdin.readline n, m = map(int, input().split()) a = list(map(int, input().split())) cnt = [0] * m x = [[] for _ in range(m)] for i in range(n): ai = a[i] % m cnt[ai] += 1 x[ai].append(i) l = n // m q = deque() for i in range(m): if cnt[i] <...
vfc_38629
{ "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\n0 1 2 3\n", "output": "0\n0 1 2 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 3\n3 2 0 6 10 12\n", "output": "3\n3 2 0 7 10 14 ", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
benny-and-interesting-numbers
Solve the following coding problem using the programming language python: Benny noticed a random property of numbers. The numbers which followed this property were called as interesting numbers by Benny. Let's dive into what Benny discovered about these numbers. 1 is an interesting number. For every N > 1 , N is int...
```python def rwh_primes(n): sieve = [True] * n for i in range(3,int(n**0.5)+1,2): if sieve[i]: sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1) return [2] + [i for i in range(3,n,2) if sieve[i]] def test(a, primes): for p in primes: n = 0 while (a % p) == 0: n += 1 a ...
vfc_38633
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n2\n3\n4\n5\n\nSAMPLE", "output": "Yes\nYes\nYes\nNo\nYes", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n177516\n548318\n947070\n996389\n442876\n581113\n232970\n244787\n709020\n23...
code_contests
verifiable_code
come-to-me
Solve the following coding problem using the programming language python: Some terrorist attacks on Indian border. Now Indian Army have to send his soldiers to fight against terrorist. There are total N soldiers in the camp. Every soldier has a skill denoted by a single character lies between A-Z (all skills are in CA...
```python def unique(s): i, j = 0, 0 I, J = 0, 0 H = set([]) while j < len(s): if s[j] in H: H.remove(s[i]) i += 1 else: H.add(s[j]) j += 1 if J - I < j - i: I, J = i, j return s[I:J] def main(): for i in xrange(inp...
vfc_38637
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nABDEFGABEF\nGHJKLMNOPQ\n\nSAMPLE", "output": "6\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nIORFHKKYVKYICQDUXHRGKBNUTQARXVAVJZYMVSVJQKKBPGXPTBPFHVHKBIGGXQWHEIZLIVOIVCBXWRLQHU...
code_contests
verifiable_code
fibofibo-3
Solve the following coding problem using the programming language python: Pseudo-code to find the nth fibonacci number : int fibo(int n) { if (n == 0) { write(0) return 0 } if (n == 1) { write(1) return 1 } return fibo(n - 1) + fibo(n - 2) } If we call fibo(3), the following happens: fibo(3) calls fi...
```python t = int(raw_input()) n0 = [None] * 42 n1 = [None] * 42 n0[0], n0[1] = 1, 0 n1[0], n1[1] = 0, 1 for i in range(2, 41): n0[i] = n0[i - 1] + n0[i - 2] n1[i] = n1[i - 1] + n1[i - 2] for _ in range(t): n = int(raw_input()) print n0[n], n1[n] ```
vfc_38641
{ "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\n2\n\nSAMPLE", "output": "0 1\n1 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n2\n\nELPMAS", "output": "0 1\n1 1\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
icl-3-bacteria-population
Solve the following coding problem using the programming language python: A bacteria lifespan is represented as follows:- 0th year- born 1st year- Does not reproduce only grows 2nd year- Gives birth to another Bacteria 3rd year- Gives birth to another Bacteria and then Dies Initially in 0th year there is only 1 b...
```python ip = int(raw_input()) c = 0 first = 1 second = 1 third = 2 forth = 2 if(ip == 0): print 1 if(ip == 1): print 1 if(ip == 2): print 2 if(ip == 3): print 2 c = 3 while c <=ip : forth = second + first first = second second = third third = forth #forth = c = c + 1 print forth ```
vfc_38645
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "40", "output": "73396\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "66", "output": "109870576\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9...
code_contests
verifiable_code
margana-is-an-anagram
Solve the following coding problem using the programming language python: Each army fighting the world war Z is denoted with a word consisting any combination of 26 alphabets. An army is a match for his/her opponent if and only if his name is an anagram of his/her opponent. Your job as a programmer is to help find whe...
```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!' t1=input() while t1>0: t1-=1 s,t=raw_input().split() s=sorted(s) t=sorted(t) if s==t: print "Yes" else: print "No" ```
vfc_38649
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nlisten silent\nmancap pacmaan\n\nSAMPLE", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nman app\na b\nabcde edcba", "output": "No\nNo\nYes\n", "type"...
code_contests
verifiable_code
number-mania
Solve the following coding problem using the programming language python: Tod is very much focus about his English subject but now he is in trouble because he have to do his Math homework but also have to go for English classes so he asks you for help to solve his Math homework question. You are given a Natural numb...
```python import math def fact(n): t=n prod =1 while(t!=1): prod*=t t-=1 print prod n = input() for num in range(2,n+1): if(all(num%i!=0 for i in range(2, int(math.sqrt(num)+1)))): fact(num) ```
vfc_38653
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n\nSAMPLE", "output": "2\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n\nSALPLE", "output": "2\n6\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
question-3-21
Solve the following coding problem using the programming language python: Hardy wants to test Ramanujam of his Mathematical skills. So he gives him a puzzle which is described below. Puzzle: There are 100 doors, numbered 1,2,....100 .Initially all doors are closed. Now a person comes(lets call him the 1st person)he o...
```python def get_primes(start, stop): dct = {x: True for x in list(range(start, stop+1))} x = start while x ** 2 <= stop: if dct[x]: y = x ** 2 while y <= stop: dct[y] = False y += x x += 1 lst = [] for x, y in dct.items(): ...
vfc_38657
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n2\n3\n\nSAMPLE", "output": "1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n2\n3\n\nSAMPLE", "output": "1\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
shil-and-special-pairs
Solve the following coding problem using the programming language python: Shil has a permutation p1 , p2 .. pN of numbers from 1 to N and M queries. Each query consists of two integers l and r . Answer to each query is total number of pairs[i , j] such that l ≤ i ≤ j ≤ r and|pi - pj| ≤ D. INPUT: First line consists...
```python (n, m, d) = [int(v) for v in raw_input().strip().split(' ')] arr = [int(v) for v in raw_input().strip().split(' ')] pos = [0] * (n + 1) q = [] for i in range(0, len(arr)): pos[arr[i]] = i for i in range(0, m): (l, r) = [int(v) for v in raw_input().strip().split(' ')] q.append(((l, r), i)) q = so...
vfc_38661
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5 1\n1 4 2 3 5\n1 3\n2 4\n1 5\n2 2\n4 5\n\nSAMPLE", "output": "4\n5\n9\n1\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10 10\n2 4 3 8 10 5 6 9 7 1 \n2 8\n3 6\n8 10\n2 10\n1 5\n5 8...
code_contests
verifiable_code
the-magician-17
Solve the following coding problem using the programming language python: Robert Angier is divising a new magic trick to beat his rival Alfred Borden. He is going to perform a card trick. In this trick, cards are numbered from 1 to N. This trick involves the following process. Angier will invite a person from audience...
```python import math n = int(raw_input()) for ii in range(n): N,K = map(int,raw_input().split()) if N % 2 == 0 and K <= N/2: print K*2-1 elif N % 2 == 1 and K <= N/2+1: print K*2-1 elif N-K == 0: pp = int(math.log(N)/math.log(2) - 1e-5) print int(2*(N-math.pow(2,pp))) else: ff = (3+2*(N-K-1)) pp ...
vfc_38665
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n6 6\n\nSAMPLE", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n12139932 8204607\n17895021 4804015\n10313563 2949333\n18903682 12991388\n12277685 7851062\n16564285 11912...
code_contests
verifiable_code
p00088 The Code A Doctor Loved
Solve the following coding problem using the programming language python: Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10...
```python # Aizu Problem 0088: The Code A Doctor Loved # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def bin5(k): b = bin(k)[2:] while len(b) < 5: b = '0' + b return b CODE1 = {' ': '101', "'": '000000', ","...
vfc_38713
{ "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": "PETER POTTER", "output": "?D-C'KOPUA", "type": "stdin_stdout" }, { "fn_name": null, "input": "PETER POTTRE", "output": "?D-C'KOPDA\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
p00220 Binary Digit A Doctor Loved
Solve the following coding problem using the programming language python: "What are your shoe sizes?" Suddenly, the doctor asked me when I met him for the first time. "It's 23.5" "Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1s...
```python def ans(N): # N:foat n=int(N) d=N-n ans_l=bin(n)[2:] ans_r='' for _ in range(4): ans_r+=str(int(d*2)) d=d*2-int(d*2) if n>=256 or d!=0: return 'NA' else: return '0'*(8-len(ans_l))+ans_l+'.'+ans_r while True: INP=float(input()) if INP<0: brea...
vfc_38717
{ "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": "23.5\n158.1\n-1.0", "output": "00010111.1000\nNA", "type": "stdin_stdout" }, { "fn_name": null, "input": "23.72975180461117\n158.1\n-1.0", "output": "NA\nNA\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
p00598 Operations with Finite Sets
Solve the following coding problem using the programming language python: Let A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions). u - union of two sets, AuB = {x ∈ U : x ∈ A or x ∈ B} is the set of all eleme...
```python import sys def rpn(str): r = [] stack = [] for i in range(0, len(str)): c = str[i] if c in "idsu": while len(stack) > 0: if stack[-1] in "idsuc": a = stack.pop() r.extend(a) else: ...
vfc_38725
{ "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": "A 3\n1 3 -1\nB 4\n3 1 5 7\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 10 8 3\nB 3\n2 4 8\nR 0\n(As(AiB))uC", "output": "7\n1 2 3 10", "type": "stdin_stdout" }, { "fn_name": null, "input": "A 3\n1 3 -1\n...
code_contests
verifiable_code
p00734 Equal Total Scores
Solve the following coding problem using the programming language python: Taro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other's hand. Which of the ca...
```python while True: n,m = map(int,input().split()) if n == 0: exit() t = [] h = [] ans = [] for i in range(n): t.append(int(input())) for i in range(m): h.append(int(input())) for i in range(n): for j in range(m): if (sum(t) - t[i] + h[j]) ==...
vfc_38729
{ "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 2\n1\n5\n3\n7\n6 5\n3\n9\n5\n2\n3\n3\n12\n2\n7\n3\n5\n4 5\n10\n0\n3\n8\n1\n9\n6\n0\n6\n7 4\n1\n1\n2\n1\n2\n1\n4\n2\n3\n4\n3\n2 3\n1\n1\n2\n2\n2\n0 0", "output": "1 3\n3 5\n-1\n2 2\n-1", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p00874 Cubist Artwork
Solve the following coding problem using the programming language python: International Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwo...
```python while True: w,d = map(int,input().split()) if w == 0 and d == 0: break h = list(map(int,input().split())) m = list(map(int,input().split())) hl = [0] * 30 ml = [0] * 30 for i in h: hl[i] += 1 for i in m: ml[i] += 1 ans = 0 for i in range(30...
vfc_38733
{ "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 5\n1 2 3 4 5\n1 2 3 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20...
code_contests
verifiable_code
p01005 The Humans Braving the Invaders
Solve the following coding problem using the programming language python: Problem Today, the Earth has been attacked by the invaders from space, Invader, and the only survivors of humankind are us at the base. There is almost no force left to compete with them. But here we do not give up. Eradication of Invaders is t...
vfc_38737
{ "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 10\n0\n4 1\n1 1\n4 1\n0\n1 1\n0\n2 2\n1 10\n0\n1 1\n0\n1 1\n0\n1 5\n3 4 0\n3 4 1\n0\n9 10\n4 1\n2 2\n3 5 5\n0\n4 1\n2 2\n3 5 5\n0\n2 1\n0 0", "output": "distance 10\ndistance 9\nhit\ndamage 2\nbomb 1\nbomb 2\nend\ndistance...
code_contests
verifiable_code
p01137 Space Coconut Grab
Solve the following coding problem using the programming language python: Space Coconut Crab Space coconut crab English text is not available in this practice contest. Ken Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space coconut crab is the largest crus...
```python import math def solve(e): k = 2 ** 32 for z in range(100, -1, -1): z3 = z * z * z if z3 > e: continue e2 = e - z3 ylm = int(math.sqrt(e2)) xzlm = 3 * z * z + 3 * z + 1 for y in range(ylm, -1, -1): y2 = y * y if e2 ...
vfc_38741
{ "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": "1\n2\n4\n27\n300\n1250\n0", "output": "1\n2\n2\n3\n18\n44", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01276 Double Sorting
Solve the following coding problem using the programming language python: Here we describe a typical problem. There are n balls and n boxes. Each ball is labeled by a unique number from 1 to n. Initially each box contains one of these balls. We can swap two balls in adjacent boxes. We are to sort these balls in increa...
vfc_38745
{ "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\n5 5\n4 4\n3 3\n2 2\n1 1\n5\n1 5\n3 4\n2 5\n2 3\n1 4\n8\n8 3\n4 2\n6 4\n3 5\n5 8\n7 1\n2 6\n1 7\n0", "output": "15\n9\n21", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 5\n4 4\n3 3\n...
code_contests
verifiable_code
p01595 Laser Puzzle
Solve the following coding problem using the programming language python: Problem E: Laser Puzzle An explorer John is now at a crisis! He is entrapped in a W times H rectangular room with a embrasure of laser beam. The embrasure is shooting a deadly dangerous laser beam so that he cannot cross or touch the laser beam...
vfc_38753
{ "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": "8 3\nL####\nS.../@.#\nD#", "output": "Yes", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01892 SNS
Solve the following coding problem using the programming language python: Problem statement AOR Ika-chan is in a bad mood lately. Apparently, I don't like the ratio of the number of followers to the number of followers of "Ikatta". Currently, AOR Ika-chan has $ A $ followers, $ B $ followers, and a ratio of $ A: B $....
```python a, b, n = map(int, input().split()) score = abs(a - b) for x in range(1, n + 1): for y in range(1, n + 1): if b * x % y == 0: new_a = b * x // y score = min(score, abs(a - new_a)) print(score) ```
vfc_38761
{ "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": "19 30 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "19 28 3", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "19 51...
code_contests
verifiable_code
p02029 Chisaki and Picnic
Solve the following coding problem using the programming language python: O: Chisaki and Picnic Chisaki, a kindergarten student, decided to bring sweets for the excursion. There are $ N $ of sweets, and the $ i $ th sweet is priced at $ A_i $ yen and tastes $ B_i $. Chisaki has $ M $ friends, and the $ j $ th frien...
vfc_38765
{ "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 1\n10 1\n20 2\n30 3\n20 2", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n10 2\n20 2\n30 3\n20 2", "output": "5\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
ai04
Solve the following coding problem using the programming language python: It's not the rivers that you might be thinking about. The question revolves around the concept of digital rivers. A digital river is a sequence of numbers where the number following n is n plus the sum of its digits. FOR EXAMPLE 12345 is follo...
```python #Merging Rivers #Testing space after all cases even final case def main(): N = int(raw_input()) counter = 1 while(N != 0): last_digit = N%10 while(last_digit != 1 and last_digit != 3 and last_digit != 9): N+=sum([int(i) for i...
vfc_38781
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "86\n 12345\n 0", "output": "Case #1\n first meets river 1 at 101\n \n Case #2\n first meets river 3 at 12423", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
chefstlt
Solve the following coding problem using the programming language python: Chef has found two very old sheets of paper, each of which originally contained a string of lowercase Latin letters. The strings on both the sheets have equal lengths. However, since the sheets are very old, some letters have become unreadable. ...
```python def main(): t = input() for x in range(0, t): s1 = raw_input() s2 = raw_input() count1 = 0 count2 = 0 for i in range(0, len(s1)): if s1[i]!=s2[i] and (s1[i]!= '?' and s2[i]!= '?'): count1 +=1 if s1[i]!=s2[i] or s1[i]==...
vfc_38785
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\na?c\n??b\n???a\n???a\n?abac\naba?w", "output": "1 3\n0 3\n3 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\na?c\n??b\n???a\n@??a\n?abac\naba?w", "output": "1 3\n0 3\n3 5\n", ...
code_contests
verifiable_code
dream
Solve the following coding problem using the programming language python: The Chef is sleeping now. He tries to cook new kind of meals in his dream. These meals are arranged in a row and numbered from 1 to N consecutively. For each meal i (1<=i<=N) there is given one integer f(i) which denotes the time needed to co...
```python n, k = map(int, raw_input().split()) times = map(int, raw_input().split()) times = sorted(zip(times, xrange(len(times))), key=lambda x: x[0]) cnt, i = 0, 0 while(i < n): j = i+1 while(j < n and times[i][0] == times[j][0] and times[j][1] - times[i][1] < k): j += 1 cnt += 1 i = j print cnt ```
vfc_38789
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n40 30 40 30 40", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
johny
Solve the following coding problem using the programming language python: Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants! Vlad built up h...
```python t=int(raw_input()) def fun(pivot, n,rn): sm=0 for j in range(rn): if n[j]<pivot: sm+=1 sm+=1 print sm for i in range(t): rn=int(raw_input()) n=map(int, raw_input().split()) k=int(raw_input()) pivot=n[k-1] fun(pivot,n,rn) ```
vfc_38793
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n1", "output": "3\n4\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n2", "output...
code_contests
verifiable_code
numfact
Solve the following coding problem using the programming language python: Alice has learnt factorization recently. Bob doesn't think she has learnt it properly and hence he has decided to quiz her. Bob gives Alice a very large number and asks her to find out the number of factors of that number. To make it a little ea...
```python def primes(n): primfac = [] d = 2 while d*d <= n: while (n % d) == 0: primfac.append(d) n /= d d += 1 if n > 1: primfac.append(n) return primfac def hist(s): d = dict() for i in s: if i in d: d[i] += 1 else:...
vfc_38797
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n3 5 7\n3\n2 4 6\n2\n5 5", "output": "8\n10\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3\n3 5 7\n3\n2 4 3\n2\n5 5", "output": "8\n8\n3\n", "type": "stdin_stdout...
code_contests
verifiable_code
skyscr
Solve the following coding problem using the programming language python: Chef had constructed 2 buildings - one of height N and another of height M. He was unhappy, and wanted both buildings to be of the same height. In one move, he could either add a floor to a building, or remove a floor from a building. Help him f...
```python t = int(raw_input()) while(t): s = map(int, raw_input().strip().split(" ")) print abs(s[0]-s[1]) t -= 1 ```
vfc_38801
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 3", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 1", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 ...
code_contests
verifiable_code
1004_D. Sonya and Matrix
Solve the following coding problem using the programming language python: Since Sonya has just learned the basics of matrices, she decided to play with them a little bit. Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhat...
```python def get(n,m,a,b,t): freq=[0]*(t+1) for i in range(n): for j in range(m): val=abs(i-a)+abs(j-b) freq[val]+=1 return freq t=int(input()) a=list(map(int,input().split())) mx=max(a) f=[0]*(t+1) for i in a: f[i]+=1 b=1 for i in range(1,mx+1): if f[i]!=4*i: ...
vfc_38805
{ "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": "20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n", "output": "4 5\n2 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1028_D. Order book
Solve the following coding problem using the programming language python: Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price. At every mome...
```python from sys import stdin import heapq MOD = pow(10, 9) + 7 n=int(stdin.readline()) a=[] for i in range(n): x=stdin.readline().split() if x[0]=='ADD': a.append((0,int(x[1]))) else: a.append((1,int(x[1]))) next_accept=[-1]*n accept = -1 for i in range(n-1, -1, -1): if a[i][0]== 1: ...
vfc_38809
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nADD 1\nACCEPT 1\nADD 2\nACCEPT 2\nADD 3\nACCEPT 3\n", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nADD 1\nADD 2\nADD 3\nACCEPT 2\n", "output": "2", "type": ...
code_contests
verifiable_code
1046_J. Self-exploration
Solve the following coding problem using the programming language python: Being bored of exploring the Moon over and over again Wall-B decided to explore something he is made of — binary numbers. He took a binary number and decided to count how many times different substrings of length two appeared. He stored those va...
vfc_38813
{ "difficulty": "16", "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\n10001\n1\n2\n3\n4\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1092_D2. Great Vova Wall (Version 2)
Solve the following coding problem using the programming language python: Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The current state of the wall can be respresent...
```python n=int(input()) a=list(map(int,input().split())) down=[] good=True for guy in a: if len(down)==0: down.append(guy) elif down[-1]>guy: down.append(guy) elif down[-1]==guy: down.pop() else: good=False break if not good: print("NO") elif len(down)>1: ...
vfc_38821
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 10\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4 5 3\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1111_C. Creative Snap
Solve the following coding problem using the programming language python: Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position...
```python def solve (l,r,y) : if (len(y) == 0) : return a if (l == r) : return b*len(y) c = [] d = [] m = (l+r)//2 for i in y : if i <= m : c += [i] else : d += [i] return min(b*(r-l+1)*len(y) , solve(l,m,c) + solve(m+1,r,d)) n,k,a...
vfc_38825
{ "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 2 1 2\n1 7\n", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 1 2\n1 3\n", "output": "6", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1141_A. Game 23
Solve the following coding problem using the programming language python: Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves. Print the number of moves needed to transform n to m. Print ...
```python def fun(a,b): if a % b != 0: return -1 temp = 0 m = a/b while m % 2 == 0: m = m / 2 temp += 1 while m % 3 == 0: m = m/3 temp += 1 if m == 1: return temp else : return -1 a,b = map(int,input().split()) print(fun(b,a)) ```
vfc_38829
{ "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": "42 42\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1159_F. Winding polygonal line
Solve the following coding problem using the programming language python: Vasya has n different points A_1, A_2, … A_n on the plane. No three of them lie on the same line He wants to place them in some order A_{p_1}, A_{p_2}, …, A_{p_n}, where p_1, p_2, …, p_n — some permutation of integers from 1 to n. After doing s...
vfc_38833
{ "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\n1 1\n3 1\n1 3\nL\n", "output": "1 2 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 0\n0 1\n0 2\n-1 0\n-1 -1\n2 1\nRLLR\n", "output": "5 4 1 6 2 3 \n", "type": "stdi...
code_contests
verifiable_code
1181_E2. A Story of One Country (Hard)
Solve the following coding problem using the programming language python: This problem differs from the previous problem only in constraints. Petya decided to visit Byteland during the summer holidays. It turned out that the history of this country is quite unusual. Initially, there were n different countries on the...
vfc_38837
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0 1 2\n0 2 1 3\n1 0 2 1\n1 1 2 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 0 2 1\n1 2 3 3\n2 0 3 2\n0 1 1 3\n", "output": "NO\n", "type": "st...
code_contests
verifiable_code
1260_A. Heating
Solve the following coding problem using the programming language python: Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house. Your house has n rooms. In the i-th room you can install a...
```python n=int(input()) for i in range(n): x = list(map(int, input().split(" "))) print(((x[1]%x[0])*((x[1]//x[0]+1)**2))+(((x[1]//x[0])**2)*(x[0]-(x[1]%x[0])))) ```
vfc_38853
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 10000\n10000 1\n2 6\n4 6\n", "output": "100000000\n1\n18\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "69\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n...
code_contests
verifiable_code
1282_B1. K for the Price of One (Easy Version)
Solve the following coding problem using the programming language python: This is the easy version of this problem. The only difference is the constraint on k — the number of gifts in the offer. In this version: k=2. Vasya came to the store to buy goods for his friends for the New Year. It turned out that he was very...
```python """ Author : thekushalghosh Team : CodeDiggers """ import sys,math input = sys.stdin.readline ############ ---- USER DEFINED INPUT FUNCTIONS ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(s[:len(s) ...
vfc_38857
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5 6 2\n2 4 3 5 7\n5 11 2\n2 4 3 5 7\n2 10000 2\n10000 10000\n2 9999 2\n10000 10000\n5 13 2\n8 2 8 2 5\n3 18 2\n1 2 3\n", "output": "3\n4\n2\n0\n4\n3\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1326_B. Maximums
Solve the following coding problem using the programming language python: Alicia has an array, a_1, a_2, …, a_n, of non-negative integers. For each 1 ≤ i ≤ n, she has found a non-negative integer x_i = max(0, a_1, …, a_{i-1}). Note that for i=1, x_i = 0. For example, if Alicia had the array a = \{0, 1, 2, 0, 3\}, the...
```python input() b = list(map(int,input().split())) a = list() sumnum = 0 negnum = 0 for i in range(len(b)): sumnum += b[i] a.append(sumnum+abs(negnum)) if b[i]<0: negnum += b[i] print(*a) ```
vfc_38865
{ "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\n1000 999999000 -1000000000\n", "output": "1000 1000000000 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 1 2 2 3\n", "output": "2 3 5 7 10\n", "type": "stdin_stdout"...
code_contests
verifiable_code
1345_A. Puzzle Pieces
Solve the following coding problem using the programming language python: You are given a special jigsaw puzzle consisting of n⋅ m identical pieces. Every piece has three tabs and one blank, as pictured below. <image> The jigsaw puzzle is considered solved if the following conditions hold: 1. The pieces are arran...
```python import sys import math import bisect from sys import stdin, stdout from math import gcd, floor, sqrt, log2, ceil from collections import defaultdict from bisect import bisect_left as bl, bisect_right as br from collections import Counter from collections import deque ip = lambda : int(stdin.readline()) inp ...
vfc_38869
{ "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\n1 3\n100000 100000\n2 2\n", "output": "YES\nNO\nYES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1366_G. Construct the String
Solve the following coding problem using the programming language python: Let's denote the function f(s) that takes a string s consisting of lowercase Latin letters and dots, and returns a string consisting of lowercase Latin letters as follows: 1. let r be an empty string; 2. process the characters of s from le...
vfc_38873
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a.ba.b.\nabb\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": ".bbac..a.c.cd\nbacd\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1387_C. Viruses
Solve the following coding problem using the programming language python: The Committee for Research on Binary Viruses discovered a method of replication for a large family of viruses whose genetic codes are sequences of zeros and ones. Each virus originates from a single gene; for simplicity genes are denoted by inte...
vfc_38877
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 750000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 6 2\n2 2 0 1\n3 3 2 0 0\n3 2 1 3\n4 4 0 3 1 2\n5 2 2 1\n5 1 5\n2 1 1\n5 0 0 1 0 0\n", "output": "NO 2\nNO 4\nNO 9\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 24 6\n2 4 1 0 1 1...
code_contests
verifiable_code
1408_G. Clusterization Counting
Solve the following coding problem using the programming language python: There are n computers in the company network. They are numbered from 1 to n. For each pair of two computers 1 ≤ i < j ≤ n you know the value a_{i,j}: the difficulty of sending data between computers i and j. All values a_{i,j} for i<j are diffe...
```python # import itertools as it # import functools as ft import math teststring = """4 0 3 4 6 3 0 2 1 4 2 0 5 6 1 5 0 """ online = __file__ != "/home/jhli/py/Grakn/Problem_G2.py" true, false = True, False if True: def spitout(): for c in teststring.splitlines(): yield c _ito = spito...
vfc_38881
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n0 1 18 15 19 12 21\n1 0 16 13 17 20 14\n18 16 0 2 7 10 9\n15 13 2 0 6 8 11\n19 17 7 6 0 4 5\n12 20 10 8 4 0 3\n21 14 9 11 5 3 0\n", "output": "1 1 2 3 4 3 1 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
142_A. Help Farmer
Solve the following coding problem using the programming language python: Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As ...
```python import math n = int(input()) mx = 0 mn = 4 * 10**18 for A in range(1, n+1): if A * A * A > n: break if n % A: continue nn = n // A for B in range(1, nn+1): if B * B > nn: break if nn % B: continue C = nn // B mn = min(mn, (A + 1) * (B + 2) * (C + 2) - n) mx = max(mx, (A + 1) * (B +...
vfc_38885
{ "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": "12\n", "output": "48 105\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "28 41\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7...
code_contests
verifiable_code
1526_D. Kill Anton
Solve the following coding problem using the programming language python: After rejecting 10^{100} data structure problems, Errorgorn is very angry at Anton and decided to kill him. Anton's DNA can be represented as a string a which only contains the characters "ANTON" (there are only 4 distinct characters). Errorg...
```python from collections import defaultdict import itertools import sys input = sys.stdin.readline t = int(input()) p = list("ANOT") q = [0, 1, 2, 3] d = dict() for i in range(4): d[p[i]] = i for _ in range(t): a = list(input().rstrip()) n = len(a) cnt = [0] * 4 x = [[0] * 4 for _ in range(4)] ...
vfc_38901
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nANTON\nNAAN\nAAAAAA\nOAANTTON\n", "output": "\nNNOTA\nAANN\nAAAAAA\nTNNTAOOA\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
code_contests
verifiable_code
158_B. Taxi
Solve the following coding problem using the programming language python: After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get...
```python n=int(input()) a=list(map(int,input().split())) s=[0]*5 sum=0 for i in a: s[i]+=1 sum+=s[4]+s[3] if s[3]<s[1]: s[1]-=s[3] s[3]=0 else : s[3]=0 s[1]=0 sum+=s[2]//2 s[2]%=2 sum+=s[1]//4 s[1]%=4 end=s[2]*2+s[1] if end>4:sum+=2 elif end>0: sum+=1 print(int(sum)) ```
vfc_38905
{ "difficulty": "8", "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 2 4 3 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n2 3 4 4 2 1 3 1\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
178_C1. Smart Beaver and Resolving Collisions
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The Beaver is interested in this problem very much and he decided to ex...
vfc_38909
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 2 7\n+ 11 0\n+ 22 2\n+ 33 6\n+ 44 0\n+ 55 0\n- 22\n+ 66 0\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 6\n+ 123 0\n+ 234 1\n+ 345 2\n- 234\n+ 456 0\n+ 567 0\n", ...
code_contests
verifiable_code
1_C. Ancient Berland Circus
Solve the following coding problem using the programming language python: Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could va...
```python from math import * def g(x,y): if y<1e-3: return x else: return g(y,fmod(x,y)) p=[list(map(float,input().split())) for i in range(3)] a,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]] A,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(...
vfc_38913
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0.000000 0.000000\n1.000000 1.000000\n0.000000 1.000000\n", "output": "1.0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "76.820252 66.709341\n61.392328 82.684207\n44.267775 -2.378694\n",...
code_contests
verifiable_code
224_D. Two Strings
Solve the following coding problem using the programming language python: A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|). You've got two strings — s and t. Let's consider all subsequences of string s, coinci...
```python import bisect import string s = input() t = input() max_match = [0 for i in range(len(s))] min_match = [0 for i in range(len(s))] char_idx = [0 for i in range(30)] char_occur = [ [] for i in range(30) ] for (i, ch) in enumerate(t): idx = ord(ch) - ord('a') char_occur[idx].append(i) for ch in strin...
vfc_38917
{ "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": "abc\nba\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abacaba\naba\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
249_B. Sweets for Everyone!
Solve the following coding problem using the programming language python: For he knew every Who down in Whoville beneath, Was busy now, hanging a mistletoe wreath. "And they're hanging their stockings!" he snarled with a sneer, "Tomorrow is Christmas! It's practically here!" Dr. Suess, How The Grinch Stole Christmas ...
```python def check(n, casas): #print('n:',n) global T,N,street current = n time = T need = 0 last_house = 0 for ind, i in enumerate(street): time -= 1 if i == 'S': current += 1 elif i == 'H': need += 1 i...
vfc_38921
{ "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": "23 50\nHHSS.......SSHHHHHHHHHH\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "14 100\n...HHHSSS...SH\n", "output": "0\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
273_C. Dima and Horses
Solve the following coding problem using the programming language python: Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3. R...
vfc_38925
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n2 1\n", "output": "00\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2\n3 2\n3 1\n", "output": "100\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
296_E. Greg and Friends
Solve the following coding problem using the programming language python: One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river...
```python from collections import deque n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] c50 = sum([1 for i in a if i == 50]) c100 = sum([1 for i in a if i == 100]) c = [[0] * 51 for i in range(51)] c[0][0] = 1 c[1][0] = 1 c[1][1] = 1 for x in range(2, 51): for y in range(x + 1): ...
vfc_38929
{ "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 50\n50\n", "output": "1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 100\n50 50 100\n", "output": "5\n2", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
31_C. Schedule
Solve the following coding problem using the programming language python: At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are...
```python from operator import add import sys from array import array # noqa: F401 from typing import TypeVar, Generic, Callable, List T = TypeVar('T') class SegmentTree(Generic[T]): __slots__ = ["size", "tree", "identity", "op", "update_op"] def __init__(self, size: int, identity: T, op: Callable[[T, T], T...
vfc_38933
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 5\n2 6\n3 7\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n3 10\n20 30\n1 3\n1 39\n", "output": "1\n4 ", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
344_C. Rational Resistance
Solve the following coding problem using the programming language python: Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resi...
```python import sys import string import math import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache from fractions import Fraction def mi(s): return map(int, s.strip().split()) def lmi(s): return list(mi(s)) def tmi(s):...
vfc_38937
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "199 200\n", "output": "200\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
367_E. Sereja and Intervals
Solve the following coding problem using the programming language python: Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r] (1 ≤ l ≤ r ≤ m). Interval [l1, r1] belongs to interval [l2, r2] if the following condition is...
vfc_38941
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5 1\n", "output": "240", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 3...
code_contests
verifiable_code
411_C. Kicker
Solve the following coding problem using the programming language python: Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the go...
```python x = [tuple(int(i) for i in input().split()) for j in range(4)] if x[0][0] + x[1][1] > x[0][1] + x[1][0]: t1atk = x[1][1] t1def = x[0][0] else: t1atk = x[0][1] t1def = x[1][0] def f(): if t1atk > t2def and t1def > t2atk: return 0 elif t1atk < t2def and t1def < t2atk: r...
vfc_38949
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n2 2\n3 3\n2 2\n", "output": "Team 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
439_B. Devu, the Dumb Guy
Solve the following coding problem using the programming language python: Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him n subjects, the ith subject has ci chapters. When you teach him, you are supposed to teach all the chapters of a subject continuously. Let us say that his initia...
```python n, x = map(int, input().split()) m = list(map(int, input().split())) m.sort() ans = 0 for i in range(n): ans += m[i] * x if x > 1: x -= 1 print(ans) ```
vfc_38953
{ "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 3\n1 1 1\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n5 1 2 1\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
460_D. Little Victor and Set
Solve the following coding problem using the programming language python: Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairwise distinct. Today Victor wants to find a set of integers S that has the following properties: * for all x <image> the follow...
```python import random l, r, k = map(int, input().split(' ')) if k == 1: print(l) print(1) print(l) quit() if k == 2: if r == l+1: a = l b = l^r if a <= b: print(a) print(1) print(l) quit() else: print(b) ...
vfc_38957
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 30 7\n", "output": "0\n4\n8 9 10 11\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
484_C. Strange Sorting
Solve the following coding problem using the programming language python: How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... Let's have a look at another specific order: d-sorting. This sorting is applied to the strings of length at lea...
vfc_38961
{ "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": "qwerty\n3\n4 2\n6 3\n5 2\n", "output": "qertwy\nqtewry\nqetyrw\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
508_C. Anya and Ghosts
Solve the following coding problem using the programming language python: Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to ...
```python import sys ghosts, duration, candles = input().split() arrival = input().split() burn = [] for j in range(len(arrival)): time = int(arrival[len(arrival) - 1 - j]) candle = int(candles) if len(burn) != 0: for k in range(len(burn)): if burn[k] <= time: candle -= ...
vfc_38965
{ "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": "1 1 3\n10\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
530_I. Different variables
Solve the following coding problem using the programming language python: N variables X1, ..., XN can have positive integer values. You are given K constraints for these value that look like "the values of variables Xi1, Xi2, ..., XiM are different". Among all possible lists of values of these variables that satisfy t...
vfc_38969
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n2 1 2\n", "output": "1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n2 1 2\n2 2 3\n", "output": "1 2 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
583_B. Robot's Task
Solve the following coding problem using the programming language python: Robot Doc is located in the hall, with n computers stand in a line, numbered from left to right from 1 to n. Each computer contains exactly one piece of information, each of which Doc wants to get eventually. The computers are equipped with a se...
```python n = int(input()) a = [int(x) for x in input().split()] hacked = 0 pos = 0 changes = 0 right = True while hacked < n: if right: r = range(pos, n) else: r = range(pos, -1, -1) for i in r: if a[i] <= hacked: a[i] = n + 1 hacked += 1 pos = ...
vfc_38977
{ "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\n0 2 0\n", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
605_B. Lazy Student
Solve the following coding problem using the programming language python: Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to lend h...
```python n, m = (int(x) for x in input().split()) edges = [] for i in range(m): w, in_tree = input().split() edges.append([int(w), i, int(in_tree)]) sorted_edges = sorted(edges, key = lambda e: (e[0], -e[2])) print def free_edge(): for y in range(3, n+1): for x in range(2, y): yield [x,...
vfc_38981
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 0\n2 1\n3 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n2 1\n3 1\n4 0\n1 1\n5 0\n", "output": "1 3\n1 4\n2 3\n1 2\n2 4\n", "type": "stdin_stdo...
code_contests
verifiable_code
627_C. Package Delivery
Solve the following coding problem using the programming language python: Johnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d. Johnny's truck has a gas tank that holds exactly ...
```python destination, max_gas_tank_volume, gas_prices_number = map(int, input().split()) start_point = 0 gas_prices = {start_point:0} for i in range(gas_prices_number): coordinate, price = map(int, input().split()) gas_prices[coordinate] = price points = sorted(gas_prices.keys(), reverse = True) current_point ...
vfc_38985
{ "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": "16 5 2\n8 2\n5 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 4 4\n3 5\n5 8\n6 3\n8 4\n", "output": "22\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
651_C. Watchmen
Solve the following coding problem using the programming language python: Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi). They need to arrange a plan, but there...
```python #!/usr/bin/env python3 # -*- coding: utf-8 -*- def inc_val_of_dict(dictionary, key): if key not in dictionary: dictionary[key] = 0 dictionary[key] += 1 def main(): n = int(input()) p_ctr = dict() x_ctr = dict() y_ctr = dict() for _ in range(n): x, y = map(int, i...
vfc_38989
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n7 5\n1 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1\n", "output": "11\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
6_A. Triangle
Solve the following coding problem using the programming language python: Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks ...
```python # https://codeforces.com/problemset/problem/6/A import sys #-----------------------------------------------------------------------------# # # comment before submission # sys.stdin = open('inputs.txt', 'r') # sys.stdout = open('output.txt', 'w') #--------------------------------------------------------------...
vfc_38997
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5 9 1\n", "output": "IMPOSSIBLE\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 2 2 4\n", "output": "SEGMENT\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
721_C. Journey
Solve the following coding problem using the programming language python: Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are n showplaces in the city, numbered from 1 to n, and some of them are connected by one-directional roads. The roads in Berlatov are designed in a wa...
```python n, m, T = map(int, input().split()) graph_a = [[] for _ in range(n+1)] graph_b = [[] for _ in range(n+1)] double_graph_a = [[0 for _ in range(n+1)] for _ in range(n+1)] double_graph_b = [[0 for _ in range(n+1)] for _ in range(n+1)] for i in range(m): u, v, t = map(int, input().split()) graph_a[v].a...
vfc_39001
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3 13\n1 2 5\n2 3 7\n2 4 8\n", "output": "3\n1 2 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 6 7\n1 2 2\n1 3 3\n3 6 3\n2 4 2\n4 6 2\n6 5 1\n", "output": "4\n1 2 4 6 ", ...
code_contests
verifiable_code
743_A. Vladik and flights
Solve the following coding problem using the programming language python: Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad. Vladik knows n airp...
```python n, a, b = list(map(int, input().split())) line = [] aa = input() for i in range(n): line += [int(aa[i])] print(0 + (line[a-1] != line[b-1])) ```
vfc_39005
{ "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 1 4\n1010\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 2\n10110\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
78_B. Easter Eggs
Solve the following coding problem using the programming language python: The Easter Rabbit laid n eggs in a circle and is about to paint them. Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied: * Each of the seven...
```python n = int(input()) s = 'ROYGBIV' s1 = 'GBIV' print(s, (n - 7) // 4 * s1, s1[:(n - 7) % 4], sep='') ```
vfc_39013
{ "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\n", "output": "ROYGBIVG", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\n", "output": "ROYGBIVGBIVGB", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
810_D. Glad to see you!
Solve the following coding problem using the programming language python: This is an interactive problem. In the output section below you will see the information about flushing the output. On Sunday Leha the hacker took Nura from the house where she lives and went with her to one of the most luxurious restaurants in...
vfc_39017
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\nNIE\nTAK\nNIE\nTAK\nTAK\nTAK\n", "output": "1 2 3\n1 1 2\n1 1 3\n2 3 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n3 5\n", "output": "1 3 4\n1 4 5\n1 2 3\n1 3 4\n1 4 5...
code_contests
verifiable_code
837_A. Text Volume
Solve the following coding problem using the programming language python: You are given a text of single-space separated words, consisting of small and capital Latin letters. Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text. Calculate the volu...
```python n = int(input()) text = input() ll = list(text.split()) num = [] for i in range(len(ll)): num.append(sum(1 for c in ll[i] if c.isupper())) print(max(num)) ```
vfc_39021
{ "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": "24\nthis is zero answer text\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\nNonZERO\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
883_C. Downloading B++
Solve the following coding problem using the programming language python: Only T milliseconds left before the start of well-known online programming contest Codehorses Round 2017. Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f bytes. Polycarp's internet tariff allows t...
vfc_39029
{ "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": "8 81 11\n4 10 16\n3 10 12\n", "output": "28\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
906_C. Party
Solve the following coding problem using the programming language python: Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown to him. He decide...
```python from collections import defaultdict def count(x): c=0 while x > 0: c+=1 x &= (x-1) return c n,m=map(int,input().split()) g=defaultdict(list) for _ in range(m): u, v = map(int,input().split()) u-=1;v-=1 g[u].append(v) g[v].append(u) mask1=0;mask2=0;MAX=(1<<n)-1 a=[...
vfc_39033
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 2\n1 3\n1 4\n3 4\n", "output": "1\n1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6\n1 2\n1 3\n2 3\n2 5\n3 4\n4 5\n", "output": "2\n2 3 \n", "type": "stdin_stdout"...
code_contests
verifiable_code
926_E. Merge Equal Elements
Solve the following coding problem using the programming language python: You are given a sequence of positive integers a1, a2, ..., an. While possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices o...
```python # https://codeforces.com/problemset/problem/926/E input() stack1 = [int(i) for i in input().split()] stack1.reverse() stack2 = [] while stack1: transfer = stack1.pop() while stack2 and stack2[-1] == transfer: stack2.pop() transfer += 1 stack2.append(transfer) print(len(stack2...
vfc_39037
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n4 10 22 11 12 5 6\n", "output": "7\n4 10 22 11 12 5 6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
955_C. Sad powers
Solve the following coding problem using the programming language python: You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = ap. Input The first line contains the number of queries Q (1 ≤ Q ≤ 105)...
```python import math import bisect import sys def flrt(exp,x): l=max(0,math.floor(x**(1/exp))-3) r= math.floor(x**(1/exp))+3 while l<r: mid=(l+r)//2 if mid**exp<=x: l=mid+1 else: r=mid return l-1 def c1(r): ans=set() pr = [5,7,11, ...
vfc_39041
{ "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": "6\n1 4\n9 9\n5 7\n12 29\n137 591\n1 1000000\n", "output": "2\n1\n0\n3\n17\n1111\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n862 928\n758 964\n541 789\n622 943\n328 900\n14 764\n217...
code_contests
verifiable_code
3-types
Solve the following coding problem using the programming language python: Russian translation Let's consider some weird country with N cities and M bidirectional roads of 3 types. It's weird because of some unusual rules about using these roads: men can use roads of types 1 and 3 only and women can use roads of types...
```python import collections import heapq def mst(graph, n): total = 0 seen_m = set([1]) seen_f = set([1]) q = graph[1] heapq.heapify(q) while q: used = False kind, node = heapq.heappop(q) # if node in seen_m and node in seen_f: continue if kind in (-1, -3) and n...
vfc_39049
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 7\n1 2 3\n2 3 3\n3 4 3\n5 3 2\n5 4 1\n5 2 2\n1 5 1\n\n\nSAMPLE", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n1 2 3\n2 3 3\n3 4 3\n5 3 2\n5 4 1\n5 2 2\n1 5 2\n\n\nSA...
code_contests
verifiable_code
big-p-and-party-1
Solve the following coding problem using the programming language python: Big P has recently become very famous among girls . Big P goes to a party and every girl present there wants to dance with him. However, Big P cannot dance with all of them, because there are many of them. Now if a girl gets to dance with Big ...
```python (n, m) = map(int, raw_input().split()) list = [-1] * n list[0] = 0 tree = [] for i in range(n): tree.append([]) for i in range(m): (a, b) = map(int, raw_input().split()) tree[a].append(b) tree[b].append(a) queue = [0] while(queue): current = queue.pop(0) for next in tree[current]: if list[next] < 0: ...
vfc_39053
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 6\n0 1\n0 2\n3 2\n2 4\n4 3\n1 2\n\nSAMPLE", "output": "1\n1\n2\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 1962\n3 391\n4 276\n5 309\n6 279\n7 675\n8 387\n9 241\n10 629\n11 5...
code_contests
verifiable_code
count-strings-1
Solve the following coding problem using the programming language python: This task is very simple.You are given two string A and B and you have to find how many times you can form string B from string A. You are only allow to delete some character from string A and Change postion of characters .You are not allow to u...
```python noc = input() mod = 1000000007 from collections import Counter while noc: noc-=1 count = 1 st1 = raw_input() st2 = raw_input() cst1 = Counter(st1) for x in xrange(len(st2)): count = ((count%mod)*(cst1[st2[x]]%mod))%mod cst1[st2[x]]-=1 print count ```
vfc_39057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\naba \nab\n\nSAMPLE", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
finding-non-primes
Solve the following coding problem using the programming language python: Statement: Write a code to display all the non-prime numbers upto N. Input: Only the value of N. Output: The numbers which are not prime upto N (including N), each in a new line. Constraints: 1 ≤ N ≤ 10^4 SAMPLE INPUT 25 SAMPLE OUTPUT 4 6 8...
```python def sieve(n): primes=[] multiples=set() for i in xrange(2,n+1): if i not in multiples: primes.append(i) multiples.update(range(i*i, n+1,i)) return primes n=input() lst=sieve(n) for i in xrange(2,n+1): if i not in lst: print i ```
vfc_39061
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4500", "output": "4\n6\n8\n9\n10\n12\n14\n15\n16\n18\n20\n21\n22\n24\n25\n26\n27\n28\n30\n32\n33\n34\n35\n36\n38\n39\n40\n42\n44\n45\n46\n48\n49\n50\n51\n52\n54\n55\n56\n57\n58\n60\n62\n63\n64\n65\n66\n68\n69\n70\n72\n74\n75\...
code_contests
verifiable_code
interesting-prime
Solve the following coding problem using the programming language python: Taru and Chandu both are getting bored. So Taru thinks to play a game and he gives a number to Chandu and asks him to find the number of combinations formed by divisors in form of prime. For example:- For N = 36 divisor in form of prime a...
```python from itertools import combinations def prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors if __name__ == '__main__': t=int(raw_input...
vfc_39065
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n36\n\nSAMPLE", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n36\n\nELPMAS", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
maximum-resistance-5
Solve the following coding problem using the programming language python: PIET's EC department students are working on a set of conductors to create a circuit with maximum resistance. The simplest circuit consists of a single conductor (i.e., a single piece of wire). Each such circuit is labeled using the string "X"....
```python import sys,string,re for __ in range(input()) : circuit = raw_input() val = list(map(int,sys.stdin.readline().split())) stack , top , bptr , fptr = [] , -1 , len(val)-1 , 0 for i in range(len(circuit)-1,-1,-1) : if circuit[i] == 'X' : stack.append(1) elif circuit[i] == 'A...
vfc_39069
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nBXBXX\n8 2 3\nAAXXAXAXX\n1 1 2 8 10\nAXBXX\n8 2 3\n\nSAMPLE", "output": "8\n22\n11", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
order-was-the-dream-of-man-8
Solve the following coding problem using the programming language python: Sanket is a very organized person. He likes to organize everything to increase his efficiency. Whenever he sees a list of numbers he like to tag the number in ascending order. Recently he has realized he is wasting a lot of time doing that and t...
```python __author__ = 'Suvojit Manna' t = raw_input() while True: try: n = raw_input() arr = [int(i) for i in raw_input().split()] ordMap = {x: i for i, x in enumerate(sorted(set(arr)))} arr = map(lambda y: ordMap[y], arr) for x in arr: print x, print "\...
vfc_39073
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 \n7 \n23 45 87 34 13 76 34 \n3 \n20 40 10\n\nSAMPLE", "output": "1 3 5 2 0 4 2 \n1 2 0", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n48\n486441203 -791436838 -166642692 -852034963 52...
code_contests
verifiable_code
range-sum-for-mapping-of-large-ranges-to-small-ranges
Solve the following coding problem using the programming language python: There are a total of n people in Prateek's class, numbered from 1 to n. Every person has some field of interest for their projects. There are a number people who have the same field of interest. Now, you are given a number of pairs of the form ...
```python def dfs(v): global mark,c_c q=[] q.append(v) s=0 while q: top=q.pop() #s=1 mark[top]=c_c for j in G[top]: if mark[j]==-1: q.append(j) s+=1 mark[j]=mark[top] d[c_c]=s t=input() m...
vfc_39077
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n6 4\n1 2\n2 3\n4 5\n2 6\n\nSAMPLE", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n6 4\n1 2\n2 3\n6 5\n2 6\n\nSAMPLE", "output": "10\n", "type": "stdin_stdout...
code_contests
verifiable_code
small-is-cute-1
Solve the following coding problem using the programming language python: Given three positive integers N, A and B (A < B < N), find the sum of all positive integers less than N, which are divisible by either A or B. For example, when N = 20, A = 4 and B = 7, the possible values are 4, 7, 8, 12, 14, and 16. Their sum...
```python #! /usr/bin/python s = raw_input() lst = s.split(' ') n = int(lst[0]) a = int(lst[1]) b = int(lst[2]) sum = 0 for x in xrange(a,n,1): if (((x % a) == 0) or ((x % b) == 0)): sum = sum + x print sum ```
vfc_39081
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20 4 7\n\nSAMPLE", "output": "61\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 3 5", "output": "233168\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
think-1
Solve the following coding problem using the programming language python: Rajesh has been challenge by his friend to find the number which have properties like, Here take no 12 such that square of 12(12*12)=144 and 21 which is reverse of 12 have square(21*21)= 441 whose reverse is equal to 144 and now Rajesh is no...
```python import math t=input() for i in range(0,t): n=input() s=n*n s=str(s) #print s p=str(n) p=p[::-1] p=int(p) p=p*p #print p p=str(p) if(p==s): print"No" continue p=p[::-1] #print p if(p==s): print int(math.sqrt(int(p[::-1]))) else: print "No" ```
vfc_39085
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n12\n11\n\nSAMPLE", "output": "21\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n12\n4\n\nSAMPLE", "output": "21\nNo\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
p00106 Discounts of Buckwheat
Solve the following coding problem using the programming language python: Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves. One day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is ...
```python while 1: try: inp=int(input()) if inp==0:break m_list=[] for i in range(4): for j in range(5): for k in range(6): for l in range(3): for m in range(4): for n in range(5): ...
vfc_39133
{ "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": "500\n2200\n0", "output": "850\n3390", "type": "stdin_stdout" }, { "fn_name": null, "input": "500\n1000\n0", "output": "850\n1520\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00240 Interest Rates
Solve the following coding problem using the programming language python: Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating princip...
```python def simple_interest(r, y): return (100 + r * y) / 100 def compound_interest(r, y): return ((100 + r) / 100) ** y import sys import operator f = sys.stdin get_ganri = {1:simple_interest,2:compound_interest} while True: n = int(f.readline()) if n == 0: break y = int(f.readline()) ...
vfc_39137
{ "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\n8\n1 5 2\n2 6 1\n2\n9\n1 5 2\n2 6 1\n0", "output": "2\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n8\n1 5 2\n2 6 1\n2\n9\n1 3 2\n2 6 1\n0", "output": "2\n2\n", "type"...
code_contests
verifiable_code
p00616 Cubes Without Holes
Solve the following coding problem using the programming language python: There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horiz...
```python # AOJ 1030 Cubes Without Holes # Python3 2018.7.6 bal4u import sys from sys import stdin input = stdin.readline # n <= 500, 2^9 = 512 while True: n, h = map(int, input().split()) if n == 0: break ans = [] for i in range(h): c, a, b = input().split() a, b = int(a)-1, int(b)-1 if c == "xy": ans ...
vfc_39145
{ "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 3\nxy 4 4\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy 3 3\nxz 3 3\nyz 2 1\nyz 3 3\n0 0", "output": "52\n46", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\nxy 4 4\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy...
code_contests
verifiable_code
p00760 Millennium
Solve the following coding problem using the programming language python: A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year sh...
```python # AOJ 1179: Millennium # Python3 2018.7.14 bal4u for cno in range(int(input())): y, m, d = map(int, input().split()) ans = 195*y if y > 1: ans += 5*((y-1)//3) if y % 3: ans += 19*(m-1) + m//2 else: ans += (m-1)*20 print(196666-ans-d) ```
vfc_39149
{ "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": "8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 8 7\n344 2 19\n696 4 19\n999 10 20", "output": "196470\n128976\n59710\n160715\n252\n128977\n59712\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
p00892 Intersection of Two Prisms
Solve the following coding problem using the programming language python: Suppose that P1 is an infinite-height prism whose axis is parallel to the z-axis, and P2 is also an infinite-height prism whose axis is parallel to the y-axis. P1 is defined by the polygon C1 which is the cross section of P1 and the xy-plane, an...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): M, N = map(int, readline().split()) if M == N == 0: return False P = [list(map(int, readline().split())) for i in range(M)] Q = [list(map(int, readline().split())) for i in range(N)] xs = set() xs.up...
vfc_39153
{ "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 3\n7 2\n3 3\n0 2\n3 1\n4 2\n0 1\n8 1\n4 4\n30 2\n30 12\n2 12\n2 2\n15 2\n30 8\n13 14\n2 8\n8 5\n13 5\n21 7\n21 9\n18 15\n11 15\n6 10\n6 8\n8 5\n10 12\n5 9\n15 6\n20 10\n18 12\n3 3\n5 5\n10 3\n10 10\n20 8\n10 15\n10 8\n4 4\n-98 99...
code_contests
verifiable_code
p01024 Sum of Last Digits
Solve the following coding problem using the programming language python: Problem Given the three integers n, m, k n1% 10 + n1 + m% 10 + n1 + 2m% 10 + ... + n1 + (k-1) m% 10 Calculate. a% b represents the remainder when a is divided by b. Constraints Input meets the following conditions * 0 ≤ n ≤ 1018 * 0 ≤ m ≤ ...
vfc_39157
{ "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": "1 1 9", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 7 12", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 11 11"...
code_contests
verifiable_code
p01156 Hyper Rock-Scissors-Paper
Solve the following coding problem using the programming language python: Rock-Scissors-Paper is a game played with hands and often used for random choice of a person for some purpose. Today, we have got an extended version, namely, Hyper Rock-Scissors-Paper (or Hyper RSP for short). In a game of Hyper RSP, the playe...
vfc_39161
{ "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": "8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n3\nRock\nScissors\nPaper\n0", "output": "Sponge\nDraw", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\nLightning\nGun\nPaper\nS...