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
487_B. Strip
Solve the following coding problem using the programming language python: Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right. Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy: * Each piece should contain at least l numbers....
```python def split(a,n,s,l): pieces = [] i = 1 tmpmin = a[0] tmpmax = a[0] tmppc = [a[0]] while i<n: if abs(a[i]-tmpmin)<=s and abs(a[i]-tmpmax)<=s: tmppc.append(a[i]) if a[i]<tmpmin: tmpmin=a[i] elif a[i]>tmpmax: tmpmax = a[i] else: ...
vfc_43961
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2 2\n1 100 1 100 1 100 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 2 2\n1 3 1 2 4 1 2\n", "output": "3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
510_A. Fox And Snake
Solve the following coding problem using the programming language python: Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead. A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c)...
```python n,m=map(int,input().split()) s="."*(m-1)+"#" #print(s) for i in range(n): if i%2==0:print("#"*m) else: print(s) s=s[::-1] ```
vfc_43965
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 9\n", "output": "#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#########\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n", "output":...
code_contests
verifiable_code
535_B. Tavas and SaDDas
Solve the following coding problem using the programming language python: Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you sol...
```python a = input().replace("4",'0').replace("7",'1') sumA = 0 for x in range(len(a)) : sumA += 2**x print((int(a,2)+sumA)) ```
vfc_43969
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "77\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", "o...
code_contests
verifiable_code
55_C. Pie or die
Solve the following coding problem using the programming language python: Volodya and Vlad play the following game. There are k pies at the cells of n × m board. Each turn Volodya moves one pie to the neighbouring (by side) cell. If the pie lies at the border of the board then Volodya can move it outside the board, ge...
```python n, m, k = [int(x) for x in input().split()] canwin = False for i in range(k): x, y = [int(x) for x in input().split()] canwin |= x < 6 or n - x < 5 canwin |= y < 6 or m - y < 5 print("YES" if canwin else "NO") ```
vfc_43973
{ "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": "100 50 2\n50 25\n50 25\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 0\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
585_F. Digits of Number Pi
Solve the following coding problem using the programming language python: Vasily has recently learned about the amazing properties of number π. In one of the articles it has been hypothesized that, whatever the sequence of numbers we have, in some position, this sequence is found among the digits of number π. Thus, if...
vfc_43977
{ "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": "31415926535\n10\n29\n", "output": "20", "type": "stdin_stdout" }, { "fn_name": null, "input": "023456789\n10\n19\n", "output": "9", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
608_A. Saitama Destroys Hotel
Solve the following coding problem using the programming language python: Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacit...
```python I=lambda:map(int,input().split()) n,s=I() print(max(max(sum(I()),s)for _ in '0'*n)) ```
vfc_43981
{ "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 10\n2 77\n3 33\n8 21\n9 12\n10 64\n", "output": "79\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
701_E. Connecting Universities
Solve the following coding problem using the programming language python: Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town. In Treeland there are 2k universities which are located in different towns. Recently, the presid...
```python from sys import stdin from collections import * class graph: def __init__(self): self.gdict = defaultdict(list) def addEdge(self, node1, node2, w=None): self.gdict[node1].append(node2) self.gdict[node2].append(node1) def subtree(self, v): queue, visit, ans = deq...
vfc_43997
{ "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": "7 2\n1 5 6 2\n1 3\n3 2\n4 5\n3 7\n4 3\n4 6\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 3\n3 2 1 6 5 9\n8 9\n3 2\n2 7\n3 4\n7 6\n4 5\n2 1\n2 8\n", "output": "9", ...
code_contests
verifiable_code
745_E. Hongcow Buys a Deck of Cards
Solve the following coding problem using the programming language python: One day, Hongcow goes to the store and sees a brand new deck of n special cards. Each individual card is either red or blue. He decides he wants to buy them immediately. To do this, he needs to play a game with the owner of the store. This game...
vfc_44005
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nR 0 1\nB 1 0\nR 1 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nR 3 0\nR 2 0\nR 1 0\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
768_G. The Winds of Winter
Solve the following coding problem using the programming language python: Given a rooted tree with n nodes. The Night King removes exactly one node from the tree and all the edges associated with it. Doing this splits the tree and forms a forest. The node which is removed is not a part of the forest. The root of a tr...
vfc_44009
{ "difficulty": "13", "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\n2 1\n0 2\n", "output": "1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n0 1\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n4 8\n4 9\n5 10\n", "output": "3\n4\n5\n5\n5\n9\n9\n9\n9\n9\n", ...
code_contests
verifiable_code
792_F. Mages and Monsters
Solve the following coding problem using the programming language python: Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells. Vova's character can learn new spells during the game. Every spell is characterized by two values ...
```python #!/usr/bin/env python3 # solution after hint # (instead of best hit/mana spell store convex hull of spells) # O(n^2) instead of O(n log n) [q, m] = map(int, input().strip().split()) qis = [tuple(map(int, input().strip().split())) for _ in range(q)] mod = 10**6 j = 0 spell_chull = [(0, 0)] # lower hull _...
vfc_44013
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 100\n1 4 9\n2 19 49\n2 19 49\n", "output": "YES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 424978864039\n2 7 3\n2 10 8\n", "output": "NO\nNO\n", "type": "stdin_std...
code_contests
verifiable_code
813_C. The Tag Game
Solve the following coding problem using the programming language python: Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree. Alice starts at vertex 1 and ...
```python import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from collections import defaultdict,deque n,x=list(map(int,input().split())) edge=defaultdict(list) child=defaultdict(list) for i in range(n-1): u,v=list(map(int,input().split())) edge[u].append(v) edge[v].append(u) def bfsD...
vfc_44017
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n1 2\n2 3\n2 4\n", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
839_B. Game of the Rows
Solve the following coding problem using the programming language python: Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army throug...
```python n,m=map(int,input().split()) l=list(map(int,input().split())) p=n for i in range(m) : b=l[i]//4 l[i]=l[i]-4*min(p,l[i]//4) p=p-min(p,b) p1=n*2 for i in range(m) : b=l[i]//2 l[i]=l[i]-2*min(p1,l[i]//2) p1=p1-min(p1,b) p2=p+p1 p3=p for i in range(m) : b=l[i]//2 l[i]=l[i]-2*min(p...
vfc_44021
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n5 8\n", "output": "YES\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
859_E. Desk Disorder
Solve the following coding problem using the programming language python: A new set of desks just arrived, and it's about time! Things were getting quite cramped in the office. You've been put in charge of creating a new seating chart for the engineers. The desks are numbered, and you sent out a survey to the engineer...
```python n = int(input()) m = 2 * n + 1 u = [[] for i in range(m)] v = [0] * m s = [0] * m d = 10 ** 9 + 7 y = 1 for j in range(n): a, b = map(int, input().split()) v[a] = b if a != b: s[b] += 1 u[b].append(a) for b in range(m): if not v[b]: x = 0 p = [b] while...
vfc_44025
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 5\n5 2\n3 7\n7 3\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 10\n2 10\n3 10\n4 10\n5 5\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
884_D. Boxes And Balls
Solve the following coding problem using the programming language python: Ivan has n different boxes. The first of them contains some balls of n different colors. Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every i (1 ≤ i ≤ n) i-th box will contain all balls w...
```python from heapq import * n = int(input()) a = list(map(int, input().split())) heap = [] res = 0 for i in range(n): heappush(heap, a[i]) if n % 2 == 0: heappush(heap, 0) while n > 1: cur = heappop(heap) cur += heappop(heap) cur += heappop(heap) res += cur heappush(heap, cur) n -= 2 p...
vfc_44029
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n2 3 4 5\n", "output": "19\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
908_F. New Year and Rainbow Roads
Solve the following coding problem using the programming language python: Roy and Biv have a set of n points on the infinite number line. Each point has one of 3 colors: red, green, or blue. Roy and Biv would like to connect all the points with some edges. Edges can be drawn between any of the two of the given point...
```python def F1(): n = int(input()) ans = 0 allc = 0 bigr = 0 bigb = 0 lastr = -1 lastb = -1 lastg = -(1 << 60) for i in range(n): x = input().split() pos, col = int(x[0]), x[1] if col == 'R' or col == 'G': if lastr != -1: bigr...
vfc_44033
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 G\n2 R\n3 B\n10 G\n", "output": "12", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 G\n5 R\n10 B\n15 G\n", "output": "23", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
958_C1. Encryption (easy)
Solve the following coding problem using the programming language python: Rebel spy Heidi has just obtained the plans for the Death Star from the Empire and, now on her way to safety, she is trying to break the encryption of the plans (of course they are encrypted – the Empire may be evil, but it is not stupid!). The ...
```python n,p = map(int,input().split()) a = list(map(int,input().split())) forward = [a[0]] for i in range(1,n): forward.append(forward[-1] + a[i]) sm = sum(a) mx = -float('inf') for i in range(n-1): mx = max(mx,(forward[i]%p) + ((sm -forward[i] )%p)) print(mx) ```
vfc_44041
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 10\n3 4 7 2\n", "output": "16", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 12\n16 3 24 13 9 8 7 5 12 12\n", "output": "13", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
983_E. NN country
Solve the following coding problem using the programming language python: In the NN country, there are n cities, numbered from 1 to n, and n - 1 roads, connecting them. There is a roads path between any two cities. There are m bidirectional bus routes between cities. Buses drive between two cities taking the shortest...
vfc_44045
{ "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": "7\n1 1 2 3 4 1\n4\n4 7\n3 5\n7 6\n7 6\n6\n4 6\n3 1\n3 2\n2 7\n6 3\n5 3\n", "output": "1\n-1\n-1\n1\n-1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 1 1 4 5 6\n4\n4 2\n5 4\n1 3\n...
code_contests
verifiable_code
a-summing-punishment-7
Solve the following coding problem using the programming language python: As always, this time again, Suresh and Ramesh went to the tailor for shortening of their father's Pent. And guess what after a bite of Perk they went insane and got it shorten more then what was expected! This time, Suresh's father wanted to pu...
```python n=int(raw_input()) a=map(int,raw_input().split()) q=int(raw_input()) for i in range(q): l,r=map(int,raw_input().split()) x=sum(a[(l-1):r]) print x ```
vfc_44049
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n897 802 765 992 1 521 220 380 729 969 184 887 104 641 909 378 724 582 387 583 241 294 159 198 653 369 418 692 36 901 516 623 703 971 304 394 491 525 464 219 183 648 796 287 979 395 356 702 667 743 976 908 728 134 106 380 193 ...
code_contests
verifiable_code
cricket-field
Solve the following coding problem using the programming language python: Assume the cricket ground to be an infinite grid and there can be more than 11 players in a team. It is known that the batsmen stand at the point (0,0). The field placement follows the following pattern 1st fielder is to be placed at 1 step to ...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' # your code goes here import math def isprime(a): n=int(math.ceil(math.sqrt(a))) if a==2 or a==3 : return True if a==1: return False else: for i in range(2,n+1...
vfc_44057
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 3\n3 4\n5 5\n6 6\n\nSAMPLE", "output": "NO\nYES\nNO\nNO", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n10007 10008\n10009 10010\n10037 10038\n10039 10040\n10061 10062\n10067 10068...
code_contests
verifiable_code
foo-and-exams-4
Solve the following coding problem using the programming language python: Foo was not amongst the most brilliant students of his class. So, he has some pending exams to clear. As the exams are approaching, this time he vowed to pass in all of them. This will only happen if he is not under stress. Foo's stress can be c...
```python def f(t,cf): s,p=0,3 for i in range(4): s+=cf[i]*(t**p) p-=1 return s c=int(raw_input()) while c>0: c-=1 cf=map(int,raw_input().split(' ')) k=cf[4] if cf[3]>k: print "0" #continue else: t=long((k*1.0/cf[0])**(1.0/3.0)) while f(t,cf)>k: t-=1 print t ```
vfc_44061
{ "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 2 2 2 10\n2 3 5 7 1000\n\nSAMPLE", "output": "1\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2 2 2 10\n2 3 1 7 1000\n\nSAMPLE", "output": "1\n7\n", "type": "std...
code_contests
verifiable_code
john-maria
Solve the following coding problem using the programming language python: In the city of Madrid, there are two types of roads - Boulevard and Woonerf. As the people of Madrid are fond of eating, there is exactly one pizzeria on the intersection of each Boulevard and Woonerf. John decides to take Maria to a pizzeria ...
```python from sys import stdin n,m = map(int,stdin.readline().split()) ans = 0 for i in xrange(n): a = map(int,stdin.readline().split()) x = min(a) if x > ans: ans = x print ans ```
vfc_44065
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n4 1 3 5\n2 2 2 2\n5 4 5 1", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2 3\n2 3 1\n3 1 2\n\nSAMPLE", "output": "1", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
milly-and-chocolates-again
Solve the following coding problem using the programming language python: Milly and Pranjul are playing a game in which Pranjul will give an index of a chocolate. Then, Milly has to tell him the box number in which that chocolate is in. There are N such boxes and Ci chocolates are there in i^th the box. Description of...
```python def findIndex(val,list,min,max): if min == max : return min avg = (min+max)/2 if val == list[avg]: return avg if val > list[avg]: if val < list[avg+1]: return avg+1 if avg<max: return findIndex(val,list,avg+1,max) return avg else: if val > list[avg-1]: return avg if avg>min: ret...
vfc_44069
{ "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 3\n2\n2\n4\n\nSAMPLE", "output": "1\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
painting-the-logo
Solve the following coding problem using the programming language python: Rahul has set upon the quest for a new logo of his company. He has created the following continuous logo: /\ / \ / /\ \ / / \ \ / / /\ \ \ \ \ \/ / / \ \ / / \ \/ / \ / \/ However, his sister, Rashi, likes t...
```python def paintRequire(num): return (4*(num*(num+1)/2)) def otimumPaint(avaPaint,optPaint): # print("optimum paint: %s and total paint: %s"%(optPaint,paintRequire(optPaint))) if(paintRequire(optPaint) <= avaPaint): return True else: return False tc = int(raw_input()) while tc >0: ...
vfc_44073
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10\n20\n30\n\nSAMPLE", "output": "0 0\n1 2\n3 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n10\n10\n10\n9\n10\n8\n10\n9\n10\n10\n8\n10\n10\n10\n10\n10\n10\n9\n10\n10\n8\n10\n10...
code_contests
verifiable_code
replicas-1
Solve the following coding problem using the programming language python: Now Flash is in serious trouble. Both Reverse_flash and Zoom are on their way to attack him. But Flash's energy is not enough to face them. Our all time genius Harrison Wells had created a replica mixture and gave it to Flash. Now Flash got 'N'...
```python from fractions import gcd n=input() for i in range(0,n): x=input() li=raw_input() li=map(int,li.split(" ")) li=(set(li)) li=sorted(li) lcm=1 for j in li: x=gcd(lcm,j) lcm=(lcm*j)/x print(lcm%1000000007) ```
vfc_44077
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n1 2 3 1\n\nSAMPLE", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n902\n1916 4171 6696 9445 8711 5524 2509 1172 6710 4018 3342 9545 6849 7289 6961 7688 487 3677 1390 7...
code_contests
verifiable_code
sonya-wants-more-equal-numbers-icpc-3
Solve the following coding problem using the programming language python: Pussycat Sonya has an array A consisting of N integers. She can replace some adjacent elements Ai and Ai+1 by their sum. Sonya can perform this operation any number of times she wants. What is the maximal number of elements with the same value S...
```python class count_num: def __init__(self): self.max_count = 1 def recursive(self,row,count,elem,matrix): self.max_count = max(self.max_count,count) for r in range(row,k): for c in range(r,k): if elem == matrix[r][c]: self.recursive(c+1,count+1,elem,matrix) k = int(raw_input().strip()) #line1 = ...
vfc_44081
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n11 5 6 2 8 10\n\nSAMPLE", "output": "2\n8 10 11 16", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n11 8 6 2 8 10\n\nSAMPLE", "output": "3\n8\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
tom-play-holi
Solve the following coding problem using the programming language python: Tom goes out on the day "HOLI" wearing a checked shirt. After having a good time he returns with colors all over his shirt. He cuts his shirt int a M*M checks, such that M is of the form 2N. Each check on his shirt has got a single color (Exact...
```python for t in range(input()): n=input() print pow(2,n) ```
vfc_44085
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n3\n\nSAMPLE", "output": "2\n8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "24\n1\n8\n9\n12\n14\n11\n56\n58\n68\n46\n54\n23\n10\n28\n19\n32\n54\n21\n46\n18\n38\n26\n24\n33", ...
code_contests
verifiable_code
p00121 Seven Puzzle
Solve the following coding problem using the programming language python: The 7 puzzle consists of 8 square cards and a frame that fits them snugly. Each card is numbered 0, 1, 2, ..., 7 to distinguish them from each other. You can arrange two cards vertically and four cards horizontally in the frame. 7 When you star...
```python from collections import deque import copy swap = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]] def bfs(): ia = list(range(8)) count = {str(ia): 0} que = deque() que.append((ia, 0)) while len(que) != 0: state, cnt = que.popleft() # pos:0????...
vfc_44133
{ "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": "0 1 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0", "output": "0\n1\n28", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 0 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0", "output": "1...
code_contests
verifiable_code
p00254 All Numbers Lead to 6174
Solve the following coding problem using the programming language python: Do the following for a four-digit number N consisting of numbers 0-9. 1. Let L be the number obtained as a result of arranging the numerical values ​​of each of the N digits in descending order. 2. Let S be the number obtained as a result of ar...
```python while True: number=int(input()) if number==0000: break trial=0 while True: if number==6174: print(trial) break box=[] for i in range(4): a=number%10 number=int(number/10) box.append(a) if bo...
vfc_44137
{ "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": "6174\n2012\n3333\n0000", "output": "0\n3\nNA", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00440 Longest Steps
Solve the following coding problem using the programming language python: problem There are n cards with one integer from 1 to n and one blank card. Of these n + 1 cards, k cards are given, but 1 ≤ k ≤ n. You can write one integer from 1 to n on a blank card. I want to make a continuous sequence of integers as long a...
```python anss = [] flag = False def main(): N, K = [int(i) for i in input().split()] if N == K == 0: global flag flag = True return A = [int(input()) for _ in range(K)] A.sort() zero = False if A[0] == 0: zero = True prev = -1 last_island = -1 current...
vfc_44141
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0", "output": "2\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 5\n6\n2\n4\n7\n1\n7 5\n5\n2\n0\n4\n7\n0 0", "output": "2\n4\n", "t...
code_contests
verifiable_code
p00631 Split Up!
Solve the following coding problem using the programming language python: Brave Ponta and his best friend, Brave Gonta, have come to Luida's bar in search of friends to embark on an epic adventure. There are many warriors, monks and wizards in the tavern who are itching to go on an adventure. Gonta, who is kind-heart...
```python def main(): while True: n = int(input()) if n == 0: break alst = list(map(int, input().split())) s = sum(alst) alst = [a * 2 for a in alst] lst = [-s] for a in alst: lst.extend([i + a for i in lst]) print(min(map(abs, lst))) main() ```
vfc_44145
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n4\n2 3 5 7\n0", "output": "1\n1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00775 Vampire
Solve the following coding problem using the programming language python: Vampire Mr. C is a vampire. If he is exposed to the sunlight directly, he turns into ash. Nevertheless, last night, he attended to the meeting of Immortal and Corpse Programmers Circle, and he has to go home in the near dawn. Fortunately, there...
```python while True: r, n = list(map(int, input().split())) if r==0: break b = [0 for i in range(60)] for i in range(n): ll, rr, x = list(map(int, input().split())) for j in range(ll, rr): b[30+j] = max(b[30+j], x) b[30-r-1], b[30+r] = 1e9, 1e9 ans = 1e9 for x in range(30-r, 30+r+1): ...
vfc_44149
{ "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 3\n-2 -1 3\n0 1 3\n2 3 3\n2 2\n-2 0 4\n0 2 3\n2 6\n-3 3 1\n-2 3 2\n-1 3 3\n0 3 4\n1 3 5\n2 3 6\n2 6\n-3 3 1\n-3 2 2\n-3 1 3\n-3 0 4\n-3 -1 5\n-3 -2 6\n0 0", "output": "0.0000\n3.0000\n2.2679\n2.2679", "type": "stdin_s...
code_contests
verifiable_code
p01040 Friday the 13th
Solve the following coding problem using the programming language python: Problem "Ritsumeikan University Competitive Programming Camp" will be held this year as well. I am very much looking forward to this annual training camp. However, I couldn't stand my desires and splurged before the training camp, so I couldn't...
```python def check_uruu(y): if y % 400 == 0: return True elif y % 100 == 0: return False elif y % 4 == 0: return True else: return False nouruu = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] uruu = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] Y1, M1, D1, Y2, M2,...
vfc_44157
{ "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": "2015 3 13 2015 3 13", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2015 2 14 2015 3 15", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01173 Dig or Climb
Solve the following coding problem using the programming language python: Benjamin Forest VIII is a king of a country. One of his best friends Nod lives in a village far from his castle. Nod gets seriously sick and is on the verge of death. Benjamin orders his subordinate Red to bring good medicine for him as soon as ...
vfc_44161
{ "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\n2 1\n0 0\n50 50\n100 0\n3\n1 1\n0 0\n50 50\n100 0\n3\n1 2\n0 0\n50 50\n100 0\n3\n2 1\n0 0\n100 100\n150 50\n6\n1 2\n0 0\n50 50\n100 0\n150 0\n200 50\n250 0\n0", "output": "70.710678\n100.000000\n50.000000\n106.066017\n150....
code_contests
verifiable_code
p01309 A Book Shop With a Frequent Greetings
Solve the following coding problem using the programming language python: Natsume loves big cats. One day, Natsume was invited by the stray cats she was always close to to go to the mysterious bookstore where the cats were open. When I heard that the bookstore sells books with many pictures of cats, Natsume decided to...
vfc_44165
{ "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\n3 3 5\n0 0\n10 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90 100\n110 100\n100 90\n100 110\n4 60 10\n100 100\n80 100\n110 100\n100 80\n100 110", "output": "9\n0\n60\nYou're always ...
code_contests
verifiable_code
p01478 Sort
Solve the following coding problem using the programming language python: Problem statement There is a permutation with $ 1,2, ..., N $ sorted. I want to select two different numbers $ i $, $ j $ and replace them repeatedly to make them sorted (in the order of $ 1,2, ..., N $). Every time you replace the numbers $ i ...
vfc_44169
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 1 3\n1 0 8\n3 8 0", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 1 3\n1 0 12\n3 8 0", "output": "5\n", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
p01638 Pie Chart is as easy as pie.
Solve the following coding problem using the programming language python: ICPC World Finals Day 3 On that day, Mr. Tee was investigating the percentage of language used within the team. Unusually, our team does not unify the languages ​​used. Research has shown that two are using C ++ and one is using Java. Now, let'...
vfc_44173
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "r x y n\np", "output": "71 156", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01790 Balanced Paths
Solve the following coding problem using the programming language python: Example Input 2 () 1 2 Output 1 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
vfc_44177
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n()\n1 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n)(\n1 2", "output": "1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01925 Quiz
Solve the following coding problem using the programming language python: quiz You are the director of a quiz show. N people will appear in the quiz show as answerers, each numbered from 1 to N. Questions will be M + 1 questions, and each question is numbered from 1 to M + 1. Questions are given in numerical order, ...
```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_44181
{ "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": "3 2\n5 2 1 3\n8 2 2 3\n2 3\n8 2 1 2\n3 1 1\n5 1 2\n2 5\n100 1 1\n100 1 1\n100 1 1\n100 1 1\n100 1 1\n3 4\n5 1 1\n5 1 2\n100 2 1 3\n100 2 2 3\n0 0", "output": "14\n11\n501\n196", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p02063 Is Greedy Optimal?
Solve the following coding problem using the programming language python: D: Is greed the best? story In Japan, where there are 1, 5, 10, 50, 100, 500 yen coins, it is known that the number of coins can be minimized by using as many coins as possible when paying a certain amount. .. If the amount of coins is differ...
```python A,B=map(int,input().split()) if A>B: A,B=B,A if B%A==0: print(-1) else: for i in range(((B//A+1)*A),B+A*2,A): if i//A < i//B+(i-i//B*B)//A+(i-i//B*B)%A: print(i) break else: print(-1) ```
vfc_44185
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 6", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 6", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7", ...
code_contests
verifiable_code
admag
Solve the following coding problem using the programming language python: Aditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle of cards each having a sorted list (in ascending order) of some distinct integers writte...
```python for cas in xrange(input()): n, c, Fc1, Fc2 = input(), 1, 1, 2 while Fc2 <= n: Fc1, Fc2, c = Fc2, Fc1+Fc2, c+1 print c ```
vfc_44197
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n4", "output": "1\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n3", "output": "1\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
chefsq
Solve the following coding problem using the programming language python: Chef has a sequence of N numbers. He like a sequence better if the sequence contains his favorite sequence as a substring. Given the sequence and his favorite sequence(F) check whether the favorite sequence is contained in the sequence Input ...
```python import sys t = int(sys.stdin.readline()) for frutta in range(t): lN = int(sys.stdin.readline()) l1 = map(int,sys.stdin.readline().split()) lF = int(sys.stdin.readline()) l2 = map(int,sys.stdin.readline().split()) sePuede = True for x in l2: sePuede = sePuede and (x in l1) if (sePuede): print ...
vfc_44201
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6\n1 2 3 4 5 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n6\n1 2 3 4 7 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "...
code_contests
verifiable_code
dragnxor
Solve the following coding problem using the programming language python: Did you ever hear about 'Dragon Food' ? Its used to refer to the chocolates bought for your loved ones :). Po offers dragon food to master Shifu, who is a famous cook in the valley of food. In return, Shifu hands over the dragon scroll to Po, wh...
```python __author__ = 'deveshbajpai' def solve(n,a,b): bin_a = bin(a).split('b')[1] bin_b = bin(b).split('b')[1] cn1_bin_a = countNoOf1(bin_a) cn1_bin_b = countNoOf1(bin_b) v = n-(cn1_bin_a+cn1_bin_b) result = "" if v==0: result = '1'*n elif v>0: result = '1'*(cn...
vfc_44205
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 5 4\n5 0 1\n4 3 7", "output": "7\n16\n14\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
jntuv1
Solve the following coding problem using the programming language python: Problem description.   JNTU College is conducting an Warmup contest for students to bring out their approaches of solving a problem. A Challenged B that he could not solve the problem.So help B in solving the problem. Given a seri...
```python read = lambda: map(int, raw_input().split()) read_s = lambda: map(str, raw_input().split()) def dfs(x, nums): if x > 1e10: return nums.append(x) dfs(x * 10 + 4, nums) dfs(x * 10 + 3, nums) nums = [] dfs(0, nums) nums.sort() n, = read() print nums[n] ```
vfc_44209
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "43", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
nukes
Solve the following coding problem using the programming language python: There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. However if at any time, there are more than N particles in a chamber, a reaction will cause 1 pa...
```python a,n,k=map(int,raw_input().split()) for i in range(k): print (a%(n+1)) a=a/(n+1) ```
vfc_44213
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 3", "output": "1 1 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 1", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1...
code_contests
verifiable_code
simpstat
Solve the following coding problem using the programming language python: Sergey has made N measurements. Now, he wants to know the average value of the measurements made. In order to make the average value a better representative of the measurements, before calculating the average, he wants first to remove the highes...
```python for t in xrange(int(raw_input())): n, k = map(int, raw_input().split()) if k == 0: a = map(int, raw_input().split()) else: a = sorted(map(int, raw_input().split()))[k:-k] print '{:.6f}'.format(float(sum(a))/len(a)) ```
vfc_44217
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 1\n2 9 -10 25 1\n5 0\n2 9 -10 25 1\n3 1\n1 1 1", "output": "4.000000\n5.400000\n1.000000\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1004_B. Sonya and Exhibition
Solve the following coding problem using the programming language python: Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put either ...
```python def calc(s): presum = [0] for ch in s: presum.append(presum[-1]) if ch == '1': presum[-1] += 1 ans = 0 for (l,r) in points: ans += ((r-l+1) - (presum[r] - presum[l-1])) * (presum[r] - presum[l-1]) return ans n, m = list(map(int, input().split())) """ points = [] for _ in range(m)...
vfc_44221
{ "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 3\n5 6\n1 4\n4 6\n", "output": "010101", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n1 3\n2 4\n2 5\n", "output": "01010", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
1028_B. Unnatural Conditions
Solve the following coding problem using the programming language python: Let s(x) be sum of digits in decimal representation of positive integer x. Given two integers n and m, find some positive integers a and b such that * s(a) ≥ n, * s(b) ≥ n, * s(a + b) ≤ m. Input The only line of input contain two in...
```python def sum_digit(n): c=0 x=n while x>0: c+=(x%10) x=x//10 return c n,m=map(int,input().split()) r='5' su=5 while su<n: r='4'+r su+=4 r=r[0:len(r)-1] r+='5' t1="" for i in range(len(r)): t1+='5' print(int(t1)) print(int(r)) ```
vfc_44225
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 16\n", "output": "11111111\n88888889", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 5\n", "output": "111111\n888889", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
1046_H. Palindrome Pairs
Solve the following coding problem using the programming language python: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whet...
```python # -*- coding:utf-8 -*- """ created by shuangquan.huang at 11/20/18 After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given stri...
vfc_44229
{ "difficulty": "14", "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\naa\nbb\ncd\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\naab\nabcac\ndffe\ned\naa\naade\n", "output": "6\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
1070_G. Monsters and Potions
Solve the following coding problem using the programming language python: Polycarp is an introvert person. In fact he is so much of an introvert that he plays "Monsters and Potions" board game alone. The board of the game is a row of n cells. The cells are numbered from 1 to n from left to right. There are three types...
```python import sys n, m = tuple(int(x) for x in sys.stdin.readline().split()) heroes = [] for i in range(m): s, h = tuple(int(x) for x in sys.stdin.readline().split()) heroes.append((s - 1, h, i)) heroes = tuple(sorted(heroes)) a = tuple(int(x) for x in sys.stdin.readline().split()) def move_right(heroes,...
vfc_44233
{ "difficulty": "13", "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 3\n8 2\n1 3\n4 9\n0 3 -5 0 -5 -4 -1 0\n", "output": "6\n3 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n1 1\n0\n", "output": "1\n1 \n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1092_C. Prefixes and Suffixes
Solve the following coding problem using the programming language python: Ivan wants to play a game with you. He picked some string s of length n consisting only of lowercase Latin letters. You don't know this string. Ivan has informed you about all its improper prefixes and suffixes (i.e. prefixes and suffixes of l...
```python def is_suffix(par,child): l=len(child) if par[n-l-1:] == child: return 1 return 0 def is_prefix(par,child): l=len(child) if par[:l] ==child: return 1 return 0 def make(pri_par,sec_par,f,s): ans=[0 for i in range(2*n-2)] ans[f]='P' ans[s]='S' for i in r...
vfc_44237
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\na\naa\naa\na\n", "output": "PPSS", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1111_A. Superhero Transformation
Solve the following coding problem using the programming language python: We all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name s can transform to another superhero with name t if s can be made equal to t by changing...
```python import math # n=int(input()) s=input() t=input() c = ['a','e','i','o','u'] if len(s)!=len(t): print("No") exit(0) for i in range(len(s)): if(s[i] in c and not(t[i] in c)): print("No") exit(0) elif(t[i] in c and not (s[i] in c)): print("No") exit(0) print("Yes") ```
vfc_44241
{ "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": "akm\nua\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "a\nu\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
1159_D. The minimal unique substring
Solve the following coding problem using the programming language python: Let s be some string consisting of symbols "0" or "1". Let's call a string t a substring of string s, if there exists such number 1 ≤ l ≤ |s| - |t| + 1 that t = s_l s_{l+1} … s_{l + |t| - 1}. Let's call a substring t of string s unique, if there...
```python n, k = map(int, input().split()) strr = "" while len(strr) < n: strr += "0" * ((n-k) // 2) + "1" strr = strr[:n] print(strr) ```
vfc_44249
{ "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\n", "output": "1111", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 3\n", "output": "0010010", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 ...
code_contests
verifiable_code
119_C. Education Reform
Solve the following coding problem using the programming language python: Yet another education system reform has been carried out in Berland recently. The innovations are as follows: An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more...
```python class Subject: def __init__(self, id, low, high, complexity): self.id = id self.low = low self.high = high self.complexity = complexity self.day_links = [ {} for i in range(high - low + 1) ] def add_link(self, link): day = link.day links = self....
vfc_44257
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5 2\n1 10 1\n1 10 2\n1 10 3\n1 20 4\n1 100 5\n", "output": "YES\n1 8\n2 10\n4 ...
code_contests
verifiable_code
1217_A. Creating a Character
Solve the following coding problem using the programming language python: You play your favourite game yet another time. You chose the character you didn't play before. It has str points of strength and int points of intelligence. Also, at start, the character has exp free experience points you can invest either in st...
```python from sys import stdin input=stdin.readline R=lambda:map(int,input().split()) I=lambda:int(input()) S=lambda:input().rstrip('\n') for _ in range(I()): a,b,c=R() ans=0 l=0;r=c while l<=r: m=(l+r)//2 if a+m>b+(c-m):ans=c-m+1;r=m-1 else:l=m+1 print(ans) ```
vfc_44261
{ "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\n5 3 4\n2 1 0\n3 5 5\n4 10 6\n", "output": "3\n1\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 100000000\n100000000 100000000 100000000\n100000000 1 100000000\n1 100000000...
code_contests
verifiable_code
123_C. Brackets
Solve the following coding problem using the programming language python: A two dimensional array is called a bracket array if each grid contains one of the two possible brackets — "(" or ")". A path through the two dimensional array cells is called monotonous if any two consecutive cells in the path are side-adjacent...
vfc_44265
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 2\n3 6\n1 4\n2 5\n", "output": "()\n)(\n()\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 1\n1 2\n", "output": "()\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
125_D. Two progressions
Solve the following coding problem using the programming language python: An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic prog...
```python n=input() a=map(int,raw_input().split()) def is_arithmetic(t): m=len(t) for i in range(m-2): if t[i+1]-t[i] != t[i+2]-t[i+1]: return False return True if n==2: print a[0] print a[1] else: found = False for start in [[0,1],[0,2],[1,2]]: b = [] c = [] for i in range(n): ...
vfc_44269
{ "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\n1 2 3 -2 -7\n", "output": "1 2 3 \n-2 -7 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n4 1 2 7 3 10\n", "output": "1 2 3 \n4 7 10 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1281_F. Miss Punyverse
Solve the following coding problem using the programming language python: The Oak has n nesting places, numbered with integers from 1 to n. Nesting place i is home to b_i bees and w_i wasps. Some nesting places are connected by branches. We call two nesting places adjacent if there exists a branch between them. A sim...
vfc_44273
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3\n10 160 70 50\n70 111 111 0\n1 2\n2 3\n3 4\n2 1\n143 420\n214 349\n2 1\n", "output": "2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9\n5 2\n3 0 1 0 3\n0 2 0 2 0\n1 2\n2 3\n3 ...
code_contests
verifiable_code
1301_F. Super Jaber
Solve the following coding problem using the programming language python: Jaber is a superhero in a large country that can be described as a grid with n rows and m columns, where every cell in that grid contains a different city. Jaber gave every city in that country a specific color between 1 and k. In one second he...
vfc_44277
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4 8\n1 2 2 8\n1 3 4 7\n5 1 7 6\n2 3 8 8\n4\n1 1 2 2\n1 1 3 4\n1 1 2 4\n1 1 4 4\n", "output": "2\n3\n3\n4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1366_E. Two Arrays
Solve the following coding problem using the programming language python: You are given two arrays a_1, a_2, ... , a_n and b_1, b_2, ... , b_m. Array b is sorted in ascending order (b_i < b_{i + 1} for each i from 1 to m - 1). You have to divide the array a into m consecutive subarrays so that, for each i from 1 to m...
```python import math n, m = tuple(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ai = n - 1 bi = m - 1 num_split = [0] * (m - 1) while bi > 0: while a[ai] > b[bi]: ai -= 1 while ai >= 0 and a[ai] >= b[bi]: num_split[bi - 1] += 1 ai -...
vfc_44289
{ "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 3\n12 10 20 20 25 30\n10 20 30\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 2\n1 2 2 2 2 2 2 2\n1 2\n", "output": "7", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
1387_B1. Village (Minimum)
Solve the following coding problem using the programming language python: This problem is split into two tasks. In this task, you are required to find the minimum possible answer. In the task Village (Maximum) you are required to find the maximum possible answer. Each task is worth 50 points. There are N houses in a ...
```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_44293
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 0, 'nanos': 750000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2\n2 3\n3 4\n", "output": "4\n2 1 4 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n4 2\n5 7\n3 4\n6 3\n1 3\n4 5\n", "output": "8\n6 4 1 2 7 3 5 ", "type": "stdin_stdo...
code_contests
verifiable_code
1408_E. Avoid Rainbow Cycles
Solve the following coding problem using the programming language python: You are given m sets of integers A_1, A_2, …, A_m; elements of these sets are integers between 1 and n, inclusive. There are two arrays of positive integers a_1, a_2, …, a_m and b_1, b_2, …, b_n. In one operation you can delete an element j f...
```python import sys;input=sys.stdin.readline def root(x): if x == p[x]:return x p[x] = y = root(p[x]);return y def unite(x, y): px = root(x); py = root(y) if px == py:return 0 rx = rank[px]; ry = rank[py] if ry < rx:p[py] = px elif rx < ry:p[px] = py else:p[py] = px;rank[px] += 1 re...
vfc_44297
{ "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": "7 8\n3 6 7 9 10 7 239\n8 1 9 7 10 2 6 239\n3 2 1 3\n2 4 1\n3 1 3 7\n2 4 3\n5 3 4 5 6 7\n2 5 7\n1 8\n", "output": "66\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 2 3\n4 5\n2 1 2\...
code_contests
verifiable_code
1428_G2. Lucky Numbers (Hard Version)
Solve the following coding problem using the programming language python: This is the hard version of the problem. The only difference is in the constraint on q. You can make hacks only if all versions of the problem are solved. Zookeeper has been teaching his q sheep how to write and how to add. The i-th sheep has t...
vfc_44301
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3 4 5 6\n2\n57\n63\n", "output": "11\n8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2 3 4 5 6\n2\n57\n72\n", "output": "11\n8\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
1452_C. Two Brackets
Solve the following coding problem using the programming language python: You are given a string s, consisting of brackets of two types: '(', ')', '[' and ']'. A string is called a regular bracket sequence (RBS) if it's of one of the following types: * empty string; * '(' + RBS + ')'; * '[' + RBS + ']'; ...
```python import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write i...
vfc_44305
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n()\n[]()\n([)]\n)]([\n)[(]\n", "output": "\n1\n2\n2\n0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n()\n()\n()\n()\n", "output": "1\n1\n1\n1\n", "type": "stdin_stdo...
code_contests
verifiable_code
1476_A. K-divisible Sum
Solve the following coding problem using the programming language python: You are given two integers n and k. You should create an array of n positive integers a_1, a_2, ..., a_n such that the sum (a_1 + a_2 + ... + a_n) is divisible by k and maximum element in a is minimum possible. What is the minimum possible max...
```python import sys import math import itertools import functools import collections import operator import fileinput import copy from collections import * ORDA = 97 # a def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return [int(i) for i in input().split()] def lcm(a, b): return ...
vfc_44309
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 5\n4 3\n8 8\n8 17\n", "output": "\n5\n2\n1\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1000000000 3\n1000000000 3\n1000000000 3\n1000000000 3\n1000000000 3\n1000000000 3\n1...
code_contests
verifiable_code
1500_F. Cupboards Jumps
Solve the following coding problem using the programming language python: In the house where Krosh used to live, he had n cupboards standing in a line, the i-th cupboard had the height of h_i. Krosh moved recently, but he wasn't able to move the cupboards with him. Now he wants to buy n new cupboards so that they look...
vfc_44313
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 6, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11 10\n5 7 2 3 4 5 2 1 8\n", "output": "\nYES\n1 1 6 8 6 5 2 0 0 1 8 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1526_B. I Hate 1111
Solve the following coding problem using the programming language python: You are given an integer x. Can you make x by summing up some number of 11, 111, 1111, 11111, …? (You can use any number among them any number of times). For instance, * 33=11+11+11 * 144=111+11+11+11 Input The first line of input con...
```python for i in range(int(input())): n=int(input()) if(n>=111*(n%11)): print("YES") else : print("NO") ```
vfc_44317
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n33\n144\n69\n", "output": "\nYES\nYES\nNO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
157_E. Cipher
Solve the following coding problem using the programming language python: Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher the correspondence, but he couldn't...
vfc_44321
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nab\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nya\nklmbfxzb\n", "output": "24\n320092793\n", "type": "stdin_stdout" }, { "fn_name": nul...
code_contests
verifiable_code
1_A. Theatre Square
Solve the following coding problem using the programming language python: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a ...
```python import math def main(): n, m, a = map(int, input().split()) sq_area = n * m stone_area = a * a if stone_area > sq_area: return 1 return math.ceil(m / a) * math.ceil(n / a) if __name__ == '__main__': print(main()) ```
vfc_44329
{ "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 6 4\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
224_B. Array
Solve the following coding problem using the programming language python: You've got an array a, consisting of n integers: a1, a2, ..., an. Your task is to find a minimal by inclusion segment [l, r] (1 ≤ l ≤ r ≤ n) such, that among numbers al, al + 1, ..., ar there are exactly k distinct numbers. Segment [l, r] (1 ≤ ...
```python MAX_N = 100005 n, k = map(int, input().split(' ')) a = list(map(int, input().split(' '))) cnt = [0 for i in range(MAX_N)] l = 0 count = 0 for i in range(n): cnt[a[i]] += 1 if cnt[a[i]] == 1: count += 1 if count == k: while l <= i: cnt[a[l]] -= 1 if cnt[a[l]] == 0: print(l + 1, end = ' ') ...
vfc_44333
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\n4 7 7 4 7 4 7\n", "output": "-1 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1 2 2 3\n", "output": "1 2", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
248_E. Piglet's Birthday
Solve the following coding problem using the programming language python: Piglet has got a birthday today. His friend Winnie the Pooh wants to make the best present for him — a honey pot. Of course Winnie realizes that he won't manage to get the full pot to Piglet. In fact, he is likely to eat all the honey from the p...
vfc_44337
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 2 3\n5\n1 2 1\n2 1 2\n1 2 2\n3 1 1\n3 2 2\n", "output": "0.00000000000\n0.33333333333\n1.00000000000\n1.00000000000\n2.00000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n4...
code_contests
verifiable_code
273_A. Dima and Staircase
Solve the following coding problem using the programming language python: Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the sta...
```python n, t, d, p = input(), [0] + list(map(int, input().split())), 0, [] for i in range(int(input())): w, h = map(int, input().split()) p.append(max(d, t[w])) d = p[i] + h print(*p) ```
vfc_44341
{ "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\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10\n", "output": "1\n3\n13\n23\n33\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
31_A. Worms Evolution
Solve the following coding problem using the programming language python: Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are n forms of worms. Worms of these forms have lengths a1, a2, ..., an. To prove his theory, professor needs to find...
```python n = int(input()) line = list(map(int,input().split())) for i in range(n-1): for j in range(i+1,n): if line[i] + line[j] in line: print(line.index(line[i] + line[j])+1, i+1, j+1) exit(0) print('-1') ```
vfc_44349
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 5 7\n", "output": "3 1 2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
344_A. Magnets
Solve the following coding problem using the programming language python: Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together ...
```python s=0 prev='' for i in range(int(input())): kk=input() if kk!=prev: s+=1 prev=kk print(s) ```
vfc_44353
{ "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\n01\n01\n10\n10\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n10\n10\n10\n01\n10\n10\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
367_C. Sereja and the Arrangement of Numbers
Solve the following coding problem using the programming language python: Let's call an array consisting of n integer numbers a1, a2, ..., an, beautiful if it has the following property: * consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; * f...
```python def readdata(): #fread = open('input.txt', 'r') global n, m, w, q n, m = [int(x) for x in input().split()] q = [0] * m w = [0] * m for i in range(m): q[i], w[i] = [int(x) for x in input().split()] def podg(): global summ w.sort(reverse = True)...
vfc_44357
{ "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": "100 3\n1 2\n2 1\n3 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n1 1\n2 100\n", "output": "100\n", "type": "stdin_stdout" }, { "fn_name"...
code_contests
verifiable_code
38_G. Queue
Solve the following coding problem using the programming language python: On a cold winter evening our hero Vasya stood in a railway queue to buy a ticket for Codeforces championship final. As it usually happens, the cashier said he was going to be away for 5 minutes and left for an hour. Then Vasya, not to get bored,...
vfc_44361
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3\n2 3\n3 3\n", "output": "3 2 1 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
411_A. Password Check
Solve the following coding problem using the programming language python: You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a ...
```python n=input() d=[] sp="!?.,_" for i in n: if len(n)>=5: d.append(1) if i.isupper()==True: d.append(2) if i.islower()==True: d.append(3) if i.isdigit()==True: d.append(4) if i in sp: d.append(5) s=set(d) if s=={1,2,3,4} or s=={1,2,3,4,5}: print("Corre...
vfc_44365
{ "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": "X12345\n", "output": "Too weak\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "CONTEST_is_STARTED!!11\n", "output": "Correct\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
438_E. The Child and Binary Tree
Solve the following coding problem using the programming language python: Our child likes computer science very much, especially he likes binary trees. Consider the sequence of n distinct positive integers: c1, c2, ..., cn. The child calls a vertex-weighted rooted binary tree good if and only if for every vertex v, t...
vfc_44369
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 7, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n1 2\n", "output": "1\n3\n9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10\n9 4 3\n", "output": "0\n0\n1\n1\n0\n2\n4\n2\n6\n15\n", "type": "stdin_stdout" }, {...
code_contests
verifiable_code
460_B. Little Dima and Equation
Solve the following coding problem using the programming language python: Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 109) of the equation: x = b·s(x)a + c, where a, b, c are some predeter...
```python a,b,c=map(int,input().split()) L=[] for i in range(1,82): val=b*(i**a)+c check=0 if val>0 and val<10**9: s=str(val) for j in s: check+=int(j) if check==i: L.append(val) if len(L)==0: print(0) else: print(len(L)) print(*L) ```
vfc_44373
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 8\n", "output": "3\n10 2008 13726\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
484_A. Bits
Solve the following coding problem using the programming language python: Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <...
```python n = int(input()) for i in range(n): l,r=map(int,input().split()) while(l|(l+1)<=r): # or make like max function here . l|=l+1 # or here like equal print(l) ```
vfc_44377
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n2 4\n1 10\n", "output": "1\n3\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "18\n1 10\n1 100\n1 1000\n1 10000\n1 100000\n1 1000000\n1 10000000\n1 100000000\n1 1000000000\n1 100...
code_contests
verifiable_code
530_G. Levenshtein distance
Solve the following coding problem using the programming language python: Levenshtein distance between two strings of letters is calculated as the minimal total cost of a sequence of edit actions that converts one of the strings into the other one. The allowed edit actions are: * substitution: the cost of substitut...
vfc_44385
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "arc\nbug\n", "output": "8\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
604_E. Lieges of Legendre
Solve the following coding problem using the programming language python: Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that there are n piles of cows, with the i-th pile co...
```python G_EVEN = {0:0, 1:1, 2:2} G_ODD = {0:0, 1:1, 2:0, 3:1} def grundy(k, ai): if k % 2: if ai <= 3: return G_ODD[ai] elif ai % 2: return 0 else: p = 0 j = ai while not j & 1: p += 1 j >>= 1 ...
vfc_44397
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n3\n", "output": "Nicky\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
627_A. XOR Equation
Solve the following coding problem using the programming language python: Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)? Input The first line of the input contains two integers s and x (2 ≤ s ≤ 1012, 0 ≤ x ≤ 1012), the sum and bit...
```python R = lambda: map(int, input().split()) s, x = R() if s < x or (s - x) & 1: print(0) exit(0) u, d = (s - x) // 2, x res = 1 while u or d: uu, dd = u & 1, d & 1 if uu and dd: res *= 0 elif uu == 0 and dd == 1: res *= 2 u, d = u >> 1, d >> 1 if s == x: res = max(0, res ...
vfc_44401
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 5\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n", ...
code_contests
verifiable_code
651_A. Joysticks
Solve the following coding problem using the programming language python: Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of e...
```python import sys input = sys.stdin.readline def inp(): return (int(input())) def inlt(): return (list(map(int, input().split()))) def insr(): s = input() return (list(s[:len(s) - 1])) def invr(): return list((map(int, input().split()))) hash_map = {} def solve(a1, a2): if a1 <= ...
vfc_44405
{ "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 4\n", "output": "5\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
676_D. Theseus and labyrinth
Solve the following coding problem using the programming language python: Theseus has just arrived to Crete to fight Minotaur. He found a labyrinth that has a form of a rectangular field of size n × m and consists of blocks of size 1 × 1. Each block of the labyrinth has a button that rotates all blocks 90 degrees clo...
```python from collections import deque import sys ROTATE = { "+": "+", "-": "|", "|": "-", "^": ">", ">": "v", "v": "<", "<": "^", "L": "U", "U": "R", "R": "D", "D": "L", "*": "*" } # l, r, u, d BINARY_MAP = { "+": (1, 1, 1, 1), "-": (1, 1, 0, 0), "|": (0,...
vfc_44409
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n&lt;&gt;&lt;\n&gt;&lt;&gt;\n1 1\n2 1\n", "output": "-1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
69_D. Dot
Solve the following coding problem using the programming language python: Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game unde...
```python import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') x, y, n, d = map(int, input().split()) vector = [list(map(int, input().split())) for _ in range(n)] dp = [[-1] * (d * 2 + 1) for _ in range(d * 2 + 1)] for i in range(d * 2 + 1): for j...
vfc_44413
{ "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": "0 0 2 4\n1 1\n1 2\n", "output": "Dasha\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0 2 3\n1 1\n1 2\n", "output": "Anton\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
721_A. One-dimensional Japanese Crossword
Solve the following coding problem using the programming language python: Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, en...
```python n=int(input()) s=input() arr,k=[],0 for i in range(len(s)): if(s[i]=='B'): k+=1 else: if(k>0): arr.append(k) k=0 if(k>0): arr.append(k) print(len(arr)) print(*arr,sep=' ') ```
vfc_44417
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nBBW\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
742_D. Arpa's weak amphitheater and Mehrdad's valuable Hoses
Solve the following coding problem using the programming language python: Just to remind, girls in Arpa's land are really nice. Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendshi...
```python from sys import stdin, stdout from collections import defaultdict as dd read, write = stdin.readline, stdout.write class DisjointSetUnion: def __init__(self, n): self.parent = list(range(n)) self.size = [1] * n self.num_sets = n def find(self, a): acopy = a wh...
vfc_44421
{ "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 2 11\n2 4 6 6\n6 4 2 1\n1 2\n2 3\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 5\n3 2 5\n2 4 2\n1 2\n", "output": "6\n", "type": "stdin_stdout" } ...
code_contests
verifiable_code
766_A. Mahmoud and Longest Uncommon Subsequence
Solve the following coding problem using the programming language python: While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem. Given two strings a and b, find the length of their longest u...
```python def uncommon(a, b): if (a == b): return -1 return max(len(a), len(b)) A = input() B = input() print(uncommon(A, B)) ```
vfc_44425
{ "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": "abcd\ndefgh\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "a\na\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
789_E. The Great Mixing
Solve the following coding problem using the programming language python: Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a gl...
```python from collections import deque MAX_A = 1000 def main(): n, k = map(int, input().split()) a = set(int(x) - n for x in input().split()) visited = [False] * (2 * MAX_A + 1) visited[n] = True Q = deque() Q.append((n, 0)) result = None while Q: u, l = Q.popleft() ...
vfc_44429
{ "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": "50 2\n100 25\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "400 4\n100 300 450 500\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
810_B. Summer sell-off
Solve the following coding problem using the programming language python: Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant. Shop, where Noora...
```python def get_line(): return [int(s) for s in input().strip().split()] n, f = get_line() kl = [] for _ in range(n): kl.append(get_line()) def get_extra(k, l): if l <= k: return 0 if l <= 2*k: return l - k return k extras = [get_extra(k, l) for k, l in kl] if f == 0: ext...
vfc_44433
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n0 2\n0 3\n3 5\n0 6\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n2 1\n3 5\n2 3\n1 5\n", "output": "10", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
835_E. The penguin's game
Solve the following coding problem using the programming language python: Pay attention: this problem is interactive. Penguin Xoriy came up with a new game recently. He has n icicles numbered from 1 to n. Each icicle has a temperature — an integer from 1 to 109. Exactly two of these icicles are special: their tempera...
vfc_44437
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 1\n2\n1\n1<span class=\"tex-font-style-it\"></span>", "output": "? 2 1 3 \n? 2 2 3 \n? 1 4 \n! 2 4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
856_A. Set Theory
Solve the following coding problem using the programming language python: Masha and Grisha like studying sets of positive integers. One day Grisha has written a set A containing n different integers ai on a blackboard. Now he asks Masha to create a set B containing n different integers bj such that all n2 integers th...
```python from random import randint def solve(): n, a = int(input()), list(map(int, input().split())) bb, ab = set(), set() while True: b = randint(1, 1000000) for i in a: if i + b in ab: break else: bb.add(b) if len(bb) == n: break for i in a: ab.add(b + i) print('YES') print(' '.jo...
vfc_44441
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1 10 100\n1\n1\n2\n2 4\n", "output": "YES\n1 2 3\nYES\n1\nYES\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n100\n74 14 24 45 22 9 49 78 79 20 60 1 31 91 32 39 90 5 42 57 30...
code_contests
verifiable_code
883_A. Automatic Door
Solve the following coding problem using the programming language python: There is an automatic door at the entrance of a factory. The door works in the following way: * when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside, ...
```python BigNum = 10 ** 20 n, m, a, d = map(int, input().split(' ')) ts = [0] + list(map(int, input().split(' '))) + [BigNum] def empsInRange(l, r): em1 = l // a + 1 em2 = r // a return (em1, min(em2, n)) empDoorGroup = d // a + 1 def moveEmps(emps, last): em1, em2 = emps if em1 > em2: ...
vfc_44445
{ "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 1 3 4\n7\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 4 2\n7 9 11\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
906_A. Shockers
Solve the following coding problem using the programming language python: Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives a...
```python n = int(input()) alphabet = "abcdefghijklmnopqrstuvwxyz" possible = set(alphabet[i] for i in range(len(alphabet))) i = 0 while i < n: signal, word = input().split() if signal == '!': possible = possible & set(word[j] for j in range(len(word))) elif signal == '.' or (signal == '?' and i != n-1): ...
vfc_44449
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h\n", "output": "...
code_contests
verifiable_code
955_A. Feed the cat
Solve the following coding problem using the programming language python: After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another time (guess why there's only one cat). The cat's current hunger level is H points, moreover each minute without food increases his hunger by D p...
```python h,m = map(int,input().split()) hu,d,c,n = map(int,input().split()) if h >= 20: if hu % n != 0: hu = hu + n-hu%n print((hu*4*c)/(5*n)) else: lhu = hu p = float('inf') if hu % n != 0: hu = hu + n-hu%n p = min(p,hu*c/n) #print(p) hu = lhu+((19-h)*60+(60-m))*d i...
vfc_44457
{ "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": "19 00\n255 1 100 1\n", "output": "25200.0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "17 41\n1000 6 15 11\n", "output": "1365\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
22-base-conflict
Solve the following coding problem using the programming language python: Announcement ************Second Round will be ONLINE instead of ONSITE************* Problem Statement Schimdt is teaching Jenko a new technique to excel at bases. He writes n numbers in base k on a piece of paper and also their decimal sum. He ...
```python import sys n = int(sys.stdin.readline()) s = ["" for _ in xrange(n)] #for i in xrange(n): # s[i] = sys.stdin.readline() s = sys.stdin.readline().split() m = int(sys.stdin.readline()) #print int('21',3) d = 0 book = ['A','B','C','D','E','F'] book2 = ['a','b','c','d','e','f'] for ss in s: for sss in ss: #p...
vfc_44465
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 21\n10\n\nSAMPLE", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n100000000000000000000000000000000000000000000000000000000000\n576460752303423488", "output": "2...
code_contests
verifiable_code
biased-chandan
Solve the following coding problem using the programming language python: Chandan is an extremely biased person, and he dislikes people who fail to solve all the problems in the interview he takes for hiring people. There are n people on a day who came to be interviewed by Chandan. Chandan rates every candidate from...
```python n = int(raw_input()) l = [] for i in xrange(0,n): x = int(raw_input()) if x == 0 and len(l) != 0: l.pop() else: l.append(x) print sum(l) ```
vfc_44469
{ "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\n3\n0\n7\n0\n\nSAMPLE", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2\n3\n0\n7\n0\n\nSBMPLE", "output": "2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
count-enemies-5
Solve the following coding problem using the programming language python: Little Arjit is the leader of a marvellous fighting army. His team is very good at fighting against all their enemies. But like Hound from Game of Thrones, Little Arjit and his entire team is scared of fire. When they see fire, they feel threate...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' if __name__ == '__main__': cases = int(raw_input()) start = 1 while start <= cases: line = raw_input() line = line.split('*') total_weak = 0 for string in line: ...
vfc_44473
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nX*OO*XX\nX*OX*XO*\nX*OO*OO*X*OX*\n\nSAMPLE", "output": "2\n0\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\nOOXO*OOXXO*O*O*OXXOO**XX***OOO*XXX*XOOOOXXX**O***X*OO**X**OOXX*X**OXO...
code_contests
verifiable_code
find-the-triangle-3
Solve the following coding problem using the programming language python: You are given N sticks, the length of the i^th stick being ai . As your professor is very interested in triangles he gives you a problem: From the N given sticks, choose 3 sticks that form a triangle. If there are many such triangles , choose th...
```python for t in range(int(raw_input())): n=int(raw_input()) N=map(int,raw_input().split()) N.sort() N.reverse() f=0 for i in range(n-2): if N[i]-N[i+1]<N[i+2]: j=i f=1 break if f: print N[j+2],N[j+1],N[j] else: print -1 ```
vfc_44477
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n2 3 2 4 6\n3\n2 99 101\n\nSAMPLE", "output": "3 4 6\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5\n2 3 2 4 6\n3\n3 99 101\n\nSAMPLE", "output": "3 4 6\n3 99 101\n", ...
code_contests
verifiable_code
inter-city-travel-3
Solve the following coding problem using the programming language python: A state consists of N cities. Some of these cities are connected to each other by one - way roads. The time taken to travel from a particular city to any other city directly connected to it is 1 hour. The entire map of the state will be given. Y...
```python CONST = 1000000007 def mul(A, B, n, c): C = [] for i in range(n): C.append([0] * n) for i in range(n): for j in range(n): for k in range(n): C[i][j] = (C[i][j] + ((A[i][k] % c) * (B[k][j] % c)) % c) % c return C f = dict() def modExp(A, b, n, c): if b in f: return f[b] if b % 2 == 1: f[b...
vfc_44481
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n7\n1 2\n1 5\n2 5\n2 3\n5 4\n3 4\n4 6\n6\n1 2 1\n2 1 2\n1 4 3\n1 6 3\n1 6 4\n6 1 8\n\nSAMPLE", "output": "1\n0\n2\n1\n2\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "50\n1000\n44 23\n...