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
1499_E. Chaotic Merge
Solve the following coding problem using the programming language python: You are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s. Let's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in some order. A merge z is...
```python from bisect import * from collections import * from math import gcd,ceil,sqrt,floor,inf from heapq import * from itertools import * from operator import add,mul,sub,xor,truediv,floordiv from functools import * #------------------------------------------------------------------------ import os import sys fr...
vfc_58461
{ "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": "code\nforces\n", "output": "\n1574\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aaa\nbb\n", "output": "\n24\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1550_C. Manhattan Subarrays
Solve the following coding problem using the programming language python: Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|. Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r). Let's...
```python A=[] t=int(input()) def isg(l,r): for i in range(l,r+1): for j in range(i+1,r+1): for k in range(j+1,r+1): if(A[i]>=A[j] and A[j]>=A[k]): return False if(A[i]<=A[j] and A[j]<=A[k]): return False return True for...
vfc_58469
{ "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\n4\n2 4 1 3\n5\n6 9 1 9 6\n2\n13 37\n", "output": "10\n12\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
197_C. Lexicographically Maximum Subsequence
Solve the following coding problem using the programming language python: You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2... s|s...
```python from collections import Counter s = input() c = Counter(s) cur_char = 'z' for ch in s: while c[cur_char] == 0: cur_char = chr(ord(cur_char) - 1) if ch == cur_char: print(cur_char, end='') c[ch] -= 1 ```
vfc_58477
{ "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": "abbcbccacbbcbaaba\n", "output": "cccccbba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ababba\n", "output": "bbba\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
220_D. Little Elephant and Triangle
Solve the following coding problem using the programming language python: The Little Elephant is playing with the Cartesian coordinates' system. Most of all he likes playing with integer points. The Little Elephant defines an integer point as a pair of integers (x; y), such that 0 ≤ x ≤ w and 0 ≤ y ≤ h. Thus, the Litt...
vfc_58481
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n", "output": "36\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n", "output": "240\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "975 ...
code_contests
verifiable_code
244_E. Colorado Potato Beetle
Solve the following coding problem using the programming language python: Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up one square meter. Old McDonald knows that the Colorado potato beetle is about to i...
vfc_58485
{ "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\nR 10\nD 2\nL 7\nU 9\nD 2\nR 3\nD 10\n", "output": "52", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nR 8\nU 9\nL 9\nD 8\nL 2\n", "output": "101", "type": "stdin_stdout" ...
code_contests
verifiable_code
26_C. Parquet
Solve the following coding problem using the programming language python: Once Bob decided to lay a parquet floor in his living room. The living room is of size n × m metres. Bob had planks of three types: a planks 1 × 2 meters, b planks 2 × 1 meters, and c planks 2 × 2 meters. Help Bob find out, if it is possible to ...
```python n, m, a, b, c = map(int, input().split()) mat = [0]*n for i in range(n): mat[i] = [0] * m n1 = [min(n*m//4, c), min(m//2 * n, a), min(n//2 * m, b)] p = ['c', 'a', 'b'] z = ['d', 'e', 'f', 'g'] z1 = ['m', 'n', 'u', 'o'] z2 = ['p', 'q', 'r', 'w'] #print(n1) def fill(h, w): if h <= 0 or w <= 0: r...
vfc_58489
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 6 2 2 1\n", "output": "aabbab\naaccab\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4 10 10 10\n", "output": "aabb\naabb\nbbaa\nbbaa\n", "type": "stdin_stdout" } ] ...
code_contests
verifiable_code
292_E. Copying Data
Solve the following coding problem using the programming language python: We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly. More formall...
```python import sys ''' SEGMENT TREE Assign ''' class SegmTree(): ''' - modify elements on interval - get single element ''' def __init__(self, size): N = 1 while N < size: N <<= 1 self.N = N self.tree = [0] * (2*N) def modify_range(self, l, r, value...
vfc_58493
{ "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 10\n1 2 0 -1 3\n3 1 5 -2 0\n2 5\n1 3 3 3\n2 5\n2 4\n2 1\n1 2 1 4\n2 1\n2 4\n1 4 2 1\n2 2\n", "output": "0\n3\n-1\n3\n2\n3\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10\n-1 1 ...
code_contests
verifiable_code
316_G1. Good Substrings
Solve the following coding problem using the programming language python: Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is...
```python def count(p, s): start = 0 c = 0 while True: try: pos = s.index(p, start) c += 1 start = pos + 1 except ValueError: return c s = input() n = int(input()) pravs = [] for i in range(n): p, l, r = input().split() l = int(l); r...
vfc_58497
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "aaab\n2\naa 0 0\naab 1 1\n", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
340_C. Tourist Problem
Solve the following coding problem using the programming language python: Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a...
```python import math n = int(input()) l = [int(x) for x in input().split()] a1 = sum(l) a2 = n a3 = 0 temp = 0 l.sort() for i in range(n): temp += l[n-i-1] a3-=(a1-temp) a3+=(n-i-1)*(l[n-i-1]) a1 = a1+a3+a3 a4 = math.gcd(a1, a2) print(a1//a4, a2//a4) ```
vfc_58501
{ "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\n2 3 5\n", "output": "22 3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
387_D. George and Interesting Graph
Solve the following coding problem using the programming language python: George loves graphs. Most of all, he loves interesting graphs. We will assume that a directed graph is interesting, if it meets the following criteria: * The graph doesn't contain any multiple arcs; * There is vertex v (we'll call her the...
```python # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def matching(n,m,path): # Hopkrocft Karp O(EV^0.5) match1 = [-1]*n match2 = [-1]*m for node in range(n): for nei in path[node]: if match2[nei] == -1: ...
vfc_58509
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n2 2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6\n1 1\n2 2\n3 1\n3 2\n2 3\n3 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
408_B. Garland
Solve the following coding problem using the programming language python: Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter. The garland must c...
```python #!/usr/bin/python import re import inspect from sys import argv, exit def rstr(): return input() def rstrs(splitchar=' '): return [i for i in input().split(splitchar)] def rint(): return int(input()) def rints(splitchar=' '): return [int(i) for i in rstrs(splitchar)] def varnames(obj, nam...
vfc_58513
{ "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": "aaabbac\naabbccac\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "a\nz\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
435_C. Cardiogram
Solve the following coding problem using the programming language python: In this problem, your task is to use ASCII graphics to paint a cardiogram. A cardiogram is a polyline with the following corners: <image> That is, a cardiogram is fully defined by a sequence of positive integers a1, a2, ..., an. Your task i...
```python n = int(input()) a_list = list(map(int, list(str(input()).split(" ")))) out = [' '*(sum(a_list))]*2000 cur,pref_size = 1000, 0 cur_max, cur_min = 1000,1000 for k in range(n): for i in range(a_list[k]): ind = pref_size + i if k % 2 == 0: out[cur] = out[cur][:ind] + '/' + out[cu...
vfc_58517
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 1 2 5 1\n", "output": " /\\ \n /\\/ \\ \n / \\ \n/ \\ \n \\/", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 5 1\n", "output": "/\\ \...
code_contests
verifiable_code
457_E. Flow Optimality
Solve the following coding problem using the programming language python: There is a computer network consisting of n nodes numbered 1 through n. There are links in the network that connect pairs of nodes. A pair of nodes may have multiple links between them, but no node has a link to itself. Each link supports unlim...
vfc_58521
{ "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 5\n1 7 2 1\n2 3 1 1\n4 5 1 0\n6 1 10 0\n1 3 1 1\n", "output": "BAD 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4\n1 3 31 41\n1 5 59 26\n2 6 53 58\n4 6 97 93\n", "output": "UN...
code_contests
verifiable_code
47_C. Crossword
Solve the following coding problem using the programming language python: Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontall...
```python from itertools import permutations v = [] for p in permutations(input() for i in range(6)): if len(p[1]) != len(p[0]) + len(p[2]) - 1 or len(p[4]) != len(p[3]) + len(p[5]) - 1: continue elif p[0][0] != p[3][0] or p[0][-1] != p[4][0]: continue elif p[1][0] != p[3][-1] or p[1][len(p[...
vfc_58525
{ "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": "NOD\nBAA\nYARD\nAIRWAY\nNEWTON\nBURN\n", "output": "BAA...\nU.I...\nR.R...\nNEWTON\n..A..O\n..YARD\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
504_C. Misha and Palindrome Degree
Solve the following coding problem using the programming language python: Misha has an array of n integers indexed by integers from 1 to n. Let's define palindrome degree of array a as the number of such index pairs (l, r)(1 ≤ l ≤ r ≤ n), that the elements from the l-th to the r-th one inclusive can be rearranged in s...
vfc_58529
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 5 2 5 2\n", "output": " 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 2 2\n", "output": " ...
code_contests
verifiable_code
528_A. Glass Carving
Solve the following coding problem using the programming language python: Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of w...
```python # import itertools # import bisect # import math from collections import defaultdict, Counter import os import sys from io import BytesIO, IOBase # sys.setrecursionlimit(10 ** 5) ii = lambda: int(input()) lmii = lambda: list(map(int, input().split())) slmii = lambda: sorted(map(int, input().split())) li = la...
vfc_58533
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3 4\nH 2\nV 2\nV 3\nV 1\n", "output": "8\n4\n4\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
57_C. Array
Solve the following coding problem using the programming language python: Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him crazy. F...
```python #love python :) #medo journy to icpc n = int(input()) m = int(1e9 + 7) p = 1 for i in range(1, n + 1): p *= 2 * n - i p *= pow(i, m - 2, m) p %= m print((2 * p - n) % m) ```
vfc_58541
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "17\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
601_B. Lipshitz Sequence
Solve the following coding problem using the programming language python: A function <image> is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all <image>. We'll deal with a more... discrete version of this term. For an array <image>, we define i...
```python f = lambda: map(int, input().split()) n, m = f() t = list(f()) p = [1e9] + [abs(b - a) for a, b in zip(t, t[1:])] + [1e9] L, R = [0] * n, [0] * n for i in range(1, n): j = n - i x, y = i - 1, j + 1 a, b = p[i], p[j] while a > p[x]: x = L[x] while b >= p[y]: y = R[y] L[i], R[j] = x, y f...
vfc_58545
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 6\n5 7 7 4 6 6 2\n1 2\n2 3\n2 6\n1 7\n4 7\n3 5\n", "output": "2\n0\n22\n59\n16\n8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 4\n1 5 2 9 1 3 4 2 1 7\n2 4\n3 8\n7 10\n1 9\n", ...
code_contests
verifiable_code
623_E. Transforming Sequence
Solve the following coding problem using the programming language python: Let's define the transformation P of a sequence of integers a1, a2, ..., an as b1, b2, ..., bn, where bi = a1 | a2 | ... | ai for all i = 1, 2, ..., n, where | is the bitwise OR operation. Vasya consequently applies the transformation P to all ...
vfc_58549
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n", "output": "48\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
645_D. Robot Rapping Results Report
Solve the following coding problem using the programming language python: While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers...
```python from collections import defaultdict class RobotRapping(): def __init__(self, n, m, battles): self.n, self.m = n, m self.battles = battles def generate_graph(self, k): edge_map = defaultdict(list) rev_map = defaultdict(list) for i in range(k): edge...
vfc_58553
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2\n3 2\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n2 1\n1 3\n2 3\n4 2\n4 3\n", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
73_B. Need For Brake
Solve the following coding problem using the programming language python: Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game! n racers take part in the cham...
```python class Racer: def __init__(self, name, points): self.name = name self.points = points def __str__(self): return '%s %d' % (self.name, self.points) n = int(input()) best = n * [ None ] worst = n * [ None ] for i in range(n): name, points = input().split() points = int(po...
vfc_58569
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nteama 10\nteamb 20\nteamc 40\n2\n10 20\nteama\n", "output": "2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nteama 10\nteamb 10\n2\n10 10\nteamb\n", "output": "2 2", "t...
code_contests
verifiable_code
786_B. Legacy
Solve the following coding problem using the programming language python: Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are n planets in their universe numbered from 1 to n. Rick is in plan...
vfc_58577
{ "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 5 1\n2 3 2 3 17\n2 3 2 2 16\n2 2 2 3 3\n3 3 1 1 12\n1 3 3 17\n", "output": "0 28 12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 1\n3 4 1 3 12\n2 2 3 4 10\n1 2 4 16\n", "out...
code_contests
verifiable_code
808_A. Lucky Year
Solve the following coding problem using the programming language python: Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are...
```python import math a = int(input()) #print(math.log(a)) b = int(10 ** ((math.log(a+1) // math.log(10)))) #print(b) total = b while total <= a: total += b print(str(total-a)) ```
vfc_58581
{ "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": "4000\n", "output": "1000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "201\n...
code_contests
verifiable_code
832_B. Petya and Exam
Solve the following coding problem using the programming language python: It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one.. There is a glob pattern in the statements (a string ...
```python a=input() s=input() k=int(input()) def qw(c): t=True w=-1 if len(s)>len(c)+1: t=False try: for j in range(len(s)): w+=1 if s[j]=='?': if c[w] not in a: t=False elif s[j]=='*': b=len(c)-len(s)+1 for e in c[j:j+b]: if e in a: t=False w+=b-1 else: if s[j]!=c[w]: ...
vfc_58585
{ "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": "ab\na?a\n2\naaa\naab\n", "output": "YES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abc\na?a?a*\n4\nabacaba\nabaca\napapa\naaaaax\n", "output": "NO\nYES\nNO\nYES\n", "t...
code_contests
verifiable_code
852_I. Dating
Solve the following coding problem using the programming language python: This story is happening in a town named BubbleLand. There are n houses in BubbleLand. In each of these n houses lives a boy or a girl. People there really love numbers and everyone has their favorite number f. That means that the boy or girl tha...
vfc_58589
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 0 0 1 0 1 0\n9 2 9 2 2 9 9\n2 6\n1 2\n4 2\n6 5\n3 6\n7 4\n2\n1 3\n7 5\n", "output": "2\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
877_D. Olya and Energy Drinks
Solve the following coding problem using the programming language python: Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formally, her room can be represented as a field of n × m cells, each cell of which is empty or littered with cans. Olya drank a lot of en...
```python from collections import deque n, m, k = map(int, input().split()) INF = float("inf") d = [[INF] * m for _ in range(n)] t = [[] for i in range(n)] for i in range(n): a = list(input()) t[i] = a sx, sy, gx, gy = map(int, input().split()) sx, sy, gx, gy = sx - 1, sy - 1, gx - 1, gy - 1 def bfs(): q...
vfc_58593
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4 4\n....\n###.\n....\n1 1 3 1\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 1\n.#\n#.\n1 1 2 2\n", "output": "-1\n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
900_E. Maximum Questions
Solve the following coding problem using the programming language python: Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form "abab...", namely there are letters 'a' on odd positions and letters 'b' on even positi...
```python n = int(input()); s = input(); m = int(input()) a = [0]*(n+2); b = [0]*(n+2); q = [0]*(n+1); dp = [(0, 0)]*(n+2) for i in range(0, n): b[i] = b[i-2]+(s[i] == 'b') a[i] = a[i-2]+(s[i] == 'a') q[i] = q[i-1]+(s[i] == '?') for i in range(n-m, -1, -1): dp[i] = dp[i+1] i_b = 1 if m%2 == 1 else 2 i_a...
vfc_58597
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\nab??ab???\n3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nbb?a?\n1\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
923_C. Perfect Security
Solve the following coding problem using the programming language python: Alice has a very important message M consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key K of the length equal to th...
```python def add(x): global tree now = 0 tree[now][2] += 1 for i in range(29, -1, -1): bit = (x>>i)&1 if tree[now][bit]==0: tree[now][bit]=len(tree) tree.append([0, 0, 0]) now = tree[now][bit] tree[now][2] += 1 def find_min(x): global tree ...
vfc_58601
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951\n226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667\n", "output": "\n128...
code_contests
verifiable_code
950_E. Data Center Maintenance
Solve the following coding problem using the programming language python: BigData Inc. is a corporation that has n data centers indexed from 1 to n that are located all over the world. These data centers provide storage for client data (you can figure out that client data is really big!). Main feature of services off...
vfc_58605
{ "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": "3 3 5\n4 4 0\n1 3\n3 2\n3 1\n", "output": "1\n3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5 4\n2 1 0 3\n4 3\n3 2\n1 2\n1 4\n1 3\n", "output": "4\n1 2 3 4 ", "type": "std...
code_contests
verifiable_code
979_A. Pizza, Pizza, Pizza!!!
Solve the following coding problem using the programming language python: Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems. Today is Shiro's birthday. She really loves pizza so she...
```python n = int(input()) + 1 if n == 1: print(0) exit() if n % 2 == 0: print(n //2) else: print(n) ```
vfc_58609
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 128000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
999_B. Reversing Encryption
Solve the following coding problem using the programming language python: A string s of length n can be encrypted by the following algorithm: * iterate over all divisors of n in decreasing order (i.e. from n to 1), * for each divisor d, reverse the substring s[1 ... d] (i.e. the substring which starts at positio...
```python l = int(input()) s = list(input()) for i in range(2, l + 1): if l % i > 0: continue s[:i] = s[i - 1::-1] print(''.join(s)) ```
vfc_58613
{ "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": "10\nrocesfedoc\n", "output": "codeforces\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nz\n", "output": "z\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
benny-and-gifts-marcheasy-3
Solve the following coding problem using the programming language python: View Russian Translation Little pig Benny has just taken a shower. Now she is going to buy some gifts for her relatives. But the problem is that Benny doesn't know how to reach to the gift shop. Her friend Mike has created a special set of inst...
```python inp=raw_input() x,y=0,0 icy={} icy[(0,0)]=1 count=0 for i in inp: if i=='L': y=y-1 if(icy.get((x,y),0)>0): count=count+1 else: icy[(x,y)]=1 if i=='R': y=y+1 if(icy.get((x,y),0)>0): count=count+1 else: icy[(x,y)]=1 if i=='U': x=x-1 if(icy.get((x,y),0)>0): count=coun...
vfc_58617
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "RRULDL\n\nSAMPLE", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "RDUUDLRLDLDLDLRUUDLRLDDURUUUUUDUDUDDDDRLLLLLLRRRRLLL", "output": "33\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
coloring-problem
Solve the following coding problem using the programming language python: In 1976 the “Four Color Map Theorem” was proven with the assistance of a computer. This theorem states that every map can be colored using only four colors, in such a way that no region is colored using the same color as a neighbor region. Here...
```python import math class Graph(object): def __init__(self, N) : self.V = N self.gr = [[] for i in range(0, self.V + 1)] def addEdge(self, x, y): self.gr[x].append(y) self.gr[y].append(x) def V(self): return self.V def adj(self, x): return self.gr[x] def dfs(G, curr, prev, vis, ans): vis[cu...
vfc_58621
{ "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\n3\n0 1\n1 2\n2 0\n\nSAMPLE", "output": "NOT BICOLORABLE.", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3\n3\n0 1\n1 2\n2 0\n3\n2\n0 1\n1 2\n9\n8\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7...
code_contests
verifiable_code
ferbs-stripes-1
Solve the following coding problem using the programming language python: Ferb purchased some colors to decorate his backyard fence. The fence is big (it has to be, as the backyard once hosted a circus, and a roller coaster ride !) and he had to buy multiple boxes of same color. He has a design in mind to paint, its s...
```python t = input(); while(t > 0): n = input(); m = f = 0; a = [int(i) for i in raw_input().split()]; for i in range(0, n): if(a[i] == m): f = 1; m = a[i]; if(f == 0): print "can do"; else: print "bad luck"; t -= 1; ```
vfc_58625
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 3 1 3 1\n6\n1 3 1 3 1 1\n\nSAMPLE", "output": "can do\nbad luck\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1\n666\n4\n1 2 1 3\n10\n1 2 3 4 5 6 7 8 9 10\n50\n1 2 3 4 5 6 7 8...
code_contests
verifiable_code
i-dont-just-scratch-mr-hahn-4
Solve the following coding problem using the programming language python: Mr. Hahn, our very own DJ, was seeing Chester and Mike fighting over such questions lately. Being a geek himself, he thought of showing off his skills and gave the both of them a question. He gave them a single positive integer, N. For all the...
```python a=[1, 3, 20, 143, 1442, 14377, 143071, 1418854, 14255667, 145674808, 1492609148] n=input() print 10**n-a[n],a[n] ```
vfc_58629
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n\nSAMPLE", "output": "7 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2", "output": "80 20", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n...
code_contests
verifiable_code
mani-and-pane-1
Solve the following coding problem using the programming language python: Mani wants to eat chocolates, but her brother Pane does not give her the chocolates easily. Pane being a mathematician wants to teach Mani an important concept. Pane makes Mani stand on an infinite straight line. He marks all integers at equal d...
```python def gcd(a,b): if(a==0): return b; elif(b==0): return a; elif(a>b): return gcd(a%b,b); else: return gcd(a,b%a); dp=[]; g = 0; g1 = 0; su = 0; for i in range(102): dp.append(0); for i in range(1,101): for j in range(i+1,101): g = gcd(i,j); for k in range(j+1,101): g1 = gcd(g,k); dp[g1...
vfc_58633
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 10\n15758 29586685\n1000 1000000000\n\nSAMPLE", "output": "0.956092\n0.839450\n0.999716", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 10\n15758 29586685\n1000 1000000000\n\nSAMPL...
code_contests
verifiable_code
noodle-jump
Solve the following coding problem using the programming language python: This time, Karan has decided to leave his laptop aside and take part in a long jump event - Noodle Jump. This is a special type of long jump event - it consists of a number of long jumps, of varying lengths. Assuming the positive x-axis as the ...
```python n,k = map(int, raw_input().split()) cords = map(int, raw_input().split())[:n] cords.sort() last_cord=0 for cord in cords: next_cord_distance= cord-last_cord if next_cord_distance<=k: last_cord=cord print last_cord ```
vfc_58637
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n1 2 3 5\n\nSAMPLE", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 2\n1 4 5 6 7 8 9 10 11 12", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
question-1-26
Solve the following coding problem using the programming language python: Problem Statement: You are one of the organizers of Pragyan.Having worked so hard to ensure success of the event, you are able to spot the word "pragyan" in any text. You are given a stream of character strings and you need to output them till ...
```python def main(): p = [] while(1): str = raw_input() p.append(str) if( str.lower() == "pragyan"): break for i in p: print(i) if __name__ == "__main__":main() ```
vfc_58641
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "The\nquick\nbrown\nfox\npragyan\njumped\nover\nthe\nlazy\ndog", "output": "The\nquick\nbrown\nfox\npragyan\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "The\nquick\nbrown\nfox\njumped\no...
code_contests
verifiable_code
shil-and-palindrome-research
Solve the following coding problem using the programming language python: Shil got interested in palindrome research. For that he needs some research data for a particular string S. To obtain this data he has some queries of following type: 1 L x - update L^th character of string to x 2 L R - find if all the charact...
```python def main(): N, Q = map(int, raw_input().strip().split()) size = (N << 1) + 2 bin_idx_tree = [] for __ in range(size): bin_idx_tree.append(dict()) S = list(raw_input().strip()) for (idx, ch) in enumerate(S): update(bin_idx_tree, size, idx+1, ch, 1) for __ in range(Q...
vfc_58645
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4\nababb\n2 2 3\n1 3 b\n2 1 4\n2 1 5\n\nSAMPLE", "output": "no\nno\nyes", "type": "stdin_stdout" }, { "fn_name": null, "input": "2809 6977\nxbtvplfmwqxdwxljcohyexaxlakgtnsuiqdsgufziqcxfbmktpdmcwntd...
code_contests
verifiable_code
the-magic
Solve the following coding problem using the programming language python: Navi got a task at school to collect N stones. Each day he can collect only one stone. As N can be a very large number so it could take many days to complete the task, but then he remembers that his mother gave him a magic that can double anyt...
```python def days(n): if( not(n-(-n&n)) ): return 1; power=0 check=False i=0 while(check is False): if(2**i > n): power=i-1 check=True i+=1 return 1+days(n-2**power) t=int(raw_input()) while t: t-=1 n=int(raw_input()) if(n==0): p...
vfc_58649
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n3\n\nSAMPLE", "output": "1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10000\n30712\n29260\n18391\n27280\n1418\n9121\n21242\n25603\n24535\n31483\n27489\n19374\n29055\n23121\n1...
code_contests
verifiable_code
zeroshark
Solve the following coding problem using the programming language python: A binary string of length N is a string of N characters, where each character is either 0 or 1. Wet Shark makes a list binStrings, consisting of all 2^N N-digit binary strings. For each string X in binStrings, Wet Shark runs a function ZeroSha...
```python t=int(raw_input()) for i in xrange(0,t): n = long(raw_input()) d=[] d.append(0) d.append(0) d.append(1) f=[] f.append(0) f.append(1) f.append(1) for i in range(3, n): f.append((f[i-1] + f[i-2])%1000000007) for i in range(3, n+1): d.append((d[i-1] + d...
vfc_58653
{ "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\n3\n\nSAMPLE", "output": "1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n3", "output": "1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p00086 Patrol
Solve the following coding problem using the programming language python: In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the sho...
```python import sys def is_half_euler_graph(node_list): for node in node_list: isBool = True for dic_key, dic_value in node.items(): if dic_key != 1 and dic_key != 2: if dic_value % 2 != 0: isBool = False break else : ...
vfc_58697
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 7\n5 6\n6 7\n5 8\n5 8\n6 8\n6 9\n7 9\n8 9\n9 2\n0 0\n1 3\n3 4\n3 4\n4 2\n0 0", "output": "OK\nNG", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n3 4\n3 5...
code_contests
verifiable_code
p00218 Dividing Students
Solve the following coding problem using the programming language python: At Aizu Shingakujuku, students are divided into classes by conducting a proficiency test when they enter the cram school. The test consists of three subjects: Mathematics, English, and Japanese, and students are divided into A, B, and C classes....
```python while True: #繰り返し回数を入力し0であった場合はbreakする num = int(input()) if num == 0: break else: for _ in range(num): a,b,c = map(int,input().split()) #100 点の科目があるまたは数学と英語の平均点が 90 点以上または3 科目の平均点が 80 点以上の場合"A"を出力する if a == 100 or b == 100 or c ...
vfc_58701
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0", "output": "A\nA\nB\nC\nA\nB", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n100 70 20\n98 86 55\n80 34 39\n65 79 65\...
code_contests
verifiable_code
p00596 Dominoes Arrangement
Solve the following coding problem using the programming language python: [0, 0] [0, 1] [1, 1] [0, 2] [1, 2] [2, 2] [0, 3] [1, 3] [2, 3] [3, 3] [0, 4] [1, 4] [2, 4] [3, 4] [4, 4] [0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5] [0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6] Consider the standard set ...
```python import sys def subset(line): l = line.strip().split(" ") a = list(map(int, l)) xy = list(map(lambda x: [x // 10, x % 10], a)) dominos = [[2 if [x, y] in xy and x == y else \ 1 if [x, y] in xy else \ 1 if [y, x] in xy else 0 \ for x in range(0, 7...
vfc_58709
{ "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": "6\n13 23 14 24 15 25\n10\n00 01 11 02 12 22 03 13 23 33", "output": "Yes\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n13 23 20 24 15 25\n10\n00 01 11 02 12 22 03 13 23 33", "...
code_contests
verifiable_code
p00732 Twirl Around
Solve the following coding problem using the programming language python: Let's think about a bar rotating clockwise as if it were a twirling baton moving on a planar surface surrounded by a polygonal wall (see Figure 1). <image> Figure 1. A bar rotating in a polygon Initially, an end of the bar (called "end A") i...
vfc_58713
{ "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.0 2.0 8\n-1 0\n5 0\n5 -2\n7 -2\n7 0\n18 0\n18 6\n-1 6\n4.0 2.0 4\n-1 0\n10 0\n10 12\n-1 12\n4.0 1.0 7\n-1 0\n2 0\n-1 -3\n-1 -8\n6 -8\n6 6\n-1 6\n4.0 2.0 6\n-1 0\n10 0\n10 3\n7 3\n7 5\n-1 5\n5.0 2.0 6\n-1 0\n2 0\n2 -4\n6 -4\n6 6\n...
code_contests
verifiable_code
p00872 Common Polynomial
Solve the following coding problem using the programming language python: Math teacher Mr. Matsudaira is teaching expansion and factoring of polynomials to his students. Last week he instructed the students to write two polynomials (with a single variable x), and to report GCM (greatest common measure) of them as a ho...
vfc_58717
{ "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": "-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^3+1\nx-1\n.", "output": "x^2-2x+1\nx+5\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\n...
code_contests
verifiable_code
p01135 Poor Mail Forwarding
Solve the following coding problem using the programming language python: The postal system in the area where Masa lives has changed a bit. In this area, each post office is numbered consecutively from 1 to a different number, and mail delivered to a post office is intended from that post office via several post offic...
```python def solve(): from sys import stdin f_i = stdin ans = '' while True: n, m = map(int, f_i.readline().split()) if n == 0: break # prep for warshall-floyd algorithm inf = 10000 * 31 + 1 dist = [[inf] * n for i in range(n)] ...
vfc_58725
{ "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 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 20 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0", "output": "Greetings 25\nLoveLetter 33\n\nBu...
code_contests
verifiable_code
p01274 Magic Slayer
Solve the following coding problem using the programming language python: You are in a fantasy monster-ridden world. You are a slayer fighting against the monsters with magic spells. The monsters have hit points for each, which represent their vitality. You can decrease their hit points by your magic spells: each spe...
vfc_58729
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n8000 15000 30000\n3\nFlare 45 Single 8000\nMeteor 62 All 6000\nUltimate 80 All 9999\n0", "output": "232", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n8000 15000 30000\n3\nFlare 45 Si...
code_contests
verifiable_code
p01444 Sky Jump
Solve the following coding problem using the programming language python: Dr. Kay Em, a genius scientist, developed a new missile named "Ikan-no-i." This missile has N jet engines. When the i-th engine is ignited, the missile's velocity changes to (vxi, vyi) immediately. Your task is to determine whether the missile ...
vfc_58733
{ "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\n1 1\n10 -480\n2\n6 7\n5 5\n4 1\n3\n10 5\n4 4\n8 4\n2 0\n0", "output": "Yes\nYes\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 1\n10 -480\n2\n6 7\n5 3\n4 1\n3\n10 5\n4 4\n8 4\n2...
code_contests
verifiable_code
p01593 Earn Big
Solve the following coding problem using the programming language python: Problem C: Earn Big A group of N people is trying to challenge the following game to earn big money. First, N participants are isolated from each other. From this point, they are not allowed to contact each other, or to leave any information f...
```python dp=[1]+[0]*1000 n,m=map(int,input().split()) for i in range(n): j=1 while i+j<=n and j<=m:dp[i+j]+=dp[i]/(n-i);j+=1 print('%.10f'%dp[n]) ```
vfc_58737
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1", "output": "0.50000000", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 50", "output": "0.31182782", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
p01750 Hyperrectangle
Solve the following coding problem using the programming language python: Sunuke received a d-dimensional hypercube with a side length of l1 × ... × ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and ate the part that satis...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): MOD = 10**9 + 7 D = int(readline()) L = [int(readline()) for i in range(D)] S = int(readline()) dp = [0]*(S+1) dp[S] = 1 for i in range(D): l = L[i] for i in range(l, S+1): dp...
vfc_58741
{ "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": "5\n12\n34\n56\n78\n90\n123", "output": "433127538", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n6\n3\n4", "output": "15", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
p01890 Non-redundant Drive
Solve the following coding problem using the programming language python: Example Input 5 5 8 1 3 5 1 2 4 2 3 3 2 4 3 1 5 7 Output 4 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_58745
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 8 1 3 5\n1 2 4\n2 3 3\n2 4 3\n1 5 7", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 8 1 3 5\n1 2 4\n2 3 3\n2 4 3\n1 7 7", "output": "4\n", "type": "stdin...
code_contests
verifiable_code
p02027 Presents
Solve the following coding problem using the programming language python: M: Presents Mr. Shirahane prepared the following set as a surprise present for a certain devil. * Consists of different $ K $ natural numbers less than or equal to $ N $ * No matter which pair of two values ​​you choose from the set, one numbe...
vfc_58749
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4", "...
code_contests
verifiable_code
cccs3
Solve the following coding problem using the programming language python: There is an infinite binary tree which has following structure: 3 / \ 6 8 / \ ...
```python for _ in range(input()): x=int(raw_input()) i=1 p=0 while (p<=x): p=2**i +i i+=1 #print i,p>x if(p>x): i-=2 p=(2**i)+i #print i,p ps=abs(p-x) if (ps%2==0) and (ps<2**i): #print 'Yes' if (ps/2)%2==0: print 'LEFT' else: print 'RIGHT' else : print '...
vfc_58765
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n39\n16\n70", "output": "RIGHT\nNO\nLEFT", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cstrike3
Solve the following coding problem using the programming language python: Shinchan is new to COUNTER STRIKE and he cannot differentiate between players of Terrorist and Counter Terrorist. Since he is new to COUNTER STRIKE so he used to kill his team members as he couldn't recognize them. Everyone got frustrated with h...
```python x=input() for i in range(x): y=raw_input() c=0 l=[] for a in y: if a not in l: l.append(a) c=c+1 if c%2==0: print "Terrorist" if c%2!=0: print "Counter Terrorist" ```
vfc_58769
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nace\nshars\nblizzard\nsak", "output": "Counter Terrorist\nTerrorist\nCounter Terrorist\nCounter Terrorist\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nace\nshars\nalizzard\nsak", ...
code_contests
verifiable_code
holes
Solve the following coding problem using the programming language python: Chef wrote some text on a piece of paper and now he wants to know how many holes are in the text. What is a hole? If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. For e...
```python t=input() list=['A','Q','D','R','B','O','P'] while(t): S=raw_input() hole=0 for i in S: if i in list: if i=='B': hole+=2 else: hole+=1 print(hole) t-=1 ```
vfc_58773
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nCODECHEF\nDRINKEATCODE", "output": "2\n5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
mmsum
Solve the following coding problem using the programming language python: You're given an array of N integer numbers. The maximal sum of the array is the maximal sum of the elements of a nonempty consecutive subarray of this array. For example, the maximal sum of the array [1, -2, 3, -2, 5] is 6 because the sum of t...
```python #!/usr/bin/python def R(): return map(int, raw_input().split()) T = R()[0] for i in range(T): N = R()[0] A = R() all_negative = True max_element = None max_so_far = 0 max_ending_left = 0 # maximum subsequence ending at prev position max_skipped_one = 0 # maximum subsequen...
vfc_58777
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 -2 3 -2 5\n2\n-1 -2", "output": "8\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n2 -2 3 -2 5\n2\n-1 -2", "output": "8\n-1\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
repub
Solve the following coding problem using the programming language python: On the occasion of 66^th Republic day, a young lad, Lemon Kumar (a.k.a Yaar Kumar), is revising his speech again and again to remember it. He found that some of the letters in his speech is repeated quite often. Being very fond of programming, l...
```python import string for _ in range(int(raw_input())): string=str(raw_input()).lower() punctuation=['!','@','#',' ','$','%','^','&','*','(',')','-','=','+','[',']',"'",';','/''1','2','3','4','5','6','','7','8','9','0'] string1=[f for f in string if f not in punctuation] string=''.join(string1) di...
vfc_58781
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nHappy Republic Day!!!", "output": "p", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tux03
Solve the following coding problem using the programming language python: Problem description  The IPL Auctions are finally over and cricket legend Rahul Dravid now wants to find the most balanced team in the league. Each player is bought at some price X in the auction. Dravid defines the balance of each team as the l...
```python t = input() for i in range(t): d = 9999999 index = 0 for j in range(10): mn = map(int,raw_input().split()) s = max(mn)-min(mn) if s<=d: d = s index = j+1 print index,d ```
vfc_58785
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 \n3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 \n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 \n4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 \n5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 \n6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 \n7 1...
code_contests
verifiable_code
1017_D. The Wu
Solve the following coding problem using the programming language python: Childan is making up a legendary story and trying to sell his forgery — a necklace with a strong sense of "Wu" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few questions about Childan's so...
```python from sys import stdin def main(): n, m, q = map(int, input().split()) c = sz = 1 << n costs, cnt = [0] * sz, [0] * sz for w in map(int, input().split()): c //= 2 for i in range(c, sz, c * 2): for j in range(i, i + c): costs[j] += w for i, c in ...
vfc_58789
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4 5\n40 20\n01\n01\n10\n11\n00 20\n00 40\n11 20\n11 40\n11 60\n", "output": "2\n4\n2\n3\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 4\n100\n0\n1\n0 0\n0 100\n1 0\n1 100\n", ...
code_contests
verifiable_code
1041_A. Heist
Solve the following coding problem using the programming language python: There was an electronic store heist last night. All keyboards which were in the store yesterday were numbered in ascending order from some integer number x. For example, if x = 4 and there were 3 keyboards in the store, then the devices had ind...
```python def heist(n,a): return max(a)-min(a)-n+1 n=int(input()) a=list(map(int,input().split())) print(heist(n,a)) ```
vfc_58793
{ "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\n10 13 12 8\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n7 5 6 4 8\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1063_F. String Journey
Solve the following coding problem using the programming language python: We call a sequence of strings t1, ..., tk a journey of length k, if for each i > 1 ti is a substring of ti - 1 and length of ti is strictly less than length of ti - 1. For example, {ab, b} is a journey, but {ab, c} and {a, a} are not. Define a ...
vfc_58797
{ "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": "4\nbbcb\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\nabcdbcc\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
1085_E. Vasya and Templates
Solve the following coding problem using the programming language python: Vasya owns three strings s , a and b, each of them consists only of first k Latin letters. Let a template be such a string of length k that each of the first k Latin letters appears in it exactly once (thus there are k! distinct templates). App...
vfc_58801
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\nbbcb\naada\naada\n3\nabc\nbbb\nbbb\n", "output": "YES\nbadc\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n5\nbcdbccc\nadaedae\neecdaca\n5\ndbeedcbcbaccdddbdcbcabacecbe\ndcae...
code_contests
verifiable_code
1105_C. Ayoub and Lost Array
Solve the following coding problem using the programming language python: Ayoub had an array a of integers of size n and this array had two interesting properties: * All the integers in the array were between l and r (inclusive). * The sum of all the elements was divisible by 3. Unfortunately, Ayoub has los...
```python MOD = 10**9 + 7 n,l,r = map(int,input().split()) dp = [[ 0,0,0]for i in range(n+1)] # In condition l <= x <= r , mod 0,1,2 number count(define a,b,c) a = r//3 - (l - 1)//3 b = (r+1)//3 - (l - 1 + 1)//3 c = (r+2)//3 - (l - 1 + 2)//3 #example #l = 2 , r = 10 #a = 10//3 - 1//3 = 3 - 0 = 3 (3,6,9) #b = 11//...
vfc_58805
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 9 99\n", "output": "711426616", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1 3\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1175_A. From Hero to Zero
Solve the following coding problem using the programming language python: You are given an integer n and an integer k. In one step you can do one of the following moves: * decrease n by 1; * divide n by k if n is divisible by k. For example, if n = 27 and k = 3 you can do the following steps: 27 → 26 → 25 ...
```python import math t=int(input()) for _ in range(t): n,k=map(int,input().split()) count=0 a,b=int(n//k),int(n%k) while n>0: if k>n: a,b=0,int(n%k) else: a,b=math.floor(n//k),int(n%k) n=a if a==0: count+=b else: count+=(b+1) print(count) ```
vfc_58817
{ "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\n59 3\n1000000000000000000 10\n", "output": "8\n19\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 99\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
1193_C. Scissors and Tape
Solve the following coding problem using the programming language python: You are given a piece of paper in the shape of a simple polygon S. Your task is to turn it into a simple polygon T that has the same area as S. You can use two tools: scissors and tape. Scissors can be used to cut any polygon into smaller polyg...
vfc_58821
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 0 0 6 0 6 4 5 4 5 9 0 9\n4 0 0 7 0 7 7 0 7\n", "output": "scissors\n0 12\n3 6.0000000000 0.0000000000 5.0769230769 1.3846153846 3.0000000000 0.0000000000\n3 0.0000000000 9.0000000000 0.0000000000 4.5000000000 2.0769230769 5...
code_contests
verifiable_code
1231_C. Increasing Matrix
Solve the following coding problem using the programming language python: In this problem, a n × m rectangular matrix a is called increasing if, for each row of i, when go from left to right, the values strictly increase (that is, a_{i,1}<a_{i,2}<...<a_{i,m}) and for each column j, when go from top to bottom, the valu...
```python def main(): n, m = map(int, input().split()) l = list(list(map(int, input().split()))[::-1] for _ in range(n))[::-1] for r0, r1 in zip(l, l[1:-1]): for i, a in enumerate(r1[1:-1], 1): if not a: r1[i] = min(r1[i - 1], r0[i]) - 1 print(sum(map(sum, l)) if all(...
vfc_58829
{ "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 3\n1 2 3\n2 0 4\n4 5 6\n", "output": "30\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2 3\n2 3 4\n3 4 2\n", "output": "-1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1252_F. Regular Forestation
Solve the following coding problem using the programming language python: A forestation is an act of planting a bunch of trees to grow a forest, usually to replace a forest that had been cut down. Strangely enough, graph theorists have another idea on how to make a forest, i.e. by cutting down a tree! A tree is a gra...
vfc_58833
{ "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": "13\n1 5\n1 7\n2 4\n2 8\n2 11\n3 12\n4 7\n4 12\n6 11\n7 13\n9 10\n9 12\n", "output": "\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 2\n1 3\n2 4\n3 5\n3 6\n", "output": "\n-...
code_contests
verifiable_code
1272_E. Nearest Opposite Parity
Solve the following coding problem using the programming language python: You are given an array a consisting of n integers. In one move, you can jump from the position i to the position i - a_i (if 1 ≤ i - a_i) or to the position i + a_i (if i + a_i ≤ n). For each position i from 1 to n you want to know the minimum ...
```python input() n=map(int,input().split()) n=list(n) ans=len(n)*[-1] a=[] go=[[] for _ in range(len(n))] for i,x in enumerate(n): for y in (x,-x): y+=i if y>=0 and y<len(n): if x%2!=n[y]%2: ans[i]=1 a.append(i) else: go[y].ap...
vfc_58837
{ "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": "10\n4 5 7 6 7 5 4 4 6 4\n", "output": "1 1 1 2 -1 1 1 3 1 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "150\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_contests
verifiable_code
1295_F. Good Contest
Solve the following coding problem using the programming language python: An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared n problems; and since the platform is very popular, 998244351 coder from all over the world is going to solve them. For each...
```python import sys from itertools import chain readline = sys.stdin.readline MOD = 998244353 def compress(L): L2 = list(set(L)) L2.sort() C = {v : k for k, v in enumerate(L2)} return L2, C N = int(readline()) LR = [tuple(map(int, readline().split())) for _ in range(N)] LR = [(a-1, b) for a, b in LR...
vfc_58841
{ "difficulty": "12", "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\n1 1\n0 0\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1\n1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1316_F. Battalion Strength
Solve the following coding problem using the programming language python: There are n officers in the Army of Byteland. Each officer has some power associated with him. The power of the i-th officer is denoted by p_{i}. As the war is fast approaching, the General would like to know the strength of the army. The stren...
vfc_58845
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 3 4\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "625000011\n13\n62500020\n375000027\n62500027\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n2\n1 2\n2 1\n", "output": "50000...
code_contests
verifiable_code
1360_A. Minimal Square
Solve the following coding problem using the programming language python: Find the minimum area of a square land on which you can place two identical rectangular a × b houses. The sides of the houses should be parallel to the sides of the desired square land. Formally, * You are given two identical rectangles wit...
```python num=int(input("")) i=0 while i<num: a,b=(input("")).split() minimum=min(int(a),int(b)) maximum=max(int(a),int(b)) if minimum*2<maximum: print(maximum**2) else: print((minimum*2)**2) i+=1 ```
vfc_58853
{ "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": "8\n3 2\n4 2\n1 1\n3 1\n4 7\n1 3\n7 4\n100 100\n", "output": "16\n16\n4\n9\n64\n9\n64\n40000\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1380_B. Universal Solution
Solve the following coding problem using the programming language python: Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string s = s_1 s_2 ... s_{n} of length n where each letter is either R, S or P. While initializing, the bot is ...
```python dic={ 'R':'P', 'P':'S', 'S':'R' } t=int(input()) for _ in range(t): S=input() n=len(S) r,p,s=[0,0,0] for i in range(len(S)): if S[i]=='R': r=r+1 elif S[i]=='P': p=p+1 else: s=s+1 m=max(r,p,s) if r==m: print...
vfc_58857
{ "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\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1400_B. RPG Protagonist
Solve the following coding problem using the programming language python: You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower wi...
```python # cook your dish here # cook your dish here from sys import stdin,stdout from collections import Counter from itertools import permutations import bisect import math I=lambda: map(int,stdin.readline().split()) I1=lambda: stdin.readline() for _ in range(int(I1())): p,f=I() cs,cw=I() s,w=I() if...
vfc_58861
{ "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\n33 27\n6 10\n5 6\n100 200\n10 10\n5 5\n1 19\n1 3\n19 5\n", "output": "11\n20\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n475033014 267058742\n26843 148652\n850113755 279316120...
code_contests
verifiable_code
1424_B. Valuable Paper
Solve the following coding problem using the programming language python: The pandemic is upon us, and the world is in shortage of the most important resource: toilet paper. As one of the best prepared nations for this crisis, BubbleLand promised to help all other world nations with this valuable resource. To do that,...
```python import os import sys from io import BytesIO, IOBase from types import GeneratorType BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): import os self.os = os self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in fil...
vfc_58865
{ "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 5\n1 2 1\n2 3 2\n3 3 3\n2 1 4\n2 2 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 12\n1 3 1\n2 3 1\n3 1 1\n3 2 1\n1 4 1\n2 4 1\n4 1 1\n4 2 1\n1 5 1\n2 5 1\n5 1 1\n5...
code_contests
verifiable_code
1469_D. Ceil Divisions
Solve the following coding problem using the programming language python: You have an array a_1, a_2, ..., a_n where a_i = i. In one step, you can choose two indices x and y (x ≠ y) and set a_x = \left⌈ (a_x)/(a_y) \right⌉ (ceiling function). Your goal is to make array a consist of n - 1 ones and 1 two in no more th...
```python import math def solution() : for tc in range(int(input())) : n = int(input()) ls = [i for i in range(1, n+1)] ans = [] for i in range(n-2, 0, -1) : while math.ceil(ls[n-1] / ls[i]) >= ls[i] : ans.append([n, i+1]) ls[n-1] = math...
vfc_58873
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n4\n", "output": "\n2\n3 2\n3 2\n3\n3 4\n4 2\n4 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n6401\n", "output": "6403\n82 6401\n83 6401\n84 6401\n85 6401\n86 6401\n87 64...
code_contests
verifiable_code
1545_D. AquaMoon and Wrong Coordinate
Solve the following coding problem using the programming language python: Cirno gives AquaMoon a problem. There are m people numbered from 0 to m - 1. They are standing on a coordinate axis in points with positive integer coordinates. They are facing right (i.e. in the direction of the coordinate increase). At this mo...
vfc_58885
{ "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 7\n6 9 9 6 9\n10 7 10 8 10\n11 11 11 10 8\n12 12 12 12 9\n14 13 12 10 13\n11 14 16 14 14\n12 15 18 15 15\n", "output": "4 13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n9 6 6 9 ...
code_contests
verifiable_code
172_C. Bus
Solve the following coding problem using the programming language python: There is a bus stop near the university. The lessons are over, and n students come to the stop. The i-th student will appear at the bus stop at time ti (all ti's are distinct). We shall assume that the stop is located on the coordinate axis Ox,...
```python from collections import defaultdict n, m = map(int, input().split()) r, p = [0] * n, defaultdict(list) i = d = 0 while i < n - m: for j in range(i, i + m): t, x = map(int, input().split()) p[x].append(j) d = max(t, d) y = sorted(p.keys()) for x in y: for j in p[x]: r[j]...
vfc_58889
{ "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": "20 4\n28 13\n31 13\n35 6\n36 4\n52 6\n53 4\n83 2\n84 4\n87 1\n93 6\n108 4\n113 6\n116 1\n125 2\n130 2\n136 13\n162 2\n166 4\n184 1\n192 2\n", "output": "51 51 43 40 93 89 86 89 114 121 118 121 137 139 139 152 195 199 193 195 ...
code_contests
verifiable_code
192_D. Demonstration
Solve the following coding problem using the programming language python: In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one ...
```python from sys import stdin, stdout n, k = map(int, stdin.readline().split()) value = int(stdin.readline()) prices = list(map(int, stdin.readline().split())) used = {} challengers = prices[:-1] for i in range(n - 1): challengers[i] = (challengers[i], i) challengers.sort(reverse = True) ind = challengers[k -...
vfc_58893
{ "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 2\n8\n2 4 5 3 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n1000000000000000\n5 4 3 2 1\n", "output": "5\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
216_D. Spider's Web
Solve the following coding problem using the programming language python: Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web. <image> There are n main threads going from the center of the web. All main threads are located i...
```python #------------------------template--------------------------# import os import sys from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output....
vfc_58897
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n3 1 6 7\n4 3 5 2 9\n2 8 1\n4 3 7 6 4\n3 2 5 9\n3 6 3 8\n3 4 2 9\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
23_D. Tetragon
Solve the following coding problem using the programming language python: You're given the centers of three equal sides of a strictly convex tetragon. Your task is to restore the initial tetragon. Input The first input line contains one number T — amount of tests (1 ≤ T ≤ 5·104). Each of the following T lines contai...
vfc_58901
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 2 2 3 3\n0 1 1 0 2 2\n9 3 7 9 9 8\n", "output": "NO\n\nYES\n0.500000000 2.500000000 -0.500000000 -0.500000000 2.500000000 0.500000000 1.500000000 3.500000000 \nNO\n\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
265_B. Roadside Trees (Simplified Edition)
Solve the following coding problem using the programming language python: Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts. Now Liss is on the root of the tree...
```python n = int(input()) l = [] for _ in range(n): l.append(int(input())) t = len(l) current = 0 t+=l[0]-current current = l[0] for i in range(1,n): if current<=l[i]: t+=1+l[i]-current current = l[i] else: t += 1+current-l[i] current = l[i] print(t) ```
vfc_58905
{ "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\n2\n1\n2\n1\n1\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n2\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
289_B. Polo the Penguin and Matrix
Solve the following coding problem using the programming language python: Little penguin Polo has an n × m matrix, consisting of integers. Let's index the matrix rows from 1 to n from top to bottom and let's index the columns from 1 to m from left to right. Let's represent the matrix element on the intersection of row...
```python n,m,d=map(int,input().split()) x=[] y=[] for i in range(n): a=list(map(int,input().split())) y+=a x.append(a) y.sort() e=y[(0+n*m-1)//2] a=x[0][0]%d count=0 ans=0 for i in x: for j in range(len(i)): if(i[j]%d!=a): pass else: count+=1 ans+=(ma...
vfc_58909
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 7\n6 7\n", "output": "-1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
314_B. Sereja and Periods
Solve the following coding problem using the programming language python: Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc. We'll say that string s can be obtained from string t, if we can re...
```python b, p = map(int, input().split()) s1 = input() s2 = input() cnt = [0] * len(s2) nxt = [0] * len(s2) for i in range(len(s2)): pos = i for j in range(len(s1)): if s1[j] == s2[pos]: pos += 1 if pos == len(s2): cnt[i] += 1 pos = 0 ...
vfc_58913
{ "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": "10 3\nabab\nbab\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "541 9\nbxhwcmunbdxcatppdsw\nshbppncwbnsxxnxunwsbncpdchcbcspdcppdchmbbcuapphpdxbpcswcxpxpdscxpddbcppdxhpxbux...
code_contests
verifiable_code
336_D. Vasily the Bear and Beautiful Strings
Solve the following coding problem using the programming language python: Vasily the Bear loves beautiful strings. String s is beautiful if it meets the following criteria: 1. String s only consists of characters 0 and 1, at that character 0 must occur in string s exactly n times, and character 1 must occur exactl...
```python import math MOD = 10**9+7 N,M,G = map(int,raw_input().split()) if M == 0: print int(G!=N%2) exit() if M == 1: ans = int(G!=N%2) for i in xrange(N): if i%2 == G: ans += 1 print ans exit() D = [0 for i in xrange(N+1)] D[0] = 1 for i in xrange(1,N+1): D[i] = D[i...
vfc_58917
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 0\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 0\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\n...
code_contests
verifiable_code
382_D. Ksenia and Pawns
Solve the following coding problem using the programming language python: Ksenia has a chessboard of size n × m. Each cell of the chessboard contains one of the characters: "<", ">", "^", "v", "#". The cells that contain character "#" are blocked. We know that all chessboard cells that touch the border are blocked. K...
vfc_58925
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n####\n#&gt;&lt;#\n####\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 5\n#####\n##v##\n##v##\n##&lt;##\n##^{}##\n##^{}##\n#####", "output": "-1\n", "t...
code_contests
verifiable_code
430_D. Working out
Solve the following coding problem using the programming language python: Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout a...
```python n,m=map(int,input().split()) a=[] for i in range(n):a.append(list(map(int,input().split()))) dpa=[[[0,0] for i in range(m+2)] for i in range(n+2)] dpb=[[[0,0] for i in range(m+2)] for i in range(n+2)] ans=0 for i in range(1,n+1): for j in range(1,m+1): dpa[i][j][0]=max(dpa[i-1][j][0],dpa[i][j-1][0])+a[i-1]...
vfc_58933
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n100 100 100\n100 1 100\n100 100 100\n", "output": "800\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n0 0 0\n0 10000 0\n0 0 0\n", "output": "0\n", "type": "stdin_std...
code_contests
verifiable_code
453_A. Little Pony and Expected Maximum
Solve the following coding problem using the programming language python: Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has m faces: th...
```python def main(): m, n = map(int, input().split()) print(sum((i + 1) * (((i + 1) / m) ** n - (i / m) ** n) for i in range(m))) if __name__ == '__main__': main() ```
vfc_58937
{ "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 2\n", "output": "1.75", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1\n", "output": "3.5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
499_E. Array and Operations
Solve the following coding problem using the programming language python: You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i1, j1), (i2, j2), ..., (im, jm). Each good pair (ik, jk) meets the following conditions: ik + jk is an odd number and 1 ≤ i...
vfc_58945
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n8 12 8\n1 2\n2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n8 3 8\n1 2\n2 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
549_H. Degenerate Matrix
Solve the following coding problem using the programming language python: The determinant of a matrix 2 × 2 is defined as follows: <image> A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a mat...
```python A,B,C,D=map(int,(input()+' '+input()).split());k=max(map(abs,[A+B+C+D,A+B-C-D,A-B+C-D,A-B-C+D]))+1e-9;print(abs(A*D-B*C)/k) ```
vfc_58953
{ "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": "1 0\n0 1\n", "output": "0.5000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n3 4\n", "output": "0.2000000000\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
576_A. Vasya and Petya's Game
Solve the following coding problem using the programming language python: Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. Petya can ask questions like: "Is the unknown number divisible by number y?". The game is played by the following rules:...
```python def input_ints(): return list(map(int, input().split())) def main(): n = int(input()) ans = [] for x in range(2, n + 1): s = set() xx = x for y in range(2, n + 1): while xx % y == 0: xx /= y s.add(y) if len(s) == 1: ...
vfc_58957
{ "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\n", "output": "3\n2 4 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "4\n2 4 3 5\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
598_E. Chocolate Bar
Solve the following coding problem using the programming language python: You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar. In one move you can break any single rectangular piece of chocolate in two rectangular piec...
```python d = [0] * 49011 def g(n, m, k): t = 1e9 for i in range(1, m // 2 + 1): for j in range(k + 1): t = min(t, f(n, m - i, k - j) + f(n, i, j)) return n * n + t def f(n, m, k): if n > m: n, m = m, n k = min(k, n * m - k) if k == 0: return 0 if k < 0: return 1e9 ...
vfc_58961
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 2 1\n2 2 3\n2 2 2\n2 2 4\n", "output": " 5\n 5\n ...
code_contests
verifiable_code
61_C. Capture Valerian
Solve the following coding problem using the programming language python: It's now 260 AD. Shapur, being extremely smart, became the King of Persia. He is now called Shapur, His majesty King of kings of Iran and Aniran. Recently the Romans declared war on Persia. They dreamed to occupy Armenia. In the recent war, the...
```python n, m = input().split() b = input() if b.isdigit() and int(b) == 0: print(int(b)) elif n == m: print(b) else: n= int(n) st1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] st2 =['0', '1','2','3','4','5','6','7','8','9','A','B','C','D', 'E', 'F','G','H','I','J','K','L','M','N','O'...
vfc_58965
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n1111001\n", "output": "1111001\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12 13\nA\n", "output": "A\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
63_B. Settlers' Training
Solve the following coding problem using the programming language python: In a strategic computer game "Settlers II" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers. Within this task we can a...
```python """ Oh, Grantors of Dark Disgrace, Do Not Wake Me Again. """ from collections import Counter n, k = map(int, input().split()) cc = Counter(map(int, input().split())) coins = 0 while cc[k] != n: t = 0 for i in range(1, k): if t+1 <= cc[i]: cc[i] -= 1 cc[i+1] += 1 ...
vfc_58969
{ "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 4\n1 2 2 3\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
667_E. Chain Reaction
Solve the following coding problem using the programming language python: Group of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a plate, can run a powerful c...
```python import sys sys.stderr = sys.stdout from collections import namedtuple Bot = namedtuple('Bot', ('x', 'y', 'i')) def yxi(bot): return bot.y, bot.x, bot.i def reaction1(B, V): Bv = sorted(B[i] for i in range(4) if V[i]) Bh = sorted((B[i] for i in range(4) if not V[i]), key=yxi) S = [None] *...
vfc_58973
{ "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": "2\n1 1\n1 -1\n-1 1\n-1 -1\n1 1\n2 2\n4 4\n6 6\n", "output": "0\n1 1\n1 -1\n-1 1\n-1 -1\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n7434523 11523154\n7611807 5876512\n3910524 115...
code_contests
verifiable_code
690_C3. Brain Network (hard)
Solve the following coding problem using the programming language python: Breaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born with a single brain, and only later it evolves into a complicated brain structure. In fact, whenever a zombie consumes a brain, a new br...
vfc_58977
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1\n2\n2\n1\n5\n", "output": "1 2 2 3 4 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
714_B. Filya and Homework
Solve the following coding problem using the programming language python: Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an array of non-negative integers a1, a2, ..., an. First, he pick an integer x and th...
```python n=int(input()) s=set() L=[ int(x) for x in input().split() ] for i in L : s.add(i) if ( len(s) > 3 ) : print("NO") elif (len(s) == 1 or len(s) == 2 ) : print("YES") else : L=[] for i in s : L.append(i) L.sort() a,b,c = L[0], L[1], L[2] if ( b-a == c-b ): print("...
vfc_58981
{ "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\n1 3 3 2 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
758_E. Broken Tree
Solve the following coding problem using the programming language python: You are given a tree that has n vertices, which are numbered from 1 to n, where the vertex number one is the root. Each edge has weight wi and strength pi. Botanist Innokentiy, who is the only member of the jury of the Olympiad in Informatics, ...
vfc_58989
{ "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": "5\n1 2 2 4\n2 4 1 9\n4 5 5 6\n4 3 4 8\n", "output": "5\n1 2 2 4\n2 4 1 9\n4 5 1 2\n4 3 2 6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
77_C. Beavermuncher-0xFF
Solve the following coding problem using the programming language python: "Eat a beaver, save a tree!" — That will be the motto of ecologists' urgent meeting in Beaverley Hills. And the whole point is that the population of beavers on the Earth has reached incredible sizes! Each day their number increases in several ...
vfc_58993
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 1 3 2\n2 5\n3 4\n4 5\n1 5\n4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 1 1\n3 2\n1 2\n3\n", "output": "2\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
803_B. Distances to Zero
Solve the following coding problem using the programming language python: You are given the array of integer numbers a0, a1, ..., an - 1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array. Input The first line contains ...
```python import sys n = int(sys.stdin.readline()) a = sys.stdin.readline().strip().split() def findDistancesToZero(n,a): pos_zero_left = a.index('0') pos_zero_right = a.index('0') pos = 0 positions = '' while pos<n: worked = False while pos<=pos_zero_right: ...
vfc_58997
{ "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": "7\n5 6 0 1 -2 3 4\n", "output": "2 1 0 1 2 3 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 1 2 3 4\n", "output": "0 1 2 3 4 ", "type": "stdin_stdout" } ] }