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
micro-and-minmax
Solve the following coding problem using the programming language python: Micro is a big fan of the famous competitive programmer Gennady Korotkevich, known by his handle tourist. He wants to be like him. He has been practising hard but is not reaching anywhere. So he has left his fate to one game he has, called MinMa...
```python t=input() while t>0: t=t-1 o=input() n=map(int ,raw_input().split()) if (max(n)-min(n))%2==0: print 'No' else: print 'Yes' ```
vfc_75717
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n1 2 3 4 5\n\nSAMPLE", "output": "No", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p-lover
Solve the following coding problem using the programming language python: A:It is a natural number greater than 1 that has no positive divisors other than 1 and itself. B: It is a number that remains the same when its digits are reversed. It is "symmetrical". Patrik lives in Palestine. He loves everything starting...
```python p=[1 , 1 , 2 , 3 , 5 , 7 , 11 , 101 , 131 , 151 , 181 , 191 , 313 , 353 , 373 , 383 , 727 , 757 , 787 , 797 , 919 , 929 , 10301 , 10501 , 10601 , 11311 , 11411 , 12421 , 12721 , 12821 , 13331 , 13831 , 13931 , 14341 , 14741 , 15451 , 15551 , 16061 , 16361 , 16561 , 16661 , 17471 , 17971 , 18181 , 18481 , 1939...
vfc_75721
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n42\n108\n250\n\nSAMPLE", "output": "101\n131\n313\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "16\n88\n445\n787\n54\n5\n5345\n68876\n45\n10\n6876\n1442\n6878\n11\n554\n53478\n989", ...
code_contests
verifiable_code
recursive-sums
Solve the following coding problem using the programming language python: Little Bear has received a home assignment to find the sum of all digits in a number N. Following his affinity towards single digit number, he intends to repeatedly compute the sum of all digits until the sum itself becomes a single digit number...
```python __author__ = 'pjha' def main(): N=input() for i in range(0,N): M=input() sum=0 for j in range(0,M): a=map(int,raw_input().split()) sum=sum+a[1]*a[0] while(sum>9): fsum=0 while(sum>0): fsum=fsum+sum%10 ...
vfc_75725
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n2 1\n1 2\n2 9\n1\n8 1\n3\n2 5\n1 4\n1 5\n\n\nSAMPLE", "output": "4\n8\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n99\n3925363 2\n2603576 6\n1234862 8\n1520732 1\n4483784 7...
code_contests
verifiable_code
solve-for-the-pastry-lover
Solve the following coding problem using the programming language python: DM of Bareilly wants to make Bareilly a smart city. So, one point amongst his management points is to arrange shops. He starts by arranging the bakery shops linearly, each at a unit distance apart and assigns them a number depending on its owne...
```python noOfTestCases = int(raw_input()) def minDistance(n): structureCount = {} curIndex = 0 for digit in n: if(structureCount.has_key(digit) == False): structureCount[digit] = [curIndex,-1] else: newDistance = curIndex - structureCount[digit][0] if(structureCount[digit][1] == -1 or newDistance < st...
vfc_75729
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n12345\n5\n12321\n7\n1234514", "output": "-1\n2\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
to-be-changed-choosing-a-project
Solve the following coding problem using the programming language python: Singh is getting bored at work. He has a lot of ideas (N) to work on (as side projects) but is unable to choose one. He chooses a random number (R) and lines up his ideas in a circle. He starts counting from first and removes the R^th idea in t...
```python n, k = list(map(int, raw_input().strip().split())) l = [i for i in range(n)] ind = 0 while len(l) != 1: ind = ( ind + k - 1 ) % len(l) l = l[0:ind] + l[ind+1:] print(l[0]+1) ```
vfc_75733
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n\nSAMPLE", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "23 9000001", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
p00116 Rectangular Searching
Solve the following coding problem using the programming language python: There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked ...
```python while True: h, w = map(int, input().split()) if h == 0: break mp = [] for _ in range(h): lst = list(input()) cum = [] acc = 0 for i in lst: acc = acc + 1 if i == "." else 0 cum.append(acc) mp.append(cum) mp.append([-1] * w) ans = 0 for i in range(w): s...
vfc_75781
{ "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": "10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n....
code_contests
verifiable_code
p00249 Ant Nest
Solve the following coding problem using the programming language python: Gaku decided to observe the ant's nest as a free study during the summer vacation. The transparent observation case that his grandpa prepared for his grandchildren is very unique and looks like Figure 1. Ant nest Figure 1 This case consists ...
vfc_75785
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 1\n0 0\n1 0\n1 2\n0 2\n0 0 0", "output": "1.000000", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1 1\n0 0\n1 0\n1 2\n-1 2\n0 0 0", "output": "0.82842712709\n", "type": "s...
code_contests
verifiable_code
p00770 Prime Caves
Solve the following coding problem using the programming language python: Prime Caves An international expedition discovered abandoned Buddhist cave temples in a giant cliff standing on the middle of a desert. There were many small caves dug into halfway down the vertical cliff, which were aligned on square grids. Th...
vfc_75797
{ "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": "49 22\n46 37\n42 23\n945 561\n1081 681\n1056 452\n1042 862\n973 677\n1000000 1000000\n0 0", "output": "0 0\n6 43\n1 23\n20 829\n18 947\n10 947\n13 947\n23 947\n534 993541", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
p00901 ASCII Expression
Solve the following coding problem using the programming language python: Mathematical expressions appearing in old papers and old technical articles are printed with typewriter in several lines, where a fixed-width or monospaced font is required to print characters (digits, symbols and spaces). Let us consider the fo...
```python MOD = 2011 while 1: n = int(input()) if n == 0: break S = [input() for i in range(n)] w = len(S[0]) def parse(bcur, bright, top, bottom): #print("parse", bcur, bright, top, bottom) base = -1 for i in range(bcur, bright): for j in range(top, bott...
vfc_75801
{ "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\n........4...2..........\n(.1.-.----.)..*.-.5.+.6\n........2..............\n.......3...............\n3\n...3.\n-.---\n...4.\n4\n.3.+.4.*.-.2.\n-------------\n..........2..\n...-.1.-.2...\n2\n...2..3\n(.4..).\n1\n2.+.3.*.5.-.7.+.9...
code_contests
verifiable_code
p01034 Yu-kun Likes a Directed Graph
Solve the following coding problem using the programming language python: Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves drawing as much as programming. So far, Yu-kun has drawn many pictures with...
vfc_75805
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 8 -8\n0 1 5\n0 4 3\n1 2 10\n1 3 1\n3 6 6\n4 3 1\n4 5 2\n4 6 2", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 -1\n0 1 1\n0 2 5", "output": "NA", "type": "st...
code_contests
verifiable_code
p01168 Lying about Your Age
Solve the following coding problem using the programming language python: You have moved to a new town. As starting a new life, you have made up your mind to do one thing: lying about your age. Since no person in this town knows your history, you don’t have to worry about immediate exposure. Also, in order to ease you...
vfc_75809
{ "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": "23 18 53\n46 30 47\n-1 -1 -1", "output": "49\n-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "23 29 53\n46 30 47\n-1 -1 -1", "output": "-1\n-1\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
p01473 Palindromic Anagram
Solve the following coding problem using the programming language python: Problem statement Given the string $ S $. Find the number of all anagrams in $ S $ that are palindromic. An anagram of the string $ X $ is an anagram of $ Y $, which means that $ X $ is equal to $ Y $, or that the rearranged characters of $ X ...
```python import collections from math import * s=input() a=collections.Counter(s) o=0 for x in a: if a[x]&1: o+=1 if o>1:print(0);break a[x]-=1 else: b=factorial(len(s)//2) for x in a.values(): b//=factorial(x//2) print(b) ```
vfc_75817
{ "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": "ab", "output": "0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01633 Hole
Solve the following coding problem using the programming language python: Problem Statement Mr. Hagiwara, a witch, has a very negative personality. When she feels depressed, she uses the magic of digging to make holes and cry and fill them. The magic of digging is as follows. She first draws N line segments on the g...
vfc_75821
{ "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": "11\n0 0 10 0\n10 0 10 10\n10 10 0 10\n0 10 0 0\n1 2 9 2\n8 1 8 9\n9 8 1 8\n2 9 2 1\n8 11 11 8\n8 11 14 10\n11 8 10 14", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n5 0 5 ...
code_contests
verifiable_code
p01785 Polygon Guards
Solve the following coding problem using the programming language python: Example Input 8 0 2 0 0 2 0 2 1 3 1 3 3 1 3 1 2 Output 1 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_75825
{ "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": "8\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n1 3\n1 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n0 3\n1 2", "output": "1\n", "type": "std...
code_contests
verifiable_code
p01920 Binary Sequence
Solve the following coding problem using the programming language python: E: Binary Sequence-Binary Sequence- story I love binaries Bonald.Brvin.Bnuth! He is known as Uncle Bnuth, who is studying the nature of binary sequences at Offtunford University! By the way, if my name "Bonald.Brvin.Bnuth" is binarized from AS...
vfc_75829
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 267386880, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n0101100110\n3\n3 3 1\n1 6 0\n2 5 1", "output": "2\n1\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n0101100110\n1\n3 3 1\n1 6 0\n2 5 1", "output": "2\n", "type": "std...
code_contests
verifiable_code
p02058 Tree
Solve the following coding problem using the programming language python: G: Tree problem Given a tree consisting of N vertices. Each vertex of the tree is numbered from 1 to N. Of the N-1 edges, the i \ (= 1, 2, ..., N-1) edge connects the vertex u_i and the vertex v_i. Write a program to find the number of K non-...
```python import sys def getpar(Edge, p): N = len(Edge) par = [0]*N par[0] = -1 par[p] -1 stack = [p] visited = set([p]) while stack: vn = stack.pop() for vf in Edge[vn]: if vf in visited: continue visited.add(vf) ...
vfc_75833
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 1073741824, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2\n1 3", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n1 2\n1 3", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
beatrice
Solve the following coding problem using the programming language python: Problem description Tris (or as her parents call her Beatrice) is going through a series of training and evaluation to get into top 10 and remain in Dauntless Faction. She is currently placed 12th and will become faction-less if she fails, today...
```python for t in xrange(int(raw_input())): s = raw_input() count = 0 start = 0 for c in s: if c=='i': start += 1 else: start -= 1 if (start<0): start = 0 count += 1 print count, start ```
vfc_75845
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\niidiiii", "output": "0 5", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\niidiiij", "output": "0 3\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
cn01
Solve the following coding problem using the programming language python: So, you are bored and you think about playing a game. The game is like, if you win your money will be doubled and eleven dollars extra will be added to it. If you lose, your money will be halved (if the amount is odd, it will be halved to the ...
```python import math x = input() z = raw_input() l = len(z) for y in xrange(l): if z[y]=="W": x*=2 x+=11 else: x = int(math.ceil(x/float(2))) print x ```
vfc_75849
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "23\nLWLW", "output": "47", "type": "stdin_stdout" }, { "fn_name": null, "input": "51\nL", "output": "26", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
flow017
Solve the following coding problem using the programming language python: Three numbers A, B and C are the inputs. Write a program to find second largest among three numbers. Input The first line contains an integer T, total number of testcases. Then follow T lines, each line contains three integers A, B and C. Ou...
```python n=input() for i in range(n): a=raw_input() s=str(a).split() s=[int(s[0]),int(s[1]),int(s[2])] s.sort () print s[1] ```
vfc_75853
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 \n120 11 400\n10213 312 10\n10 3 450", "output": "120\n312\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 \n120 14 400\n10213 312 10\n10 3 450", "output": "120\n312\n10\n", ...
code_contests
verifiable_code
lincan
Solve the following coding problem using the programming language python: On the eve of Republic Day, Teacher decided to distribute candies among N students.She brought the candies in a box and placed it in front of students. She allowed every student to take out some candies. But each one of them tried to take out ...
```python T = int(raw_input()) for t in range(T): tot =0 n = int(raw_input()) a = map(int,raw_input().split()) m = sum(a) if m%n!=0: print -1 else: for i in range(n): if abs(a[i]-m//n) >0: tot += abs(a[i]-m//n) print tot ```
vfc_75857
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1 2 3\n3\n1 2 1\n4\n9 7 8 0", "output": "2\n-1\n12\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
predict
Solve the following coding problem using the programming language python: Chef Datta likes betting in Indian Premier League very much. He has 10000 rupees. Today the match is between team A and team B. The winning probability of team A is PA, and hence winning probability of team B is PB = 1 − PA. Datta is free to be...
```python ''' Predictopus Problem code: PREDICT Chef Datta likes betting in Indian Premier League very much. He has 10000 rupees. Today the match is between team A and team B. The winning probability of team A is PA, and hence winning probability of team B is PB = 1 - PA. Datta is free to bet any integral amount of...
vfc_75861
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n0.510", "output": "10098.000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0.6759186611344643", "output": "11140.239105\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
tachstck
Solve the following coding problem using the programming language python: [Chopsticks (singular: chopstick) are short, frequently tapered sticks used in pairs of equal length, which are used as the traditional eating utensils of China, Japan, Korea and Vietnam. Originated in ancient China, they can also be found in so...
```python arr=raw_input().split(" ") n=int(arr[0]) d=int(arr[1]) inte=[] count=0 for i in range(n): inte.append(int(raw_input())) inte.sort() #print inte i=0 while i<n-1: if (inte[i+1]-inte[i])<=d: count+=1 i+=2 else: i+=1 print count ```
vfc_75865
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n1\n3\n3\n9\n4", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n2\n3\n3\n9\n4", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
1010_D. Mars rover
Solve the following coding problem using the programming language python: Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is an ...
```python import sys input=sys.stdin.readline n=int(input()) stack=[] children=[] for i in range(n): children.append([]) parent=[-1]*n nodes=[-1]*n inputs=[] functions=[-1]*n for i in range(n): a=list(map(str,input().split())) r=a[0] if r=='IN': stack.append((i,int(a[1]))) inputs.append(i) elif r=='NO...
vfc_75869
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\nAND 9 4\nIN 1\nIN 1\nXOR 6 5\nAND 3 7\nIN 0\nNOT 10\nIN 1\nIN 1\nAND 2 8\n", "output": "10110", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\nOR 17 10\nIN 0\nIN 0\nNOT 6\nOR 18 14\nI...
code_contests
verifiable_code
1034_D. Intervals of Intervals
Solve the following coding problem using the programming language python: Little D is a friend of Little C who loves intervals very much instead of number "3". Now he has n intervals on the number axis, the i-th of which is [a_i,b_i]. Only the n intervals can not satisfy him. He defines the value of an interval of i...
vfc_75873
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n1 3\n2 4\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 4\n5 7\n3 6\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
1057_A. Bmail Computer Network
Solve the following coding problem using the programming language python: Once upon a time there was only one router in the well-known company Bmail. Years went by and over time new routers were purchased. Every time they bought a new router, they connected it to one of the routers bought before it. You are given the ...
```python n=int(input()) a=list(map(int,input().split())) if len(set(a))==n: a.append(n) print(*a) else: a.insert(0,0) b=[n] x=n while x!=1: b.append(a[x-1]) x=a[x-1] print(*b[::-1]) ```
vfc_75877
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 1 2 2 3 2 5\n", "output": "1 2 5 8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 2 3 4 5\n", "output": "1 2 3 4 5 6\n", "type": "stdin_stdout" }, { "f...
code_contests
verifiable_code
107_E. Darts
Solve the following coding problem using the programming language python: The night after the graduation ceremony graduate students of German University in Cairo (GUC) are playing darts. As there's no real dart board available, the photographs of members of the GUC upper management are being used. So, n rectangular p...
vfc_75881
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0 0 1 3 1 3 0\n0 0 0 3 1 3 1 0\n3 3 2 3 2 0 3 0\n3 3 3 2 0 2 0 3\n", "output": "1.5000000000\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
109_D. Lucky Sorting
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 got an array consis...
```python #!/usr/bin/env python3 def is_lucky(v): while v > 0: r = v % 10 if r != 4 and r != 7: return False v //= 10 return True n = int(input()) arr = list(map(int, input().split())) arr_with_pos = sorted([[a, i] for i, a in enumerate(arr)]) pos, tpos = None, None # po...
vfc_75885
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 2 1\n", "output": "1\n1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n77 66 55 44 33 22 11\n", "output": "7\n1 7\n7 2\n2 6\n6 3\n3 5\n5 6\n6 7\n", "type": "stdin_st...
code_contests
verifiable_code
1120_D. Power Tree
Solve the following coding problem using the programming language python: You are given a rooted tree with n vertices, the root of the tree is the vertex 1. Each vertex has some non-negative price. A leaf of the tree is a non-root vertex that has degree 1. Arkady and Vasily play a strange game on the tree. The game c...
vfc_75889
{ "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\n5 1 3 2 1\n1 2\n2 3\n2 4\n1 5\n", "output": "4 3\n2 4 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 1\n1 2\n1 3\n", "output": "2 3\n1 2 3\n", "type": "stdin_stdou...
code_contests
verifiable_code
1147_F. Zigzag Game
Solve the following coding problem using the programming language python: You are given a complete bipartite graph with 2n nodes, with n nodes on each side of the bipartition. Nodes 1 through n are on one side of the bipartition, and nodes n+1 to 2n are on the other side. You are also given an n × n matrix a describin...
vfc_75893
{ "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": "2\n3\n3 1 9\n2 5 7\n6 4 8\n6\n-1\n1\n1\nI 1\n-1", "output": "B\nB\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2\n1 2\n3 4\n", "output": "player won game 1!\n", "type"...
code_contests
verifiable_code
1187_D. Subarray Sorting
Solve the following coding problem using the programming language python: You are given an array a_1, a_2, ..., a_n and an array b_1, b_2, ..., b_n. For one operation you can sort in non-decreasing order any subarray a[l ... r] of the array a. For example, if a = [4, 2, 2, 1, 3, 1] and you choose subbarray a[2 ... 5...
```python from sys import stdin, stdout from collections import defaultdict t = int(stdin.readline()) inf = 10**6 def merge_sort(order, a): if len(order) == 1: return order, a mid = (len(order) + 1) // 2 left_o, left_a = merge_sort(order[:mid], a[:mid]) right_o, right_a = merge_sort(order[mid:...
vfc_75901
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n7\n1 7 1 4 4 5 6\n1 1 4 4 5 7 6\n5\n1 1 3 3 5\n1 1 3 3 5\n2\n1 1\n1 2\n3\n1 2 3\n3 2 1\n", "output": "YES\nYES\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n5\n4 4 4 4 4\n5...
code_contests
verifiable_code
1206_C. Almost Equal
Solve the following coding problem using the programming language python: You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blackboa...
```python n=int(input()) if n%2==0: print('NO') else: print('YES') ans=1 c=3 for i in range(n): if i==0: print(ans,end=' ') else: print(ans+c,end=' ') ans=ans+c c=1 if c==3 else 3 ans=2 c=1 for i in range(n): if i==0...
vfc_75905
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "YES\n1 4 5 2 3 6\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
1223_F. Stack Exterminable Arrays
Solve the following coding problem using the programming language python: Let's look at the following process: initially you have an empty stack and an array s of the length l. You are trying to push array elements to the stack in the order s_1, s_2, s_3, ... s_{l}. Moreover, if the stack is empty or the element at th...
vfc_75909
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n2 1 1 2 2\n6\n1 2 1 1 3 2\n9\n3 1 2 2 1 6 6 3 3\n", "output": " 4\n 1\n ...
code_contests
verifiable_code
1249_B2. Books Exchange (hard version)
Solve the following coding problem using the programming language python: The only difference between easy and hard versions is constraints. There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his book ...
```python q = int(input()) for _ in range(q): n = int(input()) succ = list(map(lambda x: int(x) -1 ,input().split())) cycle_belong = [-1 for k in range(n)] cycle_size = [] for k in range(n): if cycle_belong[k] == -1 : # not visited yet start = k current = k ...
vfc_75913
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3\n", "output": "1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
1267_I. Intriguing Selection
Solve the following coding problem using the programming language python: This is an interactive problem. You are the head coach of a chess club. The club has 2n players, each player has some strength which can be represented by a number, and all those numbers are distinct. The strengths of the players are not known ...
vfc_75917
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n\n&gt;\n\n&lt;\n\n&gt;\n\n&lt;\n\n&gt;\n\n&gt;\n\n3\n\n&lt;\n\n&lt;\n\n&lt;\n\n&gt;\n\n&gt;\n", "output": "\n\n\n? 1 3\n\n? 4 2\n\n? 4 5\n\n? 6 5\n\n? 3 4\n\n? 5 6\n\n!\n\n? 3 4\n\n? 4 2\n\n? 5 3\n\n? 6 4\n\n? 3 1\n\n!\...
code_contests
verifiable_code
128_C. Games with Rectangle
Solve the following coding problem using the programming language python: In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint ins...
```python from math import factorial MOD = 1000000007 def c(n, k): if k > n: return 0 return factorial(n) //(factorial(k) * factorial(n - k)) n, m, k = map(int, input().split()) print ((c(n - 1, 2 * k) * c(m - 1, 2 * k)) % MOD) ```
vfc_75921
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 7 2\n", "output": "75\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
130_I. Array sorting
Solve the following coding problem using the programming language python: Sorting arrays is traditionally associated with high-level languages. How hard can it be in Befunge? Sort the given array in non-descending order. Input The first line of input contains an integer n (1 ≤ n ≤ 100) — the size of the array. The f...
vfc_75925
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n7\n1\n9\n7\n3\n", "output": "1 3 7 7 9 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n60\n1\n60\n1\n60\n1\n60\n1\n60\n1\n", "output": "1 1 1 1 1 60 60 60 60 60 \n", "t...
code_contests
verifiable_code
1332_D. Walk on Matrix
Solve the following coding problem using the programming language python: Bob is playing a game named "Walk on Matrix". In this game, player is given an n × m matrix A=(a_{i,j}), i.e. the element in the i-th row in the j-th column is a_{i,j}. Initially, player is located at position (1,1) with score a_{1,1}. To rea...
```python k = int(input()) arr = [[0, k, 0], [0, 0, k]] length = 0 t = k while t > 0: t >>= 1 length += 1 # print(((1 << length) - 1) ^ k) arr[1][1] = (1 << length) + k arr[1][0] = (1 << length) + (((1 << length) - 1) ^ k) arr[0][0] = (1 << (length + 1)) - 1 print(2, 3) for i in arr: print(*i) ``...
vfc_75929
{ "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": "1\n", "output": "2 3\n131073 131072 0\n1 131073 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "0\n", "output": "2 3\n131072 131072 0\n0 131072 0", "type": "stdin_stdout" }...
code_contests
verifiable_code
1352_G. Special Permutation
Solve the following coding problem using the programming language python: A permutation of length n is an array p=[p_1,p_2,...,p_n], which contains every integer from 1 to n (inclusive) and, moreover, each number appears exactly once. For example, p=[3,1,4,2,5] is a permutation of length 5. For a given number n (n ≥ ...
```python """ Author: guiferviz Time: 2020-05-09 16:35:02 """ def solve(): n = int(input()) if n < 4: print(-1) elif n == 4: print("3 1 4 2") else: sol = [] i = 1 while i <= n: sol.append(i) i += 2 i = sol[-1] val = i - 3 ...
vfc_75933
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n10\n2\n4\n6\n7\n13\n", "output": "9 7 5 3 1 4 2 6 8 10\n-1\n3 1 4 2\n5 3 1 4 2 6\n7 5 3 1 4 2 6\n13 11 9 7 5 3 1 4 2 6 8 10 12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n4\n3\n5...
code_contests
verifiable_code
1372_E. Omkar and Last Floor
Solve the following coding problem using the programming language python: Omkar is building a house. He wants to decide how to make the floor plan for the last floor. Omkar's floor starts out as n rows of m zeros (1 ≤ n,m ≤ 100). Every row is divided into intervals such that every 0 in the row is in exactly 1 interva...
```python from bisect import * import sys int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(r...
vfc_75937
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n2\n1 2\n3 5\n2\n1 3\n4 5\n3\n1 1\n2 4\n5 5\n3\n1 1\n2 2\n3 5\n", "output": "36\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1395_D. Boboniu Chats with Du
Solve the following coding problem using the programming language python: Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group fo...
```python n, d, m = map(int, input().split()) a = list(map(int, input().split())) less = [] more = [] for i in a: if i>m: more.append(i) else: less.append(i) less.sort(reverse = True) more.sort(reverse = True) lessp = [] if len(less)>0: lessp = [less[0]] for i in less[1:]: lessp.append(lessp[-1]+i) m...
vfc_75941
{ "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": "20 2 16\n20 5 8 2 18 16 2 16 16 1 5 16 2 13 6 16 4 17 21 7\n", "output": "195\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 11\n8 10 15 23 5\n", "output": "48\n", "type":...
code_contests
verifiable_code
1419_F. Rain of Fire
Solve the following coding problem using the programming language python: There are n detachments on the surface, numbered from 1 to n, the i-th detachment is placed in a point with coordinates (x_i, y_i). All detachments are placed in different points. Brimstone should visit each detachment at least once. You can ch...
```python # import numpy as npy import functools import math n=int(input()) x=[0 for i in range(n+2)] y=[0 for i in range(n+2)] adj=[[] for i in range(n+2)] idx=[] idy=[] for i in range(n): x[i],y[i]=map(int,input().split()) idx.append(i) idy.append(i) def cmpx(a,b): if x[a]!=x[b]: if x[a]<x[b...
vfc_75945
{ "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": "7\n0 2\n1 0\n-3 0\n0 -2\n-1 -1\n-1 -3\n-2 -3\n", "output": "-1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1462_E1. Close Tuples (easy version)
Solve the following coding problem using the programming language python: This is the easy version of this problem. The only difference between easy and hard versions is the constraints on k and m (in this version k=2 and m=3). Also, in this version of the problem, you DON'T NEED to output the answer by modulo. You a...
```python #input = sys.stdin.readline import os import sys from io import BytesIO, IOBase import heapq as h import bisect from types import GeneratorType BUFSIZE = 8192 class SortedList: def __init__(self, iterable=[], _load=200): """Initialize sorted list instance.""" values = so...
vfc_75953
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n1 2 4 3\n4\n1 1 1 1\n1\n1\n10\n5 6 1 3 2 9 8 1 2 4\n", "output": "\n2\n4\n0\n15\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1487_F. Ones
Solve the following coding problem using the programming language python: You are given a positive (greater than zero) integer n. You have to represent n as the sum of integers (possibly negative) consisting only of ones (digits '1'). For example, 24 = 11 + 11 + 1 + 1 and 102 = 111 - 11 + 1 + 1. Among all possible ...
```python def ones(a): return (10 ** a - 1) // 9 def add_in_dict(dct, key, val): if key in dct: dct[key] = min(dct[key], val) else: dct[key] = val _s = input() _n = len(_s) _x = int(_s) cur_dict = {} cur_dict[_x] = 0 for i in range(_n + 1, 0, -1): ns = ones(i) new_dict = {} ...
vfc_75957
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "24\n", "output": "\n6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1511_C. Yet Another Card Deck
Solve the following coding problem using the programming language python: You have a card deck of n cards, numbered from top to bottom, i. e. the top card has index 1 and bottom card — index n. Each card has its color: the i-th card has color a_i. You should process q queries. The j-th query is described by integer t...
```python N, Q = map(int, input().split()) A = list(map(int, input().split())) T = list(map(int, input().split())) inds = [0]*51 for i in range(N): if inds[A[i]]==0: inds[A[i]] = i+1 ans = [] for i in range(Q): ans.append(inds[T[i]]) for c in range(1,51): if inds[c]<inds[T[i]]: inds[c] += 1 inds[T...
vfc_75961
{ "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 5\n2 1 1 4 3 3 1\n3 2 1 1 4\n", "output": "\n5 2 3 1 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n6 4 3 2 1\n1 6\n", "output": "5 2 ", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1539_A. Contest Start
Solve the following coding problem using the programming language python: There are n people participating in some contest, they start participating in x minutes intervals. That means the first participant starts at time 0, the second participant starts at time x, the third — at time 2 ⋅ x, and so on. Duration of con...
```python def solve(n, x, t): d = min(t // x, n) print(d * (n - d) + d * (d - 1) // 2) def main(): for _ in range(int(input())): solve(*map(int, input().split())) if __name__ == '__main__': main() ```
vfc_75965
{ "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 2 5\n3 1 2\n3 3 10\n2000000000 1 2000000000\n", "output": "5\n3\n3\n1999999999000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n8627 2 2\n", "output": "8626\n", ...
code_contests
verifiable_code
186_D. Mushroom Scientists
Solve the following coding problem using the programming language python: As you very well know, the whole Universe traditionally uses three-dimensional Cartesian system of coordinates. In this system each point corresponds to three real coordinates (x, y, z). In this coordinate system, the distance between the center...
```python S = int(input()) v = [int(x) for x in input().strip().split()] zeroes = v.count(0) total = sum(v) ans = [] if zeroes == 0: ans = [S * v[i] / total for i in range(3)] elif zeroes == 1: for i in range(3): if v[i] == 0: total -= v[i] for i in range(3): if v[i] != 0: ...
vfc_75973
{ "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\n2 0 0\n", "output": "3.0000000000 0.0000000000 0.0000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 1\n", "output": "1.0000000000 1.0000000000 1.0000000000\n", ...
code_contests
verifiable_code
207_D6. 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...
vfc_75977
{ "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": "29000\nU.K. MONEY MARKET DEFICIT REVISED DOWNWARD\nLONDON, April 9 - The Bank of England said it has revised\nits estimate of today's shortfall to 350 mln stg from 400 mln,\nbefore taking account of 103 mln stg morning assistance.\...
code_contests
verifiable_code
258_D. Little Elephant and Broken Sorting
Solve the following coding problem using the programming language python: The Little Elephant loves permutations of integers from 1 to n very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a permutation 1, 2, 3, ..., ...
```python inp = input().split(' ') val=[]; totNums = int(inp[0]); totOpt = int(inp[1]); inp = input().split(' '); #assert(len(inp) == totNums); for it in inp: val.append(int(it)) dp = [[0.0 for _ in range(0,totNums)] for __ in range(0,totNums)] for i in range(0,totNums): for j in range(0,totNums): if val[...
vfc_75985
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n1 3 2 4\n1 2\n2 3\n1 4\n", "output": "3.000000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
281_D. Maximum Xor Secondary
Solve the following coding problem using the programming language python: Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1, x2, ..., xk (k > 1) is such maximum element xj, that the following inequality holds: <image>. The lucky number...
```python #https://codeforces.com/problemset/problem/281/D def empty(l): return len(l) == 0 def lucky_number(arr): st = [] l = 0 for d in arr: while not empty(st) and st[-1] < d: l = max(l, st.pop() ^ d) if not empty(st): l = max(l, st[-1] ^ d) st.appen...
vfc_75989
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n9 8 3 5 7\n", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 2 1 4 3\n", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "i...
code_contests
verifiable_code
304_C. Lucky Permutation Triple
Solve the following coding problem using the programming language python: Bike is interested in permutations. A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] is n...
```python r = int(input()) if r % 2 == 0: print (-1) elif r == 1: print(0) print(0) print(0) else: for i in range(r): print(i,end=" ") print() i = r - 1 while i >= 0: print(i,end=" ") i -= 2 i = r - 2 while i >= 0: print(i,end=" ") i -= 2 ...
vfc_75993
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n", "output": "0 1 2 3 4\n0 1 2 3 4\n0 2 4 1 3\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
330_D. Biridian Forest
Solve the following coding problem using the programming language python: You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest. The forest The Biridian Forest is a two-dimensional grid consisting of r rows and c ...
```python from sys import stdin rints = lambda: [int(x) for x in stdin.readline().split()] rstr = lambda: stdin.readline().strip() rstr_2d = lambda n: [rstr() for _ in range(n)] valid = lambda x, y: 0 <= x < n and 0 <= y < m and grid[x][y] != 'T' dx, dy = [0, 1, 0, -1, 1, -1, 1, -1], [1, 0, -1, 0, 1, -1, -1, 1] n, m ...
vfc_75997
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 4\nSE23\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 7\n000E0T3\nT0TT0T0\n010T0T0\n2T0T0T0\n0T0S000\n", "output": "3", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
352_B. Jeff and Periods
Solve the following coding problem using the programming language python: One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which these conditions hold: * x occurs in sequence a. * Conside...
```python le = int(input()) integers = [int(i) for i in str(input()).split(" ")] d = {} for index, ele in enumerate(integers): # should already be sorted if ele in d: d[ele].append(index) else: d[ele] = [index] ans = [] for key, items in d.items(): if len(items) == 1: ans.append...
vfc_76001
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 2 1 3 1 2 1 5\n", "output": "4\n1 2\n2 4\n3 0\n5 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2\n", "output": "1\n2 0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
376_C. Divisible by Seven
Solve the following coding problem using the programming language python: You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7. Number a doesn't contain any leading zeroes and co...
```python a=input() cnt=[0]*10 for i in (1,6,8,9): cnt[i]=-1 for i in a: cnt[int(i)]+=1 mod = [1869, 1968, 9816, 6198, 1698, 1986, 1896, 1869] modCnt=0 for i in range(1,10): for j in range(cnt[i]): modCnt= (modCnt*3 + i)%7 print(str(i)*cnt[i], end='') modCnt=(10000*modCnt)%7 print(str(mod[7-modCnt])+...
vfc_76005
{ "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": "1689\n", "output": "1869\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "18906\n", "output": "18690\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
398_E. Sorting Permutations
Solve the following coding problem using the programming language python: We are given a permutation sequence a1, a2, ..., an of numbers from 1 to n. Let's assume that in one second, we can choose some disjoint pairs (u1, v1), (u2, v2), ..., (uk, vk) and swap all aui and avi for every i at the same time (1 ≤ ui < vi ≤...
vfc_76009
{ "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 0\n1 5 2 4 3\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n1 0 2 4 0\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
421_A. Pasha and Hamsters
Solve the following coding problem using the programming language python: Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like...
```python n, a, b = map(int, input().split()) x = set(map(int, input().split())) y = set(map(int, input().split())) y -= x s = "" for i in range(1, n + 1, 1): if i in x: s += str(1) + " " else: s += str(2) + " " print(s) ```
vfc_76013
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5 2\n3 4 1 2 5\n2 3\n", "output": "1 1 1 1 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 3\n1 2\n2 3 4\n", "output": "1 1 2 2 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
447_D. DZY Loves Modification
Solve the following coding problem using the programming language python: As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decided to modify the matrix with exactly k operations. Each modification is one of the following: 1. Pick some row of the matrix an...
vfc_76017
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 5 2\n1 3\n2 4\n", "output": " 11", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
469_E. Hack it!
Solve the following coding problem using the programming language python: Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quic...
```python m = int(input()) x,t=10**100-1,m-100*45*10**99%m print(t,t+x) ```
vfc_76021
{ "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": "46\n", "output": "30 1000000000000000029\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "126444381000032\n", "output": "17579858499136 1000017579858499135\n", "type": "stdin_st...
code_contests
verifiable_code
492_A. Vanya and Cubes
Solve the following coding problem using the programming language python: Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 =...
```python n=int(input()) i=1;x=0 while 1: x+=(i*(i+1)/2) if x==n: print(i) break elif x>n: print(i-1) break i+=1 ```
vfc_76025
{ "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": "25\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "219\n", ...
code_contests
verifiable_code
515_E. Drazil and Park
Solve the following coding problem using the programming language python: Drazil is a monkey. He lives in a circular park. There are n trees around the park. The distance between the i-th tree and (i + 1)-st trees is di, the distance between the n-th tree and the first tree is dn. The height of the i-th tree is hi. D...
vfc_76029
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n2 2 2 2 2\n3 5 2 1 4\n1 3\n2 2\n4 5\n", "output": "12\n16\n18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n5 1 4\n5 1 4\n3 3\n2 2\n1 1\n", "output": "17\n22\n11\n", ...
code_contests
verifiable_code
56_B. Spoilt Permutation
Solve the following coding problem using the programming language python: Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change — he took all the coins whose r...
```python n = int(input()) l = list(map(int,input().split())) v = l.copy() v.sort() i = 0 j = 0 l1 = [] l2 = [] ans = [] while i<n and j<n: if l[i] == v[j]: i+=1 j+=1 else: l1.append(v[j]) l2.append(l[i]) ans.append(j) j+=1 i+=1 l2.reverse() if l1 == l2...
vfc_76037
{ "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\n1 6 5 4 3 2 7 8\n", "output": "2\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 3 4 1\n", "output": "0\n0\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
590_E. Birthday
Solve the following coding problem using the programming language python: Today is birthday of a Little Dasha — she is now 8 years old! On this occasion, each of her n friends and relatives gave her a ribbon with a greeting written on it, and, as it turned out, all the greetings are different. Dasha gathered all the r...
vfc_76041
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nabab\naba\naabab\nababb\nbab\n", "output": "2\n2 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\nbaba\nabba\nbab\nab\nba\na\nbbaba\nb\nbba\nbb\n", "output": "3\n4 5 10 ", ...
code_contests
verifiable_code
612_D. The Union of k-Segments
Solve the following coding problem using the programming language python: You are given n segments on the coordinate axis Ox and the number k. The point is satisfied if it belongs to at least k segments. Find the smallest (by the number of segments) set of segments on the coordinate axis Ox which contains all satisfie...
```python #### IMPORTANT LIBRARY #### ############################ ### DO NOT USE import random --> 250ms to load the library ############################ ### In case of extra libraries: https://github.com/cheran-senthil/PyRival ###################### ####### IMPORT ####### ###################### from functools imp...
vfc_76045
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n0 5\n-3 2\n3 8\n", "output": "2\n0 2\n3 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n0 5\n-3 3\n3 8\n", "output": "1\n0 5\n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
632_D. Longest Subsequence
Solve the following coding problem using the programming language python: You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l ≤ m. A subsequence of a is ...
```python import bisect from itertools import accumulate import os import sys import math from decimal import * 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 =...
vfc_76049
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 8\n6 2 9 2 7 2 3\n", "output": "6 5\n1 2 4 6 7 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 4\n2 2 2 3 3 3\n", "output": "2 3\n1 2 3 ", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
661_A. Lazy Caterer Sequence
Solve the following coding problem using the programming language python: Lazy caterer sequence is defined as the maximum number of pieces formed when slicing a convex pancake with n cuts (each cut is a straight line). The formula is Cn = n·(n + 1) / 2 + 1. You are given n; calculate n-th element of the sequence. Inp...
vfc_76053
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n", "output": "16\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
685_A. Robbers' watch
Solve the following coding problem using the programming language python: Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches. First, as they know that kingdom police is bad at math, robbers use the p...
```python from sys import exit from itertools import permutations as prm def to_base(n, base): ans = [] while n // base > 0: ans.append(n % base) n //= base ans.append(n % base) ans.reverse() return ans def le(l, n, m): prev_eq = True for i in range(len(n)): if l[i...
vfc_76057
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 2\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
72_F. Oil
Solve the following coding problem using the programming language python: After the nationalization of the oil industry, Dr. Mosaddegh wants to dig some oil wells to extract all the oil in Persian Gulf. But Persian Gulf is huge and has an infinite amount of oil. So Dr. Mosaddegh works only on a rectangular plane of si...
vfc_76065
{ "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": "2 3\n1 2\n1 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n2 2 3\n3 2 3 1\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
750_C. New Year and Rating
Solve the following coding problem using the programming language python: Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second divis...
```python I = lambda: list(map(int, input().split())) n = I()[0] c, d = [[0] * n for _ in range(2)] for i in range(n): _c, _d = I() c[i] = _c d[i] = _d lb, ub, change = -1e100, 1e100, 0 for i in range(n)[::-1]: change -= c[i] if d[i] == 1: lb = max(lb, 1900 - change) else: ub = ...
vfc_76069
{ "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\n-5 1\n", "output": "Infinity\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n57 1\n22 2\n", "output": "Impossible\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
774_A. Amusement Park
Solve the following coding problem using the programming language python: Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once. Tickets for group of x people are sold on the attra...
```python n, c1, c2 = [int(x) for x in input().split(' ')] s = input() cnt = s.count('1') def price(x): return c1 + c2 * (x - 1) ** 2 prices = [] for i in range(1, cnt + 1): bigGroupsPeople = n // i + 1 numBigGroups = n % i smallGroupsPeople = n // i numSmallGroups = i - n % i totalPrice = n...
vfc_76073
{ "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 7 2\n1101\n", "output": "18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 1\n011\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
799_A. Carrot Cakes
Solve the following coding problem using the programming language python: In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However...
```python n,t,k,d=[int(i) for i in input().split()] a = (n+k-1)//k*t b=1000000000 for i in range(n//k+1): b=min(b,max(d+i*t,(n-i*k+k-1)//k*t)) if b<a: print('YES') else: print('NO') ```
vfc_76077
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3 11 4\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 1 4\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
819_A. Mister B and Boring Game
Solve the following coding problem using the programming language python: Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens. All characters in this game are lowercase English letters. There are two players: Mister B a...
```python def main(a, b, l, r): qL = (l - 1) // (2 * a + 2 * b) rL = (l - 1) % (2 * a + 2 * b) + 1 qR = (r - 1) // (2 * a + 2 * b) rR = (r - 1) % (2 * a + 2 * b) + 1 #print(qL, qR, rL, rR) if qL == qR: #In b segment if a < rL <= a + b and a < rR <= a + b: re...
vfc_76081
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 2 6\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1 8\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
844_D. Interactive LowerBound
Solve the following coding problem using the programming language python: This is an interactive problem. You are given a sorted in increasing order singly linked list. You should find the minimum integer in the list which is greater than or equal to x. More formally, there is a singly liked list built on an array o...
```python from random import sample def R(): return map(int, input().split()) def ask(i): print('?', i, flush=True) v, nxt = R() if v < 0: exit() return v, nxt def ans(v): print('!', v) exit() n, s, x = R() mv = -1 i = s S = 800 q = range(1, n + 1) if n > S: q = sample(q, S) ...
vfc_76085
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 80\n97 -1\n58 5\n16 2\n81 1\n79 4\n", "output": "? 3\n! 97\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 3 2\n3 9\n9 -1\n0 7\n6 8\n5 4\n8 2\n1 10\n7 6\n4 5\n2 1\n", "output"...
code_contests
verifiable_code
865_A. Save the problem!
Solve the following coding problem using the programming language python: Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original pro...
```python print(int(input())*2-1,2,1,2) ```
vfc_76089
{ "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": "314\n", "output": "626 2\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "4 2\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
913_D. Too Easy Problems
Solve the following coding problem using the programming language python: You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to re...
```python # -*- coding: utf-8 -*- """ Created on Fri Jan 12 18:46:09 2018 @author: Sand Boa """ import itertools if __name__ == "__main__": n:int T:int n, T = list(map(int,input().split())) listi:list = [] tsum:int = 0 csum:int = 0 k:int k = 1 a:int b:int t:int ind:int ...
vfc_76097
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 100\n1 787\n2 788\n", "output": "0\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 300\n3 100\n4 150\n4 80\n2 90\n2 300\n", "output": "2\n2\n3 4 ", "type": "stdin_stdout" ...
code_contests
verifiable_code
935_D. Fafa and Ancient Alphabet
Solve the following coding problem using the programming language python: Ancient Egyptians are known to have used a large set of symbols <image> to write on the walls of the temples. Fafa and Fifa went to one of the temples and found two non-empty words S1 and S2 of equal lengths on the wall of temple written one bel...
```python n, m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] mult = 1 mod = 10 ** 9 + 7 res = 0 m_inv = pow(m, mod - 2, mod) for x, y in zip(a, b): if x and y: if x > y: res += mult res %= mod break ...
vfc_76101
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 26\n0 15 12 9 13 0 14\n11 1 0 13 15 12 0\n", "output": "230769233\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n0\n1\n", "output": "500000004\n", "type": "stdin_stdout...
code_contests
verifiable_code
961_C. Chessboard
Solve the following coding problem using the programming language python: Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th squ...
```python import itertools n = int(input()) a = [] for i in range(4): a.append([input() for _ in range(n)]) if i < 3: assert input() == '' best = 4*n*n for p in itertools.permutations(a): for s in range(2): count = 0 for i in range(4): for r in range(n): ...
vfc_76105
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0\n\n0\n\n1\n\n0\n", "output": "1\n", "t...
code_contests
verifiable_code
989_B. A Tide of Riverscape
Solve the following coding problem using the programming language python: Walking along a riverside, Mino silently takes a note of something. "Time," Mino thinks aloud. "What?" "Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this." "And what are you recording?" ...
```python n, p = [int(i) for i in input().split()] s = list(input()) k = 0 for index in range(n - p): if k != 0: break if s[index] == s[index + p] and s[index] == ".": s[index] = str(0) s[index + p] = str(1) k += 1 elif s[index] != s[index + p] and s[index] != "." and s[index...
vfc_76109
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 7\n1.0.1.0.1.\n", "output": "1000100010\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 9\n1........1\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
amit-and-pattern
Solve the following coding problem using the programming language python: Amit has been practicing "pattern printing" problems a lot. To test his ability Jitendra gives him a problem.He tells him to print the given matrix in the diagonal fashion. Note: Direction of the diagonal is from the upper-right corner to lower...
```python n,m = map(int,raw_input().split()) matrix = [] for x in range(n): matrix.append(map(int,raw_input().split())) maxsum = n + m - 2 for sums in range(maxsum+1): for i in range(n): for j in range(m): if i + j - sums == 0: print matrix[i][j], print ```
vfc_76113
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2 3 \n5 6 7\n0 1 2\n\nSAMPLE", "output": "1\n2 5\n3 6 0\n7 1\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
car-names-4
Solve the following coding problem using the programming language python: Brian built his own car and was confused about what name he should keep for it. He asked Roman for help. Roman being his good friend, suggested a lot of names. Brian only liked names that: - Consisted of exactly three distinct characters, say ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' def validName(s): seen = 0 seen_c = [] last_c = "" n = 0 i = 0 for c in s: if c != last_c: last_c = c seen += 1 if c in seen_c or i < n: return "Not OK"...
vfc_76117
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nbbbrrriii\nbrian\n\nSAMPLE", "output": "OK\nNot OK\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nbbbrrriii\nbrian\n\nELPMAS", "output": "OK\nNot OK\n", "type": "stdin_s...
code_contests
verifiable_code
dexters-payback-2
Solve the following coding problem using the programming language python: Frustrated from Mandark's challenges, Dexter plans an invasion in Mandark's lab. He knows that the underground entrance is the best way to get inside. But still, he needs to defuse the bombs hidden under the tiles of the floor. Dexter knows tha...
```python t=int(raw_input()) for e in range(t): s,x,=0,0 w,h=map(int,raw_input().split() ) s,x=2*(w//4),w%4 s1=s+(x//3) if x==1: s+=1 elif x!=0: s+=2 k,x=(h//4),h%4 n=2*(s+s1)*k if x==1: n+=s elif x==2: n+=2*s elif x==3: n+=2*s+s1 print n ```
vfc_76121
{ "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 2\n3 3\n\nSAMPLE", "output": "4\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 2\n3 3\n\nSPMALE", "output": "4\n5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
gcd-9
Solve the following coding problem using the programming language python: Given an array of size N of integers with each element denoted as array[i] . In this problem we are given a parameter K and we are supposed to find the size of the largest contiguous subarray whose GCD is atleast K If there is no subarray whos...
```python from fractions import gcd n,m=map(int,raw_input().split()) a=map(int,raw_input().split()) z=[] l=0 for x in xrange(n): if a[x]<m: continue s=a[x] q=0 for y in xrange(x+1,n): if a[y]<m or s<m: break s=gcd(s,a[y]) if s>=m: l=max(l,y-x+1) if l==0: print 0 else: print l ```
vfc_76125
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 9\n10 20 5 15 45\n\nSAMPLE", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 9\n10 20 5 15 61\n\nSAMPLE", "output": "2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
large-small-sum
Solve the following coding problem using the programming language python: Sidddharth is very kind-hearted. He doesn't want to give you any stupid problem statement that wastes your time. Given an array of integers, find the sum of the ith largest and jth smallest number from the array. Input Format: First line of th...
```python t=input() for i in range(t): n=input() a=map(int,raw_input().strip().split()) (i,j)=map(int,raw_input().strip().split()) a.sort() result=a[n-i]+a[j-1] print result ```
vfc_76129
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n8\n1 2 5 3 6 4 8 7\n3 4\n\nSAMPLE", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n42\n24715 31274 29928 31052 27645 15171 8854 19358 22577 28004 18229 20212 5070 766...
code_contests
verifiable_code
monk-and-some-queries
Solve the following coding problem using the programming language python: Monk was asked to answer some queries in an interview. He is given an empty array A. Queries are of 4 types:- 1. 1 X - Add number X to the array A. 2. 2 X - Remove a single instance of number X from the array A. If not possible, print "-1" witho...
```python from collections import defaultdict n=input() minn=1000001 maxx=0 a=defaultdict(int) ans=[] count=0 for i in range(0,n): x=map(int,raw_input().split()) if x[0]==1: if x[1]>maxx: maxx=x[1] if x[1]<minn: minn=x[1] a[x[1]]+=1 count+=1 elif x[0]=...
vfc_76133
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 5\n1 9\n1 6\n3\n2 1\n\nSAMPLE", "output": "9\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1 5\n3\n3\n3\n1 4\n1 1\n1 8\n3\n1 6\n4", "output": "5\n5\n5\n8\n1\n", ...
code_contests
verifiable_code
perfect-baseline
Solve the following coding problem using the programming language python: A particular name-recording system is used by N employees of a firm. Everyday, they have to enter their names into the system. To make it easier to control the system, each employee has his/her name presented as a string of lowercase letters fr...
```python for testCases in range(input()): matrix = [] n,m = map(int,raw_input().split()) for i in range(n): a = raw_input() b = [] for j in a: b.append(ord(j)) matrix.append(b) mat = [] for i in range(m): res = [] for j in range(n): ...
vfc_76137
{ "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 3\naaa\nccc\nddd\n5 1\na\na\nb\nb\na\n\nSAMPLE", "output": "ccc\na\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1 19\nmvwabkokuwzqgzvscwv\n10 10\ncibcezzbig\naaqwyzwtbx\njvpbtb...
code_contests
verifiable_code
roy-and-little-mario-4
Solve the following coding problem using the programming language python: Roy has played a lot of Mario that he got bored of playing it again and again. So now he wants to design a stage of Mario game. Right now he is simply designing a group of walls using bricks that little Mario has to cross over. Little Mario can...
```python MOD = 1000000007 def TribSeries(n,t1,t2,t3): if n==1: ans=t1 if n==2: ans=t2 if n==3: ans=t3 if n>3: for j in range(n-3): ans=(t1+t2+t3)%MOD t1=t2 t2=t3 t3=ans print ans def main(): T=int(raw_input()) t...
vfc_76141
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n\nSAMPLE", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3\n\nELPMAS", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
strings-1
Solve the following coding problem using the programming language python: Anton and Artur are old friends. Today they practice in writing strings. Anton must write each string with the lengths exactly N , based on the alphabet of size M . And Arthur, on the contrary, should write each string with the lengths exactly...
```python T = int(raw_input()) while(T): T -= 1 N,M = raw_input().split() n = int(N) m = int(M) if n == m : print "YES" elif n==2 and m==4 or n==4 and m==2: print "YES" else: print "NO" ```
vfc_76145
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n1 3\n100 500\n\nSAMPLE", "output": "YES\nNO\nNO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
vada-pav-list-3
Solve the following coding problem using the programming language python: Problem : Chotu's father is the owner of a Vada Pav shop. One Sunday, his father takes him to the shop. Father tells him that at the end of the day, Chotu has to give him a list consisting of the names of all the customers on that day who bough...
```python listi = [] for i in range(input()): s = raw_input() listi.append(s) ans = list(set(listi)) ans.sort() print len(ans) for i in ans: print i ```
vfc_76149
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\nbabu\nanand\nrani\naarti\nnandu\nrani\nrani\nap\nanand\nbabu\nnandu\n\nSAMPLE", "output": "6\naarti\nanand\nap\nbabu\nnandu\nrani\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "234\nl...
code_contests
verifiable_code
p00022 Maximum Sum Sequence
Solve the following coding problem using the programming language python: Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) if N == 0: return False mi = su = 0 ans = -10**9 for i in range(N): a = int(readline()) su += a ans = max(ans, su - mi) mi = min(su, mi) print(ans...
vfc_76193
{ "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\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0", "output": "19\n14\n1001", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00153 Triangle and Circle
Solve the following coding problem using the programming language python: Create a program to determine the positional relationship between a triangle and a circle on a plane. All target figures shall include boundaries. The triangle is given the position of three vertices, and the circle is given the position of the ...
```python def contain(x, y, r): return x**2 + y**2 <= r**2 def outer_p(x0, y0, x1, y1): return (x0*y1 - y0*x1) def line_segment_circle(x0, y0, x1, y1, r, border=True): A = x0**2 + y0**2 B = x0*x1 + y0*y1 C = x1**2 + y1**2 - r**2 D = B**2 - A*C if border: if D < 0: return ...
vfc_76197
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n3 1\n3 3\n3 2\n3\n3 12\n9 3\n11 12\n8 7\n5\n15 3\n17 7\n22 5\n7 6\n4\n6 11\n8 2\n16 9\n10 8\n2\n0 0", "output": "b\nc\nd\na", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n3 1\n3 3...
code_contests
verifiable_code
p00474 Icicles
Solve the following coding problem using the programming language python: problem There are fine icicles under the eaves of JOI's house in Canada. Because of this, JOI decided to investigate the icicles. There are N (2 ≤ N ≤ 100000 = 105) icicles under the eaves of JOI's house. These icicles are aligned and i cm (1 ...
```python def loadIcicle(): icicles = [] line = input().strip().split(" ") N, L = int(line[0]), int(line[1]) while True: icicles.append(int(input().strip())) if len(icicles) == N: break return icicles, N, L icicles, N, L = loadIcicle() def calcDiff(icicles, N): diff_2times = [0]*N for idx in range(N): di...
vfc_76205
{ "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 6\n4\n2\n3\n5", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n7\n2\n3\n5", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p00666 World Domination
Solve the following coding problem using the programming language python: Evil organizations that attempt to conquer the world are everywhere, regardless of age, east or west fiction, non-fiction, but what on earth did they try to conquer the world? I suddenly thought about that because I was also planning to conquer ...
```python E = 10 ** -9 MOD = 100000007 fact_result = {} while True: n = int(input()) if n == 0: break plst = [] wlst = [] diff = [] to = [None for _ in range(n)] for i in range(n): p, Id, w = input().split() to[i] = int(Id) plst.append(float(p)) wlst.append(float(w)) diff.append(1 / f...
vfc_76209
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0.200 3 0.500\n0.100 0 0.400\n0.900 1 1.000\n0.400 2 0.600\n2\n0.600 1 0.800\n0.500 0 1.000\n9\n0.200 7 0.600\n0.400 0 0.500\n0.700 8 1.000\n0.100 4 0.400\n0.200 2 0.600\n0.100 6 0.400\n0.100 5 0.400\n0.600 3 0.900\n0.500 1 0.90...
code_contests
verifiable_code
p00809 Nim
Solve the following coding problem using the programming language python: Let's play a traditional game Nim. You and I are seated across a table and we have a hundred stones on the table (we know the number of stones exactly). We play in turn and at each turn, you or I can remove one to four stones from the heap. You ...
vfc_76213
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 101 4 4\n1 100 4 4\n3 97 8 7 6 5 4 3\n0", "output": "0\n1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 101 4 4\n1 100 4 4\n3 97 8 7 6 5 0 3\n0", "output": "0\n1\n0\n", ...
code_contests
verifiable_code
p00940 Deadlock Detection
Solve the following coding problem using the programming language python: Example Input 2 2 7 3 4 3 2 1 3 1 1 2 2 1 2 2 1 1 2 2 2 1 1 Output 5 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): P, R, T = map(int, readline().split()) *L, = map(int, readline().split()) RS = [list(map(int, readline().split())) for i in range(P)] LG = [list(map(int, input().split())) for i in range(T)] prv = -1 K = [...
vfc_76217
{ "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": "2 2 7\n3 4\n3 2\n1 3\n1 1\n2 2\n1 2\n2 1\n1 2\n2 2\n1 1", "output": "5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01207 Hit and Blow
Solve the following coding problem using the programming language python: Hit and blow is a popular code-breaking game played by two people, one codemaker and one codebreaker. The objective of this game is that the codebreaker guesses correctly a secret number the codemaker makes in his or her mind. The game is playe...
vfc_76225
{ "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\n1234 3 0\n1245 3 0\n1\n1234 0 0\n2\n0123 0 4\n1230 0 4\n0", "output": "1235\n????\n0132", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1234 3 0\n1245 3 0\n0\n1234 0 0\n2\n0123 0 4\n12...
code_contests
verifiable_code
p01343 Psychic Accelerator
Solve the following coding problem using the programming language python: In the west of Tokyo, there is a city named “Academy City.” There are many schools and laboratories to develop psychics in Academy City. You are a psychic student of a school in Academy City. Your psychic ability is to give acceleration to a ce...
vfc_76229
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n0 0 2 0", "output": "2.8284271082", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01511 Three-way Branch
Solve the following coding problem using the programming language python: There is a grid that consists of W \times H cells. The upper-left-most cell is (1, 1). You are standing on the cell of (1,1) and you are going to move to cell of (W, H). You can only move to adjacent lower-left, lower or lower-right cells. Ther...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+9 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in ...
vfc_76233
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4 1\n2 1\n2 2 1\n2 2\n0 0 0", "output": "Case 1: 4\nCase 2: 0", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4 1\n2 1\n4 2 1\n2 2\n0 0 0", "output": "Case 1: 4\nCase 2: 0\n", ...
code_contests
verifiable_code
p01681 Putter
Solve the following coding problem using the programming language python: Problem Statement Fox Ciel is practicing miniature golf, a golf game played with a putter club only. For improving golf skills, she believes it is important how well she bounces the ball against walls. The field of miniature golf is in a two-d...
vfc_76237
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0\n-10 -10\n10 -10\n10 10\n-10 10\n0", "output": "8", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02247 Naive String Search
Solve the following coding problem using the programming language python: Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0. Constraints * 1 ≤ length of T ≤ 1000 * 1 ≤ length of P ≤ 1000 * The input consists of alphabetical characters and digit...
```python T = input() P = input() if len(P) > len(T): pass else: p = len(P) ans = [] for i in range(len(T)-len(P)+1): tmp = "" for j in range(i,i+p): tmp += T[j] if tmp == P: ans.append(i) for i in ans: print(i) ```
vfc_76253
{ "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": "aabaaa\naa", "output": "0\n3\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "xyzz\nyz", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
p02394 Circle in a Rectangle
Solve the following coding problem using the programming language python: Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$...
```python a,b,x,y,r=map(int, input().split()) if r<= y and y<= b-r and r <= x and x<=a-r: print("Yes") else: print("No") ```
vfc_76257
{ "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 4 2 2 1", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4 2 4 1", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
aran05
Solve the following coding problem using the programming language python: Now that we have recovered all our data, we can return to hacking in to the hacker's system. Our sources tell us that this hacker's lust for power is so great that it is reflected in everything he does, everything he creates. Perhaps this knowle...
```python #! /usr/bin/python # imports import sys import StringIO class Problem(object): def __init__(self, reader): self.reader = reader def run(self): test_case_count = int(self.reader.readline().strip()) for test_case in range(test_case_count): ...
vfc_76261
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naranya\nreverse\ngear", "output": "124\n252\n159", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
cipher
Solve the following coding problem using the programming language python: Pakistan Team is obsessed with match fixing. Their bookie Asif is writing a letter to them and wants nobody else to be able to read it. They use a simple substitution cipher to encode his message. Each letter in the message is replaced with its ...
```python def main(): from string import ascii_lowercase as al t = input() for i in xrange(t): string = raw_input().strip() d = {} ans = "" indx = 0 for _ in string: try: ans += d[_] except: d[_] = al[indx] ...
vfc_76265
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nhello\nsachin", "output": "abccd\nabcdef", "type": "stdin_stdout" } ] }