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
p01171 Everlasting...?
Solve the following coding problem using the programming language python: Everlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008. Fans have been looking forward to a new title of Everlasting Sa-Ga. Little Jimmy is in trouble. He is a seven-year-old boy, and he obtained the Everla...
```python import math def Soinsu(a, b) : global soin while True : if a % b == 0 : soin.append(b) if a/b == 1 : break else : Soinsu(a/b, b) break else : b += 1 if math.sqrt(a) < b : ...
vfc_59561
{ "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": "10 15\n30 20\n0 0", "output": "a\nb", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3\n30 20\n0 0", "output": "b\nb\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
p01307 Addition Game
Solve the following coding problem using the programming language python: The cat Fabre came up with a simple game using addition and decided to try it with his friend Audrey, also in the cat. The rules of the game are as follows. First of all, choose a suitable positive integer and start from there. Each player sele...
```python #!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(10000000) n = input() for loop in range(n): S = map(int, list(raw_input())) cnt = 0 while len(S) > 1: num = S[-1] + S[-2] if num >= 10: S[-2] = 1 ...
vfc_59565
{ "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\n1234\n5555\n9", "output": "Audrey wins.\nFabre wins.\nAudrey wins.", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1234\n8371\n9", "output": "Audrey wins.\nFabre wins.\nAudrey wi...
code_contests
verifiable_code
p01476 Range Minimum Query
Solve the following coding problem using the programming language python: Problem statement There are real variables $ X_1, X_2, ... $, and some initial value is assigned. From now on, $ Q $ pieces of information will be given in order. The information given is one of the following two types. * min $ \\ {X_ {a_i}, X...
vfc_59569
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 10 100 333\n0 100 1000 555", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 1 2 8\n0 2 3 9\n0 2 2 11\n1 2 2 7\n0 1 3 7", "output": "YES", "type": "stdin_...
code_contests
verifiable_code
p01636 Mysterious Operator
Solve the following coding problem using the programming language python: When Mr. Kay was browsing a certain SNS as usual, the problem that "there are people who can solve IQ150 or more" came to the timeline. Mr. Kay has an IQ of over 150, so he solved the problem in an instant without even looking at it. For him, he...
```python a = input() ans = 0 for i in range(1, len(a)): df = a[:i] sm = a[i:] if sm[0] == "0":continue df = int(df) sm = int(sm) if (df + sm) % 2 == 0 and sm >= df and (sm - df) % 2 == 0: ans += 1 if int(a) % 2 == 0:ans += 1 print(ans) ```
vfc_59573
{ "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": "19", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2", "outpu...
code_contests
verifiable_code
p01788 Tokyo Olympics Center
Solve the following coding problem using the programming language python: Example Input 3 3 1 1 1 10 10 AAA A.. A.. Output 100 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_59577
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 1\n1 1 10 10\nAAA\nA..\nA..", "output": "100", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 1\n1 1 10 6\nAAA\nA..\nA..", "output": "92\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p01923 JAG Practice Contest
Solve the following coding problem using the programming language python: JAG mock qualifying practice session The ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty eval...
```python while True: N,M=map(int,input().split()) if N==0 and M==0: break l = [0]*M for i in range(N): d,v=map(int,input().split()) if l[d-1]<v: l[d-1]=v total = 0 for i in range(M): total += l[i] print(total) ```
vfc_59581
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n1 1\n2 3\n3 2\n3 5\n2 1\n4 2\n1 7\n2 1\n1 3\n1 5\n6 1\n1 3\n1 2\n1 8\n1 2\n1 7\n1 6\n20 9\n4 10\n2 4\n5 3\n6 6\n6 3\n7 4\n8 10\n4 6\n7 5\n1 8\n5 7\n1 5\n6 6\n9 9\n5 8\n6 7\n1 4\n6 4\n7 10\n3 5\n19 6\n4 1\n6 5\n5 10\n1 10\n3 10...
code_contests
verifiable_code
p02061 Doubling
Solve the following coding problem using the programming language python: B: Twice as own problem You will be given Q queries. Since one positive integer N is given for each query, find the number of positive integers M that satisfy the following two conditions. * 2 Satisfy \ leq M \ leq N * Of the divisors of M, e...
```python import bisect MAX_N=2*10**5 isdmore5=[1 for i in range(MAX_N+1)] isprime=[1 for i in range(MAX_N+1)] i=2 isprime[0]=0;isprime[1]=0 isdmore5[0]=0;isdmore5[1]=0 while(i*i<=MAX_N): if isprime[i]!=0: for j in range(2*i,MAX_N+1,i): isprime[j]=0 i+=1 prime=[] for i in range(MAX_N+1): ...
vfc_59585
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n43\n9\n24", "output": "11\n0\n5", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n43\n8\n24", "output": "11\n0\n5\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
chefarrp
Solve the following coding problem using the programming language python: Chef likes problems involving arrays. Unfortunately, the last one he tried to solve didn't quite get solved. Chef has an array A of N positive numbers. He wants to find the number of subarrays for which the sum and product of elements are equa...
```python ''' Created on 21-Dec-2015 @author: venkatesh ''' def get_no_of_subarrays(nums, n): cnt = n for i in xrange(n): tot, prod = nums[i], nums[i] for j in xrange(i+1, n, 1): tot += nums[j] prod *= nums[j] if tot == prod: cnt += 1 re...
vfc_59597
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1 3 2\n4\n4 1 2 1\n6\n1 2 2 2 2 1", "output": "4\n5\n9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3\n1 3 2\n4\n4 1 3 1\n6\n1 2 2 2 2 1", "output": "4\n4\n9\n", "t...
code_contests
verifiable_code
insoma3
Solve the following coding problem using the programming language python: Stepford Street was a dead end street. The houses on Stepford Street were bought by wealthy millionaires. They had them extensively altered so that as one progressed along the street, the height of the buildings increased rapidly. However, not a...
```python import bisect length = int(raw_input()) l = raw_input() houses = [int(i.strip()) for i in l.split(' ')] count = 0 f = [] for i in range(length): a = bisect.bisect_left(f, houses[i]) count = count + (i-a) f.insert(a, houses[i]) print count ```
vfc_59605
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 2 4 5 3 6", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 0 4 5 3 6", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
nextnum
Solve the following coding problem using the programming language python: The Head Chef has received his id from the Association of Byteland . He wants to know the numerical rank of his number among the numbers that can be formed by the exact same digits ( i.e. among numbers having same number of 0's , 1's ... 9's as ...
```python import math listx=[0]*10 def no(x): i=int(x)-1 el=0 while(i>=0): el+=listx[i] i-=1 return el t=int(raw_input().strip()) while t: t-=1 ans=1 listx=[0]*10 num=raw_input().strip() for i in num: listx[int(i)]+=1 leng=len(num)-1 i=0 while leng...
vfc_59609
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n276\n762", "output": "2\n6", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
salary
Solve the following coding problem using the programming language python: Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th worker equals to Wi (i = 1, 2, ..., N). Once, chief decided to equalize all workers, that is, he wants to make sal...
```python t = int(raw_input()) for _ in range(t): n = int(raw_input()) lst = map(int, raw_input().split()) mn = min(lst) s = sum(lst) print s - n*mn ```
vfc_59613
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 2 3\n2\n42 42", "output": "3\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1 4 3\n2\n42 42", "output": "5\n0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
zeroes
Solve the following coding problem using the programming language python: Virat loves mathematical questions. The other day he came across an interesting question which required him to find out the number of trailing zeroes for the function. F(n) = 1^1*2^2......N^N,where N is an integer. Virat solved the problem after...
```python def f(n): count=0 temp=1 for i in range(5,n+1,5): temp=0 t=i while t%5==0: t/=5 temp+=1 count+=i*temp return count t=int(raw_input()) for i in range(t): n=int(raw_input()) print f(n) ```
vfc_59617
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n10\n2", "output": "5\n15\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1090_A. Company Merging
Solve the following coding problem using the programming language python: A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, and ...
```python n=int(input());l,q,r=[0]*n,[0]*n,0 for i in range(n): a=list(map(int,input().split())) l[i]=a[0] a.remove(l[i]) q[i]=max(a) z=max(q) for i in range(len(q)):r+=(z-q[i])*l[i] print(r) ```
vfc_59633
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 4 3\n2 2 1\n3 1 1 1\n", "output": "13", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1157_C1. Increasing Subsequence (easy version)
Solve the following coding problem using the programming language python: The only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2). You are given a sequence a consisting of n integers. All these integers are distinct, each value...
```python n=int(input()) d=list(map(int,input().split())) p=[0,n-1] e=[0] c="" while p[0]<=p[1]: if d[p[0]]<d[p[1]]: if e[-1]<d[p[0]]: e.append(d[p[0]]) p[0]+=1 c+="L" elif e[-1]<d[p[1]]: e.append(d[p[1]]) p[1]-=1 c+="R" ...
vfc_59645
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 3 5 6 7 4 2\n", "output": "7\nLRLRLLL\n\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1179_D. Fedor Runs for President
Solve the following coding problem using the programming language python: Fedor runs for president of Byteland! In the debates, he will be asked how to solve Byteland's transport problem. It's a really hard problem because of Byteland's transport system is now a tree (connected graph without cycles). Fedor's team has ...
vfc_59649
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 2\n1 3\n3 4\n3 5\n4 6\n", "output": "29\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2\n1 3\n1 4\n", "output": "11\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
1256_B. Minimize the Permutation
Solve the following coding problem using the programming language python: You are given a permutation of length n. Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2, 3, 1, 5, 4] is a permutation, but [1, 2, 2] is not a permutation (2 appears twice...
```python def fn(n,a): v=[False]*n for i in range(1,n+1): c=a.index(i)-1 while(c>=0): if(a[c]>a[c+1] and v[c]==False): v[c]=True a[c],a[c+1]=a[c+1],a[c] c=c-1 return " ".join(str(x) for x in a) m=int(input()) for i in range(m): n=in...
vfc_59665
{ "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\n5\n5 4 1 3 2\n4\n1 2 4 3\n1\n1\n4\n4 3 2 1\n", "output": "1 5 2 4 3 \n1 2 3 4 \n1 \n1 4 3 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5\n4 2 3 5 1\n", "output": "1 4 2 3...
code_contests
verifiable_code
127_B. Canvas Frames
Solve the following coding problem using the programming language python: Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with. Nicholas has n st...
```python import sys import math n = int(sys.stdin.readline()) an = [int(x) for x in (sys.stdin.readline()).split()] k = [0] * 101 for i in an: k[i] += 1 res = 0 for i in k: res += int(i / 2) print(int(res / 2)) ```
vfc_59669
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 4 3 2 3\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\n2 2 4 4 4 4 6 6 6 7 7 9 9\n", "output": "3", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
12_A. Super Agent
Solve the following coding problem using the programming language python: There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pe...
```python mat=[] for i in range(3): a = input() mat.append(list(a)) p=0 if mat[0][0]==mat[2][2] and mat[0][1]==mat[2][1] and mat[0][2]==mat[2][0] and mat[1][2]==mat[1][0]: print("YES") else: print("NO") ```
vfc_59673
{ "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": "X.X\nX..\n...\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "XX.\n...\n.XX\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1323_C. Unusual Competitions
Solve the following coding problem using the programming language python: A bracketed sequence is called correct (regular) if by inserting "+" and "1" you can get a well-formed mathematical expression from it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not. Th...
```python n=int(input()) s=input().strip() c=0 v=0 o=0 cl=0 for j in range(n): if s[j]=='(': o=o+1 if cl>0: v=v+1 else: cl=cl+1 if o==0: v=v+1 if o>0: cl=cl-1 o=o-1 if cl>0: v=v+1 if o==cl: ...
vfc_59677
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n))((())(\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1405_E. Fixed Point Removal
Solve the following coding problem using the programming language python: Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated). The weight of a is defined as the maximu...
```python class Fenwick: def __init__(self, size): self.size = size self.tree = [0] * (size + 1) def add(self, idx, val): idx = int(idx) while idx <= self.size: self.tree[idx] += val idx += idx & (-idx) def sum(self, idx): ret = 0 idx...
vfc_59693
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "13 5\n2 2 3 9 5 4 6 5 7 8 3 11 13\n3 1\n0 0\n2 4\n5 0\n0 12\n", "output": "5\n11\n6\n1\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n1 4 1 2 4\n0 0\n1 0\n", "output": "2\n0...
code_contests
verifiable_code
1427_A. Avoiding Zero
Solve the following coding problem using the programming language python: You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the same...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools # import time,random,resource # sys.setrecursionlimit(10**6) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)...
vfc_59697
{ "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\n4\n1 -2 3 -4\n3\n0 0 0\n5\n1 -1 1 -1 1\n6\n40 -31 -9 0 13 -40\n", "output": "YES\n-4 -2 1 3\nNO\nYES\n1 1 1 -1 -1\nYES\n-40 -31 -9 0 13 40\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
1450_A. Avoid Trygub
Solve the following coding problem using the programming language python: A string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "yx". You are given a string a. Your task is to reor...
```python t = int(input()) for i in range(t): n = int(input()) a = input() check = [] trygub = "trygub" k = 0 for j in range(len(trygub)): for m in range(k,len(a)): if(trygub[j] == a[m]): check.append(a[m]) k = m+1 break ...
vfc_59701
{ "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\n11\nantontrygub\n15\nbestcoordinator\n19\ntrywatchinggurabruh\n", "output": "\nbugyrtnotna\nbestcoordinator\nbruhtrywatchinggura\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n200\n...
code_contests
verifiable_code
1473_F. Strange Set
Solve the following coding problem using the programming language python: Note that the memory limit is unusual. You are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Let's call a set of integers S such that S ⊆ \{1, 2, 3, ..., n\} strange, if, for every element i of S, the followin...
```python # Author: yumtam # Created at: 2021-03-02 20:19 def main(): n = int(input()) A = [int(t) for t in input().split()] cost = [int(t) for t in input().split()] g = Flow(n+2) s, t = n, n+1 last = [-1] * 101 for i, x in enumerate(A): for d in range(1, 101): if ...
vfc_59705
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 32000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n42 42\n-37 13\n", "output": "\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n4 7 3 4 5 6 7 8 13\n-2 3 -19 5 -6 7 -8 9 1\n", "output": "\n16\n", "type": "stdin_stdout"...
code_contests
verifiable_code
1550_F. Jumping Around
Solve the following coding problem using the programming language python: There is an infinite pond that can be represented with a number line. There are n rocks in the pond, numbered from 1 to n. The i-th rock is located at an integer coordinate a_i. The coordinates of the rocks are pairwise distinct. The rocks are n...
vfc_59717
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 9 6 6\n1 2 4 9 18 19\n2 17\n1 18\n5 4\n2 11\n5 17\n6 8\n4 3\n3 3\n6 6\n", "output": "Yes\nYes\nYes\nYes\nYes\nYes\nNo\nNo\nYes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 4 4 5\n1 ...
code_contests
verifiable_code
177_B2. Rectangular Game
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b...
```python n = int(input()) i, s = 2, n m = int(n ** 0.5) + 1 while n > 1 and i < m: if n % i: i += 1 else: n //= i s += n print(s + (n > 1)) ```
vfc_59721
{ "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\n", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "99999627...
code_contests
verifiable_code
198_A. About Bacteria
Solve the following coding problem using the programming language python: Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high. At the be...
```python k, b, n, t = list(map(int, input().split())) p = 1 while p <= t: p = k * p + b n -= 1 print(max(0, n+1)) ```
vfc_59725
{ "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 2 4 100\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 3 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
221_B. Little Elephant and Numbers
Solve the following coding problem using the programming language python: The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal repres...
```python from math import sqrt def check(n, d): n = str(n) d = str(d) for c in d: if c in n: return True return False def get_divisors(n): m = int(sqrt(n)) + 1 divisors = set() for d in range(1, m): if n % d == 0: divisors.add(d) divis...
vfc_59729
{ "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\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "48\n", ...
code_contests
verifiable_code
245_C. Game with Coins
Solve the following coding problem using the programming language python: Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During ...
```python n, s = int(input()), 0 a = [0] + list(map(int, input().split())) if n % 2 == 0 or n == 1: print(-1) else: for i in range(n, 1, -2): mx = max(a[i], a[i - 1]) s += mx a[i // 2] = max(0, a[i // 2] - mx) print(s + a[1]) ```
vfc_59733
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
270_A. Fancy Fence
Solve the following coding problem using the programming language python: Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot. He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corne...
```python def solve(angle): if 360%(180-angle)!=0: return "NO" else: return "YES" cases=int(input()) results=list() for i in range(cases): results.append(int(input())) for res in results: print(solve(res)) ```
vfc_59737
{ "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\n30\n60\n90\n", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1\n2\n3\n170\n179\n25\n", "output": "NO\nNO\nNO\nYES\nYES\nNO\n", "type": "stdin_st...
code_contests
verifiable_code
293_C. Cube Problem
Solve the following coding problem using the programming language python: Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours! Today they got together again and they are playing cubes. Yaroslav took unit cubes and composed them into an a × a × a cube, Andrey ...
vfc_59741
{ "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": "93163582512000\n", "output": " 39090\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n", "output": "0\n", "type": "s...
code_contests
verifiable_code
317_A. Perfect Pair
Solve the following coding problem using the programming language python: Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. I...
```python import bisect from itertools import accumulate, count import os import sys import math from decimal import * from io import BytesIO, IOBase from sys import maxsize BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer =...
vfc_59745
{ "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": "0 -1 5\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "-1 4 15\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
341_A. Tourist Problem
Solve the following coding problem using the programming language python: Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a...
```python def gcd(m, n): return m if n == 0 else gcd(n, m%n) n = int(input()) a = sorted(map(int, input().split())) cur = sum(a) ans = cur pre = 0 for i in range(n): cur += (i+i-n) * (a[i]-pre) ans += cur pre = a[i] g = gcd(ans, n) print(ans//g, n//g) ```
vfc_59749
{ "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\n2 3 5\n", "output": "22 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1789943 1662788 8254265 2248046 2588605\n", "output": "72470111 5\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
364_C. Beautiful Set
Solve the following coding problem using the programming language python: We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if <image>, then <image>. In other words, if one number from the set is divisible by prime p, then at least half of numbers from the set is d...
```python def main(): k = input() primes = (2, 3, 5, 7, 11, 13) limit = 2 * k * k cnt = 1 a = [1] for p in primes: i = 0 while i < cnt: if a[i] * p <= limit: a.append(a[i] * p) cnt += 1 i += 1 if cnt >= k: break for i in xrange(cnt - 1, cnt - k - 1, -1): print a[i], main() ```
vfc_59753
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n", "output": "192 162 144 128 108 96 81 72 64 54 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "31\n", "output": "1728 1536 1458 1296 1152 1024 972 864 768 729 648 576 512 486 ...
code_contests
verifiable_code
408_E. Curious Array
Solve the following coding problem using the programming language python: You've got an array consisting of n integers: a[1], a[2], ..., a[n]. Moreover, there are m queries, each query can be described by three integers li, ri, ki. Query li, ri, ki means that we should add <image> to each element a[j], where li ≤ j ≤ ...
vfc_59761
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 1\n0 0 0 0 0\n1 5 0\n", "output": "1 1 1 1 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
436_A. Feed with Candy
Solve the following coding problem using the programming language python: The hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem. <image> One day, Om Nom visited his friend Evan. Evan has n candies of two types (fruit drops...
```python import queue n,maxh=[int(x) for x in input().split()] car=[] fru=[] hcar=queue.PriorityQueue(2000) hfru=queue.PriorityQueue(2000) for i in range(n): a,b,c=[int(x) for x in input().split()] if a==0: car.append((b,c)) else: fru.append((b,c)) pcar=0 mcar=len(car) pfru=0 mfru=len(fru) car.sort() fru.sort()...
vfc_59765
{ "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 3\n0 2 4\n1 3 1\n0 8 3\n0 20 10\n1 5 5\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n0 2 3\n1 9 10\n0 4 4\n", "output": "3", "type": "stdin_stdout" ...
code_contests
verifiable_code
459_B. Pashmak and Flowers
Solve the following coding problem using the programming language python: Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessari...
```python n = int(input()) a = list(map(int,input().split())) a.sort() i = 0 ln = nn = 1 j = n-1 while (a[i]==a[i+1] and i<n-1 and a[0]!=a[-1]): i+=1 nn+=1 while(a[j]==a[j-1] and j>0 and a[0]!=a[-1]): j-=1 ln+=1 dis = a[-1]-a[0] if a[0]!=a[-1]: k = ln*nn else: k = n*(n-1)//2 print(dis, end = " ") print(...
vfc_59769
{ "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\n1 4 5\n", "output": "4 1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
480_A. Exams
Solve the following coding problem using the programming language python: Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take sev...
```python # your code goes n=int(input()) l=[] for i in range(n): k=tuple(map(int,input().split())) l.append(k) d=sorted(l) a=-2 for i in range(n): if a<=d[i][1]: a=d[i][1] else: a=d[i][0] print(a) ```
vfc_59773
{ "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\n6 1\n5 2\n4 3\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5 2\n3 1\n4 2\n", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
528_D. Fuzzy Search
Solve the following coding problem using the programming language python: Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings consisting of letters 'A', 'T', 'G' and 'C'. Let's consider the fol...
vfc_59781
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4 1\nAGCAATTCAT\nACAT\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\nA\nT\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
554_B. Ohana Cleans Up
Solve the following coding problem using the programming language python: Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a cle...
```python from collections import Counter n = int(input()) print(max(Counter([input() for _ in range(n)]).values())) ```
vfc_59785
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0101\n1000\n1111\n0101\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n111\n111\n111\n", "output": "3", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
580_A. Kefa and First Steps
Solve the following coding problem using the programming language python: Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment ...
```python n,a=int(input()),list(map(int,input().split())) mx=1 c=1 for i in range(n-1): if(a[i+1]>=a[i]): c+=1 if(c>mx): mx=c else: c=1 print(mx) ```
vfc_59789
{ "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\n2 2 1 3 4 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 2 9\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
601_E. A Museum Robbery
Solve the following coding problem using the programming language python: There's a famous museum in the city where Kleofáš lives. In the museum, n exhibits (numbered 1 through n) had been displayed for a long time; the i-th of those exhibits has value vi and mass wi. Then, the museum was bought by a large financial...
vfc_59793
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 10\n30 4\n60 6\n5 1\n9\n3\n1 42 5\n1 20 3\n3\n2 2\n2 4\n3\n1 40 6\n3\n", "output": " 556674384\n 168191145\n ...
code_contests
verifiable_code
624_C. Graph and String
Solve the following coding problem using the programming language python: One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with t...
```python n, m = map(int, input().split()) s = [[0] * n for i in range(n)] for i in range(m): a, b = map(int, input().split()) s[a - 1][b - 1] = 1 s[b - 1][a - 1] = 1 for i in range(n): s[i][i] = 1 answer = [0] * n for i in range(n): flag = True for j in range(n): if s[i][j] == 0: ...
vfc_59797
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n1 2\n", "output": "Yes\nbb\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n1 2\n1 3\n1 4\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
672_E. Ultimate Weirdness of an Array
Solve the following coding problem using the programming language python: Yasin has an array a containing n integers. Yasin is a 5 year old, so he loves ultimate weird things. Yasin denotes weirdness of an array as maximum gcd(ai, aj) value among all 1 ≤ i < j ≤ n. For n ≤ 1 weirdness is equal to 0, gcd(x, y) is the ...
vfc_59805
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 6 3\n", "output": " 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n83 51 58 24 95 20 54 35 39 75 4 22 11 52 12 15...
code_contests
verifiable_code
698_A. Vacations
Solve the following coding problem using the programming language python: Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For t...
```python day = int(input()) situations = input().split(" ") dp = [[float('inf') for _ in range(3)] for _ in range(day+1)] # Base Case: for j in range(3): dp[0][j] = 0 # Inductive Step: for i in range(1, day+1): # 0: rest dp[i][0] = 1 + min(dp[i-1][0], dp[i-1][1], dp[i-1][2]) # 1: gym dp[i][1] = ...
vfc_59809
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 2 0\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
73_E. Morrowindows
Solve the following coding problem using the programming language python: Vasya plays The Elder Trolls III: Morrowindows. He has a huge list of items in the inventory, however, there is no limits on the size of things. Vasya does not know the total amount of items but he is sure that are not more than x and not less t...
```python n,x = map(int,raw_input().split()) a = set(map(int,raw_input().split())) if 1 in a and x>2: print 1 elif x>1300000: print -1 else: pr = range(x) for i in xrange(2,x): if not pr[i]: continue ii=i*i if ii>x: break pr[ii::i]=[0]*len(pr[ii::i]) pr = set(filter(None...
vfc_59817
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 4\n2\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
763_C. Timofey and remoduling
Solve the following coding problem using the programming language python: Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One of ...
```python def solve(n, m, a): if n == 0: return 0, 1 if n == 1: return a[0], 1 d = (a[1]-a[0]) % m if d < 0: d += m st = set(a) cnt = 0 for v in a: cnt += ((v + d) % m) in st cnt = n-cnt d = (d * pow(cnt, m-2, m)) % m now = a[0] while (now + m - d) % m...
vfc_59821
{ "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": "17 5\n0 2 4 13 15\n", "output": "13 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "17 5\n0 2 4 13 14\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
786_E. ALT
Solve the following coding problem using the programming language python: ALT is a planet in a galaxy called "Encore". Humans rule this planet but for some reason there's no dog in their planet, so the people there are sad and depressed. Rick and Morty are universal philanthropists and they want to make people in ALT ...
vfc_59825
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n2 4\n3 4\n1 4\n2 4\n2 1\n2 4\n1 2\n2 3\n", "output": "3\n1 5 \n2 1 3 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
808_D. Array Division
Solve the following coding problem using the programming language python: Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the...
```python import sys import bisect from bisect import bisect_left as lb input_=lambda: sys.stdin.readline().strip("\r\n") from math import log from math import gcd from math import atan2,acos from random import randint sa=lambda :input_() sb=lambda:int(input_()) sc=lambda:input_().split() sd=lambda:list(map(int,input_(...
vfc_59829
{ "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 2 3 4 5\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3 2\n", "output": "YES", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
832_E. Vasya and Shifts
Solve the following coding problem using the programming language python: Vasya has a set of 4n strings of equal length, consisting of lowercase English letters "a", "b", "c", "d" and "e". Moreover, the set is split into n groups of 4 equal strings each. Vasya also has one special string a of the same length, consisti...
vfc_59833
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\nb\n2\na\ne\n", "output": "1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4\naaaa\nbbbb\n1\ncccc\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
853_C. Boredom
Solve the following coding problem using the programming language python: Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems. First Ilya has drawn a grid ...
vfc_59837
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3\n", "output": "3\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2\n", "output": "1\n1\n1\n", "type": "stdin...
code_contests
verifiable_code
878_A. Short Program
Solve the following coding problem using the programming language python: Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well. In the language, there are only three commands: apply a bitwise operation AND, OR or...
```python n = int(input()) zero = 0 ones = 1023 for _ in range(n): op, num = input().split() num = int(num) if op == '&': zero &= num ones &= num elif op == '|': zero |= num ones |= num else: zero ^= num ones ^= num and_bits = 0 or_bits =...
vfc_59841
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n&amp; 1\n&amp; 3\n&amp; 5\n", "output": "3\n& 0\n| 0\n^ 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n| 3\n^ 2\n| 1\n", "output": "3\n& 1021\n| 1\n^ 0\n", "type": "st...
code_contests
verifiable_code
952_B. A Map of the Cat
Solve the following coding problem using the programming language python: If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat. <image> However, some cats won't tolerate this nonsense from the humans. Here i...
```python #copy marsi bal ! print('grumpy' if input('9\n')[-2:] in ['s?', 'le', 'se', 'ay', 'en'] else 'normal') ```
vfc_59853
{ "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 0 1 2 5 3 5 4 5 5\n", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
979_D. Kuro and GCD and XOR and SUM
Solve the following coding problem using the programming language python: Kuro is currently playing an educational game about numbers. The game focuses on the greatest common divisor (GCD), the XOR value, and the sum of two numbers. Kuro loves the game so much that he solves levels by levels day by day. Sadly, he's g...
```python import sys range = xrange input = raw_input big = 10**5 + 1 M = 1 while M < big: M *= 2 mini = [0] L = [0] R = [0] roots = [0]*big def add(x, i): bits = [] xx = x + M while xx != 1: bits.append(xx&1) xx >>= 1 if not roots[i]: roots[i] = len(mini) mini.a...
vfc_59857
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1 9\n2 9 9 22\n2 3 3 18\n1 25\n2 9 9 20\n2 25 25 14\n1 20\n2 26 26 3\n1 14\n2 20 20 9\n", "output": "9\n9\n9\n-1\n-1\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1\n1 2\n2 ...
code_contests
verifiable_code
comparing-strings-1
Solve the following coding problem using the programming language python: You are given two strings, A and B. Find if there is a substring that appears in both A and B. Input The first line of the input will contain a single integer T, the number of test cases. Then there will be T descriptions of the test cases. E...
```python s="abcdefghijklmnopqrstuvwxyz" t=input() for k in range(0,t): s1=raw_input() s2=raw_input() f=False for i in range(0,26): if((s[i] in s1) and (s[i] in s2)): f=True break if f==False: print "NO" else: print "YES" ```
vfc_59869
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nhello\nworld\nhi\nworld\n\nSAMPLE", "output": "YES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nhello\nworld\nhi\nworld", "output": "YES\nNO\n", "type": "stdin_std...
code_contests
verifiable_code
fibonacci-madness
Solve the following coding problem using the programming language python: This is Fibonacci madness. Given a number n. Print the first n Fibonacci numbers in reverse order. Input: First line is number T denoting number of test cases. T lines follow. Each line has number N. Output: Print the first n Fibonacci numbe...
```python from sys import stdin fib = [0,1] for i in xrange(2,105): fib.append(fib[i-1]+fib[i-2]) t = int(stdin.readline()) for _ in xrange(t): n = int(stdin.readline()) for i in xrange(n): print fib[n-i-1], print "" ```
vfc_59873
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n7\n4\n\nSAMPLE", "output": "0 \n8 5 3 2 1 1 0 \n2 1 1 0 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n3\n12\n15\n24\n36\n41\n42", "output": "1 1 0 \n89 55 34 21 13 8 5 3 ...
code_contests
verifiable_code
ideal-random-number-generator
Solve the following coding problem using the programming language python: Assume there is an Ideal Random Number Generator which generates any real number between 0 and given integer. Two numbers are generated from the above generator using integer A and B, let's assume the numbers generated are X1 and X2. There is an...
```python def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) def lowest_form(a,b): k = gcd(a,b) aa = a/k bb = b/k return (aa,bb) for i in xrange(1): a,b,c = map(int,raw_input().split()) if a + b <= c : print '1/1' else: k = min(a,b) ...
vfc_59877
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1\n\nSAMPLE", "output": "1/2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12 2 6", "output": "5/12\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
mario-and-queen
Solve the following coding problem using the programming language python: Legends who were born in 90s remember Mario very well. As we all are aware of that fabulous video game our little Mario tackling with all the problems and barriers coming his way , he finally saves his Queen from the giant monster Dragon. In th...
```python import copy def cal(l,l1,path,x,y,c,n): #print(path) path.append((x,y)) if(x-1>=0): if(y-1>=0 and (x-1,y-1) not in path): if(l[x-1][y-1]=='Q'): if(c not in l1): l1.append(c) if(l[x-1][y-1]=='.'): path1=copy.copy(path) cal(l,l1,path1,x-1,y-1,c+1,n) if((x-1,y) not in path): if(l...
vfc_59881
{ "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\n. . Q\n. . $\nM $ .\n3\nM . .\n$ $ .\nQ $ .\n\nSAMPLE", "output": "Case 1: 2 < 2 3 4 5 >\nCase 2: -1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
number-maze
Solve the following coding problem using the programming language python: Ranjit wants to design a algorithm such that, if he enters two numbers, all the numbers between these two numbers are listed(except the number divisible by 5 & 3). BUT the number divisible by both 3 & 5 is also listed (example 30) The Numbers s...
```python a, b = map(int, raw_input().split()) print ",".join(str(i) for i in range(a+1, b) if i % 3 and i % 5 or i % 15 == 0) ```
vfc_59885
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "25 44\n\nSAMPLE", "output": "26,28,29,30,31,32,34,37,38,41,43", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
quick-transaction
Solve the following coding problem using the programming language python: Your mother sends you to market to buy some stuff which costs Rs. X, you simply need to find the minimum no. of currency denominations required to complete the transaction. Assume that the seller only takes exactly Rs. X, not more nor less than ...
```python t = int(raw_input()) den=[1,2,5,10,20,50,100,500,1000] den=sorted(den, reverse=True) while (t!=0): num=int(raw_input()) sorted(den, reverse=True) coins=0 for d in den: coins += num/d num=num%d print coins t-=1 ```
vfc_59889
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n305\n67\n105\n\nSAMPLE", "output": "4\n4\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
shil-and-square-sum-qualifier2
Solve the following coding problem using the programming language python: Shil has an array of N elements A1 , A2, ... ,AN . He also has an integer K. He wants to find out value of Square Sum for every i from 1 to N-K+1. The value of Square Sum for certain i is defined as Σ1≤ j ≤ K (j^2 Ai+j-1). Input: First line of...
```python [N, K] = map(int, raw_input().split()) A = map(int, raw_input().split()) modN = 10**9+7 S_1 = 0 S_2 = 0 S_3 = 0 for i in xrange(0, K): S_3 = (S_3 + A[i]) % modN S_2 = (S_2 + (i+1) * A[i]) % modN S_1 = (S_1 + (i+1)**2 * A[i]) % modN output = [] output.append(S_1) for i in xrange(0, N-K): S_1 = (S_1 + (K...
vfc_59893
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n6 9 10 10 4 6 \n\nSAMPLE", "output": "132 139 86 80\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 20\n4 7 6 6 9 4 6 2 6 2 7 7 6 2 4 4 3 6 8 8 10 10 1 4 8 1 9 3 3 10 3 6 9 6 8 5...
code_contests
verifiable_code
the-monk-and-class-marks
Solve the following coding problem using the programming language python: Monk is a multi-talented person, and prepares results for his college in his free time. (Yes, he is still in love with his old college!) He gets a list of students with their marks. The maximum marks which can be obtained in the exam is 100. T...
```python ary = sorted( [(name, int(marks)) for k in xrange(input()) for name, marks in [raw_input().split()]], key = lambda x: x[0] ) for i in sorted(ary, key = lambda x:x[1], reverse = True): print i[0], i[1] ```
vfc_59897
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nEve 78\nBob 99\nAlice 78\n\nSAMPLE", "output": "Bob 99\nAlice 78\nEve 78\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "42\nqghumeaylnlfdxfircvscxggbwkfnqduxwfnfozvsrtkjprepggxrpnrvyst...
code_contests
verifiable_code
p00089 The Shortest Path on A Rhombic Path
Solve the following coding problem using the programming language python: <image> Arrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the ...
```python import sys s=[list(map(int,e.split(',')))for e in sys.stdin] for i in range(1,len(s)): for j in range(len(s[i])): t=j-(len(s[i])>len(s[i-1])) s[i][j]+=max(s[i-1][t*(j>0):t+2]) print(*s[-1]) ```
vfc_59945
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n3,8\n7", "output": "55", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00221 FizzBuzz
Solve the following coding problem using the programming language python: There is a game that uses numbers called "Fizz Buzz". In this game, multiple players count the numbers one by one, starting with 1, and each player says only one number after the previous player. At that time, you must say "Fizz" if it is divisi...
```python def fizzbuzz(i): if i % 15 == 0: return 'FizzBuzz' elif i % 5 == 0: return 'Buzz' elif i % 3 == 0: return 'Fizz' else: return str(i) import sys f = sys.stdin while True: m, n = map(int, f.readline().split()) if m == n == 0: break member = ...
vfc_59949
{ "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": "5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0", "output": "2 3 4 5\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n1\n0\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0", ...
code_contests
verifiable_code
p00599 Combinatorial Topology
Solve the following coding problem using the programming language python: It was long believed that a 2-dimensional place can not be filled with a finite set of polygons in aperiodic way. British mathematician, Sir Roger Penrose, developed an aperiodic tiling over the years and established a theory of what is known to...
vfc_59957
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n-5.000000 0.000000\n5.000000 0.000000\n9.635255 14.265848\n-0.364745 14.265848\n3\n-1.000000 0.000000\n0.000000 0.000000\n0.000000 1.000000", "output": "0 150\n-1 -1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00735 Monday-Saturday Prime Factors
Solve the following coding problem using the programming language python: Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is eith...
```python #!/usr/bin/env python # -*- coding: utf-8 -*- def monsat(num): L = [False for i in range(num+1)] for i in range(0,num,7): if i == 1 or i == 0: continue for d in [-1,1]: if L[i+d] == False: L[i+d] = True for j in range((i+d)*2,num...
vfc_59961
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "205920\n262144\n262200\n279936\n299998\n1", "output": "205920: 6 8 13 15 20 22 55 99\n262144: 8\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n299998: 299998", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
p00875 Repeated Substitution with Sed
Solve the following coding problem using the programming language python: Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows. 1. Within ...
```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 = 10**9+7 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 in ...
vfc_59965
{ "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\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabacfaabe\n0", "output": "3\n-1\n7\n4", "type": "...
code_contests
verifiable_code
p01006 Nasty Boys
Solve the following coding problem using the programming language python: Problem Taro hides important books in the school locker, so he manages them more strictly than other people, and in addition to the keys provided by the school, he has installed the following button authentication type keys. .. <image> Howeve...
```python # -*- coding:utf-8 -*- import sys def main(): data = [] for passwd in sys.stdin.readlines(): data.append(passwd.strip()) for answer in proc(data): print answer return 0 def proc(data): return [passwd for passwd in data if is_hitofude(passwd)] def is_hitofude(text): f...
vfc_59969
{ "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": "ABCFI\nABCABCABC\nAEI\nEFC\n(中略)\nDEHED\nEEEEE\n(以上でちょうど1000個)", "output": "ABCFI\nEFC\n(中略)\nDEHED", "type": "stdin_stdout" }, { "fn_name": null, "input": "ABCFI\nABCABCACC\nAEI\nEFC\n(中略)\nDEHED\nE...
code_contests
verifiable_code
p01277 Symmetry
Solve the following coding problem using the programming language python: Open Binary and Object Group organizes a programming contest every year. Mr. Hex belongs to this group and joins the judge team of the contest. This year, he created a geometric problem with its solution for the contest. The problem required a s...
```python from collections import defaultdict import sys readline = sys.stdin.readline write = sys.stdout.write def gcd(m, n): while n: m, n = n, m % n return m def solve(): N = int(readline()) P = [list(map(int, readline().split())) for i in range(N)] ok = 0 x0, y0 = P[0]; x1, y1 = P[1]...
vfc_59977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 2\n0 0\n-1 0\n1 0", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 1\n1 0\n0 0\n1 1", "output": "Yes", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
p01447 Earth Invasion Diary of Miyabi-sensei
Solve the following coding problem using the programming language python: The Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area around Tokyo in Japan. ...
```python N = int(input()) n = 1 ans = 1 while True: n *= 3 if n>=N: print(ans) break ans+=1 ```
vfc_59981
{ "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": "30", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "8", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2000000000", ...
code_contests
verifiable_code
p01596 Magnum Tornado
Solve the following coding problem using the programming language python: Problem F: Magnum Tornado We have a toy that consists of a small racing circuit and a tiny car. For simplicity you can regard the circuit as a 2-dimensional closed loop, made of line segments and circular arcs. The circuit has no branchings. Al...
vfc_59985
{ "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\n0 1 0 2\n1 3 2 3\n2 2 1 2\n1 1 2 1\n2 0 1 0", "output": "9.712", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n4 5 4 6\n3 7 1 7\n0 8 0 10\n1 11 3 11\n4 10 4 9\n5 8 99 8\n100 7 100 4\n...
code_contests
verifiable_code
p01753 Magic Bullet
Solve the following coding problem using the programming language python: In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition. The competition you participate in is to compete for the time it takes to destroy all the blu...
```python N, Q = map(int, input().split()) x = [None] * N y = [None] * N z = [None] * N r = [None] * N l = [None] * N for i in range(N): x[i], y[i], z[i], r[i], l[i] = map(int, input().split()) for _ in range(Q): ans = 0 sx, sy, sz, dx, dy, dz = map(int, input().split()) vx = dx - sx vy = dy - sy ...
vfc_59989
{ "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": "5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n261 -494 -87 -300 123 -463\n386 378 486 -443 ...
code_contests
verifiable_code
banrob
Solve the following coding problem using the programming language python: Two cheeky thieves (Chef being one of them, the more talented one of course) have came across each other in the underground vault of the State Bank of Churuland. They are shocked! Indeed, neither expect to meet a colleague in such a place with t...
```python t=input() for i in range(1,t+1): m,p= raw_input().split(' ') m=int(m) p=float(p) a=(10**9)*(1-(-p)**m)/(1+p) b=(10**9)*(p+(-p)**m)/(1+p) print a,b ```
vfc_60013
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 0.5\n2 0.5", "output": "1000000000.0 0.0\n500000000.0 500000000.0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cmb03
Solve the following coding problem using the programming language python: Given two binary strings, A (of length 10) and B (of length 5), output 1 if B is a substring of A and 0 otherwise. Input The first line contains the number of test cases n. This is followed by n lines each consisting of pairs of binary str...
```python def main(): test = int(raw_input()) i = 0 while i < test: l = raw_input().split() a = l[0] b = l[1] if b in a: print(1) else: print(0) i += 1 if __name__ == '__main__': main() ```
vfc_60017
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1010110010 10110", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1010110110 10110", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
flow014
Solve the following coding problem using the programming language python: A certain grade of steel is graded according to the following conditions. Hardness must be greater than 50. Carbon content must be less than 0.7. Tensile strength must be greater than 5600. The grades are as follows: Grade is 10 if all three ...
```python t= int(raw_input()) for i in range(t): h,c,t=map(float,raw_input().split()) if h>50 and c<0.7 and t>5600: print "10" elif h>50 and c<0.7: print"9" elif c<0.7 and t>5600: print"8" elif h>50 and t>5600: print "7" elif h>50 or c<0.7 or t>5600: print...
vfc_60021
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 \n53 0.6 5602\n45 0 4500\n0 0 0", "output": "10\n6\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 \n67 0.6 5602\n45 0 4500\n0 0 0", "output": "10\n6\n6\n", "type": "std...
code_contests
verifiable_code
levy
Solve the following coding problem using the programming language python: Problem Statement Levy's conjecture, named after Hyman Levy, states that all odd integers greater than 5 can be represented as the sum of an odd prime number and an even semiprime. To put it algebraically, 2n + 1 = p + 2q always has a solution i...
```python from math import sqrt def sieve(n): L = [0 for i in range(n+1)]; s = int(sqrt(n)); P,S = {},[]; L[0],L[1] = 1,1 for i in range(2,s+1): if L[i] is 0: for j in range(i*i,n+1,i): L[j] = 1 for i in range(len(L)): if L[i] is 0: P[i] = None; S.append(i) return P,S def precompute(): P,S = sieve(int(1e4)...
vfc_60025
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n7\n11", "output": "0\n1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2\n9\n11", "output": "0\n2\n2\n", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
prb01
Solve the following coding problem using the programming language python: Alice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice says out an integer and Bob has to say whether the number is prime or n...
```python import sys a=[0]*1000001 b=[0]*1000001 def sieve(): for x in xrange(2,1000001): if a[x]==0: b[x]=1 z=x while(z<1000001): a[z]=1 z+=x sieve() t=int(raw_input()) i=0 while(i<t): n=int(raw_input()) if b[n]==1: print ...
vfc_60029
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n23\n13\n20\n1000\n99991", "output": "yes\nyes\nno\nno\nyes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n32\n13\n20\n1000\n99991", "output": "no\nyes\nno\nno\nyes\n", "...
code_contests
verifiable_code
taand
Solve the following coding problem using the programming language python: Given an array of n non-negative integers: A1, A2, …, AN. Your mission is finding a pair of integers Au, Av (1 ≤ u < v ≤ N) such that (Au and Av) is as large as possible. And is a bit-wise operation which is corresponding to & in C++ and Java. ...
```python A=[] N=int(raw_input()) for count1 in range(0,N): a=int(raw_input()) A.append(a) A.sort() sum=-1 for count1 in range(1,N): count2=count1-1 temp_sum=A[count1]&A[count2] if(temp_sum>sum): sum=temp_sum print(str(sum)) ```
vfc_60033
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n4\n8\n10", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2\n6\n8\n10", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1010_B. Rocket
Solve the following coding problem using the programming language python: This is an interactive problem. Natasha is going to fly to Mars. Finally, Natasha sat in the rocket. She flies, flies... but gets bored. She wishes to arrive to Mars already! So she decides to find something to occupy herself. She couldn't thin...
```python from sys import stdin from math import * from sys import stdout line = stdin.readline().rstrip().split() m = int(line[0]) n = int(line[1]) bits = [] for i in range(n): print(m) stdout.flush() line = stdin.readline().rstrip().split() res = int(line[0]) if res == 0: exit(0) if ...
vfc_60037
{ "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 2\n1\n-1\n-1\n1\n0\n", "output": "1\n1\n3\n2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 30 1\n1 0 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 1 0 0\n", "output": "1...
code_contests
verifiable_code
1034_B. Little C Loves 3 II
Solve the following coding problem using the programming language python: Little C loves number «3» very much. He loves all things about it. Now he is playing a game on a chessboard of size n × m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places...
```python known = [ [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 4], [0, 0, 0, 4, 8, 10], [0, 0, 4, 8, 12, 14], [0, 2, 8, 12, 16, 20], [0, 4, 10, 14, 20, 24] ] n,m = map(int,input().split(" ")) if n>m: n,m = m,n if n<=5 and m<=5: print(known[m][n]) elif n==1: print(6*(m//6)+ [0,0,0,0,2,4][m%6...
vfc_60041
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 1\n",...
code_contests
verifiable_code
1056_G. Take Metro
Solve the following coding problem using the programming language python: Having problems with tram routes in the morning, Arkady decided to return home by metro. Fortunately for Arkady, there is only one metro line in the city. Unfortunately for Arkady, the line is circular. It means that the stations are enumerated...
vfc_60045
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 1024000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4\n3 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 4\n3 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
109_B. Lucky Probability
Solve the following coding problem using the programming language python: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya and his friend Vasy...
```python import itertools as it all_lucky = [] for length in range(1, 10): for comb in it.product(['7', '4'], repeat=length): all_lucky += [int(''.join(comb))] all_lucky.sort() # print(len(all_lucky)) pl, pr, vl, vr, k = map(int, input().split()) result = 0 def inters_len(a, b, c, d): a, b = s...
vfc_60053
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 10 1 10 2\n", "output": "0.32000000000000000666", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6 8 10 1\n", "output": "1", "type": "stdin_stdout" }, { "fn_name...
code_contests
verifiable_code
1120_B. Once in a casino
Solve the following coding problem using the programming language python: One player came to a casino and found a slot machine where everything depends only on how he plays. The rules follow. A positive integer a is initially on the screen. The player can put a coin into the machine and then add 1 to or subtract 1 fr...
```python def main(): n = int(input()) a = list(map(int, (x for x in input()))) b = list(map(int, (x for x in input()))) x = [0] * (n - 1) x[0] = b[0] - a[0] for i in range(1, n - 1): x[i] = b[i] - a[i] - x[i - 1] if a[n - 1] + x[n - 2] != b[n - 1]: print(-1) return ...
vfc_60057
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n35\n44\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n223\n322\n", "output": " 2\n1 1\n2 -1\n",...
code_contests
verifiable_code
1168_E. Xor Permutations
Solve the following coding problem using the programming language python: Toad Mikhail has an array of 2^k integers a_1, a_2, …, a_{2^k}. Find two permutations p and q of integers 0, 1, …, 2^k-1, such that a_i is equal to p_i ⊕ q_i for all possible i, or determine there are no such permutations. Here ⊕ denotes the [b...
vfc_60065
{ "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": "2\n0 1 2 2\n", "output": "Fou\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0 1 2 3\n", "output": "Shi\n3 0 2 1\n3 1 0 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1187_B. Letters Shop
Solve the following coding problem using the programming language python: The letters shop showcase is a string s, consisting of n lowercase Latin letters. As the name tells, letters are sold in the shop. Letters are sold one by one from the leftmost to the rightmost. Any customer can only buy some prefix of letters ...
```python from collections import defaultdict n = int(input()) s = input() r = defaultdict(list) for i, c in enumerate(s): r[c].append(i) m = int(input()) for i in range(m): t = input() ans = 0 pos = defaultdict(int) for c in t: pos[c] += 1 ans = max(ans, r[c][pos[c]-1]) print(a...
vfc_60069
{ "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": "9\narrayhead\n5\narya\nharry\nray\nr\nareahydra\n", "output": "5\n6\n5\n2\n9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\nwjtwxtttttxjjwxtjtttwxjwjjwjxtwwxxwwwtwttwxjxxjxwxwjtjjwxx...
code_contests
verifiable_code
1206_A. Choose Two Numbers
Solve the following coding problem using the programming language python: You are given an array A, consisting of n positive integers a_1, a_2, ..., a_n, and an array B, consisting of m positive integers b_1, b_2, ..., b_m. Choose some element a of A and some element b of B such that a+b doesn't belong to A and does...
```python n=int(input()) a=list(map(int,input().split())) m=int(input()) b=list(map(int,input().split())) t=[];o=[] for i in a: for j in b: t.append(i+j) o.append((i,j)) for i in range(len(t)): if (t[i] not in a) and (t[i] not in b): print(o[t.index(t[i])][0]) print(o[t.index(t[...
vfc_60073
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 5 7\n4\n7 5 3 1\n", "output": "7 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 2 2\n5\n1 5 7 7 9\n", "output": "3 9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1223_D. Sequence Sorting
Solve the following coding problem using the programming language python: You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have ...
```python import sys input=sys.stdin.buffer.readline for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) stored=[-1 for i in range(n+2)] counted=[[0,0] for i in range(n+2)] count=0 for i in range(n): stored[a[i]]=a[i] if(counted[a[i]][0]==0): ...
vfc_60077
{ "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\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 2 6 2 7\n", "output": "2\n0\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1249_A. Yet Another Dividing into Teams
Solve the following coding problem using the programming language python: You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that: * No two students i and j such that |a_i - ...
```python from itertools import * q = int(input()) for _ in range(q): n = int(input()) a = list(map(int, input().split())) a.sort() cnt = 1 while len(a) > 1: a = list(a) b = [] for i in range(1, len(a)): if a[i] - a[i - 1] <= 1: b.append(a[i]) ...
vfc_60081
{ "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\n4\n2 10 1 20\n2\n3 6\n5\n2 3 4 99 100\n1\n42\n", "output": "2\n1\n2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1\n1\n1\n1\n1\n1\n4\n2 1 4 3\n3\n1 3 2\n1\n1\n3\n1 2 3\n5\n1 4...
code_contests
verifiable_code
1267_G. Game Relics
Solve the following coding problem using the programming language python: Esports is a form of competitive sports using video games. Dota 2 is one of the most popular competitive video games in Esports. Recently, a new video game Dota 3 was released. In Dota 3 a player can buy some relics for their hero. Relics are co...
vfc_60085
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 30\n60 50 60 80\n", "output": "171.2500000000", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 20\n25 100\n", "output": "47.5000000000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
128_A. Statues
Solve the following coding problem using the programming language python: In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has sever...
```python f = [] for i in range(8): f.append(input()) d = [[[0 for i in range(8)] for j in range(8)] for k in range(100)] d[0][7][0] = 1 dx = [1, 1, 1, 0, 0, -1, -1, -1, 0] dy = [1, 0, -1, 1, -1, 1, 0, -1, 0] ans = 'LOSE' for i in range(99): for x in range(8): for y in range(8): if not d[...
vfc_60089
{ "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": ".......A\n........\n........\n........\n........\n........\n........\nM.......\n", "output": "WIN\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
130_G. CAPS LOCK ON
Solve the following coding problem using the programming language python: You are given a string which consists of letters and other characters. Convert it to uppercase, i.e., replace all lowercase letters with corresponding uppercase ones. Keep the rest of characters unchanged. Input The only line of input contains...
vfc_60093
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "cOdEfOrCeS\n", "output": "CODEFORCES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ulr#4:befunge-RULES!\n", "output": "ULR#4:BEFUNGE-RULES!\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
1419_D2. Sage's Birthday (hard version)
Solve the following coding problem using the programming language python: This is the hard version of the problem. The difference between the versions is that in the easy version all prices a_i are different. You can make hacks if and only if you solved both versions of the problem. Today is Sage's birthday, and she ...
```python # import os # import sys # from io import BytesIO, IOBase # BUFSIZE = 8192 # class FastIO(IOBase): # newlines = 0 # def __init__(self, file): # self._fd = file.fileno() # self.buffer = BytesIO() # self.writable = "x" in file.mode or "r" not in file.mode # self.w...
vfc_60113
{ "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": "7\n1 3 2 2 4 5 4\n", "output": "3\n3 1 4 2 4 2 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 2 4\n", "output": "1\n2 1 4 1 ", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1437_E. Make It Increasing
Solve the following coding problem using the programming language python: You are given an array of n integers a_1, a_2, ..., a_n, and a set b of k distinct integers from 1 to n. In one operation, you may choose two integers i and x (1 ≤ i ≤ n, x can be any integer) and assign a_i := x. This operation can be done onl...
```python import bisect def stablesort(s,l6): l3 = [] l4 = [0] for i in range(len(s)): if l6[0] == -1: if s[i]<=l[l6[1]]: k = bisect.bisect(l3,s[i]) if len(l3) == 0 or l3[-1]<=s[i]: l3.append(s[i]) l4.append(l4[-1] +...
vfc_60117
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2\n1 2 1 1 3 5 1\n3 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 0\n4 3 1 2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
1462_C. Unique Number
Solve the following coding problem using the programming language python: You are given a positive number x. Find the smallest positive integer number that has the sum of digits equal to x and all digits are distinct (unique). Input The first line contains a single positive integer t (1 ≤ t ≤ 50) — the number of tes...
```python test=int(input()) for testcase in range(test): n=int(input()) if(n<=45): if(n<10): print(n) else: i=9 s=0 ans=0 while(i>0): #print(i) if(s+i<=n): s+=i ans...
vfc_60121
{ "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\n1\n5\n15\n50\n", "output": "\n1\n5\n69\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "50\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42\n41\n42...
code_contests
verifiable_code
1487_D. Pythagorean Triples
Solve the following coding problem using the programming language python: A Pythagorean triple is a triple of integer numbers (a, b, c) such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to a, b and c, respectively. An example of the P...
```python import math t = int(input()) for _ in range(t): n = int(input()) n = math.floor(math.sqrt(n+n-1)) if n%2==0: print((n//2)-1) else: print(((n+1)//2)-1) ```
vfc_60125
{ "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\n3\n6\n9\n", "output": "\n0\n1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2131\n21165\n6666\n", "output": "32\n102\n57\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1511_A. Review Site
Solve the following coding problem using the programming language python: You are an upcoming movie director, and you have just released your first movie. You have also launched a simple review site with two buttons to press — upvote and downvote. However, the site is not so simple on the inside. There are two server...
```python t = int(input()) for _ in range(t): n = int(input()) ans = 0 a = [int(i) for i in input().split()] for i in a: if i == 1 or i == 3: ans += 1 print(ans) ```
vfc_60129
{ "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\n2\n3\n1 2 3\n5\n1 1 1 1 1\n3\n3 3 2\n", "output": "\n0\n2\n5\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "out...
code_contests
verifiable_code
1538_F. Interesting Function
Solve the following coding problem using the programming language python: You are given two integers l and r, where l < r. We will add 1 to l until the result is equal to r. Thus, there will be exactly r-l additions performed. For each such addition, let's look at the number of digits that will be changed after it. F...
```python def count(s): ans = 0 for i in range(len(s), 0 ,-1): ans += int(s[:i]) return ans for t in range(int(input())): l, r = input().split() print(count(r) - count(l)) ```
vfc_60133
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 9\n9 10\n10 20\n1 1000000000\n", "output": "\n8\n2\n11\n1111111110\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1001 10001\n", "output": "10000\n", "type": "stdin_st...
code_contests
verifiable_code
186_B. Growing Mushrooms
Solve the following coding problem using the programming language python: Each year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. This year's event brought together the best mush...
```python n, t1, t2, k = map(int, input().split()) a = n * [0] list_indexes = [] for i in range(n): x = list(map(int, input().split())) x.sort() a[i] = x for j in range(n): a[j] = max((a[j][0] * t1 * ((100 - k) / 100) + a[j][1] * t2), (a[j][1] * t1 * ((100 - k) / 100) + a[j][0] * t2)) ...
vfc_60141
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 1 1\n544 397\n280 101\n280 101\n693 970\n", "output": "4 1656.07\n1 937.03\n2 379.99\n3 379.99\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 3 50\n2 4\n4 2\n", "output": "1...
code_contests
verifiable_code
207_D4. The Beaver's Problem - 3
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem: Y...
```python print('1') ```
vfc_60145
{ "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": "21000\nSWISS TO LAUNCH NEW SERIES OF MONEY MARKET PAPER\nZURICH, April 9 - The Swiss Federal Government will launch\na new series of three month money market certificates totalling\naround 150 mln Swiss francs, the National Bank sa...
code_contests
verifiable_code
258_B. Little Elephant and Elections
Solve the following coding problem using the programming language python: There have recently been elections in the zoo. Overall there were 7 main political parties: one of them is the Little Elephant Political Party, 6 other parties have less catchy names. Political parties find their number in the ballot highly imp...
```python n=map(lambda x:ord(x)-ord('0'),list(raw_input())) M=10**9+7 c=[0]*32 s=0 k=len(n) def acc(k,s,v): if k>0: acc(k-1,s+1,v*2) acc(k-1,s,v*8) else: c[s]+=v for i in range(k): for j in range(n[i]): acc(k-i-1,s+(j in (4,7)),1) s+=n[i] in (4,7) c[s]+=1 c[0]-=1 def win(u,v,w): x=0 if v<10:...
vfc_60153
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n", "output": " 1440\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", "output": " ...
code_contests
verifiable_code
281_B. Nearest Fraction
Solve the following coding problem using the programming language python: You are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction <image> whose denominator is no more than n. Formally, you should find such pair of integers a, b (1 ≤ b ≤ n; 0 ≤ a) that the value <image> is...
```python import sys from fractions import Fraction def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) mod = int(1e9)+7 x, y, n = rin...
vfc_60157
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2 4\n", "output": "7/2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 7 6\n", "output": "2/5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...