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
kth-smallest-number-again-2
Solve the following coding problem using the programming language python: Dexter was good in finding the K th smallest number from a set of numbers. He thought he could solve any problem related to K th smallest number. His friend Pipi challenged him with a problem. He gave him various ranges of number, These numbers ...
```python test = int(raw_input()) for i in range(test): n , q = [int(x) for x in raw_input().split()] arr = [] for i in range(n): arr.append([int(x) for x in raw_input().split()]) arr.sort() a = [0] b = [0] a[0] = arr[0][0] b[0] = arr[0][1] k = 0 for i in range(1 , n): if arr[i][0] > b[k]: k += 1 a....
vfc_49893
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1 3\n1 5\n1\n3\n6\n\nSAMPLE", "output": "1\n3\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n10 30\n765 838\n64 816\n462 725\n440 903\n842 865\n495 735\n376 723\n177 800\n396 ...
code_contests
verifiable_code
monk-and-match-making
Solve the following coding problem using the programming language python: Monk has magical powers, by which he can compare any part of the strings and figure out if they're equal. His magical powers are faster than a super computer even. So, to prove his worth, he's given a string and he has to answer multiple queries...
```python s=raw_input() l=len(s) q=int(raw_input()) for i in xrange(q): L1,R1,L2,R2=map(int,raw_input().split(" ")) a=s[L1-1:R1] b=s[L2-1:R2] if a==b: print "Yes" else: print "No" ```
vfc_49897
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "monkandhismonkiness\n4\n1 1 3 3\n1 4 11 14\n3 3 6 6\n4 5 14 17\n\nSAMPLE", "output": "No\nYes\nYes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "qrstqrstqrstqrstqrstqrstqrstqrstqrstq...
code_contests
verifiable_code
password-1
Solve the following coding problem using the programming language python: Danny has a possible list of passwords of Manny's facebook account. All passwords length is odd. But Danny knows that Manny is a big fan of palindromes. So, his password and reverse of his password both should be in the list. You have to pr...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' n=input() dic={} for i in range(n): passw = raw_input() dic[passw]=1 try: if dic[passw[::-1]]==1: print len(passw), passw[len(passw)/2] except KeyError: continu...
vfc_49901
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nabc\ndef\nfeg\ncba\n\nSAMPLE", "output": "3 b\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "66\npdcvaqrbsvvwc\nfbbebolglhvot\nxkdrcsufrxvly\nqhxqjdrnhscvb\nnfweyxqcptxnb\nrnwdoqmmhyqb...
code_contests
verifiable_code
roy-and-flower-farm
Solve the following coding problem using the programming language python: Roy is the owner of a flower plant farm and sells flower plants for a living. Now the problem with flower plants is that they wither in a night if not taken care of. So at the end of the day, to make flower plants wither-resistant Roy uses spec...
```python def computeDP(totalPlants,lastDaysProfit,fertilizers,profit): # First we find what maximum profit Roy could gain dp = [[0 for x in xrange(lastDaysProfit+1)] for x in xrange(totalPlants+1)] for i in xrange(totalPlants+1): for j in xrange(lastDaysProfit+1): if i == 0 or j == 0: dp[i][j] = 0 elif...
vfc_49905
{ "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 50\n80 40\n60 20\n5 100\n100 40\n50 40\n40 50\n60 20\n100 50\n\nSAMPLE", "output": "20 90\n90 210", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n29 141\n6 92\n67 87\n85 3\n56 56\n7...
code_contests
verifiable_code
utkarsh-and-timed-jumps
Solve the following coding problem using the programming language python: Utkarsh lives in a strange country. The cities of the country are present on x axis. He is currently at a city at x = 0. He needs to reach another city at x = N. Utkarsh can move only in the positive x direction. Also due to massive traffic in t...
```python #Given a number N, find a number Y such as Y > N and Y is sum of first K natural numbers. # K is the answer to the problem. from math import sqrt, floor t = int(raw_input()) for i in range(t): n = int(raw_input()) x = n * 2 y = int(floor(sqrt(x))) k = (y * (y + 1)) / 2 if k >= n: print y else: y +...
vfc_49913
{ "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\n3\n\nSAMPLE", "output": "2\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n24597858934063494\n52948353213749172\n66008909937323155\n81760348535676591\n59094560939797792\n5912019...
code_contests
verifiable_code
p03752 square869120Contest #4 - Buildings are Colorful!
Solve the following coding problem using the programming language python: Input Format N K a_1 a_2 a_3 ... a_N Output Format Print the minimum cost in one line. In the end put a line break. Constraints * 1 ≤ K ≤ N ≤ 15 * 1 ≤ a_i ≤ 10^9 Scoring Subtask 1 [120 points] * N = K Subtask 2 [90 points] * N ≤...
```python n,k=map(int,input().split()) A=list(map(int,input().split())) ans=float("inf") for i in range(1,2**n): num=format(i,"b").zfill(n) point=0 if num.count("1")!=k:continue highest=A[0] for j in range(1,n): if highest>=A[j] and num[j]=="1": point +=highest-A[j]+1 ...
vfc_49949
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n3949 3774 3598 3469 3424", "output": "1541", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00019 Factorial
Solve the following coding problem using the programming language python: Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20. Input An integer n (1 ≤ n ≤ 20) in a line. Output Print the factorial of n in a line. Example Input 5 Output 120 The input will be g...
```python num = int(input()) ans = num for i in range(1, num): ans = ans *i print(ans) ```
vfc_49957
{ "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", "output": "120", "type": "stdin_stdout" }, { "fn_name": null, "input": "3", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4", "outp...
code_contests
verifiable_code
p00150 Twin Prime
Solve the following coding problem using the programming language python: Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs. In this problem, we call the gre...
```python def isPrime(n): for i in range(2,int(n**.5+1)): if n%i==0: return False return True while 1: n=int(input()) if not n:break for i in range(n,1,-1): if isPrime(i) and isPrime(i-2): print(i-2,i) break ```
vfc_49961
{ "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": "12\n100\n200\n300\n0", "output": "5 7\n71 73\n197 199\n281 283", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n110\n200\n300\n0", "output": "5 7\n107 109\n197 199\n281 283\n", ...
code_contests
verifiable_code
p00663 SAT-EN-3
Solve the following coding problem using the programming language python: She was worried. The grades are not good. Although she forced her parents to enroll in a dormitory school, her talent never blossomed. Or maybe he didn't have the talent in the first place, but it was possible that he didn't want to think about ...
```python # AOJ 1078: SAT-EN-3 # Python3 2018.7.10 bal4u def clause(e): f = True dic = {} f = e.split('&') for x in f: pm, t = 1, x[0] if t == '~': pm, t = -1, x[1] if t in dic and dic[t] + pm == 0: f = False dic[t] = pm return f while True: p = input() if p == '#': break exp = list(p.split('|')) ...
vfc_49973
{ "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": "(B&B&f)|(~d&~i&i)|(~v&i&~V)|(~g&~e&o)|(~f&d&~v)|(d&~i&o)|(g&i&~B)|(~i&f&d)|(e&~i&~V)|(~v&f&~d)\n(S&X&~X)\n#", "output": "yes\nno", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00806 77377
Solve the following coding problem using the programming language python: At the risk of its future, International Cellular Phones Corporation (ICPC) invests its resources in developing new mobile phones, which are planned to be equipped with Web browser, mailer, instant messenger, and many other advanced communicatio...
vfc_49977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\npush\npress\nthe\nbutton\nbottom\n77377843288866\n4\ni\nam\ngoing\ngo\n42646464\n3\na\nb\nc\n333\n0", "output": "press the button.\n--\ni am going.\ni am go go i.\n--\n--", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
p01340 Kaeru Jump
Solve the following coding problem using the programming language python: There is a frog living in a big pond. He loves jumping between lotus leaves floating on the pond. Interestingly, these leaves have strange habits. First, a leaf will sink into the water after the frog jumps from it. Second, they are aligned regu...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+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_49993
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 10\n.o....o...\no.oo......\n..oo..oo..\n..o.......\n..oo..oo..\n..o...o.o.\no..U.o....\noo......oo\noo........\noo..oo....", "output": "URRULULDDLUURDLLLURRDLDDDRRDR", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
p01507 Dungeon Creation
Solve the following coding problem using the programming language python: The king demon is waiting in his dungeon to defeat a brave man. His dungeon consists of H \times W grids. Each cell is connected to four (i.e. north, south, east and west) neighboring cells and some cells are occupied by obstacles. To attack th...
vfc_49997
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n..\n..\n3 3\n...\n...\n..#\n0 0", "output": "Case 1: 4\nCase 2: 56", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n..\n..\n3 3\n...\n...\n#..\n0 0", "output": "Case 1: 4\nCas...
code_contests
verifiable_code
p01678 Restore Calculation
Solve the following coding problem using the programming language python: Problem Statement The Animal School is a primary school for animal children. You are a fox attending this school. One day, you are given a problem called "Arithmetical Restorations" from the rabbit teacher, Hanako. Arithmetical Restorations ar...
```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_50001
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3?4\n12?\n5?6\n?2?4\n5?7?\n?9?2\n?????\n?????\n?????\n0", "output": "2\n40\n200039979", "type": "stdin_stdout" }, { "fn_name": null, "input": "3?4\n12?\n5?6\n?1?4\n5?7?\n?9?2\n?????\n?????\n?????\n0"...
code_contests
verifiable_code
p01822 Enclose Points
Solve the following coding problem using the programming language python: Example Input 4 5 3 -10 -10 10 -10 10 10 -10 10 1 2 1 3 1 4 2 3 3 4 -20 0 1 0 20 0 Output No Yes No 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_50005
{ "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": "4 5 3\n-10 -10\n10 -10\n10 10\n-10 10\n1 2\n1 3\n1 4\n2 3\n3 4\n-20 0\n1 0\n20 0", "output": "No\nYes\nNo", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01957 Tournament Chart
Solve the following coding problem using the programming language python: In 21XX, an annual programming contest, Japan Algorithmist GrandPrix (JAG) has become one of the most popular mind sports events. JAG is conducted as a knockout tournament. This year, $N$ contestants will compete in JAG. A tournament chart is r...
```python #!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, ...
vfc_50009
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "[[m-y]-[a-o]]\no 0\na 1\ny 2\nm 0", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "[[r-i]-[m-e]]\ne 0\nr 1\ni 1\nm 2", "output": "No", "type": "stdin_stdout" ...
code_contests
verifiable_code
p02244 8 Queens Problem
Solve the following coding problem using the programming language python: The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. <...
```python from itertools import product def setq(ri,ci,krc): for ir in range(8): if ir!=ri: if krc[ir*8+ci]=="Q": return False,krc else: krc[ir*8+ci]="X" for ic in range(8): if ic!=ci: if krc[ri*8+ic]=="Q": retu...
vfc_50017
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n5 3", "output": "......Q.\nQ.......\n..Q.....\n.......Q\n.....Q..\n...Q....\n.Q......\n....Q...", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 4\n5 3", "output": "..Q.......
code_contests
verifiable_code
p02390 Watch
Solve the following coding problem using the programming language python: Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. Constraints * $0 \leq S \leq 86400$ Input An integer $S$ is give...
```python s=int(input()) a=60 print(f'{s//a**2}:{s//a%a}:{s%a}') ```
vfc_50021
{ "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": "46979", "output": "13:2:59", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
atoms
Solve the following coding problem using the programming language python: Let X be the set of all integers between 0 and n-1. Suppose we have a collection S1, S2, ..., Sm of subsets of X. Say an atom A is a subset of X such that for each Si we have either A is a subset of Si or A and Si do not have any common elements...
```python # CodeChef # Practice # Easy # Breaking Into Atoms ntc = int(raw_input()) for cti in range(ntc): ec, sc = map(int, raw_input().split()) el = [0] * ec for si in range(sc): sb = 1 << si sl = map(int, raw_input().split()[1:]) for se in sl: el[se] |= sb pri...
vfc_50025
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 2\n3 0 1 2\n3 2 3 4\n4 3\n2 0 1\n2 1 2\n2 2 3", "output": "3\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 2\n3 0 1 2\n3 2 3 4\n4 3\n2 0 1\n2 1 2\n2 3 3", "output": "3...
code_contests
verifiable_code
cm03
Solve the following coding problem using the programming language python: Rohit just started his 3rd semester classes in DMS. One of the interesting parts of DMS is set theory. He has just learnt about Power Set of any set, which is the number of ways in which you can create a unique subset from the existing set. Two ...
```python t= input() for _ in range(t): res= input() print pow(2, res, 1000000007) ```
vfc_50029
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n3", "output": "2\n8", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n0", "output": "2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
flow009
Solve the following coding problem using the programming language python: While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000. If the quantity and price per item are input, write a program to calculate the total expenses. Input The first line contains an integer ...
```python DEBUG = False def print_debug(s): if DEBUG: print str(s); def calculate(quantity, price): return (quantity * price) * (0.9 if quantity > 1000 else 1.0) def run(): print_debug('Number of entries:') lines = int(raw_input()) while (lines > 0): print_debug("Entry in format '%f %f' a...
vfc_50033
{ "difficulty": "1", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 \n100 120\n10 20\n1200 20", "output": "12000.000000\n200.000000\n21600.000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 \n100 120\n10 20\n1200 40", "output": "12000.000000\...
code_contests
verifiable_code
lelouch1
Solve the following coding problem using the programming language python: Problem Statement Lelouch is one of the famous business men in Japan. One day on his way from 'Tokyo' to 'Kyoto', His vehicle is supposed to cross a CheckPoint. CheckPoint has N gates and at i th gate there are already X_i vehicles standing in a...
```python import sys n = int(sys.stdin.readline()) sys.stdin.readline() times = {'S': 1, 'C': 2, 'B': 3, 'T': 4} minn = 1000000 minni = 0 for i in xrange(n): summ = sum([times[j] for j in sys.stdin.readline().split()]) if summ < minn: minn, minni = summ, i print minni + 1 ```
vfc_50037
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3 2\nS C B\nC B T\nT T", "output": "1", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
ppnum
Solve the following coding problem using the programming language python: Polo, the Penguin, likes numbers. He says that the goodness of a number is itself multiplied by the number of digits in it's decimal representation. For example, the goodness of the integer 474 is 474*3 = 1422. Help him to count the sum of goodn...
```python import sys import math t= int(sys.stdin.readline()) while(t>0) : t = t-1 l,r = sys.stdin.readline().split(' ') l = int(l) r = int(r) cat1 = int(math.log10(l)); cat2 = int(math.log10(r)); if cat1==cat2: sum = (r*(r+1)/2 - (l*(l-1)/2))*(cat1+1); print sum%1000000007 else: cat1 = cat1+1 num1 = ...
vfc_50041
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n9 12", "output": "75\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n9 16", "output": "191\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
summath
Solve the following coding problem using the programming language python: Find sum of all the numbers that are multiples of 10 and are less than or equal to a given number "N". (quotes for clarity and be careful of integer overflow)   Input Input will start with an integer T the count of test cases, each case will ha...
```python import math for _ in range(input()): n=input() s=int(math.floor(n//10)) print ((s*(s+1))/2)*10 ```
vfc_50045
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10", "output": "10", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
100_H. Battleship
Solve the following coding problem using the programming language python: Do you know the game Battleship? If no, look into Wikipedia article http://en.wikipedia.org/wiki/Battleship_(game). You are given the positions of ships on a 10 × 10 board for playing Battleship. According to the rules, the board should contain ...
vfc_50049
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 64000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n****000000\n0000000000\n***00***00\n0000000000\n00000000**\n000**00000\n00000000**\n000*000000\n00000*00*0\n0*00000000\n\n****000000\n0000000000\n***00***00\n0000000000\n00000000**\n000**00000\n00000000**\n0000*00000\n00000*00*0...
code_contests
verifiable_code
1033_E. Hidden Bipartite Graph
Solve the following coding problem using the programming language python: Bob has a simple undirected connected graph (without self-loops and multiple edges). He wants to learn whether his graph is bipartite (that is, you can paint all vertices of the graph into two colors so that there is no edge connecting two verti...
vfc_50053
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n0\n1\n1\n1\n0", "output": "? 3\n2 3 4 \n? 2\n1 2 \n? 2\n1 3 \n? 2\n2 4 \n? 3\n1 2 4 \n? 2\n2 3 \n? 2\n1 4 \nY 2\n1 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n4\n3", ...
code_contests
verifiable_code
1056_C. Pick Heroes
Solve the following coding problem using the programming language python: Don't you tell me what you think that I can be If you say that Arkady is a bit old-fashioned playing checkers, you won't be right. There is also a modern computer game Arkady and his friends are keen on. We won't discuss its rules, the only fea...
```python # -*- coding:utf-8 -*- """ created by shuangquan.huang at 12/14/18 """ import collections import time import os import sys import bisect import heapq N, M = map(int, input().split()) P = [0] + [int(x) for x in input().split()] A = [0 for _ in range(2*N+1)] pairs = [] for i in range(M): a, b = map(in...
vfc_50057
{ "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 1\n1 2 3 4 5 6\n2 6\n1\n\n2\n\n4\n\n1\n", "output": "6\n5\n3\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1078_D. Chattering
Solve the following coding problem using the programming language python: There are n parrots standing in a circle. Each parrot has a certain level of respect among other parrots, namely r_i. When a parrot with respect level x starts chattering, x neighbours to the right and to the left of it start repeating the same ...
vfc_50061
{ "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": "8\n1 2 2 1 5 1 3 1\n", "output": "3 3 2 2 1 2 2 3 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1099_D. Sum in the tree
Solve the following coding problem using the programming language python: Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the vertice...
```python import sys def getAndParseInt(num=1): string = (sys.stdin.readline()).strip() if num==1: return int(string) else: return [int(part) for part in string.split()] def getAndParseString(num=1,delim=" "): string = (sys.stdin.readline()).strip() if num==1: return string ...
vfc_50065
{ "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\n2 -1 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 1\n1 -1 2 -1 -1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
111_C. Petya and Spiders
Solve the following coding problem using the programming language python: Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. Ther...
```python def f(n,m): if n<m:return f(m,n) if m==1: return (n+2)/3 if m==2: return (n+2)/2 if m==3: return (3*n+4)/4 if m==4: if n==5 or n==6 or n==9:return n+1 else:return n if m==5: if n==7:return (6*n+6)/5 else:return (6*n+8)/5 if m==6: if n%7==1:return (10*n+10)/7 ...
vfc_50069
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 31\n"...
code_contests
verifiable_code
1146_H. Satanic Panic
Solve the following coding problem using the programming language python: You are given a set of n points in a 2D plane. No three points are collinear. A pentagram is a set of 5 points A,B,C,D,E that can be arranged as follows. <image> Note the length of the line segments don't matter, only that those particular inte...
vfc_50073
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 0\n4 0\n0 4\n4 4\n2 3\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1168_A. Increasing by Modulo
Solve the following coding problem using the programming language python: Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n. In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≤ i_1 < i_2 < … < i_k ≤ n. He should th...
```python def check(mid,arr,n,m): prev=0 for i in range(n): if(arr[i]>prev): t=m-(arr[i]-prev) if(t>mid): prev=arr[i] else: t=prev-arr[i] if(t>mid): return False return True n,m=map(int,input().split()) arr=list(map(int,input().split())) lo=0 hi=m while(lo<=hi): mid=(lo+hi)//2 if(check(mid,...
vfc_50077
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n0 0 0 1 2\n", "output": "0\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1186_D. Vus the Cossack and Numbers
Solve the following coding problem using the programming language python: Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either ⌊ a_i ⌋ or ⌈ a_i ⌉. In other words...
```python import heapq import math n=int(input()) a=[None]*n h=[] mh=[] s=0 d=[0]*n for i in range(n): a[i]=float(input()) if a[i]!=int(a[i]): if a[i]<0: heapq.heappush(h,[math.floor(a[i])-math.ceil(a[i]),i]) else: heapq.heappush(mh,[math.ceil(a[i])-math.floor(a[i]),i]) ...
vfc_50081
{ "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\n4.58413\n1.22491\n-2.10517\n-3.70387\n", "output": "5\n2\n-3\n-4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1205_C. Palindromic Paths
Solve the following coding problem using the programming language python: This is an interactive problem You are given a grid n× n, where n is odd. Rows are enumerated from 1 to n from up to down, columns are enumerated from 1 to n from left to right. Cell, standing on the intersection of row x and column y, is denot...
```python n = int(input()) a=[] for i in range(0,n+1): temp= [0]*(n+1) a.append(temp) a[1][1]=1 def ask(x1,y1,x2,y2): print("?",x1,y1,x2,y2) a= int(input()) if a: return True else: False for i in range(3,n+1,1): a[1][i] = a[1][i-2]^(not(ask(1,i-2,1,i))) for i in range(2...
vfc_50085
{ "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\n0\n1\n0\n1\n1\n1\n1", "output": "? 1 1 1 3\n? 1 1 2 2\n? 1 1 3 1\n? 1 2 2 3\n? 1 2 3 2\n? 2 1 3 2\n? 1 1 3 2\n!\n110\n111\n010\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11\n110100...
code_contests
verifiable_code
1248_D1. The World Is Just a Programming Task (Easy Version)
Solve the following coding problem using the programming language python: This is an easier version of the problem. In this version, n ≤ 500. Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted ...
```python import sys input = sys.stdin.readline def matcher(correcti): open_=0 close_=0 count=0 excess=0 for i in range(len(correcti)): if correcti[i]=='(': open_+=1 if correcti[i]==')': close_+=1 if close_>open_ and open_==0: excess+=1 ...
vfc_50093
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12\n)(()(()())()\n", "output": "4\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n()()())(()\n", "output": "5\n7 8\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
1288_C. Two Arrays
Solve the following coding problem using the programming language python: You are given two integers n and m. Calculate the number of pairs of arrays (a, b) such that: * the length of both arrays is equal to m; * each element of each array is an integer between 1 and n (inclusive); * a_i ≤ b_i for any index i...
```python '''input 10 1 ''' # A coding delight from sys import stdin, stdout import gc gc.disable() input = stdin.readline import math # main starts n, m = list(map(int, input().split())) mod = 10 ** 9 + 7 dp1 = [[1 for x in range(m + 1)] for y in range(n + 1)] dp2 = [[1 for y in range(m + 1)] for y in range(n + 1)] ...
vfc_50101
{ "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": "723 9\n", "output": "157557417\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
1331_F. Elementary!
Solve the following coding problem using the programming language python: Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO ...
```python z="QWERTYUIOPASDFGHJKLZXCVBNM" t="01101101001001010111101011" s = input() cur = '-' for i in s: for j in range(26): if z[j] == i: if cur == '-': cur = t[j] elif t[j] != cur: print('NO') exit(0) print('YES') ```
vfc_50109
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "DOCTOR\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "SMARTPHONE\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
code_contests
verifiable_code
1352_A. Sum of Round Numbers
Solve the following coding problem using the programming language python: A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from...
```python import sys num_lines = int(input()) for i in range(num_lines): cont = 0 resp = '' whole_number = sys.stdin.readline().strip('\n') length = len(whole_number) - 1 for idx, k in enumerate(whole_number): if k != '0': cont += 1 num = int(k) * 10 **...
vfc_50113
{ "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\n5009\n7\n9876\n10000\n10\n", "output": "2\n5000 9\n1\n7\n4\n9000 800 70 6\n1\n10000\n1\n10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n954\n18\n", "output": "3\n900 50 4\n2...
code_contests
verifiable_code
1371_E2. Asterism (Hard Version)
Solve the following coding problem using the programming language python: This is the hard version of the problem. The difference between versions is the constraints on n and a_i. You can make hacks only if all versions of the problem are solved. First, Aoi came up with the following idea for the competitive programm...
```python import sys import math from math import factorial, inf, gcd, sqrt from heapq import * from functools import * from itertools import * from collections import * from typing import * from bisect import * import random sys.setrecursionlimit(10**5) def rarray(): return [int(i) for i in input().split()] t ...
vfc_50117
{ "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 3\n2 3 5 6\n", "output": "2\n3 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1000000000 1 999999999\n", "output": "1\n999999998 \n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
1394_C. Boboniu and String
Solve the following coding problem using the programming language python: Boboniu defines BN-string as a string s of characters 'B' and 'N'. You can perform the following operations on the BN-string s: * Remove a character of s. * Remove a substring "BN" or "NB" of s. * Add a character 'B' or 'N' to the end ...
vfc_50121
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nB\nN\nBN\n", "output": "1\nBN\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nBNNNBNNNNBNBBNNNBBNNNNBBBBNNBBBBBBNBBBBBNBBBNNBBBNBNBBBN\nBBBNBBBBNNNNNBBNBBBNNNBB\nBBBBBBBBBBBBBBNBBBBB...
code_contests
verifiable_code
1419_A. Digit Game
Solve the following coding problem using the programming language python: Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is gen...
```python for _ in range(int(input())): a = int(input()) number = input() raze = [0,0] #odd,even breach = [0,0] #odd,even count = 0 while count<len(number): if count%2==0: if int(number[count])%2==0: raze[1]+=1 else: r...
vfc_50125
{ "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\n2\n1\n3\n3\n102\n4\n2069\n", "output": "2\n1\n1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n33\n200000000000000000000000000000022\n", "output": "2\n", "type": "...
code_contests
verifiable_code
1461_E. Water Level
Solve the following coding problem using the programming language python: In recent years John has very successfully settled at his new job at the office. But John doesn't like to idly sit around while his code is compiling, so he immediately found himself an interesting distraction. The point of his distraction was t...
```python k, l, r, t, x, y = map(int, input().split()) k -= l r -= l l = 0 if k < x - y or (k > r - y and k < x): print("No") exit() if x > y: if k + y > r: k -= x t -= 1 print("Yes" if t <= k // (x - y) else "No") else: if l + x + y - r <= 1: print("Yes") exit() ...
vfc_50133
{ "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": "9 1 10 9 2 9\n", "output": "\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 1 10 2 6 5\n", "output": "\nYes\n", "type": "stdin_stdout" }, { "fn_name": null...
code_contests
verifiable_code
1486_F. Pairs of Paths
Solve the following coding problem using the programming language python: You are given a tree consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs (i, j) (1 ≤ i < j ≤ m) such that pat...
vfc_50137
{ "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": "1\n3\n1 1\n1 1\n1 1\n", "output": "\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2\n", "output": "\n7\n", "type": "st...
code_contests
verifiable_code
1510_H. Hard Optimization
Solve the following coding problem using the programming language python: You are given a set of n segments on a line [L_i; R_i]. All 2n segment endpoints are pairwise distinct integers. The set is laminar — any two segments are either disjoint or one of them contains the other. Choose a non-empty subsegment [l_i, r...
vfc_50141
{ "difficulty": "14", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 10\n2 3\n5 9\n6 7\n", "output": "\n7\n3 6\n2 3\n7 9\n6 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n72 85\n17 70\n54 65\n22 33\n", "output": "56\n72 85\n33 54\n54 65\n22...
code_contests
verifiable_code
164_B. Ancient Berland Hieroglyphs
Solve the following coding problem using the programming language python: Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hieroglyphs. We know that no hieroglyph occurs twice in either the first or the second circle (but in ...
vfc_50149
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2 3\n3 2 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4\n1 2 3 4 5\n1 3 5 6\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
185_C. Clever Fat Rat
Solve the following coding problem using the programming language python: The Fat Rat and his friend Сerealguy have had a bet whether at least a few oats are going to descend to them by some clever construction. The figure below shows the clever construction. <image> A more formal description of the clever construct...
```python # Clever Fat Rat import time from datetime import datetime import itertools max_oats = 10**6 + 1 def is_goal(state): (a, ws) = state if(len(ws) == 1 and ws[0][0] <= a[0]): return True def child(state): (a, ws) = state scales = ws[0] if(len(ws) == 1): return...
vfc_50153
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n1 2\n5\n", "output": "Fat Rat\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 2\n1 2\n4\n", "output": "Cerealguy\n", "type": "stdin_stdout" }, { "fn_...
code_contests
verifiable_code
207_D1. The Beaver's Problem - 3
Solve the following coding problem using the programming language python: The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem: Y...
```python print('1') ```
vfc_50157
{ "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": "36000\nU.K. MONEY MARKET DEFICIT REMOVED\nLONDON, April 9 - The Bank of England said it has satisfied\nits revised estimate of today's shortfall in the money market,\nproviding 261 mln stg assistance in afternoon operations.\nThe B...
code_contests
verifiable_code
231_D. Magic Box
Solve the following coding problem using the programming language python: One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of i...
```python x,y,z=map(int,input().split()) a,b,c=map(int,input().split()) a1,a2,a3,a4,a5,a6=map(int,input().split()) sum=0 if x>a: sum+=a6 if x<0: sum+=a5 if y>b: sum+=a2 if y<0: sum+=a1 if z>c: sum+=a4 if z<0: sum+=a3 print(sum) ```
vfc_50161
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 2\n1 1 1\n1 2 3 4 5 6\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0 10\n3 2 3\n1 2 3 4 5 6\n", "output": "4\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
257_C. View Angle
Solve the following coding problem using the programming language python: Flatland has recently introduced a new type of an eye check for the driver's licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex at the origin of coor...
```python import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br...
vfc_50165
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 0\n0 2\n", "output": "90.000000000000", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 1\n1 2\n", "output": "36.869897645844", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
303_B. Rectangle Puzzle II
Solve the following coding problem using the programming language python: You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m). Your task is to find a maximum sub-r...
```python from fractions import gcd n, m, x, y, a, b = map(int, input().split()) r = gcd(a, b) a, b = a // r, b // r r = min(n // a, m // b) a, b = a * r, b * r cx, cy = (a + 1) // 2, (b + 1) // 2 dx, dy = min(n - a, max(cx, x) - cx), min(m - b, max(cy, y) - cy) print(dx, dy, a + dx, b + dy) # Made By Most...
vfc_50173
{ "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": "100 100 52 50 46 56\n", "output": "17 8 86 92\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 9 5 5 2 1\n", "output": "1 3 9 7\n", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
351_A. Jeff and Rounding
Solve the following coding problem using the programming language python: Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: * cho...
```python n, k, s = int(input()), 0, 0 for i in input().split(): j = int(i[-3: ]) if j == 0: k += 1 else: s += j c = s // 1000 + int(s % 1000 > 500) a, b = max(0, n - k), min(2 * n - k, n) if a <= c <= b: s = abs(c * 1000 - s) else: s = min(abs(a * 1000 - s), abs(b * 1000 - s)) print(str(s // 1000) + '.' + ...
vfc_50181
{ "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\n0.000 0.500 0.750 1.000 2.000 3.000\n", "output": "0.250\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4469.000 6526.000 4864.000 9356.383 7490.000 995.896\n", "output": "0.2...
code_contests
verifiable_code
375_B. Maximum Submatrix 2
Solve the following coding problem using the programming language python: You are given a matrix consisting of digits zero and one, its size is n × m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described op...
```python ''' from bisect import bisect,bisect_left from collections import * from math import gcd,ceil,sqrt,floor,inf from heapq import * from itertools import * from operator import add,mul,sub,xor,truediv,floordiv from functools import *''' #------------------------------------------------------------------------ ...
vfc_50185
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n100\n011\n000\n101\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
397_D. On Sum of Fractions
Solve the following coding problem using the programming language python: Let's assume that * v(n) is the largest prime number, that does not exceed n; * u(n) is the smallest prime number strictly greater than n. Find <image>. Input The first line contains integer t (1 ≤ t ≤ 500) — the number of testscases...
```python T = int( input() ) #for every prime x #(b-a)/ab #1/a-1/b MAX = 33000 bePrime = [0] * MAX; primNum = [] for j in range(2, MAX): if bePrime[j] == 0: primNum.append( j ) i = j while i < MAX: bePrime[i] = 1 i = i + j def isPrime( a ): for j in primNum:...
vfc_50189
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n3\n", "output": "1/6\n7/30\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
446_C. DZY Loves Fibonacci Numbers
Solve the following coding problem using the programming language python: In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2). DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of n integers: a1, ...
vfc_50197
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 2 3 4\n1 1 4\n2 1 4\n1 2 4\n2 1 3\n", "output": "17\n12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 20\n56 12 68 23 41 29 97 69 79 76\n1 3 5\n1 8 9\n2 3 10\n1 7 10\n2 1 10\n1...
code_contests
verifiable_code
468_D. Tree
Solve the following coding problem using the programming language python: Little X has a tree consisting of n nodes (they are numbered from 1 to n). Each edge of the tree has a positive length. Let's define the distance between two nodes v and u (we'll denote it d(v, u)) as the sum of the lengths of edges in the short...
vfc_50201
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 2\n1 3 3\n2 4 4\n2 5 5\n", "output": "32\n2 1 4 5 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2 3\n", "output": "6\n2 1 \n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
490_D. Chocolate
Solve the following coding problem using the programming language python: Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a1 × b1 segments large and the second one is a2 × b2 segments large. Polycarpus wants to give...
```python def decomp(a): cnt2 = 0 while a%2==0: a = a//2 cnt2 += 1 cnt3 = 0 while a%3==0: a = a//3 cnt3 += 1 return a,cnt2,cnt3 def cut(a,b,d,p): while d>0: if a%p==0: a = (p-1)*a//p d = d-1 elif b%p==0: b = (p-...
vfc_50205
{ "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": "36 5\n10 16\n", "output": "3\n16 5\n5 16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n2 1\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
514_D. R2D2 and Droid Army
Solve the following coding problem using the programming language python: An army of n droids is lined up in one row. Each droid is described by m integers a1, a2, ..., am, where ai is the number of details of the i-th type in this droid's mechanism. R2-D2 wants to destroy the sequence of consecutive droids of maximum...
```python # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq,bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(1...
vfc_50209
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 4\n4 0\n1 2\n2 1\n0 2\n1 3\n", "output": "2 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 4\n1 2\n1 3\n2 2\n", "output": "1 3 \n", "type": "stdin_stdout" }, ...
code_contests
verifiable_code
569_A. Music
Solve the following coding problem using the programming language python: Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk. Unfortunately, internet is not that fast in the city of Ekateri...
```python T, S, q = map(int, input().split()) count = 0 while True: count += 1 ds = S * (q - 1) S += ds if S >= T: break print(count) ```
vfc_50217
{ "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 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4...
code_contests
verifiable_code
58_D. Calendar
Solve the following coding problem using the programming language python: BerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly n / 2 lines of strictly...
```python # t = int(input()) # while t>0: n = int(input()) // 2 a = sorted([input() for i in range(n * 2)], reverse=1) d = input() L = sum(len(i) for i in a) // n ans = [] for i in range(n): x = a.pop() for y in a[::-1]: if len(x) + len(y) == L: ans.append(min(x + d + y, y + d + x)) ...
vfc_50221
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nb\naa\nhg\nc\n.\n", "output": "aa.b\nc.hg\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\naa\na\n!\n", "output": "a!aa\n", "type": "stdin_stdout" }, { "fn_n...
code_contests
verifiable_code
611_F. New Year and Cleaning
Solve the following coding problem using the programming language python: Limak is a little polar bear. His parents told him to clean a house before the New Year's Eve. Their house is a rectangular grid with h rows and w columns. Each cell is an empty square. He is a little bear and thus he can't clean a house by him...
vfc_50225
{ "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 1 500000\nRLRL\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 6\nRUL\n", "output": "134\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
631_C. Report
Solve the following coding problem using the programming language python: Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes correspond...
```python def compress(ops): cops = [] for r, dir in ops: while cops and cops[-1][0] <= r: cops.pop() if not cops or cops[-1][1] != dir: cops.append((r, dir)) return cops def transform(lst, ops): mr, mdir = ops[0] sections = [range(mr, len(lst))] ost =...
vfc_50229
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n1 2 3\n2 2\n", "output": "2 1 3 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
660_A. Co-prime Array
Solve the following coding problem using the programming language python: You are given an array of n elements, you must make it a co-prime array in as few moves as possible. In each move you can insert any positive integral number you want not greater than 109 in any place in the array. An array is co-prime if any ...
```python def gcd(x, y): if y == 0: return x return gcd(y, x % y) n = int(input()) a = list(map(int, input().split())) last = 1 ans = [] for i in range(n): if gcd(a[i], last) != 1: ans.append(1) ans.append(a[i]) last = a[i] print(len(ans) - n) for i in range(len(a...
vfc_50233
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 7 28\n", "output": "1\n2 7 1 28 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
683_E. Hammer throwing
Solve the following coding problem using the programming language python: n athletes take part in the hammer throw. Each of them has his own unique identifier — the integer from 1 to n (all athletes have distinct identifiers). After the draw, the order in which the athletes will throw the hammer has been determined (t...
vfc_50237
{ "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\n2 0 1 0\n", "output": "2 4 1 3 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n2 2 0 1 1 0\n", "output": "3 6 1 2 4 5 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
729_F. Financiers Game
Solve the following coding problem using the programming language python: This problem has unusual memory constraint. At evening, Igor and Zhenya the financiers became boring, so they decided to play a game. They prepared n papers with the income of some company for some time periods. Note that the income can be posi...
vfc_50245
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n-4 -2 4 5\n", "output": "-13", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3 1\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
74_B. Train
Solve the following coding problem using the programming language python: A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wago...
```python n, rider, cop = map(int, input().split()) rider, cop = rider - 1, cop - 1 if input().strip() == 'to head': cop_dir = -1 else: cop_dir = 1 for pos, ch in enumerate(input().strip()): #print(pos, ch, rider, cop, cop_dir) if ch == '1': rider = -1 else: if cop_dir == -1 and ride...
vfc_50249
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 2\nto head\n0001001\n", "output": "Stowaway\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2 1\nto tail\n0001\n", "output": "Controller 2\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
797_F. Mice and Holes
Solve the following coding problem using the programming language python: One day Masha came home and noticed n mice in the corridor of her flat. Of course, she shouted loudly, so scared mice started to run to the holes in the corridor. The corridor can be represeted as a numeric axis with n mice and m holes on it. i...
vfc_50257
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2\n10 20 30 40 50 45 35\n-1000000000 10\n1000000000 1\n", "output": "7000000130\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n6 2 8 9\n3 6\n2 1\n3 6\n4 7\n4 7\n", "output": ...
code_contests
verifiable_code
864_A. Fair Game
Solve the following coding problem using the programming language python: Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number ...
```python #python3 #utf-8 from collections import Counter cards_nr = int(input()) number_counter = Counter() for _ in range(cards_nr): curr_number = int(input()) number_counter[curr_number] += 1 if len(number_counter) != 2: print('NO') else: num1, num2 = list(number_counter) if number_counter[num...
vfc_50269
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6\n6\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1\n1\n2\n2\n3\n3\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
889_E. Mod Mod Mod
Solve the following coding problem using the programming language python: You are given a sequence of integers a1, a2, ..., an. Let <image>, and <image> for 1 ≤ i < n. Here, <image> denotes the modulus operation. Find the maximum value of f(x, 1) over all nonnegative integers x. Input The first line contains a sing...
vfc_50273
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 4 3 2 1\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 10 5 10\n", "output": "16\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
912_C. Perun, Ult!
Solve the following coding problem using the programming language python: A lot of students spend their winter holidays productively. Vlad has advanced very well in doing so! For three days already, fueled by salads and tangerines — the leftovers from New Year celebration — he has been calibrating his rating in his fa...
```python from sys import stdin from collections import defaultdict from itertools import repeat def main(): n, m = map(int, stdin.readline().split()) b, inc, d = map(int, stdin.readline().split()) dat = map(int, stdin.read().split(), repeat(10, 3 * (n + m))) j = n * 3 ev = [[] for _ in xrange(n)] ...
vfc_50277
{ "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\n1000 10 50\n70 5 5\n90 70 1\n110 20 2\n20 2 10\n30 3 10\n", "output": "3000", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
960_E. Alternating Tree
Solve the following coding problem using the programming language python: Given a tree with n nodes numbered from 1 to n. Each node i has an associated value V_i. If the simple path from u_1 to u_m consists of m nodes namely u_1 → u_2 → u_3 → ... u_{m-1} → u_{m}, then its alternating function A(u_{1},u_{m}) is define...
```python import sys range = xrange input = raw_input MOD = 10**9 + 7 def exclusive(A, base = 0, f = lambda a,b: a + b): n = len(A) B = [base] * n for bit in reversed(range(n.bit_length())): for i in reversed(range(n)): B[i] = B[i // 2] for i in range(n & ~(bit == 0)): ...
vfc_50285
{ "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\n-4 1 5 -2\n1 2\n1 3\n1 4\n", "output": "40\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n-2 6 -4 -4 -9 -3 -7 23\n8 2\n2 3\n1 4\n6 5\n7 6\n4 7\n5 8\n", "output": "4\n", ...
code_contests
verifiable_code
988_B. Substrings Sort
Solve the following coding problem using the programming language python: You are given n strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings. String a is a substring of string b...
```python # We are the all singing all dancing crap of the world n = int(input()) khela = [] for i in range(n): s = input() khela.append([len(s),s]) khela = sorted(khela) if (n==1): print('YES') print(khela[0][1]) else: lent = len(khela) for i in range(lent-1): c = ...
vfc_50289
{ "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\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na\nba\naba\naba\n...
code_contests
verifiable_code
alternating-sequences-3
Solve the following coding problem using the programming language python: Given an array a of N integers a1, a2, a3, ... aN you have to find the longest alternating sub-sequence of this array . An alternating sequence b1, b2 ... bk, k ≥ 1 is a sequence that has the 2 following properties: 1.|b1|<|b2|<|b3|<.....<|bk...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' import math n=int(raw_input()) arr=map(int,raw_input().split(' ')) matrix=[1]*(n) for j in range(n): for i in range(j): if (arr[j] > 0 and arr[i] <0) and abs(arr[j...
vfc_50293
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 2 -2 -3 5 -7 -8 10\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n1 2 -2 -3 5 -7 -8 19\n\nSAMPLE", "output": "5\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
call-list-4
Solve the following coding problem using the programming language python: Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers: •Emergency 911 •Vidhant 97625 99944 •Bob 91125 42682 In this case, it’s not po...
```python from sys import stdin t = int(stdin.readline()) for tt in xrange(t): n = int(stdin.readline()) a = [] for i in xrange(n): x = stdin.readline().strip() a.append(x) valid = 1 a.sort() for i in xrange(n-1): for j in xrange(i+1,i+2): if a[j].startswith(a[i]): valid = 0;break if valid==0: b...
vfc_50297
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n911\n97625999\n91125426\n5\n113\n12340\n123440\n12345\n98346\n\nSAMPLE", "output": "NO\nYES", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
dee-dees-shopping-1
Solve the following coding problem using the programming language python: Dee Dee went to market to buy some eggs. There are 2 type of egg cartons available in the shop. One type contains 6 eggs and the other type contains 8 eggs. Dee Dee wants to buy exactly N eggs. Calculate the minimal number of egg cartons she mus...
```python x=input() for i in range(0,x): y=input() c=0 t=y while True: if t%8==0: t-=8 c+=1 elif t%6==0: t-=6 c+=1 else: t-=8 c+=1 if t==0: print c break if t<6: print "-1" break ```
vfc_50301
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n20\n24\n\nSAMPLE", "output": "3\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "23\n19\n20\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\n100\n44\n30\n32\n50\n26\n28\n72\n60\n58\n88", ...
code_contests
verifiable_code
game-of-subsets-1
Solve the following coding problem using the programming language python: Thomson is very weak in set theory. Recently, he came across the following problem: Given a set X with N distinct elements, in how many ways can you select two sets A and B such that both A and B are subsets of X and A is also a subset of B. Hel...
```python noOfTestCases = int(raw_input()) div = pow(10,9) + 7 for caseNo in range(1, noOfTestCases + 1): elmentCount = int(raw_input()) print pow(3,elmentCount, div) ```
vfc_50305
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9\n50\n\nSAMPLE", "output": "19683\n710104287\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n9\n50\n\nSALPLE", "output": "19683\n710104287\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
kriti-and-her-birthday-gift
Solve the following coding problem using the programming language python: Today is Kriti's birthday but I forgot to bring a gift for her. She is very angry with me. I have an idea for a gift. She likes coding very much. Why not give her a problem to solve as her gift? I know a problem but I am not sure whether its so...
```python def hash_value(s): a = [ord(i)-97 for i in s] p = 0 b = 0 #hv = 10**9 + 7 for i in xrange(len(a)-1,-1,-1): p+=(a[i]*(26**b)) #p%=hv b+=1 return p t = input() all_str = {} for i in xrange(t): xy = hash_value(raw_input()) if xy in all_str: all_str[xy]+=[i] else: all_str[xy]=[i] n = input() fo...
vfc_50309
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nabc\ndef\nabc\n3\n1 2 abc\n1 3 abc\n1 2 hgj\n\nSAMPLE", "output": "1\n2\n0", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nabc\ndef\nabc\n3\n1 4 abc\n1 3 abc\n1 2 hgj\n\nSAMPLE", ...
code_contests
verifiable_code
monk-and-his-friend
Solve the following coding problem using the programming language python: Monk has a very good friend, Puchi. As weird as his name, are the games he plays. One fine day, they decided to play a game to test how diverse their choices are. Both of them choose exactly one integer each. Monk chooses an integer M and Puchi...
```python import sys t=int(raw_input('')) for i in range(1,t+1,1): count=0 p,m=raw_input('').split() p=int(p) m=int(m) s1="{0:b}".format(p) s2="{0:b}".format(m) if len(s1)<len(s2): for j in range(1,len(s2)-len(s1)+1,1): s1='0'+s1 else: for j in range(1,len(s1)-len(s2)+1,1): s2='0'+s2 for j in ran...
vfc_50313
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 4\n3 3\n5 1\n8 7\n\nSAMPLE", "output": "2\n0\n1\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 4\n3 1\n5 1\n4 0\n3 1", "output": "2\n1\n1\n1\n1\n", "type": "stdin...
code_contests
verifiable_code
parenthesis-sequence
Solve the following coding problem using the programming language python: Today professor Ka has given a string task to Oz and RK. He has given a string STR consisting only of characters '(' and ')' and asked them to convert the string STR into a closed one by adding parenthesis to start and/or end of string STR. Th...
```python class Stack: def __init__(self): self.data = list() def push(self, value): self.data.append(value) def empty(self): if len(self.data): return False else: return True def pop(self): if not self.empty(): self.data.pop...
vfc_50317
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n)(\n\nSAMPLE", "output": "()()\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n((\n)(\n(((())))\n)()(\n()\n)((()\n())(\n)(((()(((()(\n)()()(\n()))())(()())(()()(()((()()(()()()())()...
code_contests
verifiable_code
roy-and-coding-contest
Solve the following coding problem using the programming language python: Roy is going to organize Finals of Coding Contest in his college's computer labs. According to the rules of contest, problem statements will be available on each computer as pdf file. Now there are N number of computers and only one of them has...
```python tc = int(raw_input()) c = [] for i in range(0, tc): count = 0 dc = 1 dp = 0 str = raw_input() N, M = map(int, str.split()) dnc = N - 1 dnp = M while dnc and dnp: count = count + 1 x = dp + min(dc, dnp) y = dc + min(dp, dnc) dnp = dnp - min(dnp, dc) dnc = dnc - min(dnc, dp) dp = x dc = y ...
vfc_50321
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n891404 114455\n610316 163967\n749122 997845\n190654 103521\n603077 94067\n155081 68879\n868235 163648\n892190 750264\n81323 808101\n249009 507040\n546018 794692\n467431 985208\n708086 648973\n368128 291957\n737517 66792\n23579...
code_contests
verifiable_code
string-permutations-1
Solve the following coding problem using the programming language python: You are given a list of names. Your task is to find all the distinct names in the list and after that find the frequency count of all these distinct names in the origninal list. We are interested in the maximum value of the frequency. You have t...
```python t=input() d=dict() for i in range(t): s=raw_input() if s not in d: d[s]=1 else: d[s]+=1 #print sorted(d,key=d.get,reverse=True) q=sorted(d,key=d.get,reverse=True) li=dict() sum=d[q[0]] li[q[0]]=d[q[0]] for i in range(1,len(q)): if d[q[i]]==sum: li[q[i]]=d[q[i]] res=0 for i in li...
vfc_50325
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\nveronica\nbill\nmark\nveronica\nbill\nkevin\nhillary\njack\n\nSAMPLE", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\namit\nabcdefghijklmnopqrstuvwxyzabcdefgghhhhhhh\...
code_contests
verifiable_code
utkarsh-and-faulty-rain-gauge-february-easy-1
Solve the following coding problem using the programming language python: Utkarsh is going to Cherrapunji to visit his brother Saharsh. Cherrapunji faces one of largest rainfall in the country. So, Saharsh and Utkarsh decided to measure this rainfall by T Rain Gauges. They were going to measure it by taking the produc...
```python T = int(raw_input()) ans = 1 for i in xrange(T): n, r = map(int, raw_input().split()) x, y = 0, 0 for j in xrange(1,n+1): z = (j*1.0)/(r*1.0) x = x + z**3 y = y + z**2 x = x/y ans = ans * x print "%.4f" % ans ```
vfc_50329
{ "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 4\n2 5\n\nSAMPLE", "output": "0.1620\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 4\n2 5\n\nSAMPLE", "output": "0.2314\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p00015 National Budget
Solve the following coding problem using the programming language python: A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or ...
```python p = int(input()) for j in range(p): a, b = int(input()), int(input()) x = str(a+b) print("overflow" if len(x)>80 else a+b) ```
vfc_50373
{ "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": "6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n10...
code_contests
verifiable_code
p00147 Fukushimaken
Solve the following coding problem using the programming language python: "Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissati...
```python # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0147 """ import sys from sys import stdin from heapq import heappop, heappush from collections import deque input = stdin.readline class Seat(): def __init__(self, n): self.seat = '_' * n def get(self, num...
vfc_50377
{ "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\n6\n7\n8", "output": "0\n14\n9\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n12\n7\n8", "output": "0\n3\n9\n4\n", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
p00660 High and Low Cube
Solve the following coding problem using the programming language python: I came to the summer festival with the elementary school students in my neighborhood. To put it bluntly, it plays the role of a guardian, but the smell of yakisoba and takoyaki in the store, and the sound of fireworks that can be heard from time...
```python class Surface: def __init__(self, mp): self.mp = mp def mirror(self): for y in range(5): self.mp[y] = self.mp[y][::-1] def mirror_ud(self): for y in range(2): self.mp[y], self.mp[4 - y] = self.mp[4 - y], self.mp[y] def spin90(self): ne...
vfc_50389
{ "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": ".......#######......................#######..............\n.......#.....#......................#..-..#..............\n.......#.|...#......................#.|.|.#..............\n.......#.....#......................#..-..#..............
code_contests
verifiable_code
p00803 Starship Hakodate-maru
Solve the following coding problem using the programming language python: The surveyor starship Hakodate-maru is famous for her two fuel containers with unbounded capacities. They hold the same type of atomic fuel balls. There, however, is an inconvenience. The shapes of the fuel containers #1 and #2 are always cubic...
```python ans = [] # 答え while True: N = int(input()) if not N: break now_cube = int(N ** (1 / 3 + 0.000001)) now_pyramid = 0 tmp_ans = now_cube ** 3 # 立方体の一辺を小さくしていく、立方体の辺ごとに四角錐の一辺の長さを求め、容量を求める for i in range(now_cube, -1, -1): while True: # もし次の値が最大容量を超...
vfc_50393
{ "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": "100\n64\n50\n20\n151200\n0", "output": "99\n64\n47\n20\n151200", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n84\n50\n20\n151200\n0", "output": "99\n84\n47\n20\n151200\n", ...
code_contests
verifiable_code
p00934 L Jumps
Solve the following coding problem using the programming language python: Example Input 3 2 4 0 2 2 -2 -2 -2 2 Output 15 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_50397
{ "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": "3 2 4 0\n2 2\n-2 -2\n-2 2", "output": "15", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01200 Resource
Solve the following coding problem using the programming language python: Dr. Keith Miller is a researcher who studies the history of Island of Constitutional People’s Country (ICPC). Many studies by him and his colleagues have revealed various facts about ICPC. Although it is a single large island today, it was divid...
vfc_50405
{ "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\n10.00\n3 10 10 20 10 10 20\n4 30 10 40 10 40 20 30 20\n1.00 3 0 0 10 0 0 10\n0.50 4 20 15 25 15 25 20 20 20\n0.75 6 40 35 50 40 40 50 30 50 25 45 30 40\n4 1\n5.00\n3 0 0 24 0 0 24\n3 50 0 50 24 26 0\n3 0 50 0 26 24 50\n3 50 50...
code_contests
verifiable_code
p01337 The Number of the Real Roots of a Cubic Equation
Solve the following coding problem using the programming language python: Description Since the cubic equation: ax ^ 3 + bx ^ 2 + cx + d = 0 is given, please check the number of positive real roots and the number of negative real roots, respectively. The number of roots shall be counted including the multiple roots....
```python n=int(input()) def f(a,b,c,d): return lambda x:a*x**3+b*x**2+c*x+d for i in range(n): a,b,c,d=map(int,input().split()) fx=f(a,b,c,d) D=b**2-3*a*c if D<=0 : if d==0: pl=mi=0 elif (a>0 and d<0) or (a<0 and d>0): pl,mi=1,0 elif (a<0 and d<0) or ...
vfc_50409
{ "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\n1 3 3 1\n-10 0 0 0", "output": "0 3\n0 0", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 3 3 1\n-10 0 0 1", "output": "0 3\n1 0\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p01504 AYBABTU
Solve the following coding problem using the programming language python: There is a tree that has n nodes and n-1 edges. There are military bases on t out of the n nodes. We want to disconnect the bases as much as possible by destroying k edges. The tree will be split into k+1 regions when we destroy k edges. Given t...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(t): N, T, K = map(int, readline().split()) if N == T == K == 0: return False G = [[] for i in range(N)] E = [] res = 0 for i in range(N-1): a, b, c = map(int, readline().split()) res += ...
vfc_50413
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 10, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 1\n1 2 1\n1\n2\n4 3 2\n1 2 1\n1 3 2\n1 4 3\n2\n3\n4\n0 0 0", "output": "Case 1: 1\nCase 2: 3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01675 The J-th Number
Solve the following coding problem using the programming language python: I - The J-th Number Problem Statement You are given N empty arrays, t_1, ..., t_n. At first, you execute M queries as follows. * add a value v to array t_i (a \leq i \leq b) Next, you process Q following output queries. * output the j-th ...
vfc_50417
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 4 1\n1 5 1\n1 1 3\n4 5 1\n3 4 2\n1 3 4", "output": "2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01819 Where is the Boundary
Solve the following coding problem using the programming language python: Example Input 2 1 WE Output 1 2 The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x i...
vfc_50421
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\nWE", "output": "1 2", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01952 Tiny Room
Solve the following coding problem using the programming language python: You are an employee of Automatic Cleaning Machine (ACM) and a member of the development team of Intelligent Circular Perfect Cleaner (ICPC). ICPC is a robot that cleans up the dust of the place which it passed through. Your task is an inspectio...
vfc_50425
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 536870912, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 20 20 1\n10 0\n20 10\n10 20\n0 10", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3 3 1\n114 514", "output": "Yes", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
p02239 Breadth First Search
Solve the following coding problem using the programming language python: Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$. Constraints * $1 \leq n \leq 1...
```python import sys input = lambda: sys.stdin.readline().rstrip() from collections import deque def resolve(): n = int(input()) ukv = [list(map(int, input().split())) for _ in range(n)] dist = [-1]*n que = deque() que.append(0) dist[0] = 0 while len(que)>0: v = que.popleft() ...
vfc_50433
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3", "output": "1 0\n2 1\n3 2\n4 1", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 1 4\n2 1 4\n3 0\n4 1 3", "output": "1 0\n2 -1\n3 2\n4 1\n", "...
code_contests
verifiable_code
p02385 Dice III
Solve the following coding problem using the programming language python: Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the sa...
```python roll_dict = dict(E = (3, 1, 0, 5, 4, 2), W = (2, 1, 5, 0, 4, 3), S = (4, 0, 2, 3, 5, 1), N = (1, 5, 2, 3, 0, 4)) dice1 = list(map(int, input().split())) dice2 = list(map(int, input().split())) dices = [] dices.append(dice1) judge = False for i in "EWSN": dice = dices[0] new_dice = [] for j in range(6...
vfc_50437
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 3 4 5 6\n6 5 4 3 2 1", "output": "No", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 3 4 5 6\n6 2 4 3 5 1", "output": "Yes", "type": "stdin_stdout" }, { "fn...
code_contests
verifiable_code
aba14a
Solve the following coding problem using the programming language python: Ramkumar loves to solve riddles one day SpojSathyagave him a riddle to solve. Sathya will give him pair of integers a and b. Ramkumar has to find the largest number in the range [a,b] inclusive which can be represented as product of atleast two...
```python def isprime(n): if n == 2 or n == 3: return 0 if n < 2 or n%2 == 0: return 1 if n < 9: return 0 if n%3 == 0: return 1 r = int(n**0.5) f = 5 while f <= r: if n%f == 0: return 1 if n%(f+2) == 0: return 1 f +=6 return 0 def main(): t=raw_input() for j in xrange(int(t)): ...
vfc_50441
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 11\n7 35", "output": "10 \n35", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
chefbro
Solve the following coding problem using the programming language python: Chef's younger brother is in town. He's a big football fan and has a very important match to watch tonight. But the Chef wants to watch the season finale of MasterChef which will be aired at the same time. Now they don't want to fight over it li...
```python for t in xrange(int(raw_input())): x=0 for c in xrange(int(raw_input())): n,m=map(int,raw_input().split()) g=(m+n-2)%3 x=x^g if x: print "MasterChef" else: print "Football" ```
vfc_50445
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n2 2", "output": "MasterChef", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
digrot
Solve the following coding problem using the programming language python: For any positive integer, we define a digit rotation as either moving the first digit to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation). For example, the number 12345 could be lef...
```python # code chef - easy - digit rotation def left(s): return str(int(s[-1]+s[:-1])) def right(s): return str(int(s[1:]+s[0])) nCases = int(raw_input()) for iter in range(nCases): number = raw_input() if len(number)==1: print number continue best = max(int(left(right(numbe...
vfc_50449
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n12345\n54321\n10901\n211011\n7\n90", "output": "51234\n54321\n11090\n211011\n7\n9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n12345\n43634\n10901\n211011\n7\n90", "output":...
code_contests
verifiable_code
insoma5
Solve the following coding problem using the programming language python: The planet of XANDOR was famous in the intergalactic empire for being home to the Carden - a race of super-intelligent computer scientists that were held in high regard for their achievements in the Intergalactic Mind Game Olympiads. The Carden ...
```python #!/usr/bin/python s=raw_input() dp = [ [ 0 for j in xrange(20)] for i in xrange(20) ] op = [ '_' for i in xrange(20) ] n = len(s) m = 0 f = [0, 1] for i in xrange(2,20): f.append(0) for j in xrange(1,i): f[i] += f[j] * f[i-j] for i in xrange(n): if i%2 == 0 and s[i] == 'T': dp[i/2...
vfc_50453
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "T.F+T*F", "output": "5", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
nf03
Solve the following coding problem using the programming language python: Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." wit...
```python ans=[] while True: try: s=raw_input() l=[] l=s.split() for i in l: i=i[::-1] ans.append(i) except EOFError: break for i in ans: if i[0]==".": i=i.replace(".","") print i+".", else: print i, ```
vfc_50457
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Welcome to NITMASFEST.", "output": "emocleW ot TSEFSAMTIN. \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "Welcome tp NITMASFEST.", "output": "emocleW pt TSEFSAMTIN. \n", "typ...
code_contests
verifiable_code
sanskar
Solve the following coding problem using the programming language python: Alok-nath is man of equality. He needs your help to divide his “sanskars” evenly amongst all his followers. By doing this, Alok-nath can create equality amongst his followers and he'll be called a true “sanskari”. Alok-nath has N sanskars, and K...
```python def possible(A, e, n): def rec(i, r): if r == 0: return True if i == n: return False if A[i] > 0 and r >= A[i]: p = rec(i + 1, r - A[i]) if p: A[i] = 0 return True p = rec(i + 1, r) if p...
vfc_50461
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 3\n1 2 4 5 6\n5 3\n1 2 4 5 7", "output": "yes\nno", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n5 3\n1 2 4 4 6\n5 3\n1 2 4 5 7", "output": "no\nno\n", "type": "stdin_st...
code_contests
verifiable_code
1000_B. Light It Up
Solve the following coding problem using the programming language python: Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of swi...
```python n,M=map(int,input().split()) s=[int(x) for x in input().split()] ss=[s[0]] so=[] se=[] for i in range(n-1): ss.append(s[i+1]-s[i]) ss.append(M-s[n-1]) if (n+1)%2==1: for i in range(int(n/2)): so.append(ss[2*i]) se.append(ss[2*i+1]) so.append(ss[n]) sss=sum(so) a=0 b=...
vfc_50465
{ "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 7\n3 4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 12\n1 10\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...