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
154_B. Colliders
Solve the following coding problem using the programming language python: By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, s...
```python from sys import stdin import math n, k = map(int, stdin.readline().rstrip().split(" ")) a = [[] for i in range(n+1)] act = {} active = [0]*(n+1) for i in range(2,n+1): if not a[i]: act[i]=0 for j in range(i,n+1,i): a[j].append(i) storing = {} for _ in range(k): s, v = ...
vfc_73049
{ "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": "10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3\n", "output": "Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
175_F. Gnomes of Might and Magic
Solve the following coding problem using the programming language python: Vasya plays a popular game the Gnomes of Might and Magic. In this game Vasya manages the kingdom of gnomes, consisting of several castles, connected by bidirectional roads. The kingdom road network has a special form. The kingdom has m main cas...
vfc_73053
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n1 2 3\n3 1 4 2\n3 2 5 3\n3 3 6 1\n10\n+ 1 2\n+ 4 2\n+ 1 3\n+ 2 3\n? 1 2\n+ 2 5\n? 1 2\n? 1 2\n+ 1 2\n? 1 2\n", "output": "0\n1\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 ...
code_contests
verifiable_code
196_B. Infinite Maze
Solve the following coding problem using the programming language python: We've got a rectangular n × m-cell maze. Each cell is either passable, or is a wall (impassable). A little boy found the maze and cyclically tiled a plane with it so that the plane became an infinite maze. Now on this plane cell (x, y) is a wall...
vfc_73057
{ "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 4\n##.#\n##S#\n#..#\n#.##\n#..#\n", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n##.#\n##S#\n#..#\n..#.\n#.##\n", "output": "No", "type": "stdin_stdout" ...
code_contests
verifiable_code
21_B. Intersection
Solve the following coding problem using the programming language python: You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two ...
```python a1, b1, c1 = [int(i) for i in input().split()] a2, b2, c2 = [int(i) for i in input().split()] if c1 != c2 and (a1 == 0 and b1 == 0) and (a2 == 0 and b2 == 0) : print(0) elif (a1 == 0 and b1 == 0 and c1 == 0) or (a2 == 0 and b2 == 0 and c2 == 0) : print(-1) elif (a1 == 0 and b1 == 0 and c1 != 0) or (a...
vfc_73061
{ "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": "1 1 0\n2 2 0\n", "output": "-1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
243_D. Cubes
Solve the following coding problem using the programming language python: One day Petya got a set of wooden cubes as a present from his mom. Petya immediately built a whole city from these cubes. The base of the city is an n × n square, divided into unit squares. The square's sides are parallel to the coordinate axes...
vfc_73065
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 -1 2\n5 0 0 0 1\n0 0 0 0 2\n0 0 0 1 2\n0 0 0 0 2\n2 2 2 2 3\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 -2\n5 0 0 0 1\n0 0 0 0 2\n0 0 0 1 2\n0 0 0 0 2\n2 2 2 2 ...
code_contests
verifiable_code
269_B. Greenhouse Effect
Solve the following coding problem using the programming language python: Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length. Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenho...
```python n=int(input().split()[0]) a=[] for _ in range(n): a.append(int(input().split()[0])) dp=[0]*n for i in range(n): dp[i]= 1 for j in range(i): if a[j]<= a[i] and dp[j]>= dp[i]: dp[i]=dp[j]+1 print(n-max(dp)) ```
vfc_73069
{ "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 2\n2 1\n1 2.0\n1 3.100\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 5.0\n2 5.5\n3 6.0\n", "output": "0\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
291_D. Parallel Programming
Solve the following coding problem using the programming language python: Polycarpus has a computer with n processors. Also, his computer has n memory cells. We'll consider the processors numbered by integers from 1 to n and that the memory cells are consecutively numbered by integers from 1 to n. Polycarpus needs to...
```python n, k = map(int, input().split()) a = [1 for i in range(n + 1)] a[n] = 0 for iter in range(k): for i in range(1, n - 1): target = n - i if a[i + 1] > target - a[i]: # find right number target -= a[i] print(n - target, end=' ') a[i] += a[n - ta...
vfc_73073
{ "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\n", "output": "2\t3\t3\n3\t3\t3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
316_E1. Summer Homework
Solve the following coding problem using the programming language python: By the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher: You are given a sequence of integers a1, a2, ..., an. Your task is to perform on it m consecutive operations of the follow...
```python n,m = map(int,input().split()) a = list(map(int,input().split())) f = [1,1] for i in range(2,n+1): f.append(f[i-1] + f[i-2]) f[i] %= 10 ** 9 for q in range(m): z,l,r = map(int,input().split()) if z == 1: a[l-1] = r else: s = 0 for j in range(l-1,r): ...
vfc_73077
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4\n1 3 1 2 4\n3 1 4 1\n2 2 4\n1 2 10\n2 1 5\n", "output": " 12\n 45\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
33_B. String Problem
Solve the following coding problem using the programming language python: Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. Acc...
```python import sys, string import itertools s, t = input().strip(), input().strip() if len(s) != len(t): print(-1) sys.exit() vertices = string.ascii_lowercase g = { c: { c: 0 } for c in vertices } n = int(input()) for i in range(n): u, v, cost = input().split() cost = int(cost) if v not in g[u] or g[u][...
vfc_73081
{ "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": "uayd\nuxxd\n3\na x 8\nx y 13\nd c 3\n", "output": "21\nuxyd\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
362_D. Fools and Foolproof Roads
Solve the following coding problem using the programming language python: You must have heard all about the Foolland on your Geography lessons. Specifically, you must know that federal structure of this country has been the same for many centuries. The country consists of n cities, some pairs of cities are connected b...
```python from sys import stdin, stdout, setrecursionlimit from heapq import heapify, heappop, heappush setrecursionlimit(100000) def main(): read_ints = lambda: map(int, stdin.readline().split()) n, m, p, q = read_ints() par = range(n) s = [0] * n def find(x): if x == par[x]: re...
vfc_73085
{ "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": "9 6 2 2\n1 2 2\n3 2 1\n4 6 20\n1 3 8\n7 8 3\n5 7 2\n", "output": "YES\n9 5\n3 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 0 0 2\n", "output": "YES\n", "type": "stdin_st...
code_contests
verifiable_code
386_B. Fly, freebies, fly!
Solve the following coding problem using the programming language python: Everyone loves a freebie. Especially students. It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass t...
```python n = int(input()) lst = sorted(list(map(int, input().split()))) t = int(input()) ans = 1 for i in range(len(lst) - 1): temp = 1 k = i + 1 while k < len(lst) and lst[k] - lst[i] <= t: temp += 1 k += 1 if temp > ans: ans = temp print(ans) ```
vfc_73089
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n4 1 7 8 3 8\n1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n3 3 1 2 3 3 1 3 3 2 2 2 2 1 2 3 2 1 2 2 2 2 3 2 1 3 3 3 2 1 3 1 2 1 1 2 2 3 2 2 3 1 1 3 1 2 1 3 3 1 ...
code_contests
verifiable_code
407_A. Triangle
Solve the following coding problem using the programming language python: There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integ...
```python import os import sys from io import BytesIO, IOBase def main(): pass # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
vfc_73093
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n", "output": "YES\n0 0\n3 4\n-4 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 10\n", "output": "YES\n0 0\n3 4\n-8 6\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
456_D. A Lot of Games
Solve the following coding problem using the programming language python: Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players. Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns....
```python input = __import__('sys').stdin.readline class Node: def __init__(self): self.end = False self.nxt = {} self.w = None self.l = None def __setitem__(self, i, x): self.nxt[i] = x def __getitem__(self, i): return self.nxt[i] def makeTrie(strs): root = Node() ...
vfc_73101
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\na\nb\n", "output": "First\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
479_B. Towers
Solve the following coding problem using the programming language python: As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of ai cubes stacked one on top of the other. Petya defines the instability of a set of tow...
```python n,k=map(int,input().split()) a=list(map(int,input().split())) s="" c=0 best=[max(a)-min(a),c,""] if n>1: for pog in range(k): m=0 i=0 mp=100000000000000000 ip=0 m=max(a) i=a.index(m) mp=min(a) ip=a.index(mp) if m!=mp: a[i]...
vfc_73105
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n5 8 5\n", "output": "0 2\n2 1\n2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n2 2 4\n", "output": "1 1\n3 1\n", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
501_B. Misha and Changing Handles
Solve the following coding problem using the programming language python: Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at some ...
```python n = input() lista_nuevos = [] lista_viejos = [] for i in range(int(n)): elem = input().split(' ') if (elem[0] not in lista_viejos) and (elem[0] not in lista_nuevos): lista_viejos.append(elem[0]) lista_nuevos.append(elem[1]) elif elem[0] in lista_nuevos: indice = lista_nuev...
vfc_73109
{ "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\nMisha ILoveCodeforces\nVasya Petrov\nPetrov VasyaPetrov123\nILoveCodeforces MikeMirzayanov\nPetya Ivanov\n", "output": "3\nMisha MikeMirzayanov\nVasya VasyaPetrov123\nPetya Ivanov\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
526_G. Spiders Evil Plan
Solve the following coding problem using the programming language python: Spiders are Om Nom's old enemies. They love eating candies as much as he does and that's why they keep trying to keep the monster away from his favorite candies. They came up with an evil plan to trap Om Nom. <image> Let's consider a rope stru...
vfc_73113
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n1 2 2\n2 3 2\n3 4 2\n4 6 1\n3 5 10\n3 1\n2 5\n1 1\n", "output": "14\n13\n17\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 10\n2 1 523\n9 5 165\n9 6 677\n2 4 456\n2 3 864\n1 7 989\...
code_contests
verifiable_code
552_C. Vanya and Scales
Solve the following coding problem using the programming language python: Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2 (exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m using the given w...
```python from sys import exit w, m = map(int, input().split()) if w in (2, 3): print('YES') exit() while True: if m in (0, 1): print('YES') exit() prev = 1 cur = w while cur < m: prev = cur cur *= w if cur == m: print('YES') exit() sum1k ...
vfc_73117
{ "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 7\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 50\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1...
code_contests
verifiable_code
579_C. A Problem about Polyline
Solve the following coding problem using the programming language python: There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - (2kx, 0) – (2kx + x, x) – .... We know that the polyline passes through the point (a, b). Find minimum positive value x such that it is true or dete...
```python a,b=(int(i) for i in input().split()) if (a<b): print('-1') elif (a==b): print(a) else: i1=(a+b)//(2*b); i2=(a-b)//(2*b) if i2 is not 0: p=(a+b)/2 q=(a-b)/2 print(min(p/i1,q/i2)) else: print((a+b)/(2*i1)) ```
vfc_73121
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 3\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n", "output": "1.2500000000\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
600_B. Queries about less or equal elements
Solve the following coding problem using the programming language python: You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj. Input The first line contains two integers n, m (1 ≤ n, m ≤ 2·...
```python # upsolve from bisect import bisect_right x = input() a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] a = sorted(a) for i in b: print(bisect_right(a,i), end = " ") print() ```
vfc_73125
{ "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 5\n1 2 1 2 5\n3 1 4 1 5\n", "output": "4 2 4 2 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n1 3 5 7 9\n6 4 2 8\n", "output": "3 2 1 4 ", "type": "stdin_stdout" }...
code_contests
verifiable_code
644_A. Parliament of Berland
Solve the following coding problem using the programming language python: There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indices are Republicans. New parliament assembly hall ...
```python #Codeforces : Parliament of Bearland n,a,b=[int(x) for x in input().split()] p=list() pos=a for i in range(b): pos=a if(i+1<=n): q=[i+1] else: q=[0] pos=0 for j in range(1,a): if(b%2==0): if(i%2==0): if(j%2==0): ...
vfc_73133
{ "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": "10 2 2\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 4 3\n", "output": "1 2 3 \n4 5 6 \n7 8 0 \n0 0 0 \n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
696_D. Legen...
Solve the following coding problem using the programming language python: Barney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible. <image> Initially, happiness level of Nora is 0. Nora loves...
vfc_73141
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6\n3 2 8\nheart\nearth\nart\n", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6\n3 2 1\nheart\nearth\nart\n", "output": "6\n", "type": "stdin_stdout" },...
code_contests
verifiable_code
717_E. Paint it really, really dark gray
Solve the following coding problem using the programming language python: I see a pink boar and I want it painted black. Black boars look much more awesome and mighty than the pink ones. Since Jaggy became the ruler of the forest, he has been trying his best to improve the diplomatic relations between the forest regio...
vfc_73145
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n1\n-1\n1\n-1\n2 5\n4 3\n2 4\n4 1\n", "output": "1 4 3 4 2 5 2 4 1 4 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n-1\n-1\n1\n-1\n1\n1\n-1\n1\n1\n-1\n1\n-1\n1 3\n1 2\n2 5\n2 4\...
code_contests
verifiable_code
739_A. Alyona and mex
Solve the following coding problem using the programming language python: Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent element...
```python n,m=map(int,input().split()) min_val=9999999 for _ in range(m): y,x=map(int,input().split()) if min_val>x-y: x1=x y1=y min_val=x-y print(min_val+1) L=[0]*n tp=0 listNum=[] for i in range(n): listNum.append(tp) tp+=1 if tp>min_val: tp=0 for i in listNum[:-1]:...
vfc_73149
{ "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 2\n1 4\n2 4\n", "output": "3\n0 1 2 0 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n1 3\n2 5\n4 5\n", "output": "2\n0 1 0 1 0 \n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
761_F. Dasha and Photos
Solve the following coding problem using the programming language python: Dasha decided to have a rest after solving the problem D and began to look photos from previous competitions. Let's call photos as the matrix with the size n × m, which consists of lowercase English letters. Some k photos especially interested...
vfc_73153
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 2\naaa\naaa\naaa\n1 1 2 2 b\n2 2 3 3 c\n", "output": "10\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
785_A. Anton and Polyhedrons
Solve the following coding problem using the programming language python: Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: * Tetrahedron. Tetrahedron has 4 triangular faces. * Cube. Cube has 6 square faces. * Octahedron. Octahedron has 8 tria...
```python a = int(input()) sum = 0 for i in range(1,a+1): b = input() if b == 'Tetrahedron': sum += 4 elif b == 'Cube': sum += 6 elif b == 'Octahedron': sum += 8 elif b == 'Dodecahedron': sum += 12 else: sum += 20 print(sum) ```
vfc_73157
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nDodecahedron\nOctahedron\nOctahedron\n", "output": "28\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nIcosahedron\nCube\nTetrahedron\nDodecahedron\n", "output": "42\n", ...
code_contests
verifiable_code
807_A. Is it rated?
Solve the following coding problem using the programming language python: Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each par...
```python #####--------------Template Begin-------------------#### import math import sys import string #input = sys.stdin.readline def ri(): #Regular input return input() def ii(): #integer input return int(input()) def li(): #list input return input().split() def mi(): #map input return list(map(int, input().spli...
vfc_73161
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699\n", "output": "maybe\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400\n", "outpu...
code_contests
verifiable_code
831_B. Keyboard Layouts
Solve the following coding problem using the programming language python: There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet. You are given two strings consisting ...
```python a=list(input()) b=list(input()) d=[] for i in range(26): a.append(chr(ord(a[i])-32)) b.append(chr(ord(b[i])-32)) c=list(input()) for i in c: try: d.append(b[a.index(i)]) except: d.append(i) print(''.join(d)) ```
vfc_73165
{ "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": "qwertyuiopasdfghjklzxcvbnm\nveamhjsgqocnrbfxdtwkylupzi\nTwccpQZAvb2017\n", "output": "HelloVKCup2017\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "mnbvcxzlkjhgfdsapoiuytrewq\nasdfghjklqw...
code_contests
verifiable_code
852_C. Property
Solve the following coding problem using the programming language python: Bill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on time, court decided to punish Bill by making hi...
```python n = int(input()) a = input().split() for i in range(n): a[i] = int(a[i]) b = [] for i in range(0, n-1): b.append((a[i]-(n-a[i+1]), i)) b.append((a[n-1]-(n-a[0]), n-1)) b = sorted(b) ans = n*[0] for i in range(n): # the line segment at index b[i][1] ans[b[i][1]] = i for i in range(n): print...
vfc_73169
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 1 2\n", "output": "0 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "17\n7 10 12 11 13 0 9 6 4 2 15 3 5 8 14 16 1\n", "output": "8 12 14 15 5 3 7 4 0 9 11 1 6 13 16 10 2 \n...
code_contests
verifiable_code
876_D. Sorting the Coins
Solve the following coding problem using the programming language python: Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged ...
```python import sys input = sys.stdin.readline n = int(input()) p = list(map(int, input().split())) flag = [1]*n r = n-1 cnt = 0 print(1, end=' ') for i in range(n-1): flag[p[i]-1] = 0 while flag[r]==0: r -= 1 cnt += 1 print(i+2-cnt, end=' ') print(1) ```
vfc_73173
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 4 2\n", "output": "1 2 3 2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n6 8 3 4 7 2 1 5\n", "output": "1 2 2 3 4 3 4 5 1\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
8_D. Two Friends
Solve the following coding problem using the programming language python: Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square. Once they went to the cinema, and the film impressed them so deeply, that ...
```python def a(): t1, t2 = map(int, input().split()) cinema = complex(*map(int, input().split())) house = complex(*map(int, input().split())) shop = complex(*map(int, input().split())) cinema_to_house = abs(house - cinema) cinema_to_shop = abs(shop - cinema) shop_to_house = abs(house - shop...
vfc_73177
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n0 0\n2 0\n1 0\n", "output": "2.0000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 2\n0 0\n4 0\n-3 0\n", "output": "1.0000000000\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
922_C. Cave Painting
Solve the following coding problem using the programming language python: Imp is watching a documentary about cave painting. <image> Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1...
```python n,k = list(map(int,input().split())) # n = int(input()) # k = int(input()) d = {} pos = False for i in range(1,k+1): r = n%i try: d[r] += 1 if(d[r] > 1): print("No") # print(i) pos = True break except: d[r] = i # if(i > int(1e7)): # print("No") # break if(not pos): print("Yes") ...
vfc_73181
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2324...
code_contests
verifiable_code
94_D. End of Exams
Solve the following coding problem using the programming language python: Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams! Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each...
```python import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') n, w, m = map(int, input().split()) w = float(w) eps = 1e-9 req = n * w / m cup = [req] * m ans = [[] for _ in range(m)] j = 0 for i in range(n): milk = w cnt = 0 while j < m a...
vfc_73185
{ "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": "5 500 2\n", "output": "YES\n1 500.000000 2 500.000000 3 250.000000 \n3 250.000000 4 500.000000 5 500.000000 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 100 7\n", "output": "NO...
code_contests
verifiable_code
998_A. Balloons
Solve the following coding problem using the programming language python: There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets with ...
```python def solution(n, b): if n <= 2 and b == [b[0]] * n: return -1 return f'1 {b.index(min(b)) + 1}' def main(): packs = int(input()) balloons = input().split() print(solution(packs, balloons)) if __name__ == '__main__': main() ```
vfc_73193
{ "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\n5 5\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n10\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
bear-and-crying
Solve the following coding problem using the programming language python: View Russian Translation Limak is a polar bear who often chats online with his friends. Nowadays, bears often use emoticons to express their feelings. While most emoticons are short and boring, there is one exception. Crying emoticon is made o...
```python def main(): s = raw_input() c = 0 rc = 0 i = s.find(';') if i == -1: return 0 semcols_seen = 0 while i < len(s): if s[i] == '_': rc = rc * 2 + semcols_seen else: semcols_seen += 1 c += rc i += 1 return c % (1...
vfc_73197
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": ";;;;;__;_\n\nSAMPLE", "output": "15", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
code-hunt
Solve the following coding problem using the programming language python: Little Stuart has reached the final level of 'Code Hunt', the annual treasure hunt organised by HackerEarth. Now for the final level, Little Stuart has to choose a door from infinite number of doors numbered from 1 to infinity. Out of these only...
```python t=input() while(t>0): size=input() a=[] cnt=[0]*105 count=[0]*105 """ for i in range(0,105): cnt.append(0) count.append(0) """ Count=0 a=map(int,raw_input().split()) for i in range(0,size): cnt[a[i]]+=1 for i in range(0,size): count[a[i]]+=1 j=1 while(j*j<=a[i]): num=a[i] if(num...
vfc_73201
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n10 2 3\n2\n3 5\n\nSAMPLE", "output": "1\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n10 2 3\n2\n5 5\n\nSAMPLE", "output": "1\n1\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
factor-game-5
Solve the following coding problem using the programming language python: This time Alice and Bob have devised a new game of numbers to decide who is the better player among the two. Each time they are given n positive integers and they perform an operation on these integers in each turn. In a particular operation a p...
```python sieve={i:0 for i in range(1,100001)} for i in range(2,100001): if sieve[i]==0: for j in range(1,1+100000/i): k=i*j while k%i==0: k/=i sieve[i*j]+=1 n=input() ans=0 s=map(int,raw_input().split()) for i in s: ans^=sieve[i] if ans==0: pr...
vfc_73205
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 \n1 2 3 4", "output": "ALICE", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
magical-power
Solve the following coding problem using the programming language python: Raja tranports boxes from one place to another.But the boxes are too heavy it is very diffcult for him to transport them.But he is Raja:-p he has a magical power he can choose any random number D and if sum of weight of two continuous boxes one ...
```python for _ in xrange(input()): n,a,b=input(),map(int,raw_input().split()),input() for i in xrange(n-1): if (a[i]+a[i+1])%b==0: a[i+1]=(a[i]+a[i+1])/b else : print a[i], print a[n-1] ```
vfc_73213
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n5 7 7 15 12\n7\n\nSAMPLE", "output": "5 2 15 12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5\n5 7 7 15 12\n13\n\nSAMPLE", "output": "5 7 7 15 12\n", "type": "stdi...
code_contests
verifiable_code
nikhil-and-his-golden-children
Solve the following coding problem using the programming language python: Mr Nikhil has k Children. They are suffering from a disease called Gasomia . According to his family Doctor , Child 1 requires atleast x1 tablets , Child 2 requires atleast x2 ......... Child k requires atleast xk tablets. As Nikhil got job in...
```python A,M=[1]*500005,1000000007; def fun(): for i in xrange(1,500005): A[i]=(A[i-1]*i)%M fun(); for _ in xrange(int(raw_input())): n,k=map(int,raw_input().split()); B=map(int,raw_input().split()); s=sum(B); k-=s; if k<0: print 0; continue; print ( A[n+k-1] * ( pow( A[n-1],M-2,M )* pow( A[k],M-2,M) )%M ) % M; `...
vfc_73217
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 3\n1 1\n\nSAMPLE", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n50 2234\n2 49 19 50 40 30 43 25 2 14 34 28 20 4 22 7 2 43 28 28 15 45 49 10 37 20 10 35 10 29 20 42...
code_contests
verifiable_code
psychic-powers
Solve the following coding problem using the programming language python: Little Jhool always wanted to have some psychic powers so that he could showoff his skills, and magic to people and impress them. (Specially, his girlfriend Big Jhool!) But, in spite all his efforts, hardwork, dedication, Googling, watching yout...
```python a=raw_input() if "000000" in a or "111111" in a: print "Sorry, sorry!" else: print "Good luck!" ```
vfc_73221
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0001111110\n\nSAMPLE", "output": "Sorry, sorry!\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000111000111000111000111", "output": "Good luck!\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
shil-aditya-and-utkarsh
Solve the following coding problem using the programming language python: Shil, Aditya and Utkarsh go to a candy shop. There are N candies present in the shop, which are indexed from 1 to N. All three of them select one candy to eat. However, a candy tastes delicious if and only if, the index of candy chosen by Shil ...
```python from math import factorial def fact(n): return factorial(n)/factorial(n-2) n=input() ans=0 for x in range(n-1,1,-1): ans+=fact(x) print ans ```
vfc_73225
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n\nSAMPLE", "output": "8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
the-game-of-factorials
Solve the following coding problem using the programming language python: fact(n) refers to n×(n−1)×⋯×3×2×1 Example, fact(10)=9×⋯×3×2×1=3628800, and the summation of the digits of fact(10) is 3+6+2+8+8+0+0=27. Write your program to find the summation of the digits of fact(N). Input Format The first line contains an...
```python import math for _ in xrange(input()): N=input() a=math.factorial(N) b=sum(map(int,str(a))) print b ```
vfc_73229
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n6\n\nSAMPLE", "output": "6\n9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
xsquare-and-palindromes-insertion
Solve the following coding problem using the programming language python: Xsquare likes strings a lot but much more, he likes palindromic strings. Today, he has a string S consisting of lower case English letters. Xsquare wants to convert his string S to a palindromic string. For the above purpose to be served , he ca...
```python for _ in xrange(input()): Q=raw_input(); A,l,flag=[0]*130,len(Q),0; for i in xrange(l): A[ord(Q[i])]+=1; for i in xrange(97,125): if A[i]%2: flag+=1; if flag>1: print flag-1 else: p...
vfc_73233
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nradar\nabc\nab\ncaa\nccdbb\n\nSAMPLE", "output": "0\n2\n1\n0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\nctaqinomqgoggfkanhrhfriftpfbohogtcalpcqknmphlntahibtlloqcthforeflhor...
code_contests
verifiable_code
p00080 Third Root
Solve the following coding problem using the programming language python: The solution of $ x ^ 3 = q $ is to calculate the recurrence formula $ x_ {n + 1} = x_n-\ frac {x_ {n} ^ 3 --q} {3x_ {n} ^ 2} $ It can be calculated approximately with. Put a positive number $ \ frac {q} {2} $ in $ x_1 $ $ x_2 = x_1-\ frac {x_...
```python while True : q = int(input()) if q == -1 : break else : x = q / 2 while abs(x ** 3 - q) >= 0.00001 * q : x -= ((x ** 3 - q) / (3 * x ** 2)) print(f"{x:.6f}") ```
vfc_73277
{ "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": "15\n15\n-1", "output": "2.466212\n2.466212", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00212 Highway Express Bus
Solve the following coding problem using the programming language python: Mr. A is planning to travel alone on a highway bus (hereinafter referred to as "bus") during his high school holidays. First, Mr. A chose the town he wanted to visit the most and made it his destination. Next, you have to decide the route to tra...
```python from heapq import heappush, heappop INF = 10 ** 20 while True: c, n, m, s, d = map(int, input().split()) s -= 1 d -= 1 if c == 0: break edges = [[] for _ in range(n * (c + 1))] for _ in range(m): a, b, f = map(int, input().split()) a -= 1 b -= 1 for i in range(c + 1): ed...
vfc_73281
{ "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 3 1 3\n1 3 2000\n1 2 1000\n2 3 1000\n2 3 3 1 3\n1 3 2300\n1 2 1000\n2 3 1200\n2 6 6 5 1\n1 2 1500\n1 3 4500\n2 6 2000\n5 4 1000\n6 4 2200\n3 5 3000\n0 0 0 0 0", "output": "1000\n1100\n3750", "type": "stdin_stdout" ...
code_contests
verifiable_code
p00589 Extraordinary Girl II
Solve the following coding problem using the programming language python: She loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout (Figure 1). Pushing butt...
```python # AOJ 1003: Extraordinary Girl II # Python3 2018.7.4 bal4u tbl = ["", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", \ "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"] while True: try: s = input().strip() except: break ans, i = '', 0 while i < len(s): c = s[i] w, d, i = 0, int(c), i+1 while i ...
vfc_73289
{ "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": "666660666\n44444416003334446633111\n20202202000333003330333", "output": "No\nI'm fine.\naaba f ff", "type": "stdin_stdout" }, { "fn_name": null, "input": "666660666\n62238520449600706121638\n2020220...
code_contests
verifiable_code
p00726 The Genome Database of All Space Life
Solve the following coding problem using the programming language python: In 2300, the Life Science Division of Federal Republic of Space starts a very ambitious project to complete the genome sequencing of all living creatures in the entire universe and develop the genomic database of all space life. Thanks to scient...
```python def main(): def pearser(s, n): if s == "": return "" i = 0 while 1: if not s[i].isdigit():break i += 1 if i == 0: r = pearser(s[i + 1:], n - 1) return s[0] + r if s[i] == "(": r = Parentp(s[i:],...
vfc_73293
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ABC 3\nABC 0\n2(4(AB)3(XY))10C 30\n1000(1000(1000(1000(1000(1000(NM)))))) 999999\n0 0", "output": "0\nA\nC\nM", "type": "stdin_stdout" }, { "fn_name": null, "input": "ABC 3\nABC 1\n2(4(AB)3(XY))10C 3...
code_contests
verifiable_code
p00866 Stopped Watches
Solve the following coding problem using the programming language python: In the middle of Tyrrhenian Sea, there is a small volcanic island called Chronus. The island is now uninhabited but it used to be a civilized island. Some historical records imply that the island was annihilated by an eruption of a volcano about...
```python from itertools import permutations BASE = 12*3600 def convert(v): return "%02d:%02d:%02d" % (v // 3600, (v // 60) % 60, v % 60) while 1: N = int(input()) if N == 0: break R = set() L = [] for i in range(N): ts = set() *E, = map(int, input().split()) for ...
vfc_73297
{ "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\n8 8 18\n32 32 32\n57 2 57\n5\n49 3 49\n7 30 44\n27 21 21\n33 56 56\n21 46 4\n3\n45 52 28\n36 26 36\n20 55 50\n10\n33 8 39\n50 57 43\n35 21 12\n21 17 11\n16 21 58\n45 40 53\n45 30 53\n39 1 8\n55 48 30\n7 48 15\n0", "output"...
code_contests
verifiable_code
p01129 Data Center on Fire
Solve the following coding problem using the programming language python: It's a little future story from now on. Recording devices with high-density storage and long-term storage have been developed, but the speed at which content is produced is unusually high, so a data center was established. When the data center w...
vfc_73305
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n5000\n10 20 0 30 5\n10 1000 6 1\n20 500 8 1\n3 40 25 30\n0 0", "output": "50 84.000", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n5000\n10 20 0 46 5\n10 1000 6 1\n20 500 8 1\n3 4...
code_contests
verifiable_code
p01268 Matsuzaki Number
Solve the following coding problem using the programming language python: Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzak...
```python def eratosthenes(n): prime_table = [False,False,True]+[False if i%2!=0 else True for i in range(n-2)] i=3 pn=[2] while i*i<=n: if prime_table[i]: j=i*i pn.append(i) while j<=n: prime_table[j]=False j+=i i+=2 ...
vfc_73309
{ "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": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100000 100\n-1 -1", "output": "42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
p01438 Butterfly
Solve the following coding problem using the programming language python: Claire is a man-eater. She's a real man-eater. She's going around with dozens of guys. She's dating all the time. And one day she found some conflicts in her date schedule. D'oh! So she needs to pick some dates and give the others up. The dates...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x i...
vfc_73313
{ "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\n2 100\n10 12\n14 16\n2 200\n12 13\n18 20\n4\n1 100\n6 22\n1 1000\n6 22\n1 10000\n6 22\n1 100000\n6 22\n16\n1 100000000\n6 7\n1 100000000\n7 8\n1 100000000\n8 9\n1 100000000\n9 10\n1 100000000\n10 11\n1 100000000\n11 12\n1 100000...
code_contests
verifiable_code
p01585 Mickle's Beam
Solve the following coding problem using the programming language python: Major Mickle is commanded to protect a secret base which is being attacked by N tanks. Mickle has an ultimate laser rifle called Mickle's beam. Any object shot by this beam will be immediately destroyed, and there is no way for protection. Furth...
vfc_73317
{ "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": "", "output": "", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01744 Dense Amidakuji
Solve the following coding problem using the programming language python: There is an Amidakuji that consists of w vertical bars and has a height (the number of steps to which horizontal bars can be added) of h. w is an even number. Of the candidates for the place to add the horizontal bar of this Amidakuji, the ath f...
```python from collections import defaultdict import sys def solve(): readline = sys.stdin.readline write = sys.stdout.write H, W, N = map(int, readline().split()) A = [0]*W B = [0]*W C = [0]*W for i in range(W//2): A[i] = i * 2 + 1 A[-i-1] = i * 2 B[i*2] = C[i*2 - 1...
vfc_73321
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4 1\n3 3", "output": "2\n3\n4\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 6 10\n10 4\n4 4\n5 1\n4 2\n7 3\n1 3\n2 4\n8 2\n7 5\n7 1", "output": "1\n4\n3\n2\n5\n6", "typ...
code_contests
verifiable_code
p02021 Working
Solve the following coding problem using the programming language python: G: Working Kou decided to do the same number of jobs every day for the next $ N $. $ A_i $ jobs are added on the $ i $ day of the $ N $ day. Mr. Kou has no work to do now, and he doesn't have to finish all the work by the $ N $ day. How many...
```python from itertools import accumulate n=int(input()) a=list(accumulate(map(int,input().split()))) for i in range(100,0,-1): for j in range(n): if i*(j+1)>a[j]:break else: print(i) break ```
vfc_73329
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 2 5 3 1", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4 2 5 3 0", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
p02304 Segment Intersections: Manhattan Geometry
Solve the following coding problem using the programming language python: For given $n$ segments which are parallel to X-axis or Y-axis, find the number of intersections of them. Constraints * $1 \leq n \leq 100,000$ * $ -1,000,000,000 \leq x_1, y_1, x_2, y_2 \leq 1,000,000,000$ * Two parallel segments never overlap...
```python # Acceptance of input import sys file_input = sys.stdin n = file_input.readline() EP = [] l = -1000000001 u = 1000000001 vs_x = set() for line in file_input: x1, y1, x2, y2 = (map(int, line.split())) if x1 == x2: if y1 < y2: EP.append((y1, l, x1)) EP.append((y2, u, ...
vfc_73337
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n2 2 2 5\n1 3 5 3\n4 1 4 4\n5 2 7 2\n6 1 6 3\n6 5 6 7", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 2 2 5\n1 3 5 3\n4 1 4 4\n5 2 7 2\n6 1 6 3\n4 5 6 7", "output...
code_contests
verifiable_code
ccaurcc5
Solve the following coding problem using the programming language python: An integer is said to be prime palindrome if it is a prime number and its reverse is same as that of the original number. Your task is to output the sum of all such prime palindromes lies between the range N and M (N and M both are inclusive). ...
```python a = input() def prime(number): flag = 1 if number == 2: return True else: for a in range(2,number): if number % a == 0: flag = 1 break else: flag = 0 if flag == 0: return True else:...
vfc_73345
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1 101", "output": "129", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 111", "output": "129\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
csixievr
Solve the following coding problem using the programming language python: Now a days it is possible to access particular website without typing it's full name. This helps in reducing the typing time. So in this you are given a website name as input and you have to cut short it's name and print the shoretd length of th...
```python n=input() for l in range(n): a=[] vowels="aeuio" website=raw_input() a=website.split('.') list1=['a','e','u','i','o'] for i in list1: a[1]=a[1].replace(i,"") a[1]+=".com" print str(len(a[1]))+"/"+str(len(website)) ```
vfc_73349
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nwww.google.com\nwww.yahoo.com", "output": "7/14\n6/13", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nwww.moogle.cog\nwww.yahoo.com", "output": "7/14\n6/13\n", "type": "std...
code_contests
verifiable_code
mixtures
Solve the following coding problem using the programming language python: Harry Potter has n mixtures in front of him, arranged in a row.Each mixture has one of 100 different colors (colors have numbers from 0 to 99). He wants to mix all these mixtures together. At each step, he is going to take two mixtures that sta...
```python ## MIXTURES on Codechef ## Comments say that it is just the matrix multiplication DP ## Top down attempt DP = {} c = [] def calc(s, e): if s == e: return (0, c[e]) if (s,e) in DP: return DP[(s,e)] ans = 1e9 color = -1 for i in xrange(s, e): c1, p1 = calc(s,i) ...
vfc_73357
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n18 19\n3\n40 60 20", "output": "342\n2400\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n18 19\n3\n40 60 36", "output": "342\n2400\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
repstr
Solve the following coding problem using the programming language python: Given a string S (containing at most 10^5 lowercase English letters). You are requested to find out from continuous substrings a string having length from L to H, which appears the most times; if there are more than one answer, find the most len...
```python import sys def get_int(): return int(sys.stdin.readline()) def get_ints(): return [int(i) for i in sys.stdin.readline().split()] def find_max(line, pos, L, H): for i in range(H-L): new_pos = [ j + 1 for j in pos if j != len(line) - 1] #print 'new', new_pos if len(new_pos...
vfc_73361
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5\naabcbcbca\n3 5\nbaaaababababbababbab\n1 4\nabcd\n0 0", "output": "2 4\n6 3\n1 4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tsx02
Solve the following coding problem using the programming language python: Byteland is a country whose population squares every year. The president of Byteland is aware of the situation and wants to take proper steps to control the population. For this he wants to estimate the population of the country for a given year...
```python t = int(raw_input()) for i in range(0, t): p, y = raw_input().split() p = int(p) y = int(y) for j in range(0, (y-2000)): p = p**2 % (10**9 + 7) print p % (10**9 + 7) ```
vfc_73365
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 2002\n3 2000", "output": "625\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1017_C. The Phone Number
Solve the following coding problem using the programming language python: Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number! The only thing Mrs. Smith remembered was that any permutation of n can be a secret phone number. Only those permutations that minimize secret value...
```python n = int(input()) b = int(n ** 0.5) ans = [] for i in range(0, n, b): ans = [j for j in range(i + 1, min(i + 1 + b, n + 1))] + ans print(*ans) ```
vfc_73369
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "3 4 1 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "22...
code_contests
verifiable_code
1063_E. Lasers and Mirrors
Solve the following coding problem using the programming language python: Oleg came to see the maze of mirrors. The maze is a n by n room in which each cell is either empty or contains a mirror connecting opposite corners of this cell. Mirrors in this maze reflect light in a perfect way, which causes the interesting v...
vfc_73377
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 1 3 2\n", "output": "3\n.\\.\\\n\\\\..\n....\n....\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n", "output": "1\n.\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
1153_A. Serval and Bus
Solve the following coding problem using the programming language python: It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor litt...
```python import math def main(): n,t=map(int,input().split()) num=n mini=120000000 route=0 while(n>0): s,d=map(int,input().split()) if(s>=t): wa=s-t if(wa<mini): mini=wa route=num-n+1 elif(s<t): ti=(int)(mat...
vfc_73393
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 7\n2 2\n2 3\n2 4\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n6 4\n9 5\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1174_F. Ehab and the Big Finale
Solve the following coding problem using the programming language python: This is an interactive problem. You're given a tree consisting of n nodes, rooted at node 1. A tree is a connected graph with no cycles. We chose a hidden node x. In order to find this node, you can ask queries of two types: * d u (1 ≤ u ≤...
```python from sys import stdin, stdout from itertools import repeat memo = {} def Qd(x): if x in memo: return memo[x] print 'd', x stdout.flush() res = int(stdin.readline()) if res == -1: quit() memo[x] = res return res def Qs(x): print 's', x stdout.flush() res ...
vfc_73397
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2\n1 3\n3 4\n3 5\n3\n5", "output": "d 1\nd 3\nd 1\n! 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n3 2\n1 2\n", "output": "d 1\nd 2\n! 2\n", "type": "stdin_stdout...
code_contests
verifiable_code
1193_B. Magic Tree
Solve the following coding problem using the programming language python: We have a magic tree: a rooted tree on n vertices. The vertices are numbered 1 through n. Vertex 1 is the root. The magic tree gives us magic fruit. The fruit only grows in vertices of the tree other than the root. Each vertex contains at most ...
vfc_73401
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 4 10\n1\n2\n1\n4\n4\n3 4 5\n4 7 2\n5 4 1\n6 9 3\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20 10 10\n1\n1\n3\n1\n5\n2\n1\n8\n2\n4\n6\n9\n12\n8\n15\n14\n6\n5\n17\n6 ...
code_contests
verifiable_code
1210_D. Konrad and Company Evaluation
Solve the following coding problem using the programming language python: Konrad is a Human Relations consultant working for VoltModder, a large electrical equipment producer. Today, he has been tasked with evaluating the level of happiness in the company. There are n people working for VoltModder, numbered from 1 to...
vfc_73405
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2\n2 3\n1 3\n5\n1\n2\n2\n1\n3\n", "output": "1\n1\n1\n1\n1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n1 2\n2 4\n1 3\n3 4\n2 3\n2\n2\n3\n", "output": "4\n3\n2\n", ...
code_contests
verifiable_code
1231_B. Ania and Minimizing
Solve the following coding problem using the programming language python: Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any leading zeroes and it'll...
```python n,k=map(int,input().split()) l=list(input()) if k==0: print(*l,sep='') elif n==1: print(0) else: if l[0]!='1': #print("HI") l[0]='1' k-=1 for i in range(1,n): #print(k) if k>0 and int(l[i])>0: if l[i]!='0': l[i]='0' ...
vfc_73409
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n102\n", "output": "100\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n51528\n", "output": "10028\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1272_D. Remove One Element
Solve the following coding problem using the programming language python: You are given an array a consisting of n integers. You can remove at most one element from this array. Thus, the final length of the array is n-1 or n. Your task is to calculate the maximum possible length of the strictly increasing contiguous...
```python # ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in...
vfc_73417
{ "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\n6 5 4 3 2 4 3\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 5 3 4\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1316_E. Team Building
Solve the following coding problem using the programming language python: Alice, the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of p players playing in p different positions. She also recognizes the importance of audience support, so she wants to select k pe...
```python import io import os # PSA: # The key optimization that made this pass was to avoid python big ints by using floats (which have integral precision <= 2^52) # None of the other optimizations really mattered in comparison. # Credit for this trick goes to pajenegod: https://codeforces.com/blog/entry/77309?#comm...
vfc_73425
{ "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": "4 1 2\n1 16 10 3\n18\n19\n13\n15\n", "output": "44", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1338_A. Powered Addition
Solve the following coding problem using the programming language python: You have an array a of length n. For every positive integer x you are going to perform the following operation during the x-th second: * Select some distinct indices i_{1}, i_{2}, …, i_{k} which are between 1 and n inclusive, and add 2^{x-1} ...
```python import math from sys import stdin, stdout t = int(stdin.readline().strip()) def solve(): n = int(stdin.readline().strip()) arr = list(map(int, (stdin.readline().strip().split()))) ans = 0 now = arr[0] for i in range(1, len(arr)): if arr[i] < now: ans = max(ans, len(b...
vfc_73429
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 7 6 5\n5\n1 2 3 4 5\n2\n0 -4\n", "output": "2\n0\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3\n1000000000 0 -1000000000\n1\n6\n2\n-1000000000 1000000000\n2\n1000000000 -...
code_contests
verifiable_code
135_E. Weak Subsequence
Solve the following coding problem using the programming language python: Little Petya very much likes strings. Recently he has received a voucher to purchase a string as a gift from his mother. The string can be bought in the local shop. One can consider that the shop has all sorts of strings over the alphabet of fix...
vfc_73433
{ "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 2\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n", "output": "1593\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1...
code_contests
verifiable_code
1380_A. Three Indices
Solve the following coding problem using the programming language python: You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once. Find three indices i, j and k such that: * 1 ≤ i < j < k ≤ n; * p_i < p_j an...
```python def solve(arr): for i in range(1, len(arr)-1): if arr[i] > arr[i-1] and arr[i] > arr[i+1]: print("YES") print(i, i+1, i+2) return print("NO") for _ in range(int(input())): input() arr = [int(e) for e in input().split()] solve(arr) ```
vfc_73437
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n2 1 4 3\n6\n4 6 1 2 5 3\n5\n5 3 1 2 4\n", "output": "YES\n2 3 4\nYES\n1 2 3\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4\n2 1 4 3\n6\n4 6 1 2 5 3\n5\n5 3 1 2 4\n", ...
code_contests
verifiable_code
1400_A. String Similarity
Solve the following coding problem using the programming language python: A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10010 ...
```python t = int(input()) for _ in range(t): n = int(input()) s = input() print(s[0::2]) ```
vfc_73441
{ "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\n1\n1\n3\n00000\n4\n1110000\n2\n101\n", "output": "1\n000\n1100\n11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1\n1\n3\n00000\n4\n1110000\n2\n101\n", "output": "1\n000\n110...
code_contests
verifiable_code
1424_A. Wakanda Forever
Solve the following coding problem using the programming language python: In the Kingdom of Wakanda, the 2020 economic crisis has made a great impact on each city and its surrounding area. Cities have made a plan to build a fast train rail between them to boost the economy, but because of the insufficient funds, each ...
vfc_73445
{ "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\n35 19 20\n76 14 75\n23 43 78\n14 76 98\n", "output": "3\n4\n1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 5 8\n7 1 12\n4 6 7\n8 4 5\n", "output": "-1\n", "type":...
code_contests
verifiable_code
1444_B. Divide and Sum
Solve the following coding problem using the programming language python: You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q). Let's sort p in non-decreasing order, and...
```python n=int(input()) a=list(map(int,input().split())) mod=998244353 def ncr(n, r, p): # initialize numerator # and denominator num = den = 1 for i in range(r): num = (num * (n - i)) % p den = (den * (i + 1)) % p return (num * pow(den, p - 2, p)) % p a.sort()...
vfc_73449
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1 4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 2 2 2 2 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
1469_C. Building a Fence
Solve the following coding problem using the programming language python: You want to build a fence that will consist of n equal sections. All sections have a width equal to 1 and height equal to k. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simp...
```python for _ in range(int(input())): bool = True n, h = map(int, input().split()) list = [int(x) for x in input().split()] maxi, mini = list[0], list[0] for i in range(1, n): maxi = max(maxi - h + 1, list[i]) mini = min(mini + h - 1, list[i] + h - 1) if maxi > mini: ...
vfc_73453
{ "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\n6 3\n0 0 2 5 1 1\n2 3\n0 2\n3 2\n3 0 2\n", "output": "\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 10\n7 4\n", "output": "YES\n", "type": "stdin_stdou...
code_contests
verifiable_code
172_B. Pseudorandom Sequence Period
Solve the following coding problem using the programming language python: Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i ≥ 1). Here a, b, m are constants, fixed for the given realization of...
```python import sys a, b, m, x = tuple(map(int, input().split())) z=[0]*(m+1) cnt=1 z[x]=cnt while True: cnt += 1 x = (x*a+b)%m if z[x] > 0: print(str(cnt-z[x])) sys.exit(0) z[x] = cnt ```
vfc_73469
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 6 12 11\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6 81 9\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
192_C. Dynasty Puzzles
Solve the following coding problem using the programming language python: The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of thei...
```python import sys import math from heapq import *; input = sys.stdin.readline from functools import cmp_to_key; def pi(): return(int(input())) def pl(): return(int(input(), 16)) def ti(): return(list(map(int,input().split()))) def ts(): s = input() return(list(s[:len(s) - 1])) def invr(): re...
vfc_73473
{ "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\nabc\nca\ncba\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
216_C. Hiring Staff
Solve the following coding problem using the programming language python: A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. ...
```python n, m, k = map(int, input().split()) res, x = [], 1 if k == 1: while x <= n + m: res += [str(x)] x += n - 1 else: res = ['1'] while x <= n + m: res += [str(x)]*(k-1) x += n if x <= n + m + 1: res.append(str(x-1)) print(len(res)) print(' '.join(res...
vfc_73477
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3 2\n", "output": "4\n1 1 4 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 1\n", "output": "3\n1 3 5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
23_C. Oranges and Apples
Solve the following coding problem using the programming language python: In 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges. Input The first input line contains one number T — amount o...
```python import sys input = sys.stdin.readline t = int(input()) for cs in range(t): n = int(input()) arr = [] for i in range(2 * n - 1): a, b = map(int, input().split()) arr.append((a, b, i)) arr.sort() res = [] for i in range(0, len(arr), 2): if i + 1 < len(arr): if arr[i][1] > arr[i + 1...
vfc_73481
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n10 15\n5 7\n20 18\n1\n0 0\n", "output": "YES\n1 3 \nYES\n1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n10 15\n5 7\n20 18\n1\n0 0\n", "output": "YES\n1 3 \nYES\n1 \n"...
code_contests
verifiable_code
265_A. Colorful Stones (Simplified Edition)
Solve the following coding problem using the programming language python: There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the color of...
```python stones = list(input()) instructions = list(input()) position = 0 i=0 for j in range(len(instructions)): if instructions[j] == stones[i]: i+=1 print(i+1) ```
vfc_73485
{ "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": "RRRBGBRBBB\nBBBRR\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
289_A. Polo the Penguin and Segments
Solve the following coding problem using the programming language python: Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo c...
```python a,b = map(int, input().split()) c = 0 for i in range(a): d,e = map(int, input().split()) c += (e-d+1) if not(c%b): print(0) else: print((b-(c%b))%b) ```
vfc_73489
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n1 2\n3 4\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
314_A. Sereja and Contest
Solve the following coding problem using the programming language python: During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the firs...
```python from sys import stdin,stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int,stdin.readline().split())) def fn(a): print('a',a) n=len(a) pos1=[0] for i in range(1,n): pos1+=[pos1[-1]+a[i]*i] print('pos1',pos1) neg=[] for i in range(n): neg+=[i*(n-i-1...
vfc_73493
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 0\n5 3 4 1 2\n", "output": "2\n3\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 -10\n5 5 1 7 5 1 2 4 9 2\n", "output": "2\n4\n5\n7\n8\n9\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
336_C. Vasily the Bear and Sequence
Solve the following coding problem using the programming language python: Vasily the bear has got a sequence of positive integers a1, a2, ..., an. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum. The beauty of the written out numbers b...
```python from sys import stdin,stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int,stdin.readline().split())) for _ in range(1):#nmbr()): n=nmbr() a=lst() bits=[[0 for _ in range(34)] for _ in range(n)] for i in range(n): for j in range(34): bits[i][33-j]=(a[i]>>j...
vfc_73497
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "2\n4 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 4\n", "output": "1\n4 ", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
359_D. Pair of Numbers
Solve the following coding problem using the programming language python: Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: 1. there is integer j (l ≤ j ≤ r), such that all integers a...
```python import math #import math #------------------------------warmup---------------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() s...
vfc_73501
{ "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\n1 3 5 7 9\n", "output": "1 4\n1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 3 5 7 11\n", "output": "5 0\n1 2 3 4 5 ", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
382_C. Arithmetic Progression
Solve the following coding problem using the programming language python: Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a1, a2, ..., an of length n, that the following condition fulfills: a2 - a1 = a3 - a2 = a4 - a3 = ... ...
```python n=int(input()) p=input().rstrip().split(' ') p.sort(key=int) if len(p)==1: print(-1) elif len(set(p))==1: print(1) print(p[0]) elif len(p)==2: if int(p[0])+2==int(p[1]): print(3) print(int(p[0])-2,int(p[0])+1,int(p[len(p)-1])+2) elif (int(p[0])+int(p[1]))%2==0: prin...
vfc_73505
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 3 4 5\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 3 5 9\n", "output": "1\n7\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
403_B. Upgrading Array
Solve the following coding problem using the programming language python: You have an array of positive integers a[1], a[2], ..., a[n] and a set of bad prime numbers b1, b2, ..., bm. The prime numbers that do not occur in the set b are considered good. The beauty of array a is the sum <image>, where function f(s) is d...
```python import fractions n, m = map(int, raw_input().split()) primes_cache = {} primes = [] def lowest_prime_divisor(x, sorted_primes_to_check=primes, cache=primes_cache): if x in cache: return cache[x] for i in sorted_primes_to_check: if i * i > x: cache[x] = x ...
vfc_73509
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n2 4 8 16\n3 5 7 11 17\n", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n4 20 34 10 10\n2 5\n", "output": "-2", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
452_F. Permutation
Solve the following coding problem using the programming language python: You are given a permutation of numbers from 1 to n. Determine whether there's a pair of integers a, b (1 ≤ a, b ≤ n; a ≠ b) such that the element <image> (note, that it is usual division, not integer one) is between a and b in this permutation. ...
```python n = int(input()) v = list(map(int, input().split())) ans = "NO" p = [] for i in range(n + 1): p.append(-1) for i in range(n): p[v[i]] = i for i in range(n - 1): for j in range(i + 1, min(n, i + 6)): if v[i] * 2 - v[j] >= 1 and v[i] * 2 - v[j] <= n and p[v[i] * 2 - v[j]] < i: an...
vfc_73517
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 5 2 4 3\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
475_D. CGCDSSQ
Solve the following coding problem using the programming language python: Given a sequence of integers a1, ..., an and q queries x1, ..., xq on it. For each query xi you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(al, al + 1, ..., ar) = xi. <image> is a greatest common divisor of v1, v2, ...
```python from sys import stdin import math from collections import defaultdict input = stdin.readline n = int(input()) arr = list(map(int, input().rstrip().split(" "))) q = int(input()) d = defaultdict(lambda : 0) current = defaultdict(lambda : 0) # totalCount1 = 0 # count1 = 0 for i in range(n): newCurrent = ...
vfc_73521
{ "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\n10 20 3 15 1000 60 16\n10\n1\n2\n3\n4\n5\n6\n10\n20\n60\n1000\n", "output": " 14\n 0\n ...
code_contests
verifiable_code
523_A. Rotate, Flip and Zoom
Solve the following coding problem using the programming language python: Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the verti...
```python I=input R=range w,h=map(int,I().split()) t=[I()for _ in R(h)] for r in[[t[i][j]*2for i in R(h)]for j in R(w)]:s=''.join(r);print(s+'\n'+s) ```
vfc_73529
{ "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": "9 20\n**.......\n****.....\n******...\n*******..\n..******.\n....****.\n......***\n*.....***\n*********\n*********\n*********\n*********\n....**...\n...****..\n..******.\n.********\n****..***\n***...***\n**.....**\n*.......*\n", ...
code_contests
verifiable_code
549_G. Happy Line
Solve the following coding problem using the programming language python: Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amoun...
```python R = lambda: list(map(int, input().split())) n = R()[0] a = R() for i in range(n): a[i] += i a = sorted(list(set(a))) if len(a) != n: print(':(') else: for i in range(n): print(a[i] - i, end=' ') ```
vfc_73533
{ "difficulty": "13", "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\n12 3 3\n", "output": "4 4 10 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n11 8\n", "output": "9 10 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
575_I. Robots protection
Solve the following coding problem using the programming language python: Company "Robots industries" produces robots for territory protection. Robots protect triangle territories — right isosceles triangles with catheti parallel to North-South and East-West directions. Owner of some land buys and sets robots on his ...
vfc_73537
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "17 10\n1 1 3 2 4\n1 3 10 3 7\n1 2 6 8 2\n1 3 9 4 2\n2 4 4\n1 4 15 10 6\n2 7 7\n2 9 4\n2 12 2\n2 13 8\n", "output": "2\n2\n2\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "17 10\n1 1...
code_contests
verifiable_code
598_D. Igor In the Museum
Solve the following coding problem using the programming language python: Igor is in the museum and he wants to see as many pictures as possible. Museum can be represented as a rectangular field of n × m cells. Each cell is either empty or impassable. Empty cells are marked with '.', impassable cells are marked with ...
```python import sys from queue import deque # sys.stdin = open('ivo.in') move = [(0, 1), (1, 0), (0, -1), (-1, 0)] n, m, k = map(int, sys.stdin.readline().split()) a = [] for i in range(n): a.append(sys.stdin.readline().rstrip()) visited = [] values = [] for x in range(n): visited.append([]) values.ap...
vfc_73541
{ "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": "5 6 3\n******\n*..*.*\n******\n*....*\n******\n2 2\n2 5\n4 3\n", "output": "6\n4\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4 1\n****\n*..*\n*.**\n****\n3 2\n", "output": ...
code_contests
verifiable_code
61_B. Hard Work
Solve the following coding problem using the programming language python: After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer! Some days before the contest, the teacher took a very si...
```python import itertools def remove_signs(s: str, signs: list) -> str: for i in range(len(signs)): s = s.replace(signs[i], '') return s def get_permulation_of_strings(s1, s2, s3): return list(map("".join, itertools.permutations([s1, s2, s3]))) def main(): signs = [';', '_', '-'] str1 =...
vfc_73545
{ "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": "Shapur;;\nis___\na_genius\n3\nShapur__a_is___geniUs\nis___shapur___a__Genius;\nShapur;;is;;a;;geni;;us;;\n", "output": "WA\nACC\nACC\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "Iran_\n...
code_contests
verifiable_code
63_A. Sinking Ship
Solve the following coding problem using the programming language python: The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further ...
```python a=[] for _ in range(int(input())): x,y=map(str,input().split()) if y=="rat": y=0 else: if y=="man": y=2 else: if y=="captain": y=3 else: y=1 a.append([x,y]) a.sort(key=lambda x:x[1]) a=[i[0] for i in a] print(*a,sep="\n") ```
vfc_73549
{ "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": "6\nJack captain\nAlice woman\nCharlie man\nTeddy rat\nBob child\nJulia woman\n", "output": "Teddy\nAlice\nBob\nJulia\nCharlie\nJack\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nX chi...
code_contests
verifiable_code
714_A. Meeting of Old Friends
Solve the following coding problem using the programming language python: Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minute r1 inclusive. Also, during the minute k she pri...
```python l1,r1,l2,r2,k=map(int,input().split()) ma=max(l1,l2) mi=min(r1,r2) if k<=mi and k>=ma: print(max(0,mi-ma)) else: print(max(0,mi-ma+1)) ```
vfc_73561
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 100 50 200 75\n", "output": "50\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 10 9 20 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
734_D. Anton and Chess
Solve the following coding problem using the programming language python: Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead. The first task he faced is to ...
```python MAX_NUM = 10**9 n = int(input()) king_x, king_y = [int(x) for x in input().split()] nomakers = {'Rook': {'right-down':[], 'right-up':[], 'left-down':[], 'left-up':[]}, 'Bishop': {'left':[], 'right':[], 'up':[], 'down':[]}} yes = {'Queen':{'right-down':[], 'right-up':[], 'left-down':[], 'left-up':[],'left':[],...
vfc_73565
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 2\nR 3 3\nB 1 5\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n4 2\nR 1 1\nB 1 5\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
758_D. Ability To Convert
Solve the following coding problem using the programming language python: Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thu...
```python n = input() k = input() digit = len(n) lst = [] def recul(k): if len(k)== 0: return if k[-digit:] < n: lst.append(k[-digit:]) if k[-digit:][0:1] == '0' and len(k[-digit:]) != 1: recul(k[:-digit]+'0') else: recul(k[:-digit]) else: temp = -digit+1 while k[temp:temp+1]== '0' and temp<0:...
vfc_73569
{ "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": "16\n11311\n", "output": "475", "type": "stdin_stdout" }, { "fn_name": null, "input": "17\n2016\n", "output": "594", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
77_B. Falling Anvils
Solve the following coding problem using the programming language python: For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all. Anvils come in different sizes and shapes. Quite often...
```python t = int(input()) for _ in range(t): a, b = map(int, input().split()) if a == 0 and b == 0: print(1) elif a == 0: print(0.5) elif b == 0: print(1) elif a > 4 * b: print('%.10f' % ((a - b) / a)) else: print('%.10f' % (a / 16 / b + 0.5)) ```
vfc_73573
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 2\n1 2\n", "output": "0.6250000000\n0.5312500000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n4 6\n4 2\n10 3\n6 3\n7 8\n2 5\n0 3\n6 1\n4 1\n10 9\n", "output": "0.54166666...
code_contests
verifiable_code
827_E. Rusty String
Solve the following coding problem using the programming language python: Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was written. ...
vfc_73581
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n \n5\nV??VK\n \n6\n??????\n \n4\n?VK?\n", "output": "0\n\n0\n\n0\n\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n\n2\nVV\n\n1\n?\n", "output": "2\n1 2 \n1\n1 \n", "type...
code_contests
verifiable_code
849_E. Goodbye Souvenir
Solve the following coding problem using the programming language python: I won't feel lonely, nor will I be sorrowful... not before everything is buried. A string of n beads is left as the message of leaving. The beads are numbered from 1 to n from left to right, each having a shape numbered by integers between 1 an...
vfc_73585
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 6\n1 2 3 1 3 2 1\n2 3 7\n2 1 3\n1 7 2\n1 3 2\n2 1 6\n2 5 7\n", "output": "5\n0\n7\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 5\n1 3 2 1 4 2 3\n1 1 4\n2 2 3\n1 1 7\n2 4 5\n1 1 7...