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
159_B. Matchmaker
Solve the following coding problem using the programming language python: Polycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. Cap (aj, bj) can close ma...
```python def main(): from sys import stdin l = list(map(int, stdin.read().split())) n, yx = l[0] * 2, [[0] * 1001 for _ in range(1001)] cnt = yx[0] u = v = 0 for y, x in zip(l[3:n + 3:2], l[2:n + 2:2]): cnt[y] += 1 yx[y][x] += 1 ba, l = list(zip(l[n + 3::2], l[n + 2::2])), [...
vfc_61801
{ "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": "2 2\n1 2\n2 1\n3 4\n5 1\n", "output": "1 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n1 2\n3 4\n2 4\n5 4\n2 4\n1 1\n1 2\n", "output": "3 2\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
200_E. Tractor College
Solve the following coding problem using the programming language python: While most students still sit their exams, the tractor college has completed the summer exam session. In fact, students study only one subject at this college — the Art of Operating a Tractor. Therefore, at the end of a term a student gets only ...
vfc_61809
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 15\n5 3 3 4 4 5\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 11\n3 4 3 5 5\n", "output": "1 3 3\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
225_D. Snake
Solve the following coding problem using the programming language python: Let us remind you the rules of a very popular game called "Snake" (or sometimes "Boa", "Python" or "Worm"). The game field is represented by an n × m rectangular table. Some squares of the field are considered impassable (walls), all other squa...
vfc_61813
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n#78#\n.612\n.543\n..@.\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
24_B. F1 Champions
Solve the following coding problem using the programming language python: Formula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, 12, 10, 8, 6, 4, 2, 1. A...
```python points = [25, 18, 15, 12, 10, 8, 6, 4, 2, 1] + [0] * 40 numRaces = int(input()) scores = {} for race in range(numRaces): numDrivers = int(input()) for d in range(numDrivers): driver = input() if not driver in scores: scores[driver] = [0] + [0] * 50 + [driver] scores[driver][0] += points...
vfc_61817
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n7\nProst\nSurtees\nNakajima\nSchumacher\nButton\nDeLaRosa\nBuemi\n8\nAlonso\nProst\nNinoFarina\nJimClark\nDeLaRosa\nNakajima\nPatrese\nSurtees\n", "output": "Prost\nProst\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
297_E. Mystic Carvings
Solve the following coding problem using the programming language python: The polar bears have discovered a gigantic circular piece of floating ice with some mystic carvings on it. There are n lines carved on the ice. Each line connects two points on the boundary of the ice (we call these points endpoints). The endpoi...
vfc_61825
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 7\n2 4\n3 9\n5 11\n6 8\n10 16\n13 15\n14 12\n", "output": " 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 4\n1 2...
code_contests
verifiable_code
320_C. Malek Dance Club
Solve the following coding problem using the programming language python: As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2n members and coincidentally Natalia Fan Club also has 2n members. Each member of MDC i...
```python #!/usr/local/bin/python3.3 -tt import sys if __name__ == '__main__': for l in sys.stdin: s = l.strip() break n = len(s) d = 2 ** (n - 1) print(d * int(s, 2) % 1000000007) ```
vfc_61829
{ "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\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "01\n", ...
code_contests
verifiable_code
345_C. Counting Fridays
Solve the following coding problem using the programming language python: Judging from the previous problem, Friday the 13th really doesn't treat you well, so you start thinking about how to minimize its impact on your life. You are a passionate participant of programming contests, so various competitions are an impor...
vfc_61833
{ "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": "5\n2012-01-13\n2012-09-13\n2012-11-20\n2013-09-13\n2013-09-20\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
368_E. Sereja and the Arrangement of Numbers
Solve the following coding problem using the programming language python: Let's call an array consisting of n integer numbers a1, a2, ..., an, beautiful if it has the following property: * consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; * f...
vfc_61837
{ "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 2\n1 1\n2 100\n", "output": "100", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
391_A. Genetic Engineering
Solve the following coding problem using the programming language python: You will receive 3 points for solving this problem. Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is rep...
```python class CodeforcesTask391ASolution: def __init__(self): self.result = '' self.dna = '' def read_input(self): self.dna = input() def process_task(self): currc = '' count = 0 inserts = 0 for c in self.dna: if currc != c: ...
vfc_61841
{ "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": "AACCAACCAAAAC\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "GTTAAAG\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
412_E. E-mail Addresses
Solve the following coding problem using the programming language python: One of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day. Today, the online news thundered with terrible information. The R1 database crashed and almo...
```python from sys import stdin, stdout, setrecursionlimit input = stdin.readline # setrecursionlimit(int(1e6)) inf = float('inf') from functools import cmp_to_key from collections import defaultdict as dd from collections import Counter, deque from heapq import * import math from math import floor, ceil, sqrt def geti...
vfc_61845
{ "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": "gerald.agapov1991@gmail.com\n", "output": " 18", "type": "stdin_stdout" }, { "fn_name": null, "input": ".asd123__..@\n", "output": "...
code_contests
verifiable_code
43_B. Letter
Solve the following coding problem using the programming language python: Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces o...
```python s1 = ''.join(input().split()) s2 = ''.join(input().split()) for i in s2: if s2.count(i) > s1.count(i): print("NO") exit(0) print("YES") ```
vfc_61849
{ "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": "Instead of dogging your footsteps it disappears but you dont notice anything\nYour dog is upstears\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abcdefg hijk\nk j i h g...
code_contests
verifiable_code
461_D. Appleman and Complicated Task
Solve the following coding problem using the programming language python: Toastman came up with a very complicated task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him? Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o', or nothing. How ...
```python from sys import stdin def main(): n, k = map(int, stdin.readline().split()) par = [range(n+10), range(n+10)] def find(i, x): if par[i][x] == x: return x else: par[i][x] = find(i, par[i][x]) return par[i][x] def unite(i, x, y): x, y = ...
vfc_61853
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n2 4 x\n3 4 x\n3 2 x\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 1 x\n2 2 o\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
485_C. Bits
Solve the following coding problem using the programming language python: Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <...
```python for i in range(int(input())): l,r=map(int,input().split()) L=list(bin(l)) R=list(bin(r)) L=L[2:] R=R[2:] w=0 c=0 L=['0']*(len(R)-len(L))+L #print(L,R) ans=0 if l==r: print(l) continue for i in range(len(R)): if L[i]!=R[i]: for...
vfc_61857
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n2 4\n1 10\n", "output": "1\n3\n7\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
509_C. Sums of Digits
Solve the following coding problem using the programming language python: Vasya had a strictly increasing sequence of positive integers a1, ..., an. Vasya used it to build a new sequence b1, ..., bn, where bi is the sum of digits of ai's decimal representation. Then sequence ai got lost and all that remained is sequen...
```python def fill9(x,u): k=x//9 for i in range(k): u[i]=9 if x%9: u[k]=x%9 return k+1 else: return k n=input() n=int(n) u=[0 for i in range(300//9*150+150)] k=1 for i in range(n): x=input() x=int(x) t=k-1 while t>=0: if u[t]+9*t<x: t=f...
vfc_61861
{ "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\n3\n2\n1\n", "output": "3\n11\n100\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n2\n3\n", "output": "1\n2\n3\n", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
533_E. Correcting Mistakes
Solve the following coding problem using the programming language python: Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics. P...
```python def aux(s, t): n = len(s) lpr = 0 for i in range(n): if s[i] != t[i]: break lpr += 1 lsf = 0 for i in range(n-1, -1, -1): if s[i] != t[i]: break lsf += 1 if(lpr == n): return 2 return (s[lpr:n-lsf-1] == t[lpr+1:n-ls...
vfc_61865
{ "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": "7\nreading\ntrading\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nsweet\nsheep\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
558_D. Guess Your Way Out! II
Solve the following coding problem using the programming language python: Amr bought a new video game "Guess Your Way Out! II". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is...
```python h,q=map(int,input().split()) d=[(2**h,0),(2**(h-1),0)] for _ in range(q): i,l,r,a=map(int,input().split()) l,r=l*2**(h-i),(r+1)*2**(h-i) d.extend([[(l,1),(r,-1)],[(0,1),(l,-1),(r,1)]][a]) s=0 l=0 d=sorted(d) for (a,x),(b,_) in zip(d,d[1:]): s+=x if a!=b and s==0:q=a;l+=b-a print(("Game che...
vfc_61869
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n4 10 14 1\n3 6 6 0\n2 3 3 1\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n3 4 5 1\n2 3 3 1\n", "output": "Game cheated!\n", "type": "stdin_stdout"...
code_contests
verifiable_code
584_B. Kolya and Tanya
Solve the following coding problem using the programming language python: Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle. More formally, there are 3n gnomes sitting in a circle. Each gnome can have f...
```python n = int(input()) print((27 ** n - 7 ** n) % (10 ** 9 + 7)) ```
vfc_61873
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "680", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "20", "type": "stdin_stdout" }, { "fn_name": null, "input": "68841\n", ...
code_contests
verifiable_code
606_B. Testing Robots
Solve the following coding problem using the programming language python: The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0, y0...
```python q,b,c,d = map(int,input().split()) s = input() x,y =c,d l = 1 print(1,end = ' ') a = set() a.add((c,d)) for i in range(len(s)-1): item = s[i] if (item == 'U'): if(x == 1 or (x-1,y) in a): print(0,end = ' ') if(x-1,y) in a: x-=1 else: ...
vfc_61877
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 2 2\nULD\n", "output": "1 1 1 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 2 2\nUURDRDRL\n", "output": "1 1 0 1 1 1 1 0 6 ", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
652_C. Foe Pairs
Solve the following coding problem using the programming language python: You are given a permutation p of length n. Also you are given m foe pairs (ai, bi) (1 ≤ ai, bi ≤ n, ai ≠ bi). Your task is to count the number of different intervals (x, y) (1 ≤ x ≤ y ≤ n) that do not contain any foe pairs. So you shouldn't co...
```python import sys # TLE without n, m = map(int, input().split()) pos = [None] * (n + 1) for i, a in enumerate(map(int, input().split())): pos[a] = i z = [300005] * (n + 1) for pr in sys.stdin.read().splitlines(): x, y = map(int, pr.split()) if pos[x] > pos[y]: x, y = y, x z[pos[x]] = min(z[...
vfc_61885
{ "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 2\n1 3 2 4\n3 2\n2 4\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 5\n9 7 2 3 1 4 6 5 8\n1 6\n4 5\n2 7\n7 2\n2 7\n", "output": "20", "type": "stdin_stdout"...
code_contests
verifiable_code
678_A. Johny Likes Numbers
Solve the following coding problem using the programming language python: Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k. Input The only line contains two integers n and k (1 ≤ n, k ≤ 109). Output Print the smallest integer x...
```python a,b=map(int,input().split()) print(((a//b)+1)*b) ```
vfc_61889
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "25 13\n", "output": "26", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "26 13\n"...
code_contests
verifiable_code
744_A. Hongcow Builds A Nation
Solve the following coding problem using the programming language python: Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries. The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the g...
```python class Union: def __init__(self, n): self.ancestors = [i for i in range(n+1)] self.size = [0]*(n+1) def get_root(self, node): if self.ancestors[node] == node: return node self.ancestors[node] = self.get_root(self.ancestors[node]) return self.ancesto...
vfc_61901
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 1\n2\n1 2\n1 3\n2 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1 2\n1 3\n1 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
767_C. Garland
Solve the following coding problem using the programming language python: Once at New Year Dima had a dream in which he was presented a fairy garland. A garland is a set of lamps, some pairs of which are connected by wires. Dima remembered that each two lamps in the garland were connected directly or indirectly via so...
vfc_61905
{ "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\n2 4\n0 6\n4 2\n2 1\n1 1\n4 2\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 4\n0 5\n4 2\n2 1\n1 1\n4 2\n", "output": "1 4", "type": "stdin_stdout" ...
code_contests
verifiable_code
811_D. Vladik and Favorite Game
Solve the following coding problem using the programming language python: This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as n × m matrix which consists of cells of three types: * «.» — normal cell, player can visit it. * «F» — fin...
vfc_61913
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n...\n**.\nF*.\n...\n1 1\n1 2\n1 3\n1 3\n2 3\n3 3\n4 3\n4 2\n4 1\n3 1\n", "output": "R\nL\nL\nD\nU\nU\nU\nR\nR\nD\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10 0 0\n.....*....\...
code_contests
verifiable_code
837_F. Prefix Sums
Solve the following coding problem using the programming language python: Consider the function p(x), where x is an array of m integers, which returns an array y consisting of m + 1 integers such that yi is equal to the sum of first i elements of array x (0 ≤ i ≤ m). You have an infinite sequence of arrays A0, A1, A2...
```python n, k = map(int, input().split(" ")) l = map(int, input().split(" ")) v = [] for x in l: if x != 0 or v: v.append(x) def bruteforce(v, k): ret = 0 while True: accm = 0 for i in range(len(v)): if v[i] >= k: return ret accm += v[i] v[i] = ...
vfc_61917
{ "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 6\n1 1 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n1 0 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
858_B. Which floor?
Solve the following coding problem using the programming language python: In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, t...
```python n, m = map(int, input().split()) a = [tuple(map(int, input().split())) for i in range(m)] ans = set() for i in range(1, 101): can = True for k, f in a: if (k + i - 1) // i != f: can = False break if can: ans.add((n + i - 1) // i) if len(ans) == 1: print(...
vfc_61921
{ "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": "8 4\n3 1\n6 2\n5 2\n2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3\n6 2\n2 1\n7 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
907_C. Shockers
Solve the following coding problem using the programming language python: Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives a...
```python N = int(input()) letters = set() for c in range(ord('a'), ord('z') + 1): letters.add(chr(c)) tmp = set() do_count = False count = 0 for n in range(N): act, val = input().split() if act == '.': for c in val: if c in letters: letters.remove(c) if act == '...
vfc_61929
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n! abc\n. ad\n. b\n! cd\n? c\n", "output": "1\n", "type": "s...
code_contests
verifiable_code
926_J. Segments
Solve the following coding problem using the programming language python: There is a straight line colored in white. n black segments are added on it one by one. After each segment is added, determine the number of connected components of black segments (i. e. the number of black segments in the union of the black se...
vfc_61933
{ "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": "3\n1 3\n4 5\n2 4\n", "output": "1 2 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n10 20\n50 60\n30 40\n70 80\n90 100\n60 70\n10 40\n40 50\n80 90\n", "output": "1 2 3 4 5 4 3 2 ...
code_contests
verifiable_code
957_B. Mystical Mosaic
Solve the following coding problem using the programming language python: There is a rectangular grid of n rows of m initially-white cells each. Arkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and a non-empty subset of columns Ci are chosen. ...
```python def findInArray(c, arr): ind = [] for i in range(len(arr)): if arr[i] == c: ind.append(i) return ind def solve(): numRows,numCols = map(int, input().strip().split()) mat = [[0]*numCols for _ in range(numRows)] for i in range(numRows): mat[i] = list(input().strip()) rows = [0] * numRows col...
vfc_61937
{ "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": "5 9\n........#\n#........\n..##.#...\n.......#.\n....#.#.#\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 8\n.#.#..#.\n.....#..\n.#.#..#.\n#.#....#\n.....#..\n", ...
code_contests
verifiable_code
982_B. Bus of Characters
Solve the following coding problem using the programming language python: In the Bus of Characters there are n rows of seat, each having 2 seats. The width of both seats in the i-th row is w_i centimeters. All integers w_i are distinct. Initially the bus is empty. On each of 2n stops one passenger enters the bus. The...
```python import heapq n=int(input()) w=[int(x) for x in input().split()] us={w[i]:i+1 for i in range(n)} w.sort() p=input() order="" i=0 seats=[] for x in p: if x=="0": y=w[i] order+=str(us[y])+" " heapq.heappush(seats,-y) i+=1; else: m=heapq.heappop(seats) order...
vfc_61941
{ "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\n10 8 9 11 13 5\n010010011101\n", "output": "6 6 2 3 3 1 4 4 1 2 5 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 1\n0011\n", "output": "2 1 1 2 ", "type": "stdin_stdo...
code_contests
verifiable_code
a-coin-game
Solve the following coding problem using the programming language python: Rahul and Rashi are bored with playing the game of Nim, particularly after Rahul gained a thorough understanding of game theory, and would always win. Now, they are going to play on a variation. There are only 2 piles of coins. Each player can...
```python maxn = 10**6 cold_pos = {} def gen_cold(): d = 0 i = 0 while (i < maxn): if not (cold_pos.has_key(i)): cold_pos[i] = i + d cold_pos[i + d] = i d += 1 i += 1 if __name__ == "__main__": gen_cold() t = int(raw_input()) for i in range(t): n = map(int, raw_input().split(" ")) if n[1] == co...
vfc_61945
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n0 2\n1 2\n\nSAMPLE", "output": "Play\nPlay\nDon't Play\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "216\n88 0\n452 823\n549 562\n790 873\n114 186\n216 75\n620 414\n870 68\n657 8...
code_contests
verifiable_code
bino-sum-1
Solve the following coding problem using the programming language python: Let us define F(N,K) be number of subsets of K distinct elements of S where N is the size of S. Given a P( ≤ N), let Sum = F(N,0) + F(N,1) + ... + F(N,P). You have to print Sum modulo 1000000007. Input: First line contains, T, the number of ...
```python dp=[[0 for i in range(1001)] for j in range(1001)] for i in range(1,1001): dp[i][0]=1 dp[i][1]=i for i in range(2,1001): for j in range(2,i+1): if j==i: dp[i][j]=1 else: dp[i][j]=dp[i-1][j-1]+dp[i-1][j] t=int(raw_input()) for k in range(t): n,r = [int(i) for i in raw_input().split()] if r...
vfc_61949
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n2 0\n\nSAMPLE", "output": "4\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n1000 0\n1000 1\n1000 2\n1000 3\n1000 4\n1000 5\n1000 6\n1000 7\n1000 8\n1000 9\n1000 10\n1000 ...
code_contests
verifiable_code
counting-triangles
Solve the following coding problem using the programming language python: You are given n triangles. You are required to find how many triangles are unique out of given triangles. For each triangle you are given three integers a,b,c , the sides of a triangle. A triangle is said to be unique if there is no other tri...
```python from collections import Counter if __name__ == "__main__": print Counter([" ".join(sorted(raw_input().rstrip().split(" "))) for i in range(input())]).values().count(1) ```
vfc_61953
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n7 6 5\n5 7 6\n8 2 9\n2 3 4\n2 4 3 \n\nSAMPLE", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n576378624010409 1239702190063459 663323566053051\n133603247569190 90190...
code_contests
verifiable_code
finite-automata
Solve the following coding problem using the programming language python: Consider a Deterministic Finite Automaton(DFA) which takes N states numbered from 0 to N-1, with alphabets 0 and 1. Now consider a string of 0s and 1s, let the decimal value of this string as M. For e.g., if string be "010" then the decimal valu...
```python n=input() cnt=0 for i in range(0,n): print i, print (cnt)%n,(cnt+1)%n cnt=cnt+2 ```
vfc_61957
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n\nSAMPLE", "output": "0 0 1\n1 2 3\n2 4 0\n3 1 2\n4 3 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "99", "output": "0 0 1\n1 2 3\n2 4 5\n3 6 7\n4 8 9\n5 10 11\n6 12 13\n7 14 15\...
code_contests
verifiable_code
is-divisible
Solve the following coding problem using the programming language python: Manku has still not learnt from KK's hard problem and continues bragging about himself. He claims that he can code problems even in his sleep. So one day Shark wakes him from sleep and asks him to solve a problem. Shark gives him a number x an...
```python from sys import stdin import math def gcd(a,b): while a%b: t = a%b;a=b;b=t return b t = int(stdin.readline()) for _ in xrange(t): n,m = map(int,stdin.readline().split()) u = n v = m ans = 'YES' g = gcd(m,n) if pow(n,g*n*n,m): ans = 'NO' print ans ```
vfc_61961
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 10\n5 25\n6 4\n8 3\n\nSAMPLE", "output": "NO\nYES\nYES\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n150000 234\n111111 13\n134232 2333434\n15 2456", "output": "NO\nYES\n...
code_contests
verifiable_code
memories-1
Solve the following coding problem using the programming language python: N coders decided to go for a trip for the upcoming weekend. They chose Crater Lake National Park in Oregon, USA as their destination, because they all like to take a lot of photos and the beautiful nature gives them a chance to do so. In order ...
```python import itertools t=input() while t: t-=1 n,p=map(int,raw_input().split()) c=0 c+=n mat=[] arr=range(1,n+1) for i in range(p): mat.append(map(int,raw_input().split())) for l in range(2,len(arr)+1): for subset in itertools.combinations(arr,l): temp=p for pair in mat: if not (pair[0] in sub...
vfc_61965
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 1\n1 2\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5 1\n1 2\n\nSAMPLE", "output": "23\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
oz-and-his-game-board-1
Solve the following coding problem using the programming language python: Today Oz is playing with his game-board. He has N coins of type-1 and M coins of type-2. Also the game-board has N squares of type-1 and M squares of type-2. In this game Oz must place one coin into each square. After placing all coins Oz will g...
```python diff=0 def ABS(a): if(a<0):return -a return a def MIN(one,two): if(one < two): return one return two test=input() for t in range(0,test): N,M,A,B,C=map(int,raw_input().split()) first=N*A + M*B second= MIN(N,M) if(N>M): diff=A *ABS(N-M) else: diff=B * ABS(N-M) second=2*C*second + diff if(f...
vfc_61969
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 4 500 800 600\n1 5 10 -20 -30\n\nSAMPLE", "output": "4700\n-90\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 4 611 800 600\n1 5 10 -20 -30\n\nSAMPLE", "output": "5033\n-9...
code_contests
verifiable_code
rasta-and-darie
Solve the following coding problem using the programming language python: A Darie is a special circle. Numbers 1, 2, ..., n are written clockwise around this circle in order. You can stand on a number! Initially Rasta is on number 1. In each step, he jumps exactly p numbers clockwise. For example if n = 3 and he is st...
```python def gcd(a,b): if b==0: return a else: return gcd(b,a%b) t=int(input()) while t>0: n,p,k=raw_input().split(' ') a=[1,1] n=int(n) p=int(p) k=int(k) if gcd(n,p)==1: if k>n: res=-1 else: res=k else: temp=gcd(n,p)...
vfc_61973
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n12 5 3\n12 3 2\n3 2 2\n\nSAMPLE", "output": "3\n4\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n12 5 3\n12 3 2\n3 2 0\n\nSAMPLE", "output": "3\n4\n0\n", "type": "std...
code_contests
verifiable_code
so-random
Solve the following coding problem using the programming language python: It's the rainy season again, and the city experiences frequent showers throughout the day. The weather report says that there is a P probability of rainfalls today. Raj has to step out for a meeting at the office, and would like to know the pro...
```python t = int(raw_input()) for i in range(t): p,t = map(float,raw_input().split(" ")) a = round(1 - (1 - p) ** (t / 1440.0),4) l = len(str(a)[2:]) if(l != 4): a = str(a) + "0" * (4 - l) print(a) ```
vfc_61977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n0 10\n.5 720\n\nSAMPLE", "output": "0.0000\n0.2929\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n0.18645496223766345 360\n0.17989902622977394 360\n0.45262248490623425 360\n0.04663...
code_contests
verifiable_code
tic-tac-toe-emails
Solve the following coding problem using the programming language python: Tic-Tac-Toe are three cousins. They love to send emails to each other. Tic is a naughty boy. He sends similar email to Tac multiple times. Now Tac needs your help to filter out the emails and delete the emails with similar subjects. Input: Fir...
```python n = int(raw_input()) for i in xrange(n): s = raw_input().split() dic = {} for i in s: dic[i] = 0 for i in s: dic[i] = dic[i] + 1 if dic[i] == 1: print i,#dic[i], print ```
vfc_61981
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nhello whatsup raining hello yes whatsup\nhi coming good hi\ntac who who\n\nSAMPLE", "output": "hello whatsup raining yes\nhi coming good\ntac who\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
p00111 Doctor's Memorable Codes
Solve the following coding problem using the programming language python: Hiroshi:? D-C'KOPUA Peter: What's wrong, Dr. David? I'm used to shouting something I don't understand, but I'm not even writing it today. Hiroshi: Here. <image> Peter: What? This table ... oh, there was something like this in the qualifying...
```python import sys def cv1(c): o=ord(c) if 65<=o<=90: return format(o-65,"05b") elif o==32: return "11010" elif o==46: return "11011" elif o==44: return "11100" elif o==45: return "11101" elif o==39: return "11110" elif o==63: ret...
vfc_62029
{ "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": "?D-C'KOPUA", "output": "PETER POTTER", "type": "stdin_stdout" }, { "fn_name": null, "input": "?D-C'KOQUA", "output": "PETER POTH '\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00245 Time Sale
Solve the following coding problem using the programming language python: Better things, cheaper. There is a fierce battle at the time sale held in some supermarkets today. "LL-do" here in Aizu is one such supermarket, and we are holding a slightly unusual time sale to compete with other chain stores. In a general tim...
```python from heapq import heappush, heappop from string import digits import sys readline = sys.stdin.readline write = sys.stdout.write dd = ((-1, 0), (0, -1), (1, 0), (0, 1)) INF = 10**9 while 1: X, Y = map(int, readline().split()) if X == Y == 0: break MP = [readline().split() for i in range(Y)...
vfc_62033
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 5\n1 1 . 0 0 4\n1 . . . . .\n. . 2 2 . .\n. . 2 2 3 3\nP . . . . .\n5\n0 50 5 10\n1 20 0 10\n2 10 5 15\n3 150 3 5\n4 100 8 9\n0 0", "output": "180", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00426 Cup
Solve the following coding problem using the programming language python: There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup ...
```python def biggest_cup(s,v): try: return s.index(v) except ValueError: return 127 def neighbors(s): a = biggest_cup(s,0) b = biggest_cup(s,1) c = biggest_cup(s,2) if b > a: t = list(s) t[a] = 1 yield tuple(t) elif b < a: t = list(s) ...
vfc_62037
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0", "output": "9\n3\n0\n-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10\n0\n1 1\n2 2 3\n4 20\n2 1 ...
code_contests
verifiable_code
p00621 Sleeping Cats
Solve the following coding problem using the programming language python: Jack loved his house very much, because his lovely cats take a nap on the wall of his house almost every day. Jack loved cats very much. Jack decided to keep an observation diary of the cats as a free study during the summer vacation. After obs...
```python while 1: W, Q = map(int, input().split()) if W == Q == 0: break A = [0]*W for i in range(Q): s, *qs = input().split() if s == 's': x, w = map(int, qs) su = sum(A[:w-1]) k = -1 for i in range(W-w+1): su += A...
vfc_62041
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 6\ns 0 2\ns 1 3\ns 2 1\nw 0\ns 3 3\ns 4 2\n3 3\ns 0 1\ns 1 1\ns 2 1\n0 0", "output": "0\nimpossible\n2\nimpossible\n0\nEND\n0\n1\n2\nEND", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6...
code_contests
verifiable_code
p00765 Generic Poker
Solve the following coding problem using the programming language python: You have a deck of N × M cards. Each card in the deck has a rank. The range of ranks is 1 through M, and the deck includes N cards of each rank. We denote a card with rank m by m here. You can draw a hand of L cards at random from the deck. If...
vfc_62045
{ "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 1 1\na\n3 3 4\na+ * a *\n2 2 3\na a b\n2 2 3\n* * *\n2 2 3\n* b b\n2 2 2\na a\n2 3 3\na a+ a++\n2 6 6\na a+ a++ b b+ b++\n4 13 5\na a * * *\n4 13 5\na a b b *\n4 13 5\na a a * *\n4 13 5\na a+ a++ a+++ a++++\n4 13 5\n* * * * *\n4 ...
code_contests
verifiable_code
p00897 Long Distance Taxi
Solve the following coding problem using the programming language python: A taxi driver, Nakamura, was so delighted because he got a passenger who wanted to go to a city thousands of kilometers away. However, he had a problem. As you may know, most taxis in Japan run on liquefied petroleum gas (LPG) because it is chea...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_62049
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3 34\nTokyo Kyoto\nTokyo Niigata 335\nTokyo Shizuoka 174\nShizuoka Nagoya 176\nNagoya Kyoto 195\nToyama Niigata 215\nToyama Kyoto 296\nNagoya\nNiigata\nToyama\n6 3 30\nTokyo Kyoto\nTokyo Niigata 335\nTokyo Shizuoka 174\nShizuoka ...
code_contests
verifiable_code
p01161 Traffic
Solve the following coding problem using the programming language python: You are a resident of Kyoot (oh, well, it’s not a misspelling!) city. All streets there are neatly built on a grid; some streets run in a meridional (north-south) direction and others in a zonal (east-west) direction. The streets that run from n...
vfc_62057
{ "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 4\n2 2 2\n2 2 2\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n99 1 0\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n99 1 0\n1 0\n1 6\n2 2\n10\n10\n5 5 0\n5 5 0\n5 5 0\n5 5 0\n5 0\n5 10\n0 0", "output": ...
code_contests
verifiable_code
p01300 Eleven Lover
Solve the following coding problem using the programming language python: Edward Leven loves multiples of eleven very much. When he sees a number, he always tries to find consecutive subsequences (or substrings) forming multiples of eleven. He calls such subsequences as 11-sequences. For example, he can find an 11-seq...
```python while(True): s = input() m = len(s) if s == "0": quit() dp = [[0 for j in range(11)] for i in range(m)] for i in range(m): n = int(s[i]) if n == 0: tmp = dp[i-1][1:] tmp.reverse() dp[i] = [dp[i-1][0]]+tmp else: ...
vfc_62061
{ "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": "17819\n1111\n11011\n1234567891011121314151617181920\n0", "output": "1\n4\n4\n38", "type": "stdin_stdout" }, { "fn_name": null, "input": "17819\n1011\n11011\n1234567891011121314151617181920\n0", ...
code_contests
verifiable_code
p01469 Divisor
Solve the following coding problem using the programming language python: Problem statement There is a positive integer sequence $ X_1, X_2, ..., X_N $. Select the subsequence $ S $ from the sequence $ \\ {1,2, ..., N \\} $. However, $ S $ must meet the following conditions. * $ T = \\ {X_s | s \ in S \\} $. At this...
vfc_62065
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n6 3 2", "output": "2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n10 9 8 7 6 5 4 3 2 1", "output": "1 2 3 4 5", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
p01629 Hotel
Solve the following coding problem using the programming language python: Problem Statement Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and does not have much money. She is looking for a hotel for a training camp, but is struggling to make a plan that saves as much money ...
vfc_62069
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n5500 5500 5500 5500\n5480 5780 5980 5980\n5500 5500 5500 5500", "output": "21980 1\n2\n1\n1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n3000 6000 3000\n4000 5500 4500", ...
code_contests
verifiable_code
p01781 Cube Coloring
Solve the following coding problem using the programming language python: Example Input 2 2 2 0 0 0 5 Output 1 3 3 1 0 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): X, Y, Z, A, B, C, N = map(int, readline().split()) S = [0]*max(2*(X+Y+Z+1), 2*N+2) for k in range(N): S[k] = k*(k+1)//2 for k in range(N, X+Y+Z+1): S[k] = k*(k+1)//2 + S[k-N] def calc(k, x, y, ...
vfc_62073
{ "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": "2 2 2 0 0 0 5", "output": "1 3 3 1 0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 2 0 0 0 5", "output": "2 3 4 4 3\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
p01916 Alphabet Block
Solve the following coding problem using the programming language python: A: Alphabet block Wakana Nakawa loves palindromes. Because my name is also a palindrome. Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create you...
```python import collections print(sum([v%2 for v in collections.Counter(input()).values()])//2) ```
vfc_62077
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 267386880, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "hcpc", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02054 Skewering
Solve the following coding problem using the programming language python: C: Skewering problem One day, when Homura was playing with blocks, Tempura came. Homura decided to play with blocks with Tempura. There is a rectangular parallelepiped of A \ times B \ times C, which is made by stacking A \ times B \ times C ...
```python A,B,C=map(int,input().split()) ANS=0 for i in [A,B,C]: if i%2==1: ANS+=1 if ANS>=2: print("Hom") else: print("Tem") ```
vfc_62081
{ "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": "1 1 10", "output": "Hom", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1 10", "output": "Tem\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1...
code_contests
verifiable_code
p02196 Queries with Six Inequeties
Solve the following coding problem using the programming language python: Queries with Six Inequeties Given a set of four integer pairs (a, b, c, d). The jth query determines if i exists, x_j <a_i <y_j <b_i and z_j <c_i <w_j <d_i. input N Q a_1 b_1 c_1 d_1 a_2 b_2 c_2 d_2 :: a_n b_n c_n d_n x_1 y_1 z_1 w_1 x_2 y_...
vfc_62085
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 1073741824, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n14 86 9 121\n3 34 3 34\n1 14 5 14\n1 9 1 9", "output": "No\nYes", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n14 86 9 121\n3 34 3 34\n0 14 5 14\n1 9 1 9", "output": "No\nYe...
code_contests
verifiable_code
p02350 RMQ and RUQ
Solve the following coding problem using the programming language python: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(s, t): report the minimum element in as, as+1, ..., at. Note that the initial val...
```python import math from collections import deque class SegmentTree: __slots__ = ["rank", "elem_size", "tree_size", "tree", "lazy", "default_value"] def __init__(self, a: list, default: int): self.default_value = default real_size = len(a) self.rank = math.ceil(math.log2(real_size))...
vfc_62089
{ "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 3\n1 0 0\n0 0 0 5\n1 0 0", "output": "2147483647\n5", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0 2\n1 1 2", "output": "1\n2", "type": "st...
code_contests
verifiable_code
chefhome
Solve the following coding problem using the programming language python: Our hardworking chef is bored of sleeping in his restaurants. He has decided to settle down. The first thing he must do is to find a suitable location to build a palatial home. Think of the city as a two-dimensional grid. There are N restaur...
```python t = int(raw_input()) while t > 0: t-=1 n = int(raw_input()) x=[] y=[] for i in range(n): l = map(int,raw_input().split()) x.append(l[0]) y.append(l[1]) if n % 2 == 1: print 1 else : x.sort() y.sort() print (x[n/2]-x[n/2-1]+1)*(y[n/2]-y[n/2-1]+1) ```
vfc_62097
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n0 0\n-1 0\n1 0\n0 1\n0 -1\n5\n31 11\n30 -41\n20 14\n25 18\n25 38\n2\n0 0\n1 1", "output": "1\n1\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5\n0 0\n-1 0\n1 0\n0 1\n0 -1\n5\...
code_contests
verifiable_code
integ
Solve the following coding problem using the programming language python: Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0. Chef can use two types of operations. The first type is to increase all the integers of t...
```python n = input() a = [] m = raw_input().split() total = 0 for i in range(n): k = int(m[i]) if k < 0: a.append(k) total += -k X = input() if X >= len(a): print total else: a.sort() ans = bar = 0; last = len(a)-1 while True: j = None for i in xrange(last,-1,-1)...
vfc_62105
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n-1 -2 -3\n2", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n-2 -2 -3\n2", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
nicequad
Solve the following coding problem using the programming language python: There are n points with integer coordinates. We can form different quadrangles out of them by taking four different points and connecting them with lines. Let’s call a quadrangle ABCD nice if and only if: Ax > 0 and Ay > 0; Bx > 0 and By < 0; C...
```python for t in range(int(raw_input())): a = [[0]*4 for x in range(4)] n = int(raw_input()) for i in range(n): (x, y) = (int(j) for j in raw_input().split()) index = -1 if x > 0: if y > 0: index = 0 elif y < 0: index = 1 ...
vfc_62109
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n6\n1 1\n2 2\n-1 -1\n-2 2\n2 -1\n-3 -4", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
seagm
Solve the following coding problem using the programming language python: Sereja and Dima play the game. The rules are as follows: Initially, there are n cards on the table, each card has a positive integer written on it. At the beginning Sereja writes down the number 0 on the sheet of paper. Then players pick cards f...
```python from fractions import gcd a = [] n = 0 dp1 = [[-1 for i in range(101)] for i in range(101)] dp2 = [[-1.0 for i in range(101)] for i in range(101)] def iswinning(g,taken): global n, a, dp1 if dp1[g][taken]!= -1: return dp1[g][taken] if g==1: dp1[g][taken] = 1 elif taken==n: dp1[g][taken] = 0...
vfc_62113
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5\n6 10 15 22 28\n5\n2 4 8 16 32\n4\n2 4 8 16\n4\n1 2 3 4", "output": "0 0.4000\n1 1.0000\n0 0.0000\n1 0.5833", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1000_E. We Need More Bosses
Solve the following coding problem using the programming language python: Your friend is developing a computer game. He has already decided how the game world should look like — it should consist of n locations connected by m two-way passages. The passages are designed in such a way that it should be possible to get f...
```python import sys from array import array # noqa: F401 def readline(): return sys.stdin.buffer.readline().decode('utf-8') def build_bridge_tree(v_count, edge_count, adj, edge_index): from collections import deque preorder = [0] parent, order, low = [0]+[-1]*v_count, [0]+[-1]*(v_count-1), [0]*v_coun...
vfc_62117
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n1 2\n2 3\n3 1\n4 1\n5 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n1 2\n4 3\n3 2\n", "output": "3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1025_F. Disjoint Triangles
Solve the following coding problem using the programming language python: A point belongs to a triangle if it lies inside the triangle or on one of its sides. Two triangles are disjoint if there is no point on the plane that belongs to both triangles. You are given n points on the plane. No two points coincide and no...
vfc_62121
{ "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": "6\n1 1\n2 2\n4 6\n4 5\n7 2\n5 3\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n0 -1000000000\n-5 -5\n5 -5\n-5 0\n5 0\n-2 2\n2 2\n", "output": "21\n", "type...
code_contests
verifiable_code
1045_H. 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_62125
{ "difficulty": "14", "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" }, { "fn_name": null, "input": "10\n1001\n0\n0\n1\n1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
106_B. Choosing Laptop
Solve the following coding problem using the programming language python: Vasya is choosing a laptop. The shop has n laptops to all tastes. Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties. I...
```python from sys import stdin,stdout from heapq import heapify,heappush,heappop,heappushpop from collections import defaultdict as dd, deque as dq,Counter as C from bisect import bisect_left as bl ,bisect_right as br from itertools import combinations as cmb,permutations as pmb from math import factorial as f ,ceil,g...
vfc_62129
{ "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": "5\n2100 512 150 200\n2000 2048 240 350\n2300 1024 200 320\n2500 2048 80 300\n2000 512 180 150\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n3511 981 276 808\n3317 2320 ...
code_contests
verifiable_code
1091_A. New Year and the Christmas Ornament
Solve the following coding problem using the programming language python: Alice and Bob are decorating a Christmas Tree. Alice wants only 3 types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have y yellow ornaments, b blue ornaments and r red ornaments. In Bob's opinion, a Christmas Tre...
```python y,b,r=map(int,input().split()) l,m,n=(1,2,3) while(l!=y and m!=b and n!=r): l+=1 m+=1 n+=1 s=l+m+n print(s) ```
vfc_62133
{ "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": "8 13 9\n", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 3 6\n", "output": "9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
110_D. Lucky Probability
Solve the following coding problem using the programming language python: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya and his friend Vasy...
```python #!/usr/bin/env python3 vl, vr, pl, pr, k = map(int, input().split()) lucky = [4, 7] sz = 0 for i in range(1, 9): base = 10 ** i psz, sz = sz, len(lucky) for j in [4 * base, 7 * base]: for pos in range(psz, sz): lucky.append(j + lucky[pos]) ans = 0 for i in range(0, len(lucky)...
vfc_62137
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 10 1 10 2\n", "output": "0.32000000000000000666\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
113_A. Grammar Lessons
Solve the following coding problem using the programming language python: Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be ...
```python s=input().split() if(len(s)==1): if(s[0].endswith("lios") or s[0].endswith("etr") or s[0].endswith("liala") or s[0].endswith("etra") or s[0].endswith("inites") or s[0].endswith("initis")): print("YES") else: print("NO") elif(s[0].endswith("lios") or s[0].endswith("etr")): n=len...
vfc_62141
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "petr\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "nataliala kataliala vetra feinites\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
117_D. Not Quick Transformation
Solve the following coding problem using the programming language python: Let a be an array consisting of n numbers. The array's elements are numbered from 1 to n, even is an array consisting of the numerals whose numbers are even in a (eveni = a2i, 1 ≤ 2i ≤ n), odd is an array consisting of the numberals whose number...
vfc_62149
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 5 10000\n1 2 2 2\n1 1 4 5\n1 1 2 5\n1 1 1 3\n1 2 5 5\n", "output": " 2\n0\n 0\n ...
code_contests
verifiable_code
1198_E. Rectangle Painting 2
Solve the following coding problem using the programming language python: There is a square grid of size n × n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs min(h, w) to color a rectangle of size h × w. You a...
```python import sys from collections import defaultdict class MaxFlow(object): def __init__(self): self.edges = defaultdict(lambda: defaultdict(lambda: 0)) def add_edge(self, u, v, capacity=float('inf')): self.edges[u][v] = capacity def bfs(self, s, t): open_q = [s] visi...
vfc_62153
{ "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": "10 2\n4 1 5 10\n1 4 10 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 6\n2 1 2 1\n4 2 4 3\n2 5 2 5\n2 3 5 3\n1 2 1 2\n3 2 5 3\n", "output": "3\n", "type":...
code_contests
verifiable_code
1215_D. Ticket Game
Solve the following coding problem using the programming language python: Monocarp and Bicarp live in Berland, where every bus ticket consists of n digits (n is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been era...
```python import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self...
vfc_62157
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n??\n", "output": "Bicarp\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0523\n", "output": "Bicarp\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1238_F. The Maximum Subtree
Solve the following coding problem using the programming language python: Assume that you have k one-dimensional segments s_1, s_2, ... s_k (each segment is denoted by two integers — its endpoints). Then you can build the following graph on these segments. The graph consists of k vertexes, and there is an edge between...
```python import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) ab = [list(map(int,input().split())) for i in range(n-1)] graph = [[] for i in range(n+1)] deg = [0]*(n+1) for a,b in ab: graph[a].append(b) graph[b].append(a) deg[a] += 1 deg[b] += 1 pnt = [...
vfc_62161
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n3 8\n4 9\n4 10\n", "output": "8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1257_A. Two Rival Students
Solve the following coding problem using the programming language python: You are the gym teacher in the school. There are n students in the row. And there are two rivalling students among them. The first one is in position a, the second in position b. Positions are numbered from 1 to n from left to right. Since the...
```python t = int(input()) for i in range(t): n, x, a, b = map(int, input().split(' ')) if((a==n and b==1)or(b==n and a==1)): print(n-1) elif x==0: print(abs(b-a)) else: ans=x+abs(b-a) if(ans>=n): print(n-1) else: print(ans) ...
vfc_62165
{ "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\n5 1 3 2\n100 33 100 1\n6 0 2 3\n", "output": "2\n99\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n53 1 3 2\n", "output": "2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1280_B. Beingawesomeism
Solve the following coding problem using the programming language python: You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant religion. There are onl...
```python """ This template is made by Satwik_Tiwari. python programmers can use this template :)) . """ #=============================================================================================== #importing some useful libraries. import sys import bisect import heapq from math import * from collections ...
vfc_62169
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP\n", "output": "2\n1\nMORTAL\n4\n", "type": ...
code_contests
verifiable_code
1300_A. Non-zero
Solve the following coding problem using the programming language python: Guy-Manuel and Thomas have an array a of n integers [a_1, a_2, ..., a_n]. In one step they can add 1 to any element of the array. Formally, in one step they can choose any integer index i (1 ≤ i ≤ n) and do a_i := a_i + 1. If either the sum or ...
```python import sys input = lambda: sys.stdin.readline().rstrip() t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) cnt = 0 for i in range(n): if a[i]==0: a[i] += 1 cnt += 1 if sum(a)==0: cnt += 1 print(cnt) ```
vfc_62173
{ "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\n3\n2 -1 -1\n4\n-1 0 0 1\n2\n-1 2\n3\n0 -2 1\n", "output": "1\n2\n0\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n0\n", "output": "1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1343_A. Candies
Solve the following coding problem using the programming language python: Recently Vova found n candy wrappers. He remembers that he bought x candies during the first day, 2x candies during the second day, 4x candies during the third day, ..., 2^{k-1} x candies during the k-th day. But there is an issue: Vova remember...
```python import math if __name__ == "__main__": n = int(input()) for i in range(n): m = int(input()) res = 1 test = 0 while(m > 2**res -1): res += 1 if m% (2**res -1) == 0: test = m//(2**res -1) break x = test ...
vfc_62181
{ "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": "7\n3\n6\n7\n21\n28\n999999999\n999999984\n", "output": "1\n2\n1\n7\n4\n333333333\n333333328\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n6\n", "output": "2\n", "type": "s...
code_contests
verifiable_code
1385_B. Restore the Permutation by Merger
Solve the following coding problem using the programming language python: A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutation p[...
```python n=int(input()) b=[] for i in range(n): x=int(input()) a=[int(i) for i in input().split()] d={} for j in range(len(a)): if a[j] in d: d[a[j]]+=1 else: d[a[j]]=1 b.append(list(d.keys())) for i in range(len(b)): for j in range(len(b[i])): print(b[i][j],end=" ") print() ...
vfc_62189
{ "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": "5\n2\n1 1 2 2\n4\n1 3 1 4 3 4 2 2\n5\n1 2 1 2 3 4 3 5 4 5\n3\n1 2 3 1 2 3\n4\n2 3 2 4 1 3 4 1\n", "output": "1 2 \n1 3 4 2 \n1 2 3 4 5 \n1 2 3 \n2 3 4 1 \n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1406_E. Deleting Numbers
Solve the following coding problem using the programming language python: This is an interactive problem. There is an unknown integer x (1≤ x≤ n). You want to find x. At first, you have a set of integers \{1, 2, …, n\}. You can perform the following operations no more than 10000 times: * A a: find how many number...
vfc_62193
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n\n2\n\n4\n\n0", "output": "B 2\nA 2\nA 4\nB 3\nA 3\nA 9\nC 18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100000 62016\n", "output": "62016 112\n", "type": "stdin_stdou...
code_contests
verifiable_code
1427_F. Boring Card Game
Solve the following coding problem using the programming language python: When they are bored, Federico and Giada often play the following card game with a deck containing 6n cards. Each card contains one number between 1 and 6n and each number appears on exactly one card. Initially the deck is sorted, so the first c...
vfc_62197
{ "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": "5\n1 2 3 4 5 9 11 12 13 18 19 20 21 22 23\n", "output": "1 2 3\n6 7 8\n4 5 9\n25 26 27\n11 12 13\n10 14 15\n18 19 20\n28 29 30\n21 22 23\n16 17 24\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1474_D. Cleaning
Solve the following coding problem using the programming language python: During cleaning the coast, Alice found n piles of stones. The i-th pile has a_i stones. Piles i and i + 1 are neighbouring for all 1 ≤ i ≤ n - 1. If pile i becomes empty, piles i - 1 and i + 1 doesn't become neighbouring. Alice is too lazy to ...
```python ''' Auther: ghoshashis545 Ashis Ghosh College: jalpaiguri Govt Enggineering College ''' from os import path from io import BytesIO, IOBase import sys from heapq import heappush,heappop from functools import cmp_to_key as ctk from collections import deque,Counter,defaultdict as dd from bisect import ...
vfc_62205
{ "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": "5\n3\n1 2 1\n3\n1 1 2\n5\n2 2 2 1 3\n5\n2100 1900 1600 3000 1600\n2\n2443 2445\n", "output": "\nYES\nYES\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n13\n1 2 2 3 1 3 2 ...
code_contests
verifiable_code
14_A. Letter
Solve the following coding problem using the programming language python: A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in ...
```python n,m = map(int, input().split()) data = [] for i in range(n): data.append(list(input())) boundary = [-1,-1,-1,-1] for i in range(n): for j in range(m): if data[i][j] == '*': if boundary[0]>j or boundary[0]==-1: boundary[0] = j if boundary[1]<j or bounda...
vfc_62209
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 7\n.......\n..***..\n..*....\n..***..\n..*....\n..***..\n", "output": "***\n*..\n***\n*..\n***\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n***\n*.*\n***\n", "output": "***...
code_contests
verifiable_code
1523_F. Favorite Game
Solve the following coding problem using the programming language python: <image> After William is done with work for the day, he enjoys playing his favorite video game. The game happens in a 2D world, starting at turn 0. William can pick any cell in the game world and spawn in it. Then, each turn, William may remai...
vfc_62213
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n1 1\n2 3\n5 2\n2 2 12\n5 1 4\n6 2 11\n3 5 10\n", "output": "\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 20\n8054 2992\n2546 5359\n2851 9668\n6007 5359\n9675 9171\n8399 7777\...
code_contests
verifiable_code
155_E. Double Profiles
Solve the following coding problem using the programming language python: You have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user. The social network contains n registered profiles, numbered from 1 to n...
vfc_62217
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2\n2 3\n1 3\n", "output": " 3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
177_E1. Space Voyage
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is th...
```python n, c = map(int, input().split()) a = [] b = [] for i in range(n): aa, bb = map(int, input().split()) a.append(aa) b.append(bb) def all_zero(): for aa in a: if aa > 0: return False return True def days(x): c = 0 for aa, bb in zip(a, b): c += 1 + aa*x//bb return...
vfc_62221
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 5\n1 5\n2 4\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "71 100\n1 92\n1 94\n1 97\n1 95\n1 100\n1 100\n1 98\n1 99\n1 98\n1 96\n1 97\n1 93\n1 97\n1 92\n1 91\n1 96\n1 9...
code_contests
verifiable_code
199_A. Hexadecimal's theorem
Solve the following coding problem using the programming language python: Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers. Let's remember how Fibonacci numbers...
```python import sys s=sys.stdin.readline().strip() s=int(s) def fabo(a): f0=0 f1=1 f2=1 while f2<a: f0=f1 f1=f2 f2=f1+f0 if a==f2: return print(f1,f0,0) else: pass if s==0: print(0,0,0) if s==1: print(0,0,1) else: fabo...
vfc_62225
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n", "output": "0 0 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\n", "output": "0 0 13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4...
code_contests
verifiable_code
245_H. Queries for Number of Palindromes
Solve the following coding problem using the programming language python: You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also are q queries, each query is described by two integers li, ri (1 ≤ li ≤ ri ≤ |s|). The answer to the query is the number of substrings of str...
```python import os import sys from io import BytesIO, IOBase def main(): # n, k = map(int, input().split()) # s = input() s=input() n=len(s) palin = [[0 for _ in range(n)] for _ in range(n)] dp = [[0 for _ in range(n)] for _ in range(n)] for sz in range(n): for i in range(n - sz): ...
vfc_62233
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "caaaba\n5\n1 1\n1 4\n2 3\n4 6\n4 5\n", "output": "1\n7\n3\n4\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ab\n100\n1 2\n1 2\n1 1\n1 1\n1 1\n1 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 1\n1 1\n1 ...
code_contests
verifiable_code
271_A. Beautiful Year
Solve the following coding problem using the programming language python: It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits. Now you are suggested to solve the following problem: given a year number, find the...
```python from collections import Counter n=int(input()) n1=n+1 while(True): s=list(str(n1)) c=Counter(s) if(len(c)==len(s)): print("".join(s)) break n1=n1+1 ```
vfc_62237
{ "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": "1987\n", "output": "2013\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2013\n", "output": "2014\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
294_C. Shaass and Lights
Solve the following coding problem using the programming language python: There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switche...
```python from math import factorial import re in1 = [int(x) for x in re.split("\\s", input())] in2 = [int(x) for x in re.split("\\s", input())] in2.append(0) in2.append(in1[0]+1) in2.sort() lights = [] for x in range(len(in2)-1): lights.append(in2[x+1]-in2[x]-1) lightsTotal = sum(lights) possTotal = factorial...
vfc_62241
{ "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": "11 2\n4 8\n", "output": "6720", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1 4\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
318_A. Even Odds
Solve the following coding problem using the programming language python: Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers...
```python n, m = map(int, input().split()) print((m * 2) - 1 if m <= n - (n//2) else (m - (n - (n // 2))) * 2) # UBCF # CodeForcesian # ♥ # تو شرایطی که همه درگیر خودشون و کاراشون شدن من بدون اینکه متوجه شم درگیرت شدم ```
vfc_62245
{ "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": "7 7\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
342_A. Xenia and Divisors
Solve the following coding problem using the programming language python: Xenia the mathematician has a sequence consisting of n (n is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three a, b, c the following conditions held...
```python n = int(input()) // 3 x = input() c1 = x.count('1') c2 = x.count('2') c3 = x.count('3') c4 = x.count('4') c6 = x.count('6') if c1 != n or c2 < c4 or c1 != c2 + c3 or c1 != c4 + c6: print(-1) exit() print('1 2 4\n' * c4 + '1 3 6\n' * c3 + '1 2 6\n' * (n - c4 - c3)) ```
vfc_62249
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n2 2 1 1 4 6\n", "output": "1 2 4\n1 2 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 1 1 2 2 2\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
365_C. Matrix
Solve the following coding problem using the programming language python: You have a string of decimal digits s. Let's define bij = si·sj. Find in matrix b the number of such rectangles that the sum bij for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is ...
```python def divisors(x): def f(y, q): t = -len(r) while not y % q: y //= q for i in range(t, 0): r.append(r[t] * q) return y r, p = [1], 7 x = f(f(f(x, 2), 3), 5) while x >= p * p: for s in 4, 2, 4, 2, 4, 6, 2, 6: if ...
vfc_62253
{ "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\n12345\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "16\n439873893693495623498263984765\n", "output": "40\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
389_B. Fox and Cross
Solve the following coding problem using the programming language python: Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'. A cross on the board is a connected set of exactly five cells of the board that looks like a cross. ...
```python n=int(input()) L=[input() for i in range(n)] L1=[[0 for i in range(n)] for j in range(n)] try : for i in range(n) : for j in range(n) : if L[i][j]=="#" and L1[i][j]==0 : if L1[i+1][j]==L1[i+2][j]==L1[i+1][j+1]==L1[i+1][j-1]==0 and L[i+1][j]==L[i+2][j]==L[i+1][j+1]==L[i+...
vfc_62257
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n.#....\n####..\n.####.\n.#.##.\n######\n.#..#.\n", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n.#...\n####.\n.####\n...#.\n.....\n", "output": "YES", "ty...
code_contests
verifiable_code
409_E. Dome
Solve the following coding problem using the programming language python: <image> Input The input contains a single floating-point number x with exactly 6 decimal places (0 < x < 5). Output Output two integers separated by a single space. Each integer should be between 1 and 10, inclusive. If several solutions exi...
```python import sys from math import sqrt, pi X = float(input()) def rad_len(a, h, c): x = c * a/2 # y = c * sqrt((a / 2)**2 + h**2) y = c * h return sqrt((x - a/2)**2 + (y - 0)**2) def get_max_radius(a, h): lo = 0.0 hi = 1.0 while abs(lo - hi) > 1e-9: # print(lo, hi, rad_len(a,...
vfc_62261
{ "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": "4.024922\n", "output": "9 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2.572479\n", "output": "6 5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
436_F. Banners
Solve the following coding problem using the programming language python: All modern mobile applications are divided into free and paid. Even a single application developers often release two versions: a paid version without ads and a free version with ads. <image> Suppose that a paid version of the app costs p (p i...
vfc_62265
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n3 1\n2 2\n1 3\n", "output": " 0 0\n 3 0\n ...
code_contests
verifiable_code
45_B. School
Solve the following coding problem using the programming language python: There are n students studying in the 6th grade, in group "B" of a berland secondary school. Every one of them has exactly one friend whom he calls when he has some news. Let us denote the friend of the person number i by g(i). Note that the frie...
```python import sys range = xrange input = raw_input inp = [int(x) for x in sys.stdin.read().split()]; ii = 0 n = inp[ii]; ii += 1 m = inp[ii]; ii += 1 P0 = [x - 1 for x in inp[ii: ii + n]]; ii += n V = [x - 1 for x in inp[ii: ii + m]]; ii += m B = inp[ii: ii + m]; ii += m P = [P0] for _ in range(19): Pprev = ...
vfc_62269
{ "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 4\n2 3 1\n1 2 3 4\n1 2 3 4\n", "output": "1\n1\n1\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 6\n7 6 4 2 3 5 5 7\n10 4 3 8 9 1\n1 1 1 2 2 2\n", "output": "1\n1\n1\n2\n1\n1...
code_contests
verifiable_code
482_A. Diverse Permutation
Solve the following coding problem using the programming language python: Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, that th...
```python s = input() arr = s.split() n = int(arr[0]) k = int(arr[1]) print(1,end='') i = 2 while i in range(2,k+1): if i % 2 == 0: print('',n - i//2 + 1,end='') else: print('',(i+1)//2,end='') i = i + 1 if k % 2 == 0: x = n - k//2 i = k while i in range(k,n): print('',x,end='') x = x - 1 i = i + 1 el...
vfc_62273
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n", "output": "1 3 2 4 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n", "output": "1 3 2 ", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
506_A. Mr. Kitayuta, the Treasure Hunter
Solve the following coding problem using the programming language python: The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are n gems...
vfc_62277
{ "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 10\n10\n21\n27\n27\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 7\n8\n8\n9\n16\n17\n17\n18\n21\n23\n24\n24\n26\n30\n", "output": "4\n", "type": "stdin_...
code_contests
verifiable_code
529_E. The Art of Dealing with ATM
Solve the following coding problem using the programming language python: ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiar...
```python n_k = input() n_k = n_k.split(" ") n = int(n_k[0]) k = int(n_k[1]) ais = input() ais = ais.split(" ") q = int(input()) pares = {} for a in ais: a = int(a) for i in range(k): p = int((i+1)*a) if (p not in pares) or (i+1 < pares[p]): pares[p] = i+1 m = 1000000000 for i...
vfc_62281
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 20\n10 50 100 500 1000 5000\n8\n4200\n100000\n95000\n96000\n99000\n10100\n2015\n9950\n", "output": "6\n20\n19\n20\n-1\n3\n-1\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n1 2 ...
code_contests
verifiable_code
555_B. Case of Fugitive
Solve the following coding problem using the programming language python: Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water. The only dry land there is an archipelago of n narrow islands located in a row. For more com...
```python #!/usr/bin/env python # 556D_fug.py - Codeforces.com 556D Fug quiz # # Copyright (C) 2015 Sergey # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses...
vfc_62285
{ "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": "2 1\n1 1\n1000000000000000000 1000000000000000000\n999999999999999999\n", "output": "Yes\n1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 4\n7 8\n9 10\n12 14\n4 5 3 8\n", "...
code_contests
verifiable_code
581_A. Vasya the Hipster
Solve the following coding problem using the programming language python: One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks. According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue on...
```python a,b=map(int,input().split()) countd=0 counts=0 while a>0 or b>0: if a>0 and b>0: countd=countd+1 a=a-1 b=b-1 elif a>=2 and b==0: counts=counts+1 a=a-2 elif a==0 and b>=2: counts=counts+1 b=b-2 else: a=0 b=0 print(countd,co...
vfc_62289
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n", "output": "2 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1\n", "output": "1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 3...
code_contests
verifiable_code
602_E. Kleofáš and the n-thlon
Solve the following coding problem using the programming language python: Kleofáš is participating in an n-thlon - a tournament consisting of n different competitions in n different disciplines (numbered 1 through n). There are m participants in the n-thlon and each of them participates in all competitions. In each o...
vfc_62293
{ "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": "5 5\n1\n2\n3\n4\n5\n", "output": "2.7500000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 10\n2\n1\n2\n1\n", "output": "1.0000000000000\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
64_E. Prime Segment
Solve the following coding problem using the programming language python: Positive integer number x is called prime, if it has exactly two positive integer divisors. For example, 2, 3, 17, 97 are primes, but 1, 10, 120 are not. You are given an integer number n, find the shortest segment [a, b], which contains n (i.e...
vfc_62301
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n", "output": "7 11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "97\n", "output": "97 97\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
698_F. Coprime Permutation
Solve the following coding problem using the programming language python: Two positive integers are coprime if and only if they don't have a common divisor greater than 1. Some bear doesn't want to tell Radewoosh how to solve some algorithmic problem. So, Radewoosh is going to break into that bear's safe with solutio...
vfc_62309
{ "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": "6\n0 0 1 2 0 0\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 0 1 2 0\n", "output": " 2\n", ...