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
maximum-occurrence-9
Solve the following coding problem using the programming language python: You are given a string which comprises of lower case alphabets (a-z), upper case alphabets (A-Z), numbers, (0-9) and special characters like !,-.; etc. You are supposed to find out which character occurs the maximum number of times and the numb...
```python def occur(): inp = raw_input() x = 0 val = inp[0] for i in inp: y = inp.count(i) if y == x: if val > i: x = y val = i elif y > x: x = y val = i print str(val) + ' ' + str(x) if __name__ == "__main__": occur() ```
vfc_44485
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Pulkit is a dog!!!!!!!!!!!!\n\nSAMPLE", "output": "! 12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "A cat with rabiesgivesthe kingfor a disease.", "output": " 6\n", "type"...
code_contests
verifiable_code
ones-and-zeros-and-minus-ones
Solve the following coding problem using the programming language python: Level 3 Given an array a of size n containing only 0,-1,and 1, x = number of 1's in a[l,r] (in subarray from l to r) y = number of -1's in a[l,r] (in subarray from l to r) For any sub array [l,r] function f is defined as follows if(y == 0)...
```python t = int(raw_input()) for i in range(0, t): n = raw_input() inp = raw_input() inp = inp.split('-1') count = [] for st in inp: count.append(st.count('1')) max = 0 for j in range(0, len(count)-1): if count[j] + count[j+1] > max: max = count[j] + count[j+1] if max == 0: print '0/1' els...
vfc_44489
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n1 1\n3\n1 1 -1\n\nSAMPLE", "output": "0/1\n2/1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n1 1\n3\n1 0 -1\n\nSAMPLE", "output": "0/1\n1/1\n", "type": "stdin_std...
code_contests
verifiable_code
range-query
Solve the following coding problem using the programming language python: Since chandu_don is busy in talking to his girlfriend,he wants you to solve a problem for him requiring range queries.The problem is as follows:- Given an array of N integers we have to answer Q queries on the array. Each Query is of the forma...
```python # *-* coding: utf-8 *-* N = int(raw_input()) s = raw_input() lst = s.split() Q = int(raw_input()) """ Hash = [] for i in range(0,123): new = [] for j in range(0,12345): new.append(j) Hash.append(new) """ Hash = [[0 for i in range(12349)] for j in range(123)] for i in range(0,N): Hash[int(lst[i])][i]...
vfc_44493
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 3 1 4 2\n3\n0 4 2\n1 4 2\n0 4 7\n\nSAMPLE", "output": "2\n1\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 3 1 4 2\n2\n0 4 2\n1 4 2\n0 4 7\n\nSAMPLE", "output": "2\n1\n...
code_contests
verifiable_code
skits-patties-3
Solve the following coding problem using the programming language python: SKIT’s canteen sells Patties in packages of 6, 9 or 20 . Thus, it is possible, for example, to buy exactly 15 Patties (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 Patties, since no non- negative int...
```python def ip(n): if n<=5: return False if n>=0 and (n%6==0 or n%9==0 or n%20==0): return True else: return ip(n-6) or ip(n-9) or ip(n-20) for _ in xrange(input()): print ip(input()) ```
vfc_44497
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n45\n1\n\nSAMPLE", "output": "True\nFalse\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n45\n1", "output": "True\nFalse\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
the-wars-to-come-7
Solve the following coding problem using the programming language python: You have a part to play in the Wars to Come. As everyone knows, Lord Stannis Baratheon (First of His Name, King of the Andals and the First Men, Lord of the Seven Kingdoms and Protector of the Realm) is one true king. Now, he wants to conquer t...
```python t=int(raw_input()) a=[] a=map(int,raw_input().split()) m=int(raw_input()) a.sort() c=0 x=t-1 while c<m: c=c+a[x] x=x-1 print (t-x-1) ```
vfc_44501
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n45 34 1 34 \n90", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n45 15 1 34 \n90", "output": "3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00104 Magical Tiles
Solve the following coding problem using the programming language python: There is a magic room in a homestead. The room is paved with H × W tiles. There are five different tiles: * Tile with a east-pointing arrow * Tile with a west-pointing arrow * Tile with a south-pointing arrow * Tile with a north-pointing arrow ...
```python while True: h,w = map(int,input().split()) if (h,w) == (0,0): break l = [] for i in range(h): l.append(input()) x,y = 0,0 l1 = [] while True: if (x,y) in l1: print('LOOP') break l1.append((x,y)) pos = l[y][x] if pos == '.': print(x,y) break eli...
vfc_44549
{ "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>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v", "output": "5 7\nLOOP", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00238 Time to Study
Solve the following coding problem using the programming language python: Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes a...
```python import sys f = sys.stdin while True: t = int(f.readline()) if t == 0: break n = int(f.readline()) sf = (map(int, f.readline().split()) for _ in range(n)) rest = t - sum(f - s for s, f in sf) print('OK' if rest <= 0 else rest) ```
vfc_44553
{ "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\n3\n6 11\n12 15\n18 22\n14\n2\n6 11\n13 20\n0", "output": "OK\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n3\n6 11\n12 15\n18 22\n14\n2\n6 14\n13 20\n0", "output": "OK\nOK...
code_contests
verifiable_code
p00614 ICPC: Ideal Coin Payment and Change
Solve the following coding problem using the programming language python: Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to do smoothly when he buys something. One day, however, he doubt if this way is really efficient. When he pays more...
```python price = [1, 5, 10, 50, 100, 500] while True: values = list(map(int, input().split())) p, n = values[0], values[1:] ans = 1e100 if p == 0: break p_sum = sum(map(lambda s: s[0] * s[1], zip(price, n))) for change in range(1000): total = p + change pay = [0] * 6 ...
vfc_44561
{ "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": "123 3 0 2 0 1 1\n999 9 9 9 9 9 9\n0 0 0 0 0 0 0", "output": "6\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "123 3 0 2 0 1 1\n999 9 9 9 9 9 10\n0 0 0 0 0 0 0", "output": "6\n3\n",...
code_contests
verifiable_code
p00752 Laser Beam Reflections
Solve the following coding problem using the programming language python: A laser beam generator, a target object and some mirrors are placed on a plane. The mirrors stand upright on the plane, and both sides of the mirrors are flat and can reflect beams. To point the beam at the target, you may set the beam to severa...
vfc_44565
{ "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\n30 10 30 75\n60 30 60 95\n90 0\n0 100\n1\n20 81 90 90\n10 90\n90 10\n2\n10 0 10 58\n20 20 20 58\n0 70\n30 0\n4\n8 0 8 60\n16 16 16 48\n16 10 28 30\n16 52 28 34\n24 0\n24 64\n5\n8 0 8 60\n16 16 16 48\n16 10 28 30\n16 52 28 34\n10...
code_contests
verifiable_code
p00890 Test Case Tweaking
Solve the following coding problem using the programming language python: You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer...
```python import sys from heapq import heappush, heappop readline = sys.stdin.buffer.readline write = sys.stdout.write def solve(): N, M, C = map(int, readline().split()) if N == M == C == 0: return False G = [[] for i in range(N)] for i in range(M): f, t, c = map(int, readline().split(...
vfc_44569
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 3\n1 2 3\n2 3 3\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 3000\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 300\n9 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 9\n1 3 2\n1 4 6\n2 5 0\n2 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7...
code_contests
verifiable_code
p01022 Yu-kun Likes Building Block
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 rectangular blocks as much as programming. Yu-kun has been enthusiastic abo...
vfc_44573
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n2 2\n3 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 5\n2 4\n3 3\n4 2\n5 1", "output": "5", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
p01154 Light The Room
Solve the following coding problem using the programming language python: You are given plans of rooms of polygonal shapes. The walls of the rooms on the plans are placed parallel to either x-axis or y-axis. In addition, the walls are made of special materials so they reflect light from sources as mirrors do, but only...
vfc_44577
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 0\n2 0\n2 2\n0 2\n1 1\n6\n2 2\n2 5\n0 5\n0 0\n5 0\n5 2\n1 4\n0", "output": "0.000\n3.000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01293 Whist
Solve the following coding problem using the programming language python: Whist is a game played by four players with a standard deck of playing cards. The players seat around a table, namely, in north, east, south, and west. This game is played in a team-play basis: the players seating opposite to each other become a...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x i...
vfc_44581
{ "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": "H\n4C 8H QS 5D JD KS 8S AH 6H 7H 3S 7S 6D\nTC JC JS KD AC QC QD 2H QH 3H 3C 7C 4D\n6C 9C AS TD 5H 6S 5S KH TH AD 9S 8D 2D\n8C 5C 2S 7D KC 4S TS JH 4H 9H 2C 9D 3D\nD\n8D 9D 9S QS 4H 5H JD JS 9H 6S TH 6H QH\nQD 9C 5S 7S 7H AC 2D KD 6...
code_contests
verifiable_code
p01621 Sim Forest 2013
Solve the following coding problem using the programming language python: There is a game called Sim Forest 2013. In this game, the player can become a forest god and raise forest animals. Animals hatch from eggs and breed. When certain conditions are met, eggs are mutated with a certain probability to give birth to ...
vfc_44589
{ "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 3 All All 1 1\n2 37 5 All Night 150 1\n16 2 20 All Day 5 10\n1 14 15 Mon All 20000 100\n0 0 0 None None 0 0", "output": "1.0000000000\n0.2192439716\n0.9884707850\n0.0649933899", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p01774 Digital Clock
Solve the following coding problem using the programming language python: C: Digital Clock story Aizu Nyan has recently caught a cold. I can't get out of bed because I'm too lazy. The spicy appearance is also cute. However, Aizu Nyan, who had no choice but to spare time, came up with a way to play with the digital ...
vfc_44593
{ "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": "28\n0", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "28\n000", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "28\n000...
code_contests
verifiable_code
p02047 String Magic
Solve the following coding problem using the programming language python: String magic As a witch, you are still practicing magic today. You now have the string X, which consists of lowercase letters, at hand. The task of your training today is to change this string to another string Y. You have mastered four types ...
vfc_44601
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "typewriter\nperiodicity\n100010\n100100\n101000\n110000\nperiodicity\ntypewriter\n100010\n100100\n101000\n110000\nperiodicity\ntypewriter\n100010\n100100\n101000\n1\ndomestic\ncontest\n100010\n100100\n101000\n110000\n#", "out...
code_contests
verifiable_code
p02189 Min Element
Solve the following coding problem using the programming language python: Min Element Given the sequence a_1, a_2, .., a_N. Find the minimum number in this sequence. If the minimum value is in more than one place, answer the one with the lowest number. input N a_1 a_2 ... a_N output Output the smallest i such...
```python N = int(input()) a = [int(x) for x in input().split()] print(a.index(min(a)) + 1) ```
vfc_44605
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 1073741824, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n8 6 9 1 2 1", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n8 6 9 0 2 1", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02343 Disjoint Set: Union Find Tree
Solve the following coding problem using the programming language python: Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}. First of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively. Next, the program should read an...
```python # class UnionFind: # # def __init__(self,n): # self.roots = range(n) # # def def root(i): if par[i] == i: return i par[i]=root(par[i]) return par[i] def unite(x,y): xr = root(x) yr = root(y) par[yr] = xr def same(x,y): return root(x)==root(y) n,q = ma...
vfc_44609
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "output": "0\n0\n1\n1\n1\n0\n1\n1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02476 Remainder of Big Integers
Solve the following coding problem using the programming language python: Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the remainder in a line. Constraints * $0 \l...
```python import math n, m = map(int, input().split()) print(n % m) ```
vfc_44613
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 8", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 3", "...
code_contests
verifiable_code
cdxm1
Solve the following coding problem using the programming language python: Like most of the demanding childs.Pratik don't stop until he gets that.He keep on repeating the name of that thing again and again. For example if he want a computer,He will keep on repeating "computer" again and again. His dad has decided to an...
```python s=raw_input() t=int(input()) while t>0: a,b=map(int,raw_input().split()) if s[(a-1)%len(s)]==s[(b-1)%len(s)]: print "Yes" else: print "No" t-=1 ```
vfc_44617
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "computer\n4\n3 7\n2 10\n5 21\n11 26", "output": "No\nYes\nYes\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "computer\n4\n5 7\n2 10\n5 21\n11 26", "output": "No\nYes\nYes\nNo\n", ...
code_contests
verifiable_code
dcgame
Solve the following coding problem using the programming language python: Devu and Churu love to play games a lot. Today, they have an array A consisting of N positive integers. First they listed all N × (N+1) / 2 non-empty continuous subarrays of the array A on a piece of paper and then replaced all the subarrays on ...
```python import bisect import time import sys A = [] subarray = {} keys = [] subarray_low = {} subarray_high = {} subarray_length = 0 # (val,start,pos) stack # (start,end,pos) dict def preprocess(n): global keys global A global subarray global subarray_low global subarray_high global subarray_length for i in ...
vfc_44621
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5\n1 2 3\n> 1 D\n< 2 C\n= 3 D\n> 4 C\n< 5 D", "output": "DCDDC", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
iiti13
Solve the following coding problem using the programming language python: John Watson always knew that one of the favourite hobbies of Sherlock Holmes was to tinker with ciphers. Though Watson was not that good with ciphers, he learnt a few things being with him. Right now, Watson is in trouble! He has been locked in...
```python test = int(raw_input()) i=0 while(test > 0): n=int(raw_input()) s=list(raw_input()) a=map(int,raw_input().split()) b='' for i in xrange(0,n): t=a[i]-1 tmp=s[i] s[i]=s[t] s[t]=tmp print "".join(s) test=test-1 ```
vfc_44625
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\nabcde\n1 2 3 4 5\n6\nfluxus\n6 5 4 3 2 1\n8\nhrcksleo\n5 5 7 5 6 8 7 8", "output": "abcde\nfluxus\nsherlock", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
name1
Solve the following coding problem using the programming language python: In an attempt to reduce the growing population, Archer was asked to come up with a plan. Archer being as intelligent as he is, came up with the following plan: If N children, with names C1, C2, ..., CN, are born to parents with names A and B, an...
```python import sys from collections import Counter num = int(sys.stdin.readline().rstrip()) while num != 0: parents = sys.stdin.readline().rstrip().split() text = parents[0] + parents[1] p_count = Counter(text) num_child = int(sys.stdin.readline().rstrip()) children = '' while num_child != 0: children += sys....
vfc_44629
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ntom marvoloriddle\n2\nlord\nvoldemort\ncheap up\n1\nheapcup\nbruce wayne\n2\nbat\nman", "output": "YES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\ntom marwoloriddle\n2\n...
code_contests
verifiable_code
rrjoke
Solve the following coding problem using the programming language python: Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem: Given N points on a plane. Each point p is defined by it's two integer coordinates — px and py. The distance between points a...
```python for t in range(int(raw_input())): n = int(raw_input()) for i in range(n): raw_input() result = 0 for i in range(1, n+1): result ^= i print result ```
vfc_44633
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n1 2\n0 0\n3\n3 3\n0 0\n0 3", "output": "3\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n1 2\n1 0\n3\n3 3\n0 0\n0 3", "output": "3\n0\n", "type": "stdin_stdout"...
code_contests
verifiable_code
wolvxr
Solve the following coding problem using the programming language python: For Turbo C++ Users : Read the following document before attempting the question : Problem description Logan is tired of not being able to clear security clearances while travelling (thanks to his Adamantium skeleton :\ ). He goes to Magn...
```python #Enter your code here t=int(raw_input()) for i in xrange(t): n=int(raw_input()) if n==1: print 1 else: print 0 ```
vfc_44637
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1", ...
code_contests
verifiable_code
1020_C. Elections
Solve the following coding problem using the programming language python: As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the numbe...
```python import sys f=sys.stdin out=sys.stdout n,m=map(int,f.readline().rstrip('\r\n').split()) cos={} cost=[] nvot=[0 for i in range(m+1)] party=[[] for i in range(m+1)] for i in range(n): p,c=map(int,f.readline().rstrip('\r\n').split()) if p!=1: if c in cos: cos[c]+=1 else: cos[c]=1 cost.append(c...
vfc_44641
{ "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 2\n1 100\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n2 100\n3 200\n4 300\n5 800\n5 900\n", "output": "600\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1043_F. Make It One
Solve the following coding problem using the programming language python: Janusz is a businessman. He owns a company "Januszex", which produces games for teenagers. Last hit of Januszex was a cool one-person game "Make it one". The player is given a sequence of n integers a_i. It is allowed to select any subset of th...
vfc_44645
{ "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": "3\n2 4 6\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n30 60 21 42 70 15 30\n", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1066_D. Boxes Packing
Solve the following coding problem using the programming language python: Maksim has n objects and m boxes, each box has size exactly k. Objects are numbered from 1 to n in order from left to right, the size of the i-th object is a_i. Maksim wants to pack his objects into the boxes and he will pack objects by the fol...
```python from sys import stdin input=stdin.readline def check(a,m,mx): t=mx for i in a: if t-i>=0: t-=i else: if m-1>0: m-=1 t=mx-i else: return False return True def f(n,m,mx,a): hi=len(a) lo=0 res=0 while lo<=hi: mid=(lo+hi)//2 if check(a[mid:],m,mx): hi=mid-1 res=n-mid e...
vfc_44649
{ "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 3\n1 2 3 1 1\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1 4\n4 2 3 4 1\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1108_B. Divisors of Two Integers
Solve the following coding problem using the programming language python: Recently you have received two positive integer numbers x and y. You forgot them, but you remembered a shuffled list containing all divisors of x (including 1 and x) and all divisors of y (including 1 and y). If d is a divisor of both numbers x ...
```python t=int(input()) lis=list(map(int,input().split())) maxnum=max(lis) lis.remove(maxnum) for x in range (1,maxnum//2+1): if maxnum%x==0: lis.remove(x) maxnum2=max(lis) print("{} {}".format(maxnum,maxnum2)) ```
vfc_44657
{ "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\n10 2 8 1 2 4 1 20 4 5\n", "output": "20 8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 53 1\n", "output": "53 2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1137_D. Cooperative Game
Solve the following coding problem using the programming language python: This is an interactive problem. Misha likes to play cooperative games with incomplete information. Today he suggested ten his friends to play a cooperative game "Lake". Misha has already come up with a field for the upcoming game. The field fo...
vfc_44661
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 05 12346789\n\n3 246789 135 0\n\n3 246789 0 135\n\n3 246789 0 135\n\n2 135 0246789\n\n1 0123456789\n", "output": "next 0 1\nnext 0\nnext 0 1\nnext 0\nnext 0 1\nnext 0\nnext 0 1 2 3 4 5 6 7 8 9\ndone\n", "type": "stdin...
code_contests
verifiable_code
1178_C. Tiles
Solve the following coding problem using the programming language python: Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure be...
```python def powmod(x, k, m): res = 1 s = 1 while s <= k: if k & s: res = res * x % m x = x * x % m s <<= 1 return res m = 998244353 w, h = map(int, input().split()) print(powmod(2, w + h, m)) ```
vfc_44669
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n", "output": "64\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n...
code_contests
verifiable_code
1196_C. Robot Breakout
Solve the following coding problem using the programming language python: n robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous! Fortunately, even though your robots have escap...
```python def solve(): n = int(input()) x_d = [-100000, 100000] y_d = [-100000, 100000] robots = [] for i in range(n): robots.append([int(i) for i in input().split(' ')]) for r in robots: x, y, l, u, r, d = r # if l == 0 and r == 0: # if x_d[0] > x or x_d[1] <...
vfc_44673
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n-1 -2 0 0 0 0\n-1 -2 0 0 0 0\n3\n1 5 1 1 1 1\n2 5 0 1 0 1\n3 5 1 0 0 0\n2\n1337 1337 0 1 1 1\n1336 1337 1 1 0 1\n1\n3 5 1 1 1 1\n", "output": "1 -1 -2\n1 2 5\n0\n1 -100000 -100000\n", "type": "stdin_stdout" },...
code_contests
verifiable_code
1213_D2. Equalizing by Division (hard version)
Solve the following coding problem using the programming language python: The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move you c...
```python from sys import stdin n, k = [int(i) for i in stdin.readline().strip().split()] a = [int(i) for i in stdin.readline().strip().split()] p = [19 * [0] for _ in range(max(a) + 1)] nums = set() for m in a: for i in range(19): p[m >> i][i] += 1 nums.add(m >> i) if (m >> i) == 0: ...
vfc_44677
{ "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 3\n1 2 3 3 3\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1236_F. Alice and the Cactus
Solve the following coding problem using the programming language python: Alice recently found some cactuses growing near her house! After several months, more and more cactuses appeared and soon they blocked the road. So Alice wants to clear them. [A cactus](https://en.wikipedia.org/wiki/Cactus_graph) is a connected...
vfc_44681
{ "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": "5 6\n1 2\n2 3\n1 3\n3 4\n4 5\n3 5\n", "output": "250000002\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2\n2 3\n1 3\n", "output": "984375007\n", "type": "stdin_stdout...
code_contests
verifiable_code
1278_D. Segment Tree
Solve the following coding problem using the programming language python: As the name of the task implies, you are asked to do some work with segments and trees. Recall that a tree is a connected undirected graph such that there is exactly one simple path between every pair of its vertices. You are given n segments ...
```python import sys class segmTree(): def __init__(self, size=None, array=None): if array is not None: size = len(array) N = 1 while N < size: N <<= 1 self.N = N self.tree = [0] * (2*self.N) if array is not None: for i in range(si...
vfc_44689
{ "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 8\n3 6\n2 9\n7 10\n1 4\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1299_A. Anu Has a Function
Solve the following coding problem using the programming language python: Anu has created her own function f: f(x, y) = (x | y) - y where | denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR). For example, f(11, 6) = (11|6) - 6 = 15 - 6 = 9. It can be proved that for any nonnegative ...
```python t=1 import sys input=sys.stdin.readline while t>0: t-=1 n=int(input()) a=[int(x) for x in input().split()] d={} l=[0 for i in range(40)] for i in range(n): u=bin(a[i])[2:] #print(a[i],"0"*(40-len(u))+u) for k in range(len(u)): if u[k]=='1': l[len(u)-k-1]+=1 a.sort(reverse=True) maxi=-1 ...
vfc_44693
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n13\n", "output": "13\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1321_E. World of Darkraft: Battle for Azathoth
Solve the following coding problem using the programming language python: Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind. Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i h...
```python # quick input by @c1729 and @pajenegod import io,os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline from bisect import bisect_right from operator import itemgetter class SegmTree: ''' - increment on interval - get max on interval ''' def __init__(self, size): N = 1 ...
vfc_44697
{ "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": "2 3 3\n2 3\n4 7\n2 4\n3 2\n5 11\n1 2 4\n2 1 6\n3 4 6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4 5\n5 10\n6 2\n10 3\n9 5\n7 7\n4 3\n9 2\n3 6\n7 1 6\n8 3 2\n2 6 9\n...
code_contests
verifiable_code
1340_D. Nastya and Time Machine
Solve the following coding problem using the programming language python: Denis came to Nastya and discovered that she was not happy to see him... There is only one chance that she can become happy. Denis wants to buy all things that Nastya likes so she will certainly agree to talk to him. The map of the city where ...
```python import sys range = xrange input = raw_input from types import GeneratorType def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is Gener...
vfc_44701
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2\n2 3\n2 4\n4 5\n", "output": "13\n1 0\n2 1\n3 2\n3 1\n2 2\n4 3\n4 1\n5 2\n5 1\n4 2\n2 3\n2 0\n1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "35\n23 9\n10 34\n3 28\n21 17\n29 2\...
code_contests
verifiable_code
1403_C. Chess Rush
Solve the following coding problem using the programming language python: The mythic world of Chess Land is a rectangular grid of squares with R rows and C columns, R being greater than or equal to C. Its rows and columns are numbered from 1 to R and 1 to C, respectively. The inhabitants of Chess Land are usually me...
vfc_44713
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 8 5\nP 1 2\nR 4 8\nQ 2 3\nB 3 6\nK 5 5\n", "output": "\n0 0\n2 2\n2 5\n2 2\n7 393\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1425_E. Excitation of Atoms
Solve the following coding problem using the programming language python: Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it. There are N atoms numbered from 1 to N. These atoms are especially quirky. Initially, each atom is i...
```python n, k = map(int, input().split()) a = list(map(int, input().split())) d = list(map(int, input().split())) pref=[0] for i in range(n): pref.append(pref[-1]+a[i]) if k==0: ans=0 for i in range(1,n+1): ans=max(ans,pref[-1]-pref[i-1]-d[i-1]) print(ans) elif k == 1: best = sum(a[:n-1]) ...
vfc_44717
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 1\n5 6 7 8 10 2\n3 5 6 7 1 10\n", "output": "35\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n1 12 13 20\n10 5 4 100\n", "output": "40\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
1498_D. Bananas in a Microwave
Solve the following coding problem using the programming language python: You have a malfunctioning microwave in which you want to put some bananas. You have n time-steps before the microwave stops working completely. At each time-step, it displays a new operation. Let k be the number of bananas in the microwave curr...
```python #!/usr/bin/env python from __future__ import division, print_function import math import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip BASE = int(10**5) def main(): ...
vfc_44729
{ "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 20\n1 399999 2\n2 412345 2\n1 1000001 3\n", "output": "\n-1 -1 -1 1 -1 -1 -1 1 -1 -1 3 -1 -1 -1 3 -1 2 -1 3 -1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 20\n1 300000 2\n2 400000...
code_contests
verifiable_code
1520_C. Not Adjacent Matrix
Solve the following coding problem using the programming language python: We will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1. We will consider cells of a square matrix n × n as adjacent if they have a common side, that is, for cell (r, c) cells (r, c-1), (r, c+1), (r-1, c...
```python '''Author- Akshit Monga''' from sys import stdin, stdout input = stdin.readline t = int(input()) for _ in range(t): n=int(input()) mat=[[-1 for i in range(n)] for j in range(n)] k=1 for i in range(n): for j in range(n): mat[i][j]=k k+=2 if k>n*n: ...
vfc_44733
{ "difficulty": "9", "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\n1\n2\n3\n", "output": "\n1\n-1\n2 9 7\n4 6 3\n1 8 5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n2\n3\n", "output": "1\n-1\n1 8 6 \n7 5 3 \n4 2 9 \n", "type": "stdi...
code_contests
verifiable_code
154_A. Hometask
Solve the following coding problem using the programming language python: Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin...
```python ans = 0 t = [] x = input() y = int(input()) for i in range(y): z = input() t.append(z) #x = codeforces #y = 2 #t = [do, cs] pt = -1 ln = len(x) for i in t: a = i[0] b = i[1] pt = 0 for j in range(ln): ded1=0 ded2=0 if j >= pt: if x[j] in [a,b]: ...
vfc_44737
{ "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": "ababa\n1\nab\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
175_E. Power Defence
Solve the following coding problem using the programming language python: Vasya plays the Power Defence. He must pass the last level of the game. In order to do this he must kill the Main Villain, who moves in a straight line at speed 1 meter per second from the point ( - ∞, 0) to the point ( + ∞, 0) of the game wor...
vfc_44741
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 0 0\n10 10 10\n100 100\n", "output": "1989.97487421\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 0 1\n10 10 10\n100 100\n", "output": "3979.94974843\n", "type": "stdin_s...
code_contests
verifiable_code
196_A. Lexicographically Maximum Subsequence
Solve the following coding problem using the programming language python: You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2... s|s...
```python s = input() n = len(s) temp = list(set(s)) x = {} temp = sorted(temp,reverse=True) i = 0 while(i < n ): x[s[i]] = i i +=1 string = "" i = 0 j = 0 while(i< n and j < len(temp)): if i <= x[temp[j]]: if s[i]== temp[j]: string += temp[j] if i== x[temp[j]]: j += 1 ...
vfc_44745
{ "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": "ababba\n", "output": "bbba\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abbcbccacbbcbaaba\n", "output": "cccccbba\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
21_A. Jabber ID
Solve the following coding problem using the programming language python: Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where * <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is b...
```python s = input() if s.count('@') != 1 or s.count('/') > 1: print('NO') exit() p1 = s.find('@') p2 = s.find('/') if p2 == -1: p2 = len(s) import re u = re.compile('(\w){1,16}$') h = re.compile('(\w{1,16}\.)*\w{1,16}$') k1 = h.match(s[p1 + 1 : p2]) k2 = u.match(s[0:p1]) k3 = u.match(s[p2 + 1 : len(s)]) if le...
vfc_44749
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "mike@codeforces.com\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "john.smith@codeforces.ru/contest.icpc/12\n", "output": "NO\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
243_C. Colorado Potato Beetle
Solve the following coding problem using the programming language python: Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up one square meter. Old McDonald knows that the Colorado potato beetle is about to i...
vfc_44753
{ "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\nR 10\nD 2\nL 7\nU 9\nD 2\nR 3\nD 10\n", "output": " 52\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
269_A. Magical Boxes
Solve the following coding problem using the programming language python: Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes. From the top view each magical box looks like a square with side length equa...
```python from math import * n = int(input()) mx = 0 for i in range(n): k, a = map(int, input().split()) mx = max(mx, 2*k + log2(a)) mx = max(mx, 2*(k+1)) print(int(ceil(mx/2))) ```
vfc_44757
{ "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\n0 3\n1 5\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n0 4\n", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
291_C. Network Mask
Solve the following coding problem using the programming language python: The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively. Polycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, rep...
```python def f(t): a, b, c, d = map(int, t.split('.')) return d + (c << 8) + (b << 16) + (a << 24) def g(x): p = [0] * 4 for i in range(4): p[3 - i] = str(x % 256) x //= 256 return '.'.join(p) n, k = map(int, input().split()) t = [f(input()) for i in range(n)] p = [0] * n x = 1 <<...
vfc_44761
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n0.0.0.1\n0.1.1.2\n0.0.2.1\n0.1.1.0\n0.0.2.3\n", "output": "255.255.254.0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n255.0.0.1\n0.0.0.2\n", "output": "-1\n", "typ...
code_contests
verifiable_code
316_D3. PE Lesson
Solve the following coding problem using the programming language python: Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is thro...
```python m = 1000000007 n = int(input()) a = map(int, input().split()) t1, t2 = 0, 0 for i in a: if i == 1: t1 += 1 else: t2 += 1 a = [1, 2] for i in range(3, t1+1): a = a[::-1] a[1] = (a[0]+(i-1)*a[1])%m if not t1 or t1 == 1: a[1] = 1 for i in range(t1+1, n+1): a[1] = a[1]*i%m print(a[1]) ```
vfc_44765
{ "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": "8\n1 2 2 1 2 1 1 2\n", "output": "16800\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 2 1 2\n", "output": "120\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
33_A. What is for dinner?
Solve the following coding problem using the programming language python: In one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several rows of teeth, and feeds on crucians. One of Valerie's distinguishing features is that while eating one crucian ...
```python n, m, k = list(map(int,input().split())) tooth = [[0,True]] * n for i in range(n): r, c = list(map(int,input().split())) if tooth[r-1][0] > c or tooth[r-1][1] == True: tooth[r-1] = [c,False] ad = 0 for i in tooth: ad += i[0] print(min(ad,k)) ```
vfc_44769
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 13\n1 13\n2 12\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 18\n2 3\n1 2\n3 6\n2 3\n", "output": "11\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
362_C. Insertion Sort
Solve the following coding problem using the programming language python: Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that implements this algorithm ...
```python arr = [0 for i in range(5001)] def insertion_sort(n, a): def modify(t): while t > 0: arr[t] += 1 t -= t & (-t) def query(t): res = 0 while t < 5001: res += arr[t] t += t & (-t) return res s = 0 ans = 0 way ...
vfc_44773
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 0\n", "output": "3 4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
386_A. Second-Price Auction
Solve the following coding problem using the programming language python: In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs th...
```python a=int(input()) a=list(map(int,input().split())) ind=a.index(max(a)) a.sort() print(str(ind+1)+' '+str(a[-2])) ```
vfc_44777
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n3 8 2 9 4 14\n", "output": "6 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 7\n", "output": "2 5\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
406_E. Hamming Triples
Solve the following coding problem using the programming language python: Little Chris is having a nightmare. Even in dreams all he thinks about is math. Chris dreams about m binary strings of length n, indexed with numbers from 1 to m. The most horrifying part is that the bits of each string are ordered in either as...
vfc_44781
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 4\n1 5\n0 5\n0 5\n1 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n0 3\n0 5\n1 4\n1 5\n", "output": "3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
434_A. Ryouko's Memory Note
Solve the following coding problem using the programming language python: Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and ...
```python def median(a): if len(a) == 0: return 0 if len(a) % 2 == 1: return a[len(a) // 2] else: return (a[len(a) // 2] + a[(len(a) // 2) - 1]) // 2 def profit(a, old_val): a.sort() med = median(a) sum_old = 0 sum_new = 0 for i in a: sum_old += abs(i - ...
vfc_44785
{ "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 6\n1 2 3 4 3 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 5\n9 4 3 8 8\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
456_C. Boredom
Solve the following coding problem using the programming language python: Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it. Given a sequence a consisting of n integers. The player can make several steps. In a si...
```python #!/usr/bin/env python3 # -*- coding: utf-8 -*- s=0 n = int(input()) dp=[0]*(10**5+1) sec = [int(x) for x in input().split()] ls = [0]*(10**5+1) for x in sec: ls[x]+=1 dp[1]=ls[1] for i in range(2,10**5+1): dp[i]=max(dp[i-1],dp[i-2]+ls[i]*i) print(dp[10**5]) ```
vfc_44789
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\n1 2 1 3 2 2 2 2 3\n", "output": "10\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
479_A. Expression
Solve the following coding problem using the programming language python: Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and...
```python a1 = int(input()) a2 = int(input()) a3 = int(input()) listValue = [a1*a2*a3, a1*(a2+a3), a1*a2+a3, a1+a2*a3, (a1+a2)*a3, a1+a2+a3] maxValue = listValue[0] for x in listValue: if x > maxValue: maxValue = x print(maxValue) ```
vfc_44793
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10\n3\n", "output": "60\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2\n3\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
501_A. Contest
Solve the following coding problem using the programming language python: Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that cost...
```python a,b,c,d=map(int,input().split()) x=max((3*a//10),(a-(a//250*c))) y=max((3*b//10),(b-((b//250)*d))) # print(x,y) if y>x: print('Vasya') elif x>y: print('Misha') else: print('Tie') ```
vfc_44797
{ "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": "1000 1000 1 1\n", "output": "Tie", "type": "stdin_stdout" }, { "fn_name": null, "input": "1500 1000 176 177\n", "output": "Misha", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
526_F. Pudding Monsters
Solve the following coding problem using the programming language python: In this problem you will meet the simplified model of game Pudding Monsters. An important process in developing any game is creating levels. A game field in Pudding Monsters is an n × n rectangular grid, n of its cells contain monsters and some...
vfc_44801
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 1\n4 3\n3 2\n2 4\n5 5\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "23\n1 9\n2 17\n3 18\n4 8\n5 19\n6 5\n7 6\n8 20\n9 15\n10 21\n11 2\n12 16\n13 11\n14 22\n15 7\n1...
code_contests
verifiable_code
579_B. Finding Team Member
Solve the following coding problem using the programming language python: There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the value...
```python def main(): mode="filee" if mode=="file":f=open("test.txt","r") if mode=="file":n=int(f.readline()) else:n=int(input()) w=[] for i in range(2,2*n+1): if mode=="file":g=[int(x) for x in f.readline().split()] else:g=[int(x) for x in input().split()] for j in rang...
vfc_44809
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6\n1 2\n3 4 5\n", "output": "2 1 4 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 ...
code_contests
verifiable_code
600_A. Extract Numbers
Solve the following coding problem using the programming language python: You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for ex...
```python def main(): str = input().replace(';', ',') input_list = str.split(',') def pred(x): return x.isdigit() and (x[0] != '0' or len(x) == 1) lA = list(filter(pred, input_list)) lB = list(filter(lambda x: not pred(x), input_list)) print('"{}"'.format(','.join(lA))) if lA else print...
vfc_44813
{ "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": "1;;01,a0,\n", "output": "\"1\"\n\",01,a0,\"\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "a\n", "output": "-\n\"a\"\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
622_D. Optimal Number Permutation
Solve the following coding problem using the programming language python: You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let number i be in positions xi, yi (xi < yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the pos...
```python n = int(input()) A = [i for i in range(1, n+1, 2)] B = [i for i in range(n-2 if n%2 else n-1, 0, -2)] C = [i for i in range(2, n+1, 2)] D = [i for i in range(n-1 if n%2 else n-2, 0, -2)] ans = ' '.join(map(str, A+B+C+D+[n])) print(ans) ```
vfc_44817
{ "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": "1\n", "output": "1 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "1 1 2 2 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n"...
code_contests
verifiable_code
643_G. Choosing Ads
Solve the following coding problem using the programming language python: One social network developer recently suggested a new algorithm of choosing ads for users. There are n slots which advertisers can buy. It is possible to buy a segment of consecutive slots at once. The more slots you own, the bigger are the cha...
vfc_44821
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 9 33\n1 2 1 3 3\n2 1 5\n2 1 5\n2 1 3\n2 3 3\n1 2 4 5\n2 1 5\n2 3 5\n1 4 5 1\n2 1 5\n", "output": "3 1 2 3 \n3 1 2 3 \n2 1 2 \n1 1 \n3 1 5 3 \n2 5 3 \n2 1 5 \n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
670_F. Restore a Number
Solve the following coding problem using the programming language python: Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n. Magically, all the numbers were shuffled in arbitrary order while this note was...
```python a = input() b = input() d = [0] * 10 n = 0 for j in range(1000100): t = str(j) if len(t) + j == len(a): n = j for x in str(n): d[ord(x) - ord('0')] -= 1 for x in a: d[ord(x) - ord('0')] += 1 for x in b: d[ord(x) - ord('0')] -= 1 if sum(d)==0: print(b) else: A = [] B = [...
vfc_44825
{ "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": "199966633300\n63\n", "output": "3036366999", "type": "stdin_stdout" }, { "fn_name": null, "input": "003512\n021\n", "output": "30021", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
696_C. PLEASE
Solve the following coding problem using the programming language python: As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under ...
```python k = int(input()) n = list(map(int, input().split())) for i in range(k): n[i] = bin(n[i]) n[i] = n[i][2:] magic = 1000000007 def par(s): if s[-1] == '0': return True else: return False def mod_pow(x, s, p): ans = 1 for i in range(len(s)): if s[i] == '1': ...
vfc_44829
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n", "output": "1/2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 1\n", "output": "0/1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
717_D. Dexterina’s Lab
Solve the following coding problem using the programming language python: Dexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes in a peaceful and nonviolent way. After god knows how many different...
```python import sys #sys.stdin=open("data.txt") input=sys.stdin.readline n,x=map(int,input().split()) def mult(a,b): # compute a*b c=[0]*128 for i in range(128): for j in range(128): c[i^j]+=a[i]*b[j] return c def quickpow(a,b): # compute a**b if b==1: return a ...
vfc_44833
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n0.500000 0.250000 0.250000\n", "output": "0.62500000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 9\n0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100...
code_contests
verifiable_code
784_G. BF Calculator
Solve the following coding problem using the programming language python: In this problem you will write a simple generator of Brainfuck (<https://en.wikipedia.org/wiki/Brainfuck>) calculators. You are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Out...
```python for n in str(eval(input())): for _ in range(ord(n)): print('+',sep='',end='') print('.>') ```
vfc_44845
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2+3\n", "output": "+++++++++++++++++++++++++++++++++++++++++++++++++++++.>\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9-7\n", "output": "++++++++++++++++++++++++++++++++++++++++...
code_contests
verifiable_code
831_A. Unimodal Array
Solve the following coding problem using the programming language python: Array of integers is unimodal, if: * it is strictly increasing in the beginning; * after that it is constant; * after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is ...
```python n=int(input()) arr=list(map(int,input().split())) s,t,p=0,0,0 for i in range(1,n) : if arr[i] < arr[i - 1]: s = 1 elif arr[i]==arr[i-1] and s: t=1 elif arr[i]==arr[i-1] and not s: p=1 if arr[i]>arr[i-1] and (s or p):t=1 if t: print("NO") else : print("YES") ```
vfc_44853
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n3 3 3 3 3 3 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 5 5 5 4 2\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
852_B. Neural Network country
Solve the following coding problem using the programming language python: Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with many layers, each layer possibly having many cities. They also have one entry, and one ex...
```python from sys import stdin input = stdin.readline def main(): mod = 10**9 + 7 n,l,m = map(int,input().split()) ar = [0 for i in range(m)] ar3 = [0 for i in range(m)] def f(num): return int(num) % m def f2(num): return num % 1000000007 ai1 = list(map(f,input().spli...
vfc_44857
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3 13\n4 6\n2 1\n3 4\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4 3\n2 1 0 1 2\n0 1 2 1 0\n1 2 1 0 2\n", "output": "209\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
876_C. Classroom Watch
Solve the following coding problem using the programming language python: Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answe...
```python import sys text = sys.stdin.read().strip() n = int(text) q = lambda x: sum([int(b) for b in str(x)]) e = [] for i in range(max(0, n-81), n): if i + q(i) == n: e.append(i) print(len(e)) for z in e: print(z) ```
vfc_44861
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "21\n", "output": "1\n15 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n",...
code_contests
verifiable_code
8_C. Looking for Order
Solve the following coding problem using the programming language python: Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag were thrown about the room. Of course, she w...
```python import sys def main(): BITS = [1 << sh for sh in range(24)] B2N = {v: u for u, v in enumerate(BITS)} def getPt(): return tuple(map(int, input().split())) def dist(ptA, ptB): return sum(((u - v) ** 2 for u, v in zip(ptA, ptB))) def getBits(val): return tuple(fil...
vfc_44865
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n2\n1 1\n-1 1\n", "output": "8\n0 1 2 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n3\n4 3\n3 4\n0 0\n", "output": "32\n0 1 2 0 3 0\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
922_B. Magic Forest
Solve the following coding problem using the programming language python: Imp is in a magic forest, where xorangles grow (wut?) <image> A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count th...
```python import math n = int(input()) ans = 0 for a in range(1, n+1): for b in range(a, n+1): c= a^b if c < b or c > n: continue if a+b > c: ans += 1 print(ans) ```
vfc_44869
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1051\n", ...
code_contests
verifiable_code
94_C. Frames
Solve the following coding problem using the programming language python: Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbi...
```python import math n,m,a,b=map(int,input().split()) if (a-1)//m==(b-1)//m: print(1) elif (a-1)%m==0 and b%m==0: print(1) elif (a-1)%m==0 and b==n or m==1: print(1) elif (a-1)%m==0 or b%m==0 or b==n: print(2) elif abs((a-1)//m - (b-1)//m)==1 or m==2: print(2) elif (a-1)%m==b%m: print(2) else:...
vfc_44873
{ "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": "20 5 2 20\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11 4 3 9\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
978_A. Remove Duplicates
Solve the following coding problem using the programming language python: Petya has an array a consisting of n integers. He wants to remove duplicate (equal) elements. Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should n...
```python n = int(input()) A = list(map(int, input().split())) from collections import Counter C = Counter(A) res = [] for a in A: C[a] -= 1 if C[a] == 0: res.append(a) print(len(res)) print(*res) ```
vfc_44877
{ "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\n6 6 6 6 6\n", "output": "1\n6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 5 5 1 6 1\n", "output": "3\n5 6 1\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
bear-and-chocolate
Solve the following coding problem using the programming language python: View Russian Translation Limak is a little polar bear. Today he found something delicious in the snow. It's a square bar of chocolate with N x N pieces. Some pieces are special because there are cherries on them. You might be surprised by cherr...
```python for _ in xrange(input()): size = input() hor, vert =[0]*size, [0]*size choco = 0 for j in xrange(size): val = raw_input() for chk in xrange(len(val)): if val[chk] == '#': hor[chk] +=1 vert[j] += 1 choco += 1 flag = False present_sum = 0 for a in xrange(size): present_sum += hor[...
vfc_44885
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n###\n##.\n###\n4\n####\n.##.\n.#..\n#...\n\nSAMPLE", "output": "NO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n###\n##.\n$##\n4\n####\n.##.\n.#..\n#...\n\nSAMPLE", ...
code_contests
verifiable_code
code-gjd
Solve the following coding problem using the programming language python: Little Pandey and GJ are coding buddies - since they are the part of ACM ICPC team together. But, GJ is fed up of Pandey's weird coding habits - like using editors which are slow, and irritating. Importantly, GJ believes that Pandey over-complic...
```python t=input() for i in range(t): n=input() time=0 arr=map(int,raw_input().split()) arr.sort() while(len(arr)!=1): a1=arr.pop() a2=arr.pop() sumn=a1+a2 time+=sumn arr.append(sumn) print time ```
vfc_44889
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n4 2 1 3\n5\n2 3 9 8 4\n\nSAMPLE", "output": "26\n88\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
extraordinarily-large-1
Solve the following coding problem using the programming language python: You need to handle two extraordinarily large integers. The good news is that you don't need to perform any arithmetic operation on them. You just need to compare them and see whether they are equal or one is greater than the other. Given two st...
```python import math,string,re class ExtraordinarilyLarge: def compare(self, x, y): if x.startswith("0!"): x = "1" + x[2:] if y.startswith("0!"): y = "1" + y[2:] nx = re.findall(r"\d+", x)[0] ny = re.findall(r"\d+", y)[0] xf = len(x) - len(nx) yf = len(y) - len(ny) nx = int(nx) ny = int(ny) wh...
vfc_44893
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "27\n0!!!\n0\n1\n1!!!\n2!!!\n2\n3!!!\n999999999\n0!\n0\n11!\n40000000\n3!!\n721\n3\n2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n7!!!\n3!!!!\n0!\n2\n1\n2\n0\n0\n3!!!!\n4!!!!\n15!\n999999999\n999999999\n4!!\n7!!!\n5000!!\n40321\n8!\...
code_contests
verifiable_code
hit-me-baby-one-more-time
Solve the following coding problem using the programming language python: The Enigma crew came to know some of the location where the bombs are planted. So they started to find the code through which they can diffuse the bombs .Each bomb has different code for diffusion. The crew found the solution the diffusion code ...
```python def ap(n): return (n*(n+1)/2) x=int(raw_input()) print(ap((x-1)/3)*3+ap((x-1)/5)*5-ap((x-1)/15)*15) ```
vfc_44897
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n\nSAMPLE", "output": "23\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "884423119", "output": "182514325474105428\n", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
magical-number-a-3
Solve the following coding problem using the programming language python: Programmer Deepak has created a program which calculates magical number as 2^n * 3^n * 5^n where "n" is an integer. Now he wants to find the magical number which is just greater than the input. Help him in finding it. NOTE : a^b denotes a rai...
```python print 900 ```
vfc_44901
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "456", "output": "900\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
shikhars-fibonacci-a-4
Solve the following coding problem using the programming language python: Mathematician Shikhar has invented a new type of fibonacci series in which fib(1)=a fib(2)=b fib(n)=(fib(n-1)+fib(n-2))%1000000007 for all n>2 and now help him find the nth term of this series. Input contains 3 space separated integers a...
```python print 29860704 ```
vfc_44913
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4 35", "output": "29860704\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 36", "output": "29860704\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
the-football-fest-6
Solve the following coding problem using the programming language python: The very famous football club Manchester United decided to popularize football in India by organizing a football fest. The fest had many events for different sections of people. For the awesome coders of Hacker Earth, there was an event called P...
```python t = int(raw_input()) for i in range(t): n , p1 = map(int , raw_input().split()) p = [] p.append(p1) for i in range(n): s = raw_input().split() if s[0] == 'P': p.append(int(s[1])) else: k = p[-1] p.pop() l = p[-1] p.append(k) p.append(l) print "Player" , p[-1] ```
vfc_44917
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10 23\nP 86\nP 63\nP 60\nB\nP 47\nB\nP 99\nP 9\nB\nB\n\nSAMPLE", "output": "Player 9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n10 23\nP 42\nP 63\nP 60\nB\nP 47\nB\nP 99\nP 9\nB...
code_contests
verifiable_code
xsquare-and-interesting-sequences
Solve the following coding problem using the programming language python: Xsquare get bored playing with the arrays all the time. So,he decided to buy a new character set to play with. Xsquare's character set contains only lower case alphabets more specifically characters from 'a' to 'z' (both inclusive). Xsquare was ...
```python t=input() for i in range(t): n=input() if n%2==0:n=n/2 else: n=n/2+1 prac=1 while n>0: i=2 prod=26 while i<n: prod=(prod*prod)%1000000009 i=i*2 prac=(prod*prac)%1000000009 i=i/2 n=n-i print prac ```
vfc_44921
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n2\n15\n6\n5\n12\n1\n7\n9\n17\n2", "output": "26\n827062704\n17576\n17576\n308915776\n26\n456976\n11881376\n503630115\n26\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n72713\n116...
code_contests
verifiable_code
p00211 Jogging
Solve the following coding problem using the programming language python: At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do ...
```python from fractions import gcd from functools import reduce from sys import stdin def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) while(True): n = int(stdin.readline()) if not n...
vfc_44969
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3\n5 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0", "output": "15\n16\n1598397732\n1209243492\n1939462992\n1782294192\n1360317793\n1\n1", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
p00588 Extraordinary Girl I
Solve the following coding problem using the programming language python: She is an extraordinary girl. She works for a library. Since she is young and cute, she is forced to do a lot of laborious jobs. The most annoying job for her is to put returned books into shelves, carrying them by a cart. The cart is large enou...
```python # AOJ 1002: Extraordinary Girl I # Python3 2018.7.5 bal4u import sys from sys import stdin input = stdin.readline INF = 0x7fffffff cost = ((((0,3),(1,3)),((1,2),(1,2)),((2,2),(2,2))), (((1,2),(1,2)),((0,1),(1,2)),((1,1),(2,2))), (((2,2),(2,2)),((1,1),(2,2)),((0,1),(3,3)))) for cno in range(int(in...
vfc_44977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\nYNNNNYYY\n4\nNYNNYYNNNYNYYNNN", "output": "6\n9", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\nYNNNNYYY\n2\nNYNNYYNNNYNYYNNN", "output": "6\n6\n", "type": "stdin_std...
code_contests
verifiable_code
p00865 Expected Allowance
Solve the following coding problem using the programming language python: Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n pieces of m-sided dice and declares the cutback k. Hid...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split...
vfc_44985
{ "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 6 0\n2 6 3\n3 10 9\n13 3 27\n1 2008 3\n0 0 0", "output": "7.00000000\n4.11111111\n7.71000000\n1.42902599\n1001.50298805", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 6 0\n2 6 3\n3 10 3...
code_contests
verifiable_code
p01128 Railroad Conflict
Solve the following coding problem using the programming language python: Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other. In this metrop...
```python m = int(input()) while m: m -= 1 ax, ay, bx, by = map(int, input().split()) n = int(input()) dx, dy = bx - ax, by - ay intersections = set() while n: n -= 1 sx, sy, tx, ty, o, l = map(int, input().split()) tdx, tdy = tx - sx, ty - sy asx, asy = sx - ax, ...
vfc_44993
{ "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\n-10 1 10 1\n4\n-6 2 -2 -2 0 1\n-6 -2 -2 2 1 0\n6 2 2 -2 0 0\n6 -2 2 2 1 1\n8 12 -7 -3\n8\n4 -5 4 -2 1 1\n4 -2 4 9 1 0\n6 9 6 14 1 1\n-7 6 7 6 0 0\n1 0 1 10 0 0\n-5 0 -5 10 0 1\n-7 0 7 0 0 1\n-1 0 -1 -5 0 1", "output": "1\n...
code_contests
verifiable_code
p01437 Infinity Maze
Solve the following coding problem using the programming language python: Dr. Fukuoka has placed a simple robot in a two-dimensional maze. It moves within the maze and never goes out of the maze as there is no exit. The maze is made up of H × W grid cells as depicted below. The upper side of the maze faces north. Con...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-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_45001
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 10\nE..\n.#.\n...\n5 5 19\n####.\n.....\n.#S#.\n...#.\n#.##.\n5 5 6\n#.#..\n#....\n##.#.\n#..S.\n#....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0", "output": "1 3 E\n4 5 S\n4 4 E\n1 1 N", "type": "stdin_stdout" ...
code_contests
verifiable_code
p01584 Divide the Water
Solve the following coding problem using the programming language python: A scientist Arthur C. McDonell is conducting a very complex chemical experiment. This experiment requires a large number of very simple operations to pour water into every column of the vessel at the predetermined ratio. Tired of boring manual w...
vfc_45005
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "", "output": "", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01743 Clique Coloring
Solve the following coding problem using the programming language python: There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices w...
```python N = int(input()) A = [int(input()) for i in range(N)] INF = 10**18 N2 = 2**N def dfs(i, D): if i == N: return sum(D) b = 1 << i a = A[i] def sel(j, state, u): if j == N2: D2 = D[:] for e in u: D2[e] -= 1 D2[e | b] += 1 ...
vfc_45009
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2\n3\n4\n5\n6", "output": "12", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n3", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
p01883 Parentheses
Solve the following coding problem using the programming language python: Example Input 1 Output )( 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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-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_45013
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": ")(", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p02020 Tea Party
Solve the following coding problem using the programming language python: F: Tea Party Yun decided to hold a tea party at the company. The shop sells $ N $ sets of bread, each containing $ A_1, A_2, A_3, \ dots, A_N $. Yun decided to make a sandwich by combining two breads into a pair. Yun-san is very careful, so ...
```python N = int(input()) A = list(map(int, input().split())) oc = 0 mi = 1e9 for a in A: if a % 2: oc += 1 mi = min(mi, a) print((sum(A) - [0, mi][oc % 2]) // 2) ```
vfc_45017
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 3 5 6 7", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4 3 5 6 7", "output": "11\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
p02303 Closest Pair
Solve the following coding problem using the programming language python: For given n points in metric space, find the distance of the closest points. Constraints * 2 ≤ n ≤ 100,000 * -100 ≤ x, y ≤ 100 Input n x0 y0 x1 y1 : xn-1 yn-1 The first integer n is the number of points. In the following n lines, the coo...
```python import sys from operator import itemgetter from itertools import permutations from math import sqrt def solve(a: list): length = len(a) if length <= 3: return min(sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in permutations(a, 2)) x_set_len = len(set(x for (x, _) in a)) axis = ...
vfc_45025
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0.0 0.0\n2.0 0.0\n1.0 1.0", "output": "1.41421356237", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
anuund
Solve the following coding problem using the programming language python: Problem description You will be given a zero-indexed array A. You need to rearrange its elements in such a way that the following conditions are satisfied: A[i] ≤ A[i+1] if i is even. A[i] ≥ A[i+1] if i is odd. In other words the following ine...
```python import math t=input() while t>0: n=input() a=[] for x in raw_input().split(): a.append(int(x)) a.sort() n=int(math.ceil(n/2.0)) res=a[n:] a=a[:n] count=1 for x in res: a.insert(count,x) count+=2 for x in a: print x, print '' t-=1 ...
vfc_45033
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n3 2\n3\n10 5 2", "output": "2 3 \n2 10 5 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\n3 2\n3\n9 5 2", "output": "2 3\n2 9 5\n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
chrl3
Solve the following coding problem using the programming language python: Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. Input Th...
```python def index(lis,l,r,k): while(r-l>1): m=l+(r-l)/2; if(lis[m]>=k): r=m else: l=m return r def count(lis,n): t=[] len1=1 t+=[lis[0]] i=1 while i<n: if(lis[i]<t[0]): t[0]=lis[i] elif(lis[i]>t[len1-1]): ...
vfc_45037
{ "difficulty": "3", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 \n1 2 3", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n4 1 2 3", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
etmx04
Solve the following coding problem using the programming language python: Least Distance Mr. John has a habit of implementing new programming methods. This time he needs your help to solve a problem. He needs a method such that it accepts a series of numbers (all in single digits) and returns a typical answer. The ans...
```python import sys L = map(int,sys.stdin.readline().split()) min = 10 for i in range(len(L)) : if i == 0 : continue else : dif = abs(L[i]-L[i-1]) if min > dif : min = dif print min ```
vfc_45041
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 7 4 9 7 2", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
kttable
Solve the following coding problem using the programming language python: There are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with a timetable for kitchen's usage in order to avoid the conflicts: The first stud...
```python import sys n = int(raw_input().strip()) for i in xrange(n) : len_a = int(raw_input().strip()) a = map(int,raw_input().strip().split(' ')) b = map(int,raw_input().strip().split(' ')) counter = 0 for i in range(0,len_a) : if i == 0 : if a[i] >= b[i] : coun...
vfc_45045
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 10 15\n1 10 3\n3\n10 20 30\n15 5 20", "output": "2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1 10 15\n1 10 3\n3\n19 20 30\n15 5 20", "output": "2\n1\n", ...
code_contests
verifiable_code
pchips
Solve the following coding problem using the programming language python: Rohit loves to play poker. He has N piles of poker chips in a line. Number of chips in pile i is Ai. He wants to rearrange them such that Ai+1 = Ai + 1 for 1 ≤ i ≤ N-1 . The final piles can contain 0 chips as well. To achieve this,he can take ...
```python for x in range(0,input()): k,q = input(),map(int,raw_input().split()) n = (2*sum(q) -k*k -k)/(2.0*k)+1 if(n == int(n)): print sum(([abs(a - b) for a, b in zip(q, range( int(n), int(n)+k))]))/2 else: print - 1 ```
vfc_45049
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n2 3 4 5 1\n3\n10 10 10\n4\n3 3 3 3", "output": "4\n1\n-1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
stacks
Solve the following coding problem using the programming language python: As every other little boy, Mike has a favorite toy to play with. Mike's favorite toy is a set of N disks. The boy likes to compose his disks in stacks, but there's one very important rule: the disks in a single stack must be ordered by their rad...
```python def bs(k,start,end,search): mid =(start+end)/2 if(start>end): k[start] = search return 0 if(start == end): if(k[start] >search): k[start] = search else: k[start+1] = search return 0 else: if(search<k[mid]): ...
vfc_45053
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n14 5 13 19 17 10 18 12", "output": "3 1 1 2\n5 2 2 4 7 10\n4 5 10 12 18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n6\n3 4 5 1 1 2\n...
code_contests
verifiable_code
1030_D. Vasya and Triangle
Solve the following coding problem using the programming language python: Vasya has got three integers n, m and k. He'd like to find three integer points (x_1, y_1), (x_2, y_2), (x_3, y_3), such that 0 ≤ x_1, x_2, x_3 ≤ n, 0 ≤ y_1, y_2, y_3 ≤ m and the area of the triangle formed by these points is equal to nm/k. Hel...
```python # import math n, m, k = [int(x) for x in input().split()] a = n b = k if (2 * n * m) % k != 0: print("no") else: c = a % b while (c != 0): a = b b = c c = a % b # print(b) # b is GCD if b == 1: x = n y = 2 * m // k else: if b != k: x = n // b y = 2 * m // (k // b) else: x = 2 * ...
vfc_45061
{ "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": "4 4 7\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 3\n", "output": "YES\n0 0\n4 0\n0 2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1053_B. Vasya and Good Sequences
Solve the following coding problem using the programming language python: Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 ...
```python import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self...
vfc_45065
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n6 7 14\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 1 16\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input"...