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
679_C. Bear and Square Grid
Solve the following coding problem using the programming language python: You have a grid with n rows and n columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X'). Two empty cells are directly connected if they share a side. Two cells (r1, c1) (located in the row r1 and column c1) and (r2, c2...
vfc_69809
{ "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": "5 3\n.....\n.XXX.\n.XXX.\n.XXX.\n.....\n", "output": "25\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
723_E. One-Way Reform
Solve the following coding problem using the programming language python: There are n cities and m two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itself. It is possible that there...
```python import sys from collections import defaultdict rlines = sys.stdin.readlines() lines = (l.strip() for l in rlines) def eucycle(n,m,adj): dir_edges = [] us = list(adj.keys()) for u in us: while adj[u]: v0 = u v1 = adj[v0].pop() adj[v1].remove(v0) dir_edges.append((v0, v1)) while v1 != u:...
vfc_69817
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5\n2 1\n4 5\n2 3\n1 3\n3 5\n7 2\n3 7\n4 2\n", "output": "3\n1 2\n2 3\n3 1\n3 5\n5 4\n3\n2 4\n3 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n13 9\n13 12\n3 11\n12 10\n12 9\n2 1...
code_contests
verifiable_code
745_D. Hongcow's Game
Solve the following coding problem using the programming language python: This is an interactive problem. In the interaction section below you will see the information about flushing the output. In this problem, you will be playing a game with Hongcow. How lucky of you! Hongcow has a hidden n by n matrix M. Let Mi, ...
```python import sys n = int(input()) MAX = 2000 * 1000 * 1000 res = [MAX] * n k = 1 while k < n: x = [0] * n output = [] sz = 0 for i in range(0, n, 2 * k): for j in range(0, min(n - i, k)): output.append(i + j + 1) sz += 1 #print(i + j + 1, end = ' ') ...
vfc_69821
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n0 0\n0 0", "output": "1\n1 \n1\n2 \n-1\n0 0 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n0 0 0\n2 7 0\n0 0 4\n3 0 8\n0 5 4", "output": "2\n1 3 \n1\n2 \n2\n1 2 \n1\n3 \n-1\n...
code_contests
verifiable_code
768_F. Barrels and boxes
Solve the following coding problem using the programming language python: Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are place...
```python import sys def factorial(): global mod fac = [1] * int(3e5 + 1) for i in range(1, int(3e5)): fac[i] = i*fac[i-1] % mod return fac def inverse(x): global mod return pow(x, mod-2, mod) def C(n, r): global fac if n < 0 or n < r: return 0 return fac[n]*inverse(f...
vfc_69825
{ "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": "1 1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 1\n", "output": "666666672\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
792_E. Colored Balls
Solve the following coding problem using the programming language python: There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains ai balls, all of which have color i. You have to write a program that will divide all balls into sets such that: * each ball belongs to exac...
```python import time import sys from math import sqrt n = int(input()) a = list(map(int, input().split())) sq = int(sqrt(a[0]))+2 s = set() for box in range(1, sq): if a[0] % box == 0: s.add(a[0] // box) s.add(a[0] // box - 1) else: s.add(a[0] // box) for balls in range(1, sq): ...
vfc_69829
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 7\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
813_B. The Golden Age
Solve the following coding problem using the programming language python: Unlucky year in Berland is such a year that its number n can be represented as n = xa + yb, where a and b are non-negative integer numbers. For example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 20 + 31, 17 = 23 + 32 = 24 + 3...
```python x, y, l, r = map(int, input().split()) def gen_list(var): cur = 1 while cur <= r: yield cur cur *= var x_list = list(gen_list(x)) # print(x_list) y_list = list(gen_list(y)) # print(y_list) numbers = [l-1, r+1] for _x in x_list: for _y in y_list: n = _x + _y if n...
vfc_69833
{ "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 5 10 22\n", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 1 10\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
839_A. Arya and Bran
Solve the following coding problem using the programming language python: Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies. At first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds ai candies in a box, that is giv...
```python n, k = map(int, input().split()) a = list(map(int, input().split())) aria = 0 bran = 0 for i in range(n): aria += a[i] if aria > 8: bran += 8 aria -= 8 else: bran += aria aria = 0 if bran >= k: print(i + 1) break if bran < k: print(-1...
vfc_69837
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 9\n10\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n1 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
code_contests
verifiable_code
859_D. Third Month Insanity
Solve the following coding problem using the programming language python: The annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, numbered from 1 to 2N. The tournament lasts N rounds, wi...
```python n = int(input()) # Using the same index I would for a tree m = 2**n points = [0]*(2*m) points[1] = 2**(n-1) for i in range(1,m): x = points[i]//2 points[2*i] = x points[2*i+1] = x P = [[int(x)/100.0 for x in input().split()] for _ in range(m)] state = [[0.0]*64 for _ in range(2*m)] for i in r...
vfc_69841
{ "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\n0 0 100 0 100 0 0 0\n100 0 100 0 0 0 100 100\n0 0 0 100 100 0 0 0\n100 100 0 0 0 0 100 100\n0 100 0 100 0 0 100 0\n100 100 100 100 100 0 0 0\n100 0 100 0 0 100 0 0\n100 0 100 0 100 100 100 0\n", "output": "12.0000000000000...
code_contests
verifiable_code
884_C. Bertown Subway
Solve the following coding problem using the programming language python: The construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself. There are n stations in the subway. It was built according to the Bertown Transport Law: 1. For e...
```python input() l = [[int(x)-1,False] for x in input().split()] loop = [] for begin in l: if begin[1]: continue count = 0; nextI = begin[0]; while not l[nextI][1]: l[nextI][1]=True nextI = l[nextI][0] count += 1 loop.append(count) s = sorted(loop,reverse=True) total...
vfc_69845
{ "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\n2 1 3\n", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 5 4 3 2\n", "output": "17", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
908_E. New Year and Entity Enumeration
Solve the following coding problem using the programming language python: You are given an integer m. Let M = 2m - 1. You are also given a set of n integers denoted as the set T. The integers will be provided in base 2 as n binary strings of length m. A set of integers S is called "good" if the following hold. ...
```python from collections import defaultdict as di MOD = int(1e9+7) bells = di(int) bells[0,0] = 1 K=1000 for j in range(1,K): bells[0,j] = bells[j-1,j-1] for i in range(j): bells[i+1,j] = (bells[i,j] + bells[i,j-1])%MOD def bellman(n): return bells[n-1,n-1] m,n = [int(x) for x in input().sp...
vfc_69849
{ "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 3\n11010\n00101\n11000\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "30 2\n010101010101010010101010101010\n110110110110110011011011011011\n", "output": "86061644...
code_contests
verifiable_code
92_D. Queue
Solve the following coding problem using the programming language python: There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal ...
```python from bisect import bisect_left n = int(input()) a = list(map(int, input().split())) b = [0] * n for i in range(n - 1, -1, -1): b[i] = bisect_left(a, a[i], i + 1, len(a)) - i - 2 a[i] = min(a[i + 1], a[i]) if i != n - 1 else a[i] print (*b) # Made By Mostafa_Khaled ```
vfc_69853
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n10 8 5 3 50 45\n", "output": "2 1 0 -1 0 -1 ", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
958_B2. Maximum Control (medium)
Solve the following coding problem using the programming language python: The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets. The...
```python from sys import stdin from collections import defaultdict import heapq n = int(stdin.readline()) a = [[] for _ in range(n)] for _ in range(n-1): e = stdin.readline().split(' ') u, v = int(e[0]), int(e[1]) a[u-1].append(v-1) a[v-1].append(u-1) leaves = [i for i in range(n) if len(a[i]) == 1]...
vfc_69857
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n2 3\n", "output": "1 3 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2\n3 2\n4 2\n", "output": "1 3 4 4 ", "type": "stdin_stdout" }, { "fn_name": ...
code_contests
verifiable_code
983_D. Arkady and Rectangles
Solve the following coding problem using the programming language python: Arkady has got an infinite plane painted in color 0. Then he draws n rectangles filled with paint with sides parallel to the Cartesian coordinate axes, one after another. The color of the i-th rectangle is i (rectangles are enumerated from 1 to ...
vfc_69861
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n-1 -1 1 1\n-4 0 0 4\n0 0 4 4\n-4 -4 0 0\n0 -4 4 0\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 0 4 4\n-4 -4 0 0\n0 -4 4 0\n-2 -4 2 4\n", "output": "5", ...
code_contests
verifiable_code
a-simple-task
Solve the following coding problem using the programming language python: Oz has a list arr[] of M integers. He has to find all integers K such that : 1) K > 1 2) arr[1]%K = arr[2]%K = arr[3]%K = ... = arr[M]%K where '%' is a modulus operator Help Oz to find all such K's. Input : First line of input contains an int...
```python from math import sqrt def check_k(ls, k): v = ls[0] % k for item in ls: if item % k != v: return False return True M = int(raw_input()) l = [] for _ in xrange(M): l.append(int(raw_input())) p = l[0] - l[1] if p < 0: p = -p ks = [] for d in xrange(1, int(sqrt(p) + 1)): if p % d...
vfc_69865
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n38\n6\n34\n\nSAMPLE", "output": "2 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "90\n1468\n2168\n6268\n7568\n1268\n6768\n8368\n7368\n5368\n1168\n3368\n68\n8168\n6568\n4568\n4868\n95...
code_contests
verifiable_code
blackbox-1-3
Solve the following coding problem using the programming language python: Paul was the most famous character in Tekken-3. Of course he went to college and stuff. In one of the exams he wasn't able to answer a question which asked to check if a tuple of 3 non negative integers constituted a Primitive Pythagorian Triple...
```python from fractions import gcd def isPithagorean(a, b, c): if a**2 + b**2 == c**2 or a**2 + c**2 == b**2 or b**2 + c**2 == a**2: return True return False def isCoPrime(a, b, c): if gcd(a,b) == 1 or gcd(a,c) == 1 or gcd(b,c) == 1: return True return False def isPrimitivePythagorean(a, b, c): if isPithag...
vfc_69869
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 4 5\n10 8 6\n9 2 5\n12 5 13\n\nSAMPLE", "output": "YES\nNO\nNO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n130 0 130\n8938 6200 6439\n1059 816 676\n2421 621 2340\n9530 7...
code_contests
verifiable_code
creativity
Solve the following coding problem using the programming language python: Ed, Edd and Eddy are given an art homework. They have to prepare a banner and print a single line of text on it. They can print any text they want. Ed has decided the text that he wants to put on his banner. Lets call it string s1. But he is t...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=raw_input() t=int(t) arr=[] for i in range(t): str1=raw_input() str2=raw_input() str2.split() if str1 in str2: arr.append("possible") else: arr.append("not possib...
vfc_69873
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nhello\nhi hello hi\ndef\nabc def\njava\npython\nc\ncplusplus\nhellohi\nhellotherehi\n\nSAMPLE", "output": "possible\npossible\nnot possible\npossible\nnot possible\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
flowers-arrangement
Solve the following coding problem using the programming language python: Serena is interested in only red and yellow roses. She is arranging flowers in some fashion to be presented at her friend's birthday. Her friend loves only red and yellow roses(but mostly red ones). The flowers can be arranged only in the follow...
```python import fileinput import re flower_regex = re.compile("^(RY{0,2})+$") for line in fileinput.input(): if fileinput.isfirstline(): continue print flower_regex.match(line) and "YES" or "NO" ```
vfc_69877
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nRYRR\nRWR\nRRYRRY\nRRRR\nYYRYWG\n\nSAMPLE", "output": "YES\nNO\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "47\nRRYRRY\nRRRR\nYYRWBR\nR\nRY\nRRY\nW\nYRY\nRGGGGGGGGG\nRY...
code_contests
verifiable_code
john-and-hesa
Solve the following coding problem using the programming language python: John is very good in shooting. We wants to get admitted in HackerEarth Shooting Academy (HESA). But HESA take very hard interview process to select the candidates. In the Interview process, an assignment is given to John. In this assignment, so...
```python t=int(raw_input()) while t>0: t-=1;cnt=0; x,p=(int(i) for i in raw_input().split()) while (x%p==0) and( x!=0): cnt+=1; if x==p: x=0;break; x//=p; print cnt,x; ```
vfc_69881
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2\n\nSAMPLE", "output": "2 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n27 3\n64 4\n23 5\n10 2\n12 4", "output": "3 0\n3 0\n0 23\n1 5\n1 3\n", "type": "stdin_stdou...
code_contests
verifiable_code
milly-and-chocolates-4
Solve the following coding problem using the programming language python: Milly loves to eat chocolates. She buys only those food items which contain some amount or percentage of chocolate in it. She has purchased N such food items and now she is planning to make a new food item by her own. She will take equal propor...
```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 for _ in xrange(input()): N=input() l=map(int,raw_input().split()) s=sum(l) le=len(l) out=float(s)/le print '%.8f'%out ```
vfc_69885
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n80 30 90\n\nSAMPLE", "output": "66.66666667\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n332\n2 63 41 84 96 4 62 52 38 36 89 99 82 72 50 100 26 34 57 54 38 62 57 39 94 4 87 34 ...
code_contests
verifiable_code
paint-the-house-5
Solve the following coding problem using the programming language python: You want to repaint your house entirely for an upcoming occasion. The total area of your house is D units. There are a total of N workers. The i^th worker has his available time Ti, hiring cost Xi and speed Yi. This means that he is available fo...
```python ''' Created on 07-Jan-2016 @author: jana ''' import sys class Worker: def __init__(self,T,X,Y): self.T = T self.X = X self.Y = Y def sort_key(a,b): if a.T == b.T: if a.Y == b.Y: return a.X < b.X return a.Y > b.Y return a.T < b.T Work...
vfc_69889
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 1 1\n2 2 2\n3 1 5\n\nSAMPLE", "output": "3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
repeated-substring
Solve the following coding problem using the programming language python: Given a String(only lower case letters) , check if any substring has occured Twice : Example : iwsagoodboody Here, substring "ood" occurs twice. Output "YES" if there is any such substring else output "NO" .(without qoutes) Input: First l...
```python for t in xrange(input()): s = raw_input() ok = False for i in xrange(len(s)): for j in xrange(i,len(s)): ss = s[i:j] if len(ss)<1: continue if s.count(ss)>=2: #print ss ok = True break if ok: break if ok: print "YES" else: print "NO" ```
vfc_69893
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nabcdefghi\ndogsbarkatdogs\nhowtheydo\n\nSAMPLE", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\nhq\nh\nmeayl\nlfdxfi\ncvscxggb\nkfnqdux\nfnf\nzvsrt\njprep\...
code_contests
verifiable_code
sonu-and-monu
Solve the following coding problem using the programming language python: Sonu and Monu are good friends. One day, Sonu gave a binary string of length L to Monu, and asks Monu to pick two positions a and b in the string. Now he given a number P to Monu and he have to tell what are the chances that there will be 1 on b...
```python def gcd(a, b): while b: a, b = b, a % b return a t = int(raw_input()) for tt in range(t) : l,p = [int(i) for i in raw_input().split()] a = [int(i) for i in raw_input()] ii = 0 count = [] for e in a : if e == 1 : ii += 1 count.append(ii) else : count.append(ii) ans = 0 for...
vfc_69897
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3\n1011\n4 1\n1011\n\nSAMPLE", "output": "9/16\n5/16", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
tom-in-gym
Solve the following coding problem using the programming language python: The Tom has become health conscious and is now lifting weights at the gym. But its his first time so the trainer gives him a simple job to do. He has been given a weight lifting rod and N heavy weights, each weighing 2^0, 2^1, .... , 2^n-1. He ...
```python for _ in range(input()): n = input() if n < 0: print "0" fact = 1 start= 1 for i in range(1, n+1): fact *= start start += 2 print fact ```
vfc_69901
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n5\n4\n7\n\nSAMPLE", "output": "3\n945\n105\n135135\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n6\n8\n3\n2\n11\n13\n15\n17", "output": "10395\n2027025\n15\n3\n13749310575...
code_contests
verifiable_code
p00120 Patisserie
Solve the following coding problem using the programming language python: The cake shop made a lot of roll cakes of various sizes. You have been tasked with arranging this cake in a box. The roll cake is so soft that it will collapse if another roll cake is on top. Therefore, as shown in Fig. (A), all roll cakes must...
```python from collections import deque def calcwidth(cks): if len(cks) == 1: return cks[0]*2 width = cks[0] + cks[-1] for ck1,ck2 in zip(cks[:-1],cks[1:]): width += ((ck1+ck2)**2-(ck1-ck2)**2)**0.5 return width while True: try: W, *rs = list(map(float,input().split())) except: break ...
vfc_69949
{ "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": "30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10", "output": "OK\nOK\nOK\nNA", "type": "stdin_stdout" }, { "fn_name": null, "input": "30 4 5 6\n8 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10", "outp...
code_contests
verifiable_code
p00253 Kitchen Garden
Solve the following coding problem using the programming language python: I decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time. One day, when I was watering the seedlings as usual...
```python from sys import exit while(True): N = int(input()) # print(N) if N == 0: break h = list(map(int, input().split())) for i in range(N+1): targ = h[:i] + h[i+1:] diff = targ[1] - targ[0] OK = True for j in range(1, N): if diff != targ[j] - t...
vfc_69953
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 6 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "6\n1\n12", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 6 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 6\n0", "ou...
code_contests
verifiable_code
p00439 Maximum Sum
Solve the following coding problem using the programming language python: problem Given a sequence of n integers a1, a2, ..., an and a positive integer k (1 ≤ k ≤ n), then the sum of k consecutive integers Si = ai + ai + Create a program that outputs the maximum value of 1 + ... + ai + k-1 (1 ≤ i ≤ n --k + 1). inp...
```python while True: n , k = map(int,input().split()) if (n,k) == (0,0): break a = [int(input()) for _ in range(n)] s = sum(a[0:k]) l = [s] for i in range(k,n): s = s + a[i] - a[i-k] l.append(s) print(max(l)) ```
vfc_69957
{ "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 3\n2\n5\n-4\n10\n3\n0 0", "output": "11", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p00630 CamelCase
Solve the following coding problem using the programming language python: When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply t...
```python while True: name,typ = input().split() if typ=="X": break ans = [] if "_" in name: ans = name.split("_") else: j = 0 for i in range(1,len(name)): if name[i].isupper(): ans.append(name[j:i]) j = i ans.append(n...
vfc_69961
{ "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": "get_user_name L\ngetUserName U\nGetUserName D\nEndOfInput X", "output": "getUserName\nGetUserName\nget_user_name", "type": "stdin_stdout" }, { "fn_name": null, "input": "get_user_name L\ngetUserOame ...
code_contests
verifiable_code
p00905 Stylish
Solve the following coding problem using the programming language python: Stylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{...
```python import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in ...
vfc_69969
{ "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 4\n(Follow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.t...
code_contests
verifiable_code
p01039 Manhattan Warp Machine 1
Solve the following coding problem using the programming language python: Problem In a certain universe, stars exist on one-dimensional integer coordinate points, and aliens use the Manhattan warp device to move between stars. This warp device has N buttons, and when you press button i, you can warp any star whose Ma...
vfc_69973
{ "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": "1 3\n4 1", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 12\n9 1\n3 2", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
p01172 Headstrong Student
Solve the following coding problem using the programming language python: You are a teacher at a cram school for elementary school pupils. One day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everything was going so well - ex...
```python def gcd(a,b): while b:a,b=b,a%b return a def f(n,m): if m==1:return 0 x=1 for i in range(m): x=(x*n)%m if x==1:return i+1 while 1: a,b=map(int,input().split()) if a==0:break c=gcd(a,b) a//=c;b//=c cnt=0;d=gcd(b,10) while d!=1: b//=d...
vfc_69977
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 3\n1 6\n3 5\n2 200\n25 99\n0 0", "output": "0 1\n1 1\n1 0\n2 0\n0 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3\n1 6\n3 5\n2 200\n25 99\n0 0", "output": "0 1\n1 1\n1 0\n2 0\n...
code_contests
verifiable_code
p01308 Angel Stairs
Solve the following coding problem using the programming language python: An angel lives in the clouds above the city where Natsume lives. The angel, like Natsume, loves cats and often comes down to the ground to play with cats. To get down to the ground, the angel made a long, long staircase leading from the clouds t...
```python dic = {"C":0, "C#":1, "D":2, "D#":3, "E":4, "F":5, "F#":6, "G":7, "G#":8, "A":9, "A#":10, "B":11} t = int(input()) for _ in range(t): n, m = map(int, input().split()) t_lst = [-100] + list(map(lambda x:dic[x],input().split())) s_lst = list(map(lambda x:dic[x],input().split())) s_lst.reve...
vfc_69981
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6 4\nC E D# F G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B", "output": "Yes\nNo\nYes\nNo", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
p01477 Sharp 2SAT
Solve the following coding problem using the programming language python: Problem statement $ (X_ {1,1} ∨X_ {1,2}) ∧ (X_ {2,1} ∨X_ {2,2}) ∧ ... ∧ (X_ {M, 1} ∨X_ {M,2 }) Given a logical expression represented by $. However, it is $ X_ {i, j} \ in \\ {x_1, x_2, ..., x_N, ~ x_1, ~ x_2, ..., ~ x_N \\} $. I want to assign...
vfc_69985
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n-1 -2\n1 -3", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 -2", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input...
code_contests
verifiable_code
p01637 Change
Solve the following coding problem using the programming language python: ICPC World Finals Day 2 Mr. Tee and his colleagues arrived at the airport terminal. From now on, I will transfer the plane and board the enemy land R country. Since we go through Country D, we have to exchange our money into two currencies. Mr...
vfc_69989
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "M r", "output": "9333", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
p01789 Unfair Game
Solve the following coding problem using the programming language python: Example Input 3 5 4 3 6 12 Output Hanako The input will be given via stdin and the output should be printed to stdout by your code. Now solve the problem by providing the code.
```python import sys readline = sys.stdin.readline write = sys.stdout.write def check(N, A, B, S): K = min(A, B) g = 0 for s in S: g ^= s % (K+1) if A == B: return g != 0 if A > B: if g != 0: return 1 for s in S: if s > B: retu...
vfc_69993
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 134217728, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5 4\n3\n6\n12", "output": "Hanako", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5 4\n3\n6\n3", "output": "Hanako\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
p01924 Coastline
Solve the following coding problem using the programming language python: coastline Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1...
```python while True: t,d,l=map(int,input().split()) if t==0: break ls=[] for i in range(t): ls.append(int(input())) ans=0 r=0 for j in range(t): if ls[j]>=l: ans+=1 if r<d: r=d-1 else: if r>0: ...
vfc_69997
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 8, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n5\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0", "output": "3\n0\n11\n5", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
p02062 Short Circuit Evaluation
Solve the following coding problem using the programming language python: C: Short-circuit evaluation problem Naodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF. <formula> :: = <or-expr> <or-expr> :: = <and-expr> | <or-expr...
```python # from inspect import currentframe # from sys import exit, stderr # debug function # def debug(*args): # names = {id(v):k for k,v in currentframe().f_back.f_locals.items()} # print(', '.join(names.get(id(arg),'???') + str(id(arg)) +' = '+repr(arg) for arg in args), file=stderr) src = list(str(inpu...
vfc_70001
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 268435456, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "?&?|?&?|?&?", "output": "3 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "?&?&?|?|?&?", "output": "3 2\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
code_contests
verifiable_code
buy1get1
Solve the following coding problem using the programming language python: One day Alice visited Byteland to purchase jewels for her upcoming wedding anniversary. In Byteland, every Jewelry shop has their own discount methods to attract the customers. One discount method called Buy1-Get1 caught Alice's attention. That ...
```python from collections import Counter for _ in xrange(int(raw_input())): st=raw_input() st=st.strip() a=[] su=0 for let in st: a.append(let) counts=Counter(a) for key in counts: if key!=" " and counts[key]%2==0: counts[key]=counts[key]/2 continue elif key!=" ": counts[key]=(counts[key]+...
vfc_70013
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nssss\nssas\nsa\ns", "output": "2\n3\n2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nssss\nrsas\nsa\ns", "output": "2\n3\n2\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
comr03
Solve the following coding problem using the programming language python: On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If atleast one bulb in the set is on at a...
```python t=int(raw_input()) for i in range(t): n=int(raw_input()) print (pow(2,n,100000)-1%100000)%100000 ```
vfc_70017
{ "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\n2", "output": "1\n3", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
gerald03
Solve the following coding problem using the programming language python: Problem Statement Chef has a sequence of N segments: [L1, R1], [L2, R2], ..., [LN, RN]. He wants to transform the first segment to the last one (with index N). His plan is to do this big deal with a number of transformations: firstly he will tra...
```python t=input() while t: t-=1 n=input() l=[0]*(n+1) r=[0]*(n+1) for i in range(n): l[i],r[i]=map(int,raw_input().split()) i=0 count=0 ans="" while i<(n-1): if l[i+1]>=r[i]: ans=ans+"L+"*(r[i]-l[i]-1)+"R+L+"*(l[i+1]-r[i]+1)+"R+"*(r[i+1]-l[i+1]-1) ...
vfc_70021
{ "difficulty": "2", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3\n-1 0\n0 1\n3 5\n1\n0 1\n3\n-2 -1\n-2 -1\n-2 0\n4\n4 6\n3 5\n-1 1\n1 2", "output": "9\nR+L+R+L+R+L+R+L+R+\n0\n\n1\nR+\n13\nL-R-L-L-L-L-R-R-R-R-L+R+L+", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
psudo1
Solve the following coding problem using the programming language python: Chef is all ready to show his new dish at the restaurant but he is very scared if the people dislike it. He wants to show them his dish at a perfect time, so that all may like the dish. If the time displayed as HH:MM, where HH is the hour and MM...
```python for _ in range(input()): s=raw_input().split() c=0 for i in range(len(s)): if s[i][0]==s[i][4] and s[i][1]==s[i][3]: c+=1 elif s[i][0]==s[i][1]and s[i][3]==s[i][4]: c+=1 elif s[i][0]==s[i][3] and s[i][1]==s[i][4]: c+=1 print c ```
vfc_70029
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n12:21 11:10\n06:00", "output": "1\n0", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
time
Solve the following coding problem using the programming language python: Exciting offer….!!! It’s World Cup time…. :) Here is an offer awaiting for you i.e… you will get a ticket to watch world cup finals @ Australia. Your task is so simple. You will be given a function . In order to win the prize, you need to red...
```python n=int(input()) def fun( n): if n==0: return 1 if n==1: return 2 return 2*fun(n-1) ans=fun(n) print ans ```
vfc_70033
{ "difficulty": "6", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2", "output": "4", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1013_B. And
Solve the following coding problem using the programming language python: There is an array with n elements a1, a2, ..., an and the number x. In one operation you can select some i (1 ≤ i ≤ n) and replace element ai with ai & x, where & denotes the [bitwise and](https://en.wikipedia.org/wiki/Bitwise_operation#AND) op...
```python from sys import stdin,stdout a,b=map(int,stdin.readline().split()) z=set(map(int,stdin.readline().split())) if len(z)!=a:stdout.write("0");exit() r=set() for i in z: if i&b in z and i&b!=i:stdout.write("1");exit() r.add(i&b) if len(r)!=a:stdout.write("2");exit() stdout.write("-1") ```
vfc_70037
{ "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 228\n1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n1 2 3 7\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
1060_D. Social Circles
Solve the following coding problem using the programming language python: You invited n guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles. Your guests happen to be a little bit shy, so the i-th ...
```python import heapq n=int(input()) fa=[i for i in range(n)] ls=[] rs=[] for i in range(n): l,r=[int(x) for x in input().split()] ls.append((l,i)) rs.append((r,i)) ls.sort() rs.sort() ans=n for i in range(n): ans+=max(ls[i][0],rs[i][0]) # heapq.heapify(ls) # heapq.heapify(rs) # # ans=n # if n==1: # ...
vfc_70045
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 6\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2\n2 1\n3 5\n5 3\n", "output": "15\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
1082_B. Vova and Trophies
Solve the following coding problem using the programming language python: Vova has won n trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row. The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to sw...
```python from sys import stdin input=stdin.readline n=int(input()) s="a"+input().rstrip() l=[0]*(n+1) r=[0]*(n+1) cnt_g=0 for i in range(len(s)): if s[i]=="G": cnt_g+=1 if n==cnt_g: print(n) exit() for i in range(1,n+1): if s[i]=="G": l[i]=r[i]=1 for i in range(1,n+1): if s[i]=="G" and s[i-1]=="G": ...
vfc_70049
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nGGGG\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\nGGGSGGGSGG\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
code_contests
verifiable_code
1101_D. GCD Counting
Solve the following coding problem using the programming language python: You are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to a_i. Let's denote the function g(x, y) as the greatest common divisor of the numbers written on the vertices belonging to the ...
```python from sys import stdin, stdout from math import * from heapq import * from collections import * dv=list(range(200002)) for i in range(2,200002): if ((i*i)>=200002): break if (dv[i]==i): j=i while ((i*j)<200002): dv[i*j]=i j=j+1 def loPr(x): global d...
vfc_70053
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 500000000}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3 4\n1 2\n2 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 3 4\n1 3\n2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
112_B. Petya and Square
Solve the following coding problem using the programming language python: Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task. The task is to draw a broken line that would go along the grid lines and that woul...
```python n,x,y=map(int,input().split()) a=[(n//2),(n//2)+1] print(['YES','NO'][x in a and y in a]) ```
vfc_70057
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 2\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
114_C. Grammar Lessons
Solve the following coding problem using the programming language python: Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be ...
```python import re def f(x): if x.endswith("lios"): return 1 elif x.endswith("liala"): return -1 elif x.endswith("etr"): return 2 elif x.endswith("etra"): return -2 elif x.endswith("initis"):return 3 elif x.endswith("inites"): return -3 else: return 0 a,b=input().strip().split(),[] for s ...
vfc_70061
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "etis atis animatis etis atis amatis\n", "output": "NO\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1170_H. Longest Saw
Solve the following coding problem using the programming language python: You are given the sequence a_1, a_2, ..., a_n. You can choose any subset of elements and then reorder them to create a "saw". The sequence b_1, b_2, ..., b_m is called a "saw" if the elements satisfy one of the following series of inequalities:...
vfc_70065
{ "difficulty": "14", "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\n10\n10 9 8 7 6 5 4 3 2 1\n7\n1 2 2 2 3 2 2\n3\n100 100 100\n", "output": "\n10\n1 6 2 7 3 8 4 9 5 10 \n4\n2 1 3 2 \n1\n100 \n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1189_F. Array Beauty
Solve the following coding problem using the programming language python: Let's call beauty of an array b_1, b_2, …, b_n (n > 1) — min_{1 ≤ i < j ≤ n} |b_i - b_j|. You're given an array a_1, a_2, … a_n and a number k. Calculate the sum of beauty over all subsequences of the array of length exactly k. As this number c...
```python from collections import defaultdict import sys input = sys.stdin.readline ''' for CASES in range(int(input())): n, m = map(int, input().split()) n = int(input()) A = list(map(int, input().split())) S = input().strip() sys.stdout.write(" ".join(map(str,ans))+"\n") ''' inf = 100000000000000000 # 1e17 mod = 998...
vfc_70069
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 5, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n1 10 100 1000 10000\n", "output": "9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1208_G. Polygons
Solve the following coding problem using the programming language python: You are given two integers n and k. You need to construct k regular polygons having same [circumcircle](https://en.wikipedia.org/wiki/Circumscribed_circle), with distinct number of sides l between 3 and n. <image> Illustration for the first e...
vfc_70073
{ "difficulty": "13", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 2\n", "output": "6\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1227_F1. Wrong Answer on test 233 (Easy Version)
Solve the following coding problem using the programming language python: Your program fails again. This time it gets "Wrong answer on test 233" . This is the easier version of the problem. In this version 1 ≤ n ≤ 2000. You can hack this problem only if you solve and lock both problems. The problem is about a test ...
```python n,k=[int(kk) for kk in input().strip().split(" ")] h=[int(kk) for kk in input().strip().split(" ")] fact=[1]*(n+1) mod=998244353 for i in range(1,n+1): fact[i]=(fact[i-1]*i)%mod def inv(x): return pow(x,mod-2,mod) def C(n,k): return (fact[n]*inv(fact[k])*inv(fact[n-k]))%mod ng=0 for i in...
vfc_70077
{ "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": "3 3\n1 3 1\n", "output": "9\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1250_E. The Coronation
Solve the following coding problem using the programming language python: The coronation of King Berl XXII is soon! The whole royal family, including n daughters of Berl XXII, will be present. The King has ordered his jeweler to assemble n beautiful necklaces, so each of the princesses could wear exactly one necklace...
vfc_70081
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 512000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 7 2\n1010100\n0010101\n1111010\n1000010\n0000101\n6 9 3\n011111110\n100111000\n111100000\n000111111\n110100111\n111110111\n3 4 2\n0001\n1000\n0000\n3 4 4\n0001\n1000\n0000\n2 4 3\n0001\n1000\n", "output": "\n2\n1 3 \n1\n...
code_contests
verifiable_code
126_C. E-reader Display
Solve the following coding problem using the programming language python: After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual ...
vfc_70085
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n01110\n10010\n10001\n10011\n11110\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1001\n0000\n1001\n0110\n", "output": "10\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
1292_B. Aroma's Search
Solve the following coding problem using the programming language python: [THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover h...
```python """ Satwik_Tiwari ;) . 12th july , 2020 - Sunday """ #=============================================================================================== #importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import ...
vfc_70089
{ "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": "1 1 2 3 1 0\n2 2 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 2 3 1 0\n15 27 26\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_nam...
code_contests
verifiable_code
1312_C. Adding Powers
Solve the following coding problem using the programming language python: Suppose you are performing the following algorithm. There is an array v_1, v_2, ..., v_n filled with zeroes at start. The following operation is applied to the array several times — at i-th step (0-indexed) you can: * either choose position ...
```python def convert(n, base): a = "01" if n < base: if n % base >= 2: return False return a[n % base] else: if n % base >= 2: return False x = convert(n // base, base) if x: return x + a[n % base] return False t = int(in...
vfc_70093
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 100\n0 0 0 0\n1 2\n1\n3 4\n1 4 1\n3 2\n0 1 3\n3 9\n0 59049 810\n", "output": "YES\nYES\nNO\nNO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 12\n11\n", "output": "NO...
code_contests
verifiable_code
1355_B. Young Explorers
Solve the following coding problem using the programming language python: Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possible. Russell was trying to...
```python for i in range(int(input())): n=int(input()) l=list(map(int,input().split())) l.sort() i1,i2=1,0 for j in l: if j==i1: i2+=1 i1=0 i1+=1 print(i2) ```
vfc_70101
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 1 1\n5\n2 3 1 2 2\n", "output": "3\n2\n\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
1398_D. Colored Rectangles
Solve the following coding problem using the programming language python: You are given three multisets of pairs of colored sticks: * R pairs of red sticks, the first pair has length r_1, the second pair has length r_2, ..., the R-th pair has length r_R; * G pairs of green sticks, the first pair has length g_1,...
```python #!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def main(): from functools import lru_cach...
vfc_70109
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1 3\n9 5\n1\n2 8 5\n", "output": "99\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\n3\n5\n4\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name":...
code_contests
verifiable_code
1421_E. Swedish Heroes
Solve the following coding problem using the programming language python: While playing yet another strategy game, Mans has recruited n [Swedish heroes](https://www.youtube.com/watch?v=5sGOwFVUU0I), whose powers which can be represented as an array a. Unfortunately, not all of those mighty heroes were created as capa...
```python n = int(input()) a = list(map(int,input().split())) INF = 10 ** 20 DP = [-INF] * 12 DP[1] = a[0] DP[5] = -a[0] for elem in a[1:]: newDP = [] newDP.append(DP[5] + elem) newDP.append(DP[3] + elem) newDP.append(DP[4] + elem) newDP.append(DP[1] - elem) newDP.append(DP[2] - elem) newDP....
vfc_70113
{ "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\n4 -5 9 -2 1\n", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 6 7 8\n", "output": "26", "type": "stdin_stdout" }, { "fn_name": null, "...
code_contests
verifiable_code
143_D. Help General
Solve the following coding problem using the programming language python: Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of...
```python n, m = map(int, input().split()) if n > m: n, m = m, n if n > 2 and m > 2: print(((n * m) + 1) // 2) elif n == 1: print(m) else: print(2 * (((m // 4) * 2) + min(m % 4, 2))) # Made By Mostafa_Khaled ```
vfc_70117
{ "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 4\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 393\n...
code_contests
verifiable_code
1466_I. The Riddle of the Sphinx
Solve the following coding problem using the programming language python: What walks on four feet in the morning, two in the afternoon, and three at night? This is an interactive problem. This problem doesn't support hacks. Sphinx's duty is to guard the city of Thebes by making sure that no unworthy traveler crosses...
vfc_70121
{ "difficulty": "15", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n\nyes\n\nno\n\nno\n\nno\n\nno\n\nyes\n", "output": "\n5 101\n\n5 110\n\n4 100\n\n3 101\n\n2 001\n\n1 000\n\n0 110\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n", "output...
code_contests
verifiable_code
1513_F. Swapping Problem
Solve the following coding problem using the programming language python: You are given 2 arrays a and b, both of size n. You can swap two elements in b at most once (or leave it as it is), and you are required to minimize the value $$$∑_{i}|a_{i}-b_{i}|.$$$ Find the minimum possible value of this sum. Input The fi...
```python # Codeforces - 1513-F (https://codeforces.com/problemset/problem/1513/F) n = int(input()) a = [int(val) for val in input().split()] b = [int(val) for val in input().split()] # step 1: partition s = [] t = [] for i in range(n): if a[i] < b[i]: s.append((a[i], b[i])) elif a[i] > b[i]: t.append((b...
vfc_70129
{ "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": "2\n1 3\n4 2\n", "output": "\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n5 4 3 2 1\n1 2 3 4 5\n", "output": "\n4", "type": "stdin_stdout" }, { "fn_name": n...
code_contests
verifiable_code
168_D. Wizards and Huge Prize
Solve the following coding problem using the programming language python: One must train much to do well on wizardry contests. So, there are numerous wizardry schools and magic fees. One of such magic schools consists of n tours. A winner of each tour gets a huge prize. The school is organised quite far away, so one ...
```python from __future__ import division from sys import stdin def dp(i, j, m): if i >= n: if j < l or m < 0: return 0 else: return 1 if mem[i][j][m] != -1: return mem[i][j][m] choice1 = (p[i] / 100) * dp(i + 1, j + 1, min(m + a[i], 200)) choice2 = (...
vfc_70137
{ "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 1 0\n10 20 30\n-1 -1 2\n", "output": "0.3000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1\n100\n123\n", "output": "1.0000000000\n", "type": "stdin_stdout" ...
code_contests
verifiable_code
189_B. Counting Rhombi
Solve the following coding problem using the programming language python: You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties: * Have positive area. * With vertices at integer points. * All vertices of the rhombi are located inside or on the ...
```python w,h=map(int,input().split()) ans=0 for i in range(2,w+1,2): for j in range(2,h+1,2): ans+=(w+1-i)*(h+1-j) print(ans) ```
vfc_70141
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 1402...
code_contests
verifiable_code
212_B. Polycarpus is Looking for Good Substrings
Solve the following coding problem using the programming language python: We'll call string s[a, b] = sasa + 1... sb (1 ≤ a ≤ b ≤ |s|) a substring of string s = s1s2... s|s|, where |s| is the length of string s. The trace of a non-empty string t is a set of characters that the string consists of. For example, the tra...
vfc_70145
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 4, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abacaba\n3\nac\nba\na\n", "output": "1\n2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aaaaa\n2\na\na\n", "output": "1\n1\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
236_B. Easy Number Challenge
Solve the following coding problem using the programming language python: Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum: <image> Find the sum modulo 1073741824 (230). Input The first line contains three spac...
```python a,b,c=map(int,input().split()) M=1073741824 n=a*b*c d=[1]*(n+1) for i in range(2,n+1): for j in range(i,n+1,i): d[j]+=1 r=0 for i in range(1,a+1): for j in range(1,b+1): for k in range(1,c+1): r+=(d[i*j*k])%M print(r%M) ```
vfc_70149
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 2\n", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6 7\n", "output": "1520\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
284_E. Coin Troubles
Solve the following coding problem using the programming language python: In the Isle of Guernsey there are n different types of coins. For each i (1 ≤ i ≤ n), coin of type i is worth ai cents. It is possible that ai = aj for some i and j (i ≠ j). Bessie has some set of these coins totaling t cents. She tells Jessie...
vfc_70157
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 6\n3 1 1\n1 2\n2 3\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 17\n3 1 2 5\n4 2\n3 4\n", "output": "3\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
309_E. Sheep
Solve the following coding problem using the programming language python: Information technologies are developing and are increasingly penetrating into all spheres of human activity. Incredible as it is, the most modern technology are used in farming! A large farm has a meadow with grazing sheep. Overall there are n ...
vfc_70161
{ "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\n1 3\n4 6\n5 7\n2 3\n", "output": "1 4 2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 3\n5 7\n2 4\n", "output": "1 3 2\n", "type": "stdin_stdout" }, { ...
code_contests
verifiable_code
332_C. Students' Revenge
Solve the following coding problem using the programming language python: A student's life is fraught with complications. Some Berland University students know this only too well. Having studied for two years, they contracted strong antipathy towards the chairperson of some department. Indeed, the person in question w...
```python from sys import stdin, stdout from heapq import * def main(): n, p, k = map(int, stdin.readline().split()) a = [] for i in xrange(n): t = map(int, stdin.readline().split()) a.append([t[1], -t[0], i]) d = [0] * n o = [] a.sort() for i, x in enumerate(a): d[x[...
vfc_70165
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 3\n10 18\n18 17\n10 20\n20 18\n20 18\n", "output": "4 5 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3 2\n5 6\n5 8\n1 3\n4 3\n4 11\n", "output": "2 1 3 \n", "type":...
code_contests
verifiable_code
355_C. Vasya and Robot
Solve the following coding problem using the programming language python: Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights wi kilograms. Vasya...
```python path = list(map(int, input().split())) n, L, R, QL, QR = path[0], path[1], path[2], path[3], path[4] w = list(map(int, input().split())) sumpref = [0] for i in range(1, n + 1) : sumpref.append(w[i - 1] + sumpref[i - 1]) answer = QR * (n - 1) + sumpref[n] * R for i in range(1, n + 1) : energy = L * ...
vfc_70169
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 7 2 3 9\n1 2 3 4\n", "output": "34\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4 4 19 1\n42 3 99\n", "output": "576\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
379_D. New Year Letter
Solve the following coding problem using the programming language python: Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve...
```python def main(): k, x, n, m = map(int, input().split()) def f(s, e, n, cnt): ret = [""] * n ret[0] = s ret[-1] = e sa = 0 if s == 'A' else 1 for i in range(cnt): ret[sa] = 'A' ret[sa + 1] = 'C' sa += 2 for j in range(s...
vfc_70173
{ "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": "3 2 2 2\n", "output": "AC\nAC\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 2 2\n", "output": "Happy new year!\n", "type": "stdin_stdout" }, { "fn_name": nu...
code_contests
verifiable_code
39_K. Testing
Solve the following coding problem using the programming language python: You take part in the testing of new weapon. For the testing a polygon was created. The polygon is a rectangular field n × m in size, divided into unit squares 1 × 1 in size. The polygon contains k objects, each of which is a rectangle with sides...
vfc_70177
{ "difficulty": "17", "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 2 1\n.*\n..\n", "output": " 4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 3\n*.*\n...\n*..\n", "output": " ...
code_contests
verifiable_code
44_E. Anfisa the Monkey
Solve the following coding problem using the programming language python: Anfisa the monkey learns to type. She is yet unfamiliar with the "space" key and can only type in lower-case Latin letters. Having typed for a fairly long line, Anfisa understood that it would be great to divide what she has written into k lines...
```python k,a,b=map(int,input().split()) ss=input() h=len(ss) q,r=divmod(h,k) if q<a or q>b or (q==b and r>0): print('No solution') else: i=0 while r>0: print(ss[i:i+q+1]) r-=1 i=i+q+1 while i<h: print(ss[i:i+q]) i=i+q ```
vfc_70185
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 5\nabrakadabra\n", "output": "abra\nkada\nbra\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1 2\nabrakadabra\n", "output": "No solution\n", "type": "stdin_stdout" }...
code_contests
verifiable_code
471_A. MUH and Sticks
Solve the following coding problem using the programming language python: Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from ...
```python a = list(map(int,input().split())) for i in range(6): if a.count(a[i])>=4: v = a[i] break else: print("Alien") exit() for i in range(4): a.remove(v) a.sort() if a[0]<a[1]: print("Bear") elif a[0]==a[1]: print("Elephant") else: print("Alien") ```
vfc_70189
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 3 4 5 6\n", "output": "Alien\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
495_B. Modular Equations
Solve the following coding problem using the programming language python: Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by <image>. A Modular Equation, as Hamed's teacher described, is an eq...
```python a, b = map(int, input().split()) if a == b: print ('infinity') elif b > a: print (0) else: a -= b i = 1 cont = 0 while (i*i) <= a: if (a % i) == 0: if i > b: cont += 1 if (a/i) > b and (i*i) != a: cont += 1 i += 1 print (cont) ...
vfc_70193
{ "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": "9435152 272\n", "output": "282", "type": "stdin_stdout" }, { "fn_name": null, "input": "21 5\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
code_contests
verifiable_code
519_E. A and B and Lecture Rooms
Solve the following coding problem using the programming language python: A and B are preparing themselves for programming contests. The University where A and B study is a set of rooms connected by corridors. Overall, the University has n rooms connected by n - 1 corridors so that you can get from any room to any ot...
```python from collections import defaultdict as df from collections import deque import os import sys from io import BytesIO, IOBase _str = str str = lambda x=b"": x if type(x) is bytes else _str(x).encode() BUFSIZE = 8192 from types import GeneratorType def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwa...
vfc_70197
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2\n1 3\n2 4\n1\n2 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2\n2 3\n2 4\n2\n1 2\n1 3\n", "output": "0\n2\n", "type": "stdin_stdout" } ]...
code_contests
verifiable_code
546_A. Soldier and Bananas
Solve the following coding problem using the programming language python: A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). He has n dollars. How many dollars does he hav...
```python price = 0 iter = 1 k,n,w = list(map(int,input().split())) for i in range (w): price += k*iter iter += 1 if price <= n: print(0) else: output = price - n print(output) ```
vfc_70201
{ "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 17 4\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "111 111111111 111\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
572_C. Lengthening Sticks
Solve the following coding problem using the programming language python: You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total b...
```python a, b, c, l = map(int, input().split()) ans = (l + 3) * (l + 2) * (l + 1) // 3 for z in (a, b, c): s = 2 * z - a - b - c for x in range(max(0, -s), l + 1): m = min(s + x, l - x) ans -= (m + 1) * (m + 2) print(ans // 2) # Made By Mostafa_Khaled ```
vfc_70205
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 2 1 7\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1 2\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
code_contests
verifiable_code
594_A. Warrior and Archer
Solve the following coding problem using the programming language python: In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and mod...
```python n = int(input()) x = sorted(list(map(int, input().split()))) print(min([x[i + n // 2] - x[i] for i in range(n // 2)])) ```
vfc_70209
{ "difficulty": "7", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n73 37\n", "output": "36\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n0 1 3 7 15 31\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, ...
code_contests
verifiable_code
615_D. Multipliers
Solve the following coding problem using the programming language python: Ayrat has number n, represented as it's prime factorization pi of size m, i.e. n = p1·p2·...·pm. Ayrat got secret information that that the product of all divisors of n taken modulo 109 + 7 is the password to the secret data base. Now he wants t...
```python MD = 1000000007 m = int(input()) p = list(map(int, input().split())) q = {} for el in p: if el in q: q[el] += 1 else: q[el] = 2 sum1 = 1 sum2 = 1 for el in q: sum1=sum1*q[el] sum2=sum2*pow(el,(q[el]-1),MD) sum=pow(sum2,sum1//2,MD) if sum1 % 2 == 1: for el in q: sum ...
vfc_70213
{ "difficulty": "10", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3 2\n", "output": "1728\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
634_F. Orchestra
Solve the following coding problem using the programming language python: Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul...
```python r, c, n, k = map(int, input().split()) board = [[0 for col in range(c)] for row in range(r)] for i in range(n): x, y = map(lambda x: int(x)-1, input().split()) board[x][y] = 1 photos = 0 for x1 in range(r): for y1 in range(c): for x2 in range(x1, r): for y2 in range(y1, c): ...
vfc_70217
{ "difficulty": "12", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 3 2\n1 1\n3 1\n2 2\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
663_D. To Hack or not to Hack
Solve the following coding problem using the programming language python: Consider a regular Codeforces round consisting of three problems that uses dynamic scoring. You are given an almost final scoreboard. For each participant (including yourself), the time of the accepted submission for each of the problems is giv...
vfc_70221
{ "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\n0 0 119\n-3 -17 -42\n0 7 0\n51 0 0\n", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
688_B. Lovely Palindromes
Solve the following coding problem using the programming language python: Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not. Pari is trying to love them too, but on...
```python n = input() print(n + "".join(reversed(list(n)))) ```
vfc_70225
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n", "output": "1001\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", ...
code_contests
verifiable_code
710_A. King Moves
Solve the following coding problem using the programming language python: The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king. Check the king's moves here ht...
```python import sys from collections import Counter from math import factorial input = sys.stdin output = sys.stdout # input = open('input.txt') def read_int(): return [int(x) for x in input.readline().rstrip().split()] line = input.readline().rstrip() x = ord(line[0]) - ord('a') y = ord(line[1]) - ord('1') a...
vfc_70229
{ "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": "e4\n", "output": "8", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
731_A. Night at the Museum
Solve the following coding problem using the programming language python: Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition. Embosser is a special devise that allows to "print" the t...
```python import sys from math import ceil,log RI = lambda : [int(x) for x in sys.stdin.readline().split()] ri = lambda : sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] f...
vfc_70233
{ "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": "ares\n", "output": "34\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
755_C. PolandBall and Forest
Solve the following coding problem using the programming language python: PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree. There is exactly one relative ...
```python n = int(input()) a = [0] + list(map(int, input().split())) was = set() for i in range(1, n + 1): if a[a[i]] == i: was.add(min(i, a[i])) print(len(was)) ```
vfc_70237
{ "difficulty": "9", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 1, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 1 5 3 3", "output": "2\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
7_E. Defining Macros
Solve the following coding problem using the programming language python: Most C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use. In this problem we consider the following model of #defi...
```python P, A, S, M, D = 1, 2, 4, 8, 16 ADD = A | S ANY = A | S | M | D OP_BIT = {"+": A, "-": S, "*": M, "/": D, ")": 0} UNSAFE_BEFORE = {P: 0, A: 0, S: ADD, M: ADD, D: ANY} UNSAFE_AFTER = {P: 0, A: 0, S: 0, M: ADD, D: ADD} macro = dict() def expr(chars, pseudo=P, expand=macro.get, op_bit=O...
vfc_70245
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n#define sum x + y\n1 * sum\n", "output": "Suspicious\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
821_B. Okabe and Banana Trees
Solve the following coding problem using the programming language python: Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a poi...
```python m,b=map(int,input().split()) f=lambda n: n*(n+1)//2 def g(y): x=m*(b-y) return f(x)*(y+1)+f(y)*(x+1) print(max(g(y) for y in range(b+1))) ```
vfc_70249
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 5\n", "output": "30", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
847_B. Preparing for Merge Sort
Solve the following coding problem using the programming language python: Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into o...
```python from sys import stdin from collections import deque from bisect import bisect_right as br n=int(stdin.readline().strip()) s=list(map(int,stdin.readline().strip().split())) arr=deque([s[0]]) ans=deque([[s[0]]]) for i in range(1,n): x=br(arr,s[i]) if x==0: arr.appendleft(s[i]) ans.appen...
vfc_70253
{ "difficulty": "8", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 3 2 1\n", "output": "4\n3\n2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 3 2 5 4\n", "output": "1 3 5\n2 4\n", "type": "stdin_stdout" }, { "fn_na...
code_contests
verifiable_code
868_D. Huge Strings
Solve the following coding problem using the programming language python: You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation saisbi is saved into a new string ...
```python from math import log n = int(input()) p = [bin(p)[2:] for p in range(0,512)] def mset(s): ss = set() for k in range(0,10): for pi in range(0,2 ** k): cs = p[pi] cs = (k - len(cs)) * "0" + cs if cs in s: ss.add(cs) return ss def q(s): ...
vfc_70257
{ "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\n01\n10\n101\n11111\n0\n3\n1 2\n6 5\n4 4\n", "output": "1\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n0\n40\n1 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n10 10\n11 11\n12 12\n...
code_contests
verifiable_code
894_A. QAQ
Solve the following coding problem using the programming language python: "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (...
```python # QAQ def crying(s): ans = 0 for i in range(len(s)): if (s[i] != "Q"): continue for j in range(i + 1, len(s)): if s[j] != 'A': continue for k in range(j + 1, len(s)): if s[k] == 'Q': ans += 1 ...
vfc_70261
{ "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": "QAQAQYSYIOIWIN\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
915_D. Almost Acyclic Graph
Solve the following coding problem using the programming language python: You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. Can y...
```python def dfs(g, u, visited, call_stack): visited[u] = True call_stack.add(u) for v in g[u]: if v in call_stack: return [u, v] if not visited[v]: d = dfs(g, v, visited, call_stack) call_stack.discard(v) if d is not None: ret...
vfc_70265
{ "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": "3 4\n1 2\n2 3\n3 2\n3 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6\n1 2\n2 3\n3 2\n3 1\n2 1\n4 5\n", "output": "NO\n", "type": "stdin_stdout" },...
code_contests
verifiable_code
938_E. Max History
Solve the following coding problem using the programming language python: You are given an array a of length n. We define fa the following way: * Initially fa = 0, M = 1; * for every 2 ≤ i ≤ n if aM < ai then we set fa = fa + aM and then set M = i. Calculate the sum of fa over all n! permutations of the arra...
```python import atexit import io import sys # IO Buffering _INPUT_LINES = sys.stdin.read().splitlines() input = iter(_INPUT_LINES).__next__ _OUTPUT_BUFFER = io.StringIO() sys.stdout = _OUTPUT_BUFFER @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.getvalue()) def main(): n = int(i...
vfc_70269
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 3, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 2\n", "output": "4\n", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
963_E. Circles of Waiting
Solve the following coding problem using the programming language python: A chip was placed on a field with coordinate system onto point (0, 0). Every second the chip moves randomly. If the chip is currently at a point (x, y), after a second it moves to the point (x - 1, y) with probability p1, to the point (x, y - 1...
vfc_70273
{ "difficulty": "11", "memory_limit": null, "memory_limit_bytes": 256000000, "problem_url": null, "time_limit": "{'seconds': 2, 'nanos': 0}" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1 1 1\n", "output": "666666674", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 2 1 2\n", "output": "538461545", "type": "stdin_stdout" }, { "fn_name": null,...
code_contests
verifiable_code
991_A. If at first you don't succeed...
Solve the following coding problem using the programming language python: Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after th...
```python n=list(map(int,input().split())) s=n[0]-n[2] v=n[1]-n[2] w=n[3]-(s+v+n[2]) if(w==0 or s<0 or v<0 or w<0): print('-1') elif(w>n[3]): print(-1) else: print(w) ```
vfc_70277
{ "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 2 2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 10 5 20\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
code_contests
verifiable_code
aqua-park
Solve the following coding problem using the programming language python: You came to a brand-new aqua park. In this aqua park you are not sliding like in most of aqua parks, but falling. There are N objects. Each object is non-horizontal and non-vertical segment. When you fall on the segment you start sliding on it a...
```python x,n=(int(i) for i in raw_input().split()) l=[] for kkk in range(0,n): x1,y1,x2,y2=(int(i) for i in raw_input().split()) if y1<=y2: l.append([y1,y2,x1,x2]) else: l.append([y2,y1,x2,x1]) l.sort(reverse=True) index=0 while index<n: if min(l[index][2],l[index][3])<=x<=max(l[index][...
vfc_70281
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n0 1 2 2\n2 4 4 5\n\n\nSAMPLE", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "100 1\n50 20 100 30", "output": "50", "type": "stdin_stdout" }, { "...
code_contests
verifiable_code
chandu-and-his-toy-stack
Solve the following coding problem using the programming language python: After setting up the area. Chandu wanted all his toys to be stacked there in that area. So that all of them are accessible easily. Currently, He is having N stacks of toys each with height H_1,H_2...H_n (assuming all toys are of same height).Cha...
```python T = input() def brokenInput(): A = map(int, raw_input().strip().split()) while len(A) < 3: A += map(int, raw_input().strip().split()) return A for _ in xrange(T): N, X, Y = brokenInput() effortRequired = 0 initList = [] finalList = [] stacks = {} for __ in xrange(N): initH, finalH = map(int, ra...
vfc_70285
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 6 4\n3 1\n1 2\n1 2\n\nSAMPLE", "output": "10", "type": "stdin_stdout" } ] }
code_contests
verifiable_code
divide-array-2
Solve the following coding problem using the programming language python: Given an array A of size N. Given Q operations, each operation contains an integer D. In each operation you have to divide all the elements of the array by D. For example, for each operation with a given D, the new array A would be: A[0] / D, ...
```python r = input() A = map(int, raw_input().split()) s = 1 for i in range(input()): s *= input() for i in A: print i/s, ```
vfc_70289
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n50 20 18 27 19\n3\n2\n3\n2\nSAMPLE", "output": "4 1 1 2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n384 887 778 916 794 336 387 493 650 422 363 28 691 60 764 927 541 427 173...
code_contests
verifiable_code
good-times-vs-bad-times-3
Solve the following coding problem using the programming language python: Chandan, our problem moderator, recently got a digital clock as a birthday present. A digital clock shows time in the format HH:MM:SS, where HH, MM, SS represents hours , minutes, and seconds respectively. It is a 24 hour clock and so the day st...
```python import fractions def factors(num): ans = set() for i in range(2,num+1): if num%i == 0: ans.add(i) return ans sets = [] for i in range(0,61): sets.append(factors(i)) ans = [0]*86400 hrs = 0 mins = 0 secs = 0 k = 0 while hrs != 24: while secs != 60: while mins != 60: count = 0 if hrs == 0: ...
vfc_70293
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n23 59 58\n23 46 22\n\nSAMPLE", "output": "0:2\n1:408\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n23 59 58\n23 46 22\n\nSAMPLD", "output": "0:2\n1:408\n", "type": "std...
code_contests
verifiable_code
little-deepu-and-array
Solve the following coding problem using the programming language python: Little Deepu loves positive things in life, positive girlfriends, positive marks. He's, in general a lover of positive things, so for obvious reasons he loves an array which contains positive elements. Anyway, Little Deepu also thinks that not ...
```python n=int(raw_input()) a=map(int,raw_input().split()) for i in xrange(n): a[i]=[a[i],i] a.sort() temp=[] def binary_search(low,high,x): global a if high>=low: mid=low+(high-low)/2 #print mid,"mid" if ((a[mid][0]-findpindex(mid))>x and (mid == low or (a[mid-1][0]-findpindex(mid-1)...
vfc_70297
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n19 8 17 20 13 2 3 20 30 40\n10\n1\n1\n1\n2\n2\n2\n40\n30\n10\n10", "output": "11 2 10 12 7 1 1 12 22 31", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n19 8 17 20 13 2 3 20 30 75\n10...
code_contests
verifiable_code
monks-school-4
Solve the following coding problem using the programming language python: Today is the 25th anniversary of Berland International School in Berland. On this auspicious Occasion, our friend Monk has been given the responsibility of preparing the Inventory for his school. There are exactly N teachers and M students in...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' n,m=[int(i) for i in raw_input().split()] l=[] d=dict() for i in range(n): l.append(raw_input()) for i in range(m): info=raw_input() pos=info.find(' ') a=info[...
vfc_70301
{ "difficulty": "0", "memory_limit": null, "memory_limit_bytes": 0, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\nvasya\npetya\nkolya\nvasya errichto 21\nkolya petr 22\npetya egor 19\nvasya tourist 19\n\nSAMPLE", "output": "kolya\npetr 22\npetya\negor 19\nvasya\ntourist 19\nerrichto 21", "type": "stdin_stdout" }, { ...