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 | car-parking-4 | Solve the following coding problem using the programming language python:
You are looking for a place to park your car on a wall street. You can park at any position that meets the following requirements:
1. It is not directly in front of a private driveway.
2. It is not directly in front of a bus stop.
3. It is no... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(raw_input())
while t>0:
s=raw_input()
r=0
for i in range(len(s)):
if s[i]=='-':
p=0
try:
if s[i+1]=='B' or s[i+1]=='S':
p=1
#print("a "+str(... | vfc_79445 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n---B--S-D--S--\nDDBDDBDDBDD\n--S--S--S--S--\n\nSAMPLE",
"output": "4\n0\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "46\n---B--S-D--S--\nDDBDDBDDBDD\n--S--S--S--S--\nSSD-B---BD-DD... |
code_contests | verifiable_code | dfs-2 | Solve the following coding problem using the programming language python:
You have some boxes. All of them are assigned a unique positive integer. This number is written on them with a marker. Your task is simple that is to evaluate a number of queries. The description of a single query is
given below:
The query cons... | ```python
import bisect;
N=input(); A=map(int,raw_input().split()); A.sort();
for _ in xrange(int(raw_input())):
L,R=map(int,raw_input().split());
print bisect.bisect_right(A,R) - bisect.bisect_left(A,L)
``` | vfc_79449 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4 3 2 1 1\n4\n1 2\n2 3\n5 6\n1 1\n\nSAMPLE",
"output": "3\n2\n0\n2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | gcd-game-11 | Solve the following coding problem using the programming language python:
Life and death, win or lose - both have two sides to each other. And that's what Arjit and Chandu Don are fighting about. They are tired of gang-wars between each other, and thus decide to settle like men in a field, of Mathematics.
But even wh... | ```python
from sys import stdin
from fractions import gcd
# for result memoization
registry = {}
def get_result(a,b):
if not registry.has_key((a,b)):
if a== 1:
registry[(a,b)] = 0
elif b == 1:
registry[(a,b)] = 1
else:
greatest_div =gcd(a,b)
if greatest_div == 1:
registry[(a,b)] = 1 ^ get_resu... | vfc_79453 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1000\n1 1\n42 468\n335 1\n170 225\n479 359\n463 465\n206 146\n282 328\n462 492\n496 443\n328 437\n392 105\n403 154\n293 383\n422 217\n219 396\n448 227\n272 39\n370 413\n168 300\n36 395\n204 312\n323 334\n174 165\n142 212\n254 369\n... |
code_contests | verifiable_code | largest-volume-84 | Solve the following coding problem using the programming language python:
Now our heroes - Maga and Alex are working for Oil Company as developers. Recently they have faced a great problem.
They couldn’t find the correct solution. Could you help them?
We are given r – radius of lower base and s – slant height. The ... | ```python
import math
r,s=map(int,raw_input().split())
max_V=0
R=r
h=s
while h>=0:
t=s**2-(R-r)**2
if t<0:
break
h=t**.5
V=(math.pi*h)*(r**2+R**2+R*r)/3.0
if V>=max_V:
max_V=V
R=R+0.001
print"%0.2f" % max_V
``` | vfc_79457 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n\nSAMPLE",
"output": "4.33",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "97 33",
"output": "1028727.30",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | monk-and-tasks | Solve the following coding problem using the programming language python:
Monk A loves to complete all his tasks just before the deadlines for introducing unwanted thrill in his life. But, there is another Monk D who hates this habit of Monk A and thinks it's risky.
To test Monk A, Monk D provided him tasks for N d... | ```python
N=int(raw_input())
for i in xrange(0,N):
n=raw_input()
x={}
line=raw_input().split()
maxm=0
for j in line:
lent=bin(int(j)).count("1")
if(x.get(lent)==None):
x[lent]=[j]
if(lent>maxm):
maxm=lent
else:
temp=x[lent]
... | vfc_79461 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n384\n846930887 1681692778 1714636916 1957747794 424238336 719885387 1649760493 596516650 1189641422 1025202363 1350490028 783368691 1102520060 2044897764 1967513927 1365180541 1540383427 304089173 1303455737 35005212 521595369 ... |
code_contests | verifiable_code | perfect-square-5 | Solve the following coding problem using the programming language python:
Shreyan is appearing for CAT examination and is stuck at a problem to find minimum value needed to be added or subtracted to make a number perfect square.You as his friend and a good programmer agrees to help him find the answer.
INPUT:
First... | ```python
import math
for j in range(input()):
n = input()
x = math.sqrt(n)
a = int(x) ** 2
b = (int(x) + 1) ** 2
if a == n:
print 'YES'
elif b-n < n-a:
print '+' + str(b-n)
else:
print '-' + str(n-a)
``` | vfc_79465 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n25\n168\n19\n\nSAMPLE",
"output": "YES\n+1\n-3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | roy-and-matrix-sum-1 | Solve the following coding problem using the programming language python:
Roy has a matrix of size NxN. Rows and Columns are numbered from 0 to N-1.
jth column of ith row contains absolute difference between i and j.
In other words, Matrix[i][j] = abs(i-j) where 0 ≤ i, j < N.
Your task is to find sum of this matri... | ```python
t=input()
for i in range(t):
a=input()
print (a*(a-1)*(a+1))/3
``` | vfc_79469 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n9\n10\n99\n100\n999\n1000\n9999\n10000\n99999\n100000",
"output": "240\n330\n323400\n333300\n332334000\n333333000\n333233340000\n333333330000\n333323333400000\n333333333300000\n",
"type": "stdin_stdout"
},
{... |
code_contests | verifiable_code | strings-awesomeness | Solve the following coding problem using the programming language python:
Vivek likes strings a lot but moreover he likes Awesome strings. Vivek calls a string str Awesome if zero or more letters of the string str can be rearranged to form the string "HackerEarth" (case insensitive). For eg : strings HackerEarth , Ear... | ```python
p=[0]*500001
c=[0]*26
t=[0]*26
c[ord('h')-97]=c[ord('a')-97]=c[ord('e')-97]=c[ord('r')-97]=2
c[ord('c')-97]=c[ord('k')-97]=c[ord('t')-97]=1;
s=raw_input().lower()
k=len(s)
if k>10:
for i in range(11):
t[ord(s[i])-97]+=1
if t==c:
p[10]=1
for i in range(11,k):
p[i]=p[i-1]
if s[i]==s[i-11]:
if ... | vfc_79473 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "HackerEarthhACKEReARTH\n5\n1 11\n2 15\n5 15\n7 20\n7 22\n\nSAMPLE",
"output": "1\n4\n1\n4\n6",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | vaishnav-and-factorials | Solve the following coding problem using the programming language python:
As we have seen our little Vaishanavi playing with the plywood, her brother Vaishnav was playing
with numbers.
Read about Factorial
As we all know this kid always thinks in a different way than others think. He have some numbers with him. He... | ```python
def calculate_factorial(number):
isPrime = [True] * (number + 1)
result = 1
for i in xrange(2, number + 1):
if isPrime[i]:
j = i + i
while j <= number:
isPrime[j] = False
j += i
sum = 0
t = i
while t <= number:
sum += number // t
t *= i
result *= i**sum
return resu... | vfc_79477 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n6\n8\n\nSAMPLE",
"output": "0\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n200\n201\n202\n203\n204\n205\n206\n207\n208\n209\n210\n211\n212\n213\n214\n215\n216\n217\n218... |
code_contests | verifiable_code | p00023 Circles Intersection | Solve the following coding problem using the programming language python:
You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.
Write a program which prints:
* "2" if $B$ is in $A$,
* "-2" if $A$ is in $B$,
* "1"... | ```python
n = int(input())
for _ in range(n):
xa, ya, ra, xb, yb, rb = map(float, input().split())
dist = ((xa - xb)**2 + (ya - yb)**2)**.5
if ra + rb < dist:
print('0')
elif abs(ra - rb) <= dist:
print('1')
elif (rb < ra):
print('2')
elif (ra < rb):
print('-2')
... | vfc_79521 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0",
"output": "2\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622",
... |
code_contests | verifiable_code | p00154 Sum of Cards | Solve the following coding problem using the programming language python:
Let's play the game using a bag containing several cards with integers written on it. In each game, participants first declare one of their favorite number n. Then, take out an appropriate number of cards from the bag at a time, and if the sum o... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
ans = []
while 1:
M = int(readline())
if M == 0:
break
P = [list(map(int, input().split())) for i in range(M)]
memo = {}
def dfs(i, rest):
if i == M:
return rest == 0
key = (i, rest)
... | vfc_79525 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n50 10\n100 10\n3\n452\n574\n787\n0",
"output": "16\n0\n12\n7\n9789\n13658\n17466",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00475 Exposition | Solve the following coding problem using the programming language python:
problem
JOI City will hold a large-scale exposition.
There are two themes for this exposition, and each of the N exhibition facilities in JOI City will exhibit on one of the two themes.
The location of the facility is represented by plane coo... | ```python
# AOJ 0552: Exposition
# Python3 2018.7.1 bal4u
import sys
from sys import stdin
input = stdin.readline
x, y = [], []
n = int(input())
for i in range(n):
a, b = map(int, input().split())
x.append(a+b)
y.append(a-b)
xmin, xmax = min(x), max(x)
ymin, ymax = min(y), max(y)
ans1 = ans2 = 0
for i in range(n):... | vfc_79533 | {
"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\n0 0\n1 0\n-1 -2\n0 1\n-1 1",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n-1 0\n1 0\n-1 -2\n0 1\n-1 1",
"output": "3\n",
"type": "stdin_stdout"
},
{... |
code_contests | verifiable_code | p00667 11224111122411 | Solve the following coding problem using the programming language python:
My arm is stuck and I can't pull it out.
I tried to pick up something that had rolled over to the back of my desk, and I inserted my arm while illuminating it with the screen of my cell phone instead of a flashlight, but I accidentally got caug... | ```python
def f3(n):
a=b=c=0
for _ in range(n):
a,b,c=(a+b+c+1)%100000007,a,b
return a
def f5(n):
a=b=c=d=e=0
for _ in range(n):
a,b,c,d,e=(a+b+c+d+e+1)%100000007,a,b,c,d
return a
while 1:
s=input()
if s=="#":break
ans=1
num="_"
cnt=1
for n in s+"_":... | vfc_79537 | {
"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": "1\n11\n111111\n111111111111\n12345\n11111111119999999999\n11111111113333333333\n11111111118888888888\n11111111112222222222111111111\n11111111110000000000444444444\n11224111122411\n888888888888999999999999888888888888999999999999999... |
code_contests | verifiable_code | p00810 Super Star | Solve the following coding problem using the programming language python:
During a voyage of the starship Hakodate-maru (see Problem A), researchers found strange synchronized movements of stars. Having heard these observations, Dr. Extreme proposed a theory of "super stars". Do not take this term as a description of ... | ```python
def distance(star, position):
return sum([(a - b)**2 for a, b in zip(star, position)])**(1 / 2)
def difference(star, position):
return [(a - b) for a, b in zip(star, position)]
while True:
n = int(input())
if n == 0:
break
stars = [list(map(float, input().split())) for i in ran... | vfc_79541 | {
"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\n10.00000 10.00000 10.00000\n20.00000 10.00000 10.00000\n20.00000 20.00000 10.00000\n10.00000 20.00000 10.00000\n4\n10.00000 10.00000 10.00000\n10.00000 50.00000 50.00000\n50.00000 10.00000 50.00000\n50.00000 50.00000 10.00000\n0... |
code_contests | verifiable_code | p00941 Do Geese See God? | Solve the following coding problem using the programming language python:
Example
Input
crc
1
Output
crc
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
from heapq import heappush, heappop
def solve():
S = input()
K = int(input())
L = len(S)
INF = 10**9
cost = [[INF]*(L+1) for i in range(L+1)]
cost[0][L] = 0
ss = []
que = [(0, 0, L)]
while que:
d, a, b = heappop(que)
if cost[a][b] < d:
continue
... | vfc_79545 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "crc\n1",
"output": "crc",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "crb\n1",
"output": "bcrcb\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "b... |
code_contests | verifiable_code | p01208 Turn Left | Solve the following coding problem using the programming language python:
Taro got a driver’s license with a great effort in his campus days, but unfortunately there had been no opportunities for him to drive. He ended up obtaining a gold license.
One day, he and his friends made a plan to go on a trip to Kyoto with ... | vfc_79553 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\nKarasumaKitaoji 0 6150\nKarasumaNanajo 0 0\nKarasumaNanajo KarasumaKitaoji\nKarasumaKitaoji KarasumaNanajo\n3 2\nKujoOmiya 0 0\nKujoAburanokoji 400 0\nOmiyaNanajo 0 1150\nKujoOmiya KujoAburanokoji\nKujoOmiya OmiyaNanajo\nKujoA... | |
code_contests | verifiable_code | p01344 Bouldering | Solve the following coding problem using the programming language python:
Bouldering is a style of rock climbing. Boulderers are to climb up the rock with bare hands without supporting ropes. Your friend supposed that it should be interesting and exciting, so he decided to come to bouldering gymnasium to practice boul... | vfc_79557 | {
"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": "7\n4 2 4\n11 18\n14 18\n10 14\n13 14\n14 17\n17 21\n16 26",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n2 3 3\n11 22\n12 20\n10 15\n11 17\n13 23\n16 22",
"output": ... | |
code_contests | verifiable_code | p01682 Shipura | Solve the following coding problem using the programming language python:
Problem Statement
Dr. Suposupo developed a programming language called Shipura. Shipura supports only one binary operator ${\tt >>}$ and only one unary function ${\tt S<\ >}$.
$x {\tt >>} y$ is evaluated to $\lfloor x / 2^y \rfloor$ (that is, ... | vfc_79565 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "S< S< 12 >> 2 > >\n123 >> 1 >> 1\n1000000000 >>129\nS<S<S<S<S<2>>>>>\nS <S< S<2013 >>> 11 >>> 10 >\n#",
"output": "81\n30\n0\n294967268\n14592400",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | p01826 Live Programming | Solve the following coding problem using the programming language python:
Example
Input
2 10
10 200 1
10 100 100
Output
200
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | vfc_79569 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 10\n10 200 1\n10 100 100",
"output": "200",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 10\n10 200 1\n10 100 101",
"output": "200\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | p01961 RPG Maker | Solve the following coding problem using the programming language python:
You are planning to create a map of an RPG. This map is represented by a grid whose size is $H \times W$. Each cell in this grid is either '@', '*', '#', or '.'. The meanings of the symbols are as follows.
* '@': The start cell. The story shoul... | vfc_79573 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11 7\n.......\n.......\n*.....*\n.......\n..@....\n.......\n*......\n.......\n....*..\n.......\n.......",
"output": ".......\n.......\n*#####*\n......#\n..@...#\n..#.###\n*##.#..\n#...#..\n####*..\n.......\n.......",
"t... | |
code_contests | verifiable_code | p02248 String Search | Solve the following coding problem using the programming language python:
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P ≤ 10000
* The input consists of alphabetical characters and d... | ```python
s=input();t=input()
[print(x) for x in range(len(s)-len(t)+1) if s[x:x+len(t)]==t]
``` | vfc_79581 | {
"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": "xyzz\nyz",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabaaa\naa",
"output": "0\n3\n4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | p02396 Print Test Cases | Solve the following coding problem using the programming language python:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.
Write a program which ... | ```python
i = 0
while True:
n = int(input())
i += 1
if n == 0:
break
print("Case {}: {}".format(i, n))
``` | vfc_79585 | {
"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\n5\n11\n7\n8\n19\n0",
"output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n5\n11\n3\n8\n19\n0",
"output": ... |
code_contests | verifiable_code | c4 | Solve the following coding problem using the programming language python:
The Chef is having a dinner party and invited over all his friends. His guests
being fairly health conscious have exact protein requirements, and The Chef wishes to oblige them all.
The Chef will cook dishes for each individual guest using th... | ```python
import sys
def create_meal_from_rawinput():
temp = sys.stdin.readline()
proteinsStr = temp.split()[1:]
proteins = [int(i) for i in proteinsStr]
ingredients = sys.stdin.readline().strip()
desiredProteins = int(sys.stdin.readline())
return Meal(
proteins,
ingredients,
desiredProteins
)
class Me... | vfc_79589 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 12 1 12 4 4\nacccdadceb\n2\n3 5 4 6\nabcbacbabcc\n15\n2 3 4\nbaba\n7",
"output": "IMPOSSIBLE\naaa\nab",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n5 12 1 12 4 4\nacccdadceb\n4\n3 ... |
code_contests | verifiable_code | coop5 | Solve the following coding problem using the programming language python:
Bala's room is in a mess. He's been so busy doing research that he hasn't bothered to clean out his room for months. Now he has decided to sort out all the items in his room and keep only the essential ones. He knows the usefulness of each of th... | ```python
test=input()
for i in range(test):
x=[]
while len(x)==0:
x=raw_input().split()
y=raw_input().split()
for k in range(int (x[0])):
y[k]=int(y[k])
y.sort()
k=len(y)
sum=0
s=int(x[1])
for j in range (s):
sum=sum+int(y[k-j-1])
print sum
``` | vfc_79593 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 45 99 27 58 100 38 50 31 62",
"output": "70\n348\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 45 99 27 58 100 40 ... |
code_contests | verifiable_code | goc202 | Solve the following coding problem using the programming language python:
Aniket Verma aka Math Bond flaunts his mathematics skill whenever he gets the opportunity. But this time he gets into trouble when he meets Sakshi, another mathematician. Sakshi gave him a problem and asked him to solve. Help Aniket to solve the... | ```python
mod = 10**9+7
t = input()
while t > 0:
n = input()
ans = 0
for i in range(1,n+1):
res = int(n/i)
ans += i*res
print ans%mod
t -= 1
``` | vfc_79597 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3\n5",
"output": "4\n8\n21",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | marcha2 | Solve the following coding problem using the programming language python:
The following problem appeared in the CodeChef March '09 Challenge. A discussion of possible approaches to solving this problem can be found in our blog.
One evening Johnny found some funny looking beens in his grandfather's garden shed, and de... | ```python
n = int(raw_input())
import sys
for _ in xrange(n):
raw_input()
n = 1.0
for l in map(int, raw_input().split()):
n = (n - l) * 2
print "No" if n else "Yes"
``` | vfc_79601 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n0 1 2\n3\n0 0 3",
"output": "Yes\nNo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3\n0 1 2\n3\n0 0 0",
"output": "Yes\nNo\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | quest | Solve the following coding problem using the programming language python:
Smaug, the dragon, rules under The Mountain, Erabor which was originally the ruling place of Dwarf King. King Thorin, who is the rightful heir to the throne is on his way to take back his kingdom from Smaug. With the help of a map, King Thorin i... | ```python
lis=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
a=raw_input().strip()
leng=len(a)
count=0
if(leng%2==1):
count+=1
flag=1
for i in lis:
k=a.count(i)
if(k%2==1):
if(count>0):
count-=1
else:
flag=0
break
if(flag==1):
print "YES"
else:... | vfc_79605 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "cdcdcdcdeeeef",
"output": "YES",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | tomjer | Solve the following coding problem using the programming language python:
Jerry is not good in studies, but he likes to solve puzzles and always challenges his friend Tom. Today Jerry challenged Tom to solve a new riddle. He says "You are given a Pascal's triangle of infinite height, and you are supposed to find the ... | ```python
t=int(raw_input())
for i in xrange(t):
n=int(raw_input())
print (2**(n-1))%1000
``` | vfc_79609 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n5\n10",
"output": "1\n16\n512\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1\n9\n10",
"output": "1\n256\n512\n",
"type": "stdin_stdout"
},
{
"fn_name"... |
code_contests | verifiable_code | 1015_B. Obtaining the String | Solve the following coding problem using the programming language python:
You are given two strings s and t. Both strings have length n and consist of lowercase Latin letters. The characters in the strings are numbered from 1 to n.
You can successively perform the following move any number of times (possibly, zero):
... | ```python
n = int(input())
s = input()
t = input()
if s == t:
print(0)
elif sorted(s) != sorted(t):
print(-1)
else:
res = list()
ls = list(s)
lt = list(t)
for i in range(n):
if ls[i] != lt[i]:
pos = ls.index(lt[i], i+1)
j = pos-1
while j >= i:
... | vfc_79613 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nabcd\naccd\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\nabcdef\nabdfec\n",
"output": "4\n3 5 4 5 ",
"type": "stdin_stdout"
},
{
"fn_name"... |
code_contests | verifiable_code | 1038_F. Wrap Around | Solve the following coding problem using the programming language python:
You are given a binary string s.
Find the number of distinct cyclical binary strings of length n which contain s as a substring.
The cyclical string t contains s as a substring if there is some cyclical shift of string t, such that s is a subs... | ```python
n=int(input())
s=[c=='1' for c in input()]
m=len(s)
z=[[0,0]]
for c in s:
ind = z[-1][c]
z[-1][c] = len(z)
z.append(z[ind][:])
assert(len(z) == m+1)
z[m][0] = z[m][1] = m # make it sticky
# how many things match directly
dp = [0 for _ in range(m+1)]
dp[0] = 1
for i in range(n):
ndp = [0 for _ in range(m+... | vfc_79617 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1010\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n10101010101010\n",
"output": "962\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1061_B. Views Matter | Solve the following coding problem using the programming language python:
You came to the exhibition and one exhibit has drawn your attention. It consists of n stacks of blocks, where the i-th stack consists of a_i blocks resting on the surface.
The height of the exhibit is equal to m. Consequently, the number of blo... | ```python
n,m=map(int,input().split(' '))
a=list(map(int,input().split(' ')))
a.sort()
count=0
prev=0
for i in range(n):
count+=1
if a[i]>prev:
prev+=1
count+=a[n-1]-prev
print(sum(a)-count)
``` | vfc_79621 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n1 2 4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 6\n3 3 3 3 3\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1083_A. The Fair Nut and the Best Path | Solve the following coding problem using the programming language python:
The Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a car in... | ```python
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
adj = [[] for i in range(n)]
for i in range(n-1):
u, v, w = map(int, input().split())
u -= 1
v -= 1
adj[u].append((v, w))
adj[v].append((u, w))
best = [0] * n
ans = 0
def dfs(u):
stack = list()... | vfc_79625 | {
"difficulty": "7",
"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 3 3\n1 2 2\n1 3 2\n",
"output": " 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n6 3 2 5 0\n1 2 10\n2 3 3\n2 4 1\n1... |
code_contests | verifiable_code | 1102_C. Doors Breaking and Repairing | Solve the following coding problem using the programming language python:
You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.
There are n doors, the i-th door... | ```python
n, x, y = map(int, input().split())
a = list(map(int,input().split()))
if x > y:
print( n )
else:
m = 0
for i in a:
if i <= x:
m += 1
print( m - m // 2 )
``` | vfc_79629 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 6\n1 2 6 10 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 3 2\n2 3 1 3 4 2\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": ... |
code_contests | verifiable_code | 1130_C. Connect | Solve the following coding problem using the programming language python:
Alice lives on a flat planet that can be modeled as a square grid of size n × n, with rows and columns enumerated from 1 to n. We represent the cell at the intersection of row r and column c with ordered pair (r, c). Each cell in the grid is eit... | ```python
#complexity - O(n^2)
import math
import sys
sys.setrecursionlimit(2600)
class UnionFind():
def __init__(self, num_elements):
self.parent = list(range(num_elements))
self.rank = [1] * num_elements
def union(self, a, b):
par_a = self.find(a)
par_b = self.find(b)
if par_a == par_b... | vfc_79633 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 1\n5 5\n00001\n11111\n00111\n00110\n00110\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 3\n3 1\n010\n101\n010\n",
"output": "8\n",
"type": "stdin_... |
code_contests | verifiable_code | 1172_D. Nauuo and Portals | Solve the following coding problem using the programming language python:
Nauuo is a girl who loves playing games related to portals.
One day she was playing a game as follows.
In an n× n grid, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. We denote a ... | vfc_79641 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3 2\n3 1 2\n",
"output": "2\n1 1 1 2\n3 2 2 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n3 1 5 4 2\n4 2 1 3 5\n",
"output": "3\n2 1 1 3\n5 2 2 2\n5 3 3 4\n",
"type... | |
code_contests | verifiable_code | 1190_A. Tokitsukaze and Discard Items | Solve the following coding problem using the programming language python:
Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1 ≤ m ≤ n) special items of them.
These n items are marked wi... | ```python
##n,m,k=list(map(int,input().split()))
##p=list(map(int,input().split()))
##p.sort()
##import math
##ok=k
##ip=0
##s=1
##cnt=0
##a=False
##for i in p:
##
## if ip<i<=k:
##
## cnt+=1
##
## a=True
## elif ip<i<=k+cnt:
##
## s+=1
## k+=cnt+1
## ... | vfc_79645 | {
"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": "13 4 5\n7 8 9 10\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4 5\n3 5 7 10\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | 1209_E1. Rotate Columns (easy version) | Solve the following coding problem using the programming language python:
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular n × m matrix a. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation... | ```python
def naiveSolve():
return
def main():
t=int(input())
allans=[]
for _ in range(t):
n,m=readIntArr()
grid=[]
for __ in range(n):
grid.append(readIntArr())
columns=[]
for col in range(m):
temp=[grid[i][col] for... | vfc_79649 | {
"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\n2 3\n2 5 7\n4 2 4\n3 6\n4 1 5 2 10 4\n8 6 6 4 9 10\n5 4 9 5 8 7\n",
"output": "12\n29\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4 3\n1 1 100\n1 3 1\n2 100 100\n1 3 1\n",
... |
code_contests | verifiable_code | 1270_D. Strange Device | Solve the following coding problem using the programming language python:
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can an... | ```python
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
def inout(A):
print("?", end=" ")
print(*A)
sys.stdout.flush()
pos, a = map(int, input().split())
return pos, a
dic = {}
for k in range(1, K+2):
A = list(range(1,k)) + list(range(k+1, K+2))
pos, a = inout(A)... | vfc_79661 | {
"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 3\n4 9\n4 9\n4 9\n1 2",
"output": "? 2 3 4 \n? 1 3 4 \n? 1 2 4 \n? 1 2 3 \n! 3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1293_B. JOE is on TV! | Solve the following coding problem using the programming language python:
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a ... | ```python
n = int(input())
c = 0
while n>0:
c += 1/n
n -= 1
print(c)
``` | vfc_79665 | {
"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\n",
"output": "1.0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "1.5\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1313_B. Different Rules | Solve the following coding problem using the programming language python:
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of ... | ```python
"""
1
6 3 4
"""
n = int(input())
for _ in range(n):
nums = list(map(int,input().split()))
if nums[0] == 1:
print(1,1)
continue
if nums[1]+nums[2] <= nums[0]:
ans = 1
else:
ans = min(nums[0], nums[1]+nums[2]-nums[0]+1)
res = nums[0] if nums[1]+nums[2] > nums[... | vfc_79669 | {
"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\n6 3 4\n",
"output": "2 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n5 1 3\n",
"output": "1 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 1358_B. Maria Breaks the Self-isolation | Solve the following coding problem using the programming language python:
Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.
She has n friends who are also grannies (Maria is not included in this number). The i-th granny is rea... | ```python
t = int(input())
for i in range(t):
n = int(input())
nums = list(map(int, input().split()))
ans = False
nums.sort()
for j in range(n-1, -1,-1):
if nums[j] <= j+1:
print(j+2)
ans = True
break
if not ans:
print(1)
... | vfc_79677 | {
"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\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6\n",
"output": "6\n1\n6\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n1\n1\n1\n2\n1\n3\n1\n4\n1\n5\n1\n6\n1\n7\n1\n8\n"... |
code_contests | verifiable_code | 1399_C. Boats Competition | Solve the following coding problem using the programming language python:
There are n people who want to participate in a boat competition. The weight of the i-th participant is w_i. Only teams consisting of two people can participate in this competition. As an organizer, you think that it's fair to allow only teams w... | ```python
from collections import Counter
def solve():
n=int(input())
A=list(map(int,input().split()))
if n==1:
return 0
A.sort()
mi=A[0]+A[1]
ma=A[-1]+A[-2]
a=Counter(A)
t=0
q=-1
for i in range(mi,ma+1):
t=0
for j in a:
if i-j in a:
... | vfc_79685 | {
"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\n5\n1 2 3 4 5\n8\n6 6 6 6 6 6 8 8\n8\n1 2 2 1 2 1 1 2\n3\n1 3 3\n6\n1 1 3 4 2 2\n",
"output": "2\n3\n4\n1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n14\n2 6 5 9 5 8 13 14 12 5... |
code_contests | verifiable_code | 1422_F. Boring Queries | Solve the following coding problem using the programming language python:
Yura owns a quite ordinary and boring array a of length n. You think there is nothing more boring than that, but Vladik doesn't agree!
In order to make Yura's array even more boring, Vladik makes q boring queries. Each query consists of two int... | ```python
import sys
range = xrange
input = raw_input
# MOD
MOD = 10**9 + 7
def fast_modder(MOD):
""" Returns function modmul(a,b) that quickly calculates a * b % MOD, assuming 0 <= a,b < MOD """
import sys, platform
impl = platform.python_implementation()
maxs = sys.maxsize
if 'PyPy' in impl and ... | vfc_79689 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 3 5\n4\n1 3\n3 3\n2 3\n2 3\n",
"output": "6\n2\n15\n30\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n10 2 8 8 8 8 8 10 2 3\n10\n1 2\n6 1\n4 10\n1 9\n9 1\n6 10\n3 3\n8 1\n4 10\n6... |
code_contests | verifiable_code | 1491_I. Ruler Of The Zoo | Solve the following coding problem using the programming language python:
After realizing that Zookeeper is just a duck, the animals have overthrown Zookeeper. They now have to decide a new ruler among themselves through a fighting tournament of the following format:
Initially, animal 0 is king, while everyone else q... | vfc_79701 | {
"difficulty": "15",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5 1 2\n10 8 11\n9 0 3\n7 4 6\n",
"output": "\n-1 -1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n11 7 12\n8 6 14\n2 1 10\n13 0 9\n5 3 4\n",
"output": "\n1 7\n",
"type": ... | |
code_contests | verifiable_code | 1515_A. Phoenix and Gold | Solve the following coding problem using the programming language python:
Phoenix has collected n pieces of gold, and he wants to weigh them together so he can feel rich. The i-th piece of gold has weight w_i. All weights are distinct. He will put his n pieces of gold on a weight scale, one piece at a time.
The scal... | ```python
import sys
input = sys.stdin.readline
for i in range(int(input())):
n,x = map(int,input().split())
arr = list(map(int,input().split()))
if sum(arr)==x:
print("NO")
else:
arr.sort()
print("YES")
s = 0
temp = -1
for i in range(n):
if s+... | vfc_79705 | {
"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": "3\n3 2\n3 2 1\n5 3\n1 2 3 4 8\n1 5\n5\n",
"output": "\nYES\n3 2 1\nYES\n8 1 2 3 4\nNO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1541_E2. Converging Array (Hard Version) | Solve the following coding problem using the programming language python:
This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length ... | vfc_79709 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 3 4\n2 1\n5\n-1 0 1 -100000 100000\n",
"output": "56\n28\n4\n60\n0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 169_E. Conveyor | Solve the following coding problem using the programming language python:
Anton came to a chocolate factory. There he found a working conveyor and decided to run on it from the beginning to the end.
The conveyor is a looped belt with a total length of 2l meters, of which l meters are located on the surface and are ar... | vfc_79713 | {
"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 3 1 2\n2 5\n",
"output": "0.3333333333333333333423683514373792036167\n0.6666666666666666666847367028747584072335\n0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 18_C. Stripe | Solve the following coding problem using the programming language python:
Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum of num... | ```python
n=int(input())
l=list(map(int,input().split()))
s=[0]*n
for i in range(n):
if i==0:
s[i]=l[i]
else:
s[i]=l[i]+s[i-1]
ans=0
for i in range(1,n):
if s[i-1]==s[-1]-s[i-1]:
ans=ans+1
print(ans)
``` | vfc_79717 | {
"difficulty": "9",
"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\n0 0\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
code_contests | verifiable_code | 213_C. Relay Race | Solve the following coding problem using the programming language python:
Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number.
At the beginning of the race Fu... | vfc_79721 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n25 16 25\n12 18 19\n11 13 8\n",
"output": "136\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 237_C. Primes on Interval | Solve the following coding problem using the programming language python:
You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.
Consider positive integers a, a + 1, ..., b (a ≤ b). You w... | ```python
p=[1]*(1000005)
p[0]=0
p[1]=0
for i in range(2,1001):
if p[i]:
for j in range(2*i,1000005,i):
p[j]=0
for i in range(1,1000001):
p[i]+=p[i-1]
a,b,k=map(int,input().split())
if p[b]-p[a-1]<k:
exit(print(-1))
i=j=a
l=0
while j<=b:
if p[j]-p[i-1]<k:
j+=1
else:
... | vfc_79725 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4 2\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 4 3\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 13 1... |
code_contests | verifiable_code | 262_A. Roma and Lucky Numbers | Solve the following coding problem using the programming language python:
Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.
Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47... | ```python
n, k = map(int,input().split())
l = list(map(int,input().split()))
a = 0
for i in range(len(l)):
c = list(str(l[i]))
s = 0
for j in range(len(c)):
if c[j] == "7" or c[j] == "4":
s += 1
if s <= k:
a += 1
print(a)
``` | vfc_79729 | {
"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 4\n1 2 4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n447 44 77\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 286_A. Lucky Permutation | Solve the following coding problem using the programming language python:
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n).
A lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition ppi = n - i +... | ```python
n=int(input())
if(n%4>1):
print(-1)
else:
ans=[0]*(n+1)
i,j,a,b=1,n,1,n
while(i<j and a<=n and b>=1):
ans[i],ans[j]=a+1,b-1
ans[i+1],ans[j-1]=b,a
i+=2
j-=2
a+=2
b-=2
if(i==j):
ans[i]=a
for i in range(1,n+1):
print(ans[i],e... | vfc_79733 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n",
"output": "2 4 1 3 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
... |
code_contests | verifiable_code | 311_A. The Closest Pair | Solve the following coding problem using the programming language python:
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem... | ```python
r = input().split(' ')
n = int( r[ 0 ] )
k = int( r[ 1 ] )
if n * ( n - 1 ) >> 1 <= k:
print( 'no solution' )
else:
for i in range( 0 , n ):
print( 0 , i + 1 )
``` | vfc_79737 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3\n",
"output": "0 0\n0 1\n0 2\n0 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 100\n",
"output": "no solution\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 356_D. Bags and Coins | Solve the following coding problem using the programming language python:
When you were a child you must have been told a puzzle of bags and coins. Anyway, here's one of its versions:
A horse has three bags. The first bag has one coin, the second bag has one coin and the third bag has three coins. In total, the hors... | vfc_79745 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n1 3 1\n",
"output": "1 0\n2 1 3\n0 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 3 1\n",
"output": "1 0\n2 1 3\n0 1 1\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 37_C. Old Berland Language | Solve the following coding problem using the programming language python:
Berland scientists know that the Old Berland language had exactly n words. Those words had lengths of l1, l2, ..., ln letters. Every word consisted of two letters, 0 and 1. Ancient Berland people spoke quickly and didn’t make pauses between the ... | ```python
#!/usr/bin/python3
counts = [0]*1024
for x in range(len(counts)): counts[x] = []
N = int(input())
x = [int(t) for t in input().strip().split()]
for i,t in enumerate(x): counts[t].append(i)
curr = 0
ans = [0]*N
for i in range(1,1024):
while len(counts[i]) > 0:
x = bin(curr)[2:]
if len(x) > i:
print(... | vfc_79749 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 3\n",
"output": "YES\n0\n10\n110",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 1\n",
"output": "NO\n\n",
"type": "stdin_stdout"
},
{
"fn_name": null... |
code_contests | verifiable_code | 400_B. Inna and New Matrix of Candies | Solve the following coding problem using the programming language python:
Inna likes sweets and a game called the "Candy Matrix". Today, she came up with the new game "Candy Matrix 2: Reload".
The field for the new game is a rectangle table of size n × m. Each line of the table contains one cell with a dwarf figurine... | ```python
n, m = (int(x) for x in input().split())
st = set()
for i in range(n):
s = input()
g = s.index('G')
s = s.index('S')
if g > s:
print(-1)
exit(0)
st.add(s - g)
print(len(st))
``` | vfc_79753 | {
"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 4\n*G*S\nG**S\n*G*S\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3\nS*G\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
code_contests | verifiable_code | 450_A. Jzzhu and Children | Solve the following coding problem using the programming language python:
There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.
Jzzhu asks children to line up. Initially, the i-th child stands at... | ```python
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
l[i]=math.ceil(l[i]/k)
f=max(l)
for i in range(n-1,-1,-1):
if f==l[i]:
print(i+1)
break
``` | vfc_79761 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n1 3 1 4 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 4\n1 1 2 2 3 3\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 496_C. Removing Columns | Solve the following coding problem using the programming language python:
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second... | ```python
import sys,heapq,math
from collections import defaultdict,deque
input=sys.stdin.readline
r,c=map(int,input().split())
grid=[]
for i in range(r):
grid.append(input().strip())
equal=[0 for _ in range(c)]
less=[0 for _ in range(c)]
for i in range(c):
for row in range(1,r):
if(gri... | vfc_79769 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 10\ncodeforces\n",
"output": "0",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 547_B. Mike and Feet | Solve the following coding problem using the programming language python:
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A... | ```python
import math
import random
class AVLTree():
def __init__(self, x):
self.left = None
self.rght = None
self.val = x
self.height = 1
def getHeight0(root):
if root==None: return 0
return max(getHeight0(root.left), getHeight0(root.rght))+1
def getHeight(root):
... | vfc_79777 | {
"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\n1 2 3 4 5 4 3 2 1 6\n",
"output": "6 4 4 3 3 2 2 1 1 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n585325539 365329221 412106895 291882089 564718673\n",
"output": "585325... |
code_contests | verifiable_code | 573_D. Bear and Cavalry | Solve the following coding problem using the programming language python:
Would you want to fight against bears riding horses? Me neither.
Limak is a grizzly bear. He is general of the dreadful army of Bearland. The most important part of an army is cavalry of course.
Cavalry of Bearland consists of n warriors and n... | vfc_79781 | {
"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": "7 4\n1 2 4 8 16 32 64\n87 40 77 29 50 11 18\n1 5\n2 7\n6 2\n5 6\n",
"output": " 9315\n 9308\n ... | |
code_contests | verifiable_code | 595_B. Pasha and Phone | Solve the following coding problem using the programming language python:
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits.
Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a1, a2, ..., an ... | ```python
import sys
n, k = sys.stdin.readline().split()
n = int(n)
k = int(k)
a = [int(x) for x in sys.stdin.readline().split()]
b = [int(x) for x in sys.stdin.readline().split()]
MOD = (10 ** 9) + 7
res = 1
for i in range(0, n // k):
lo = b[i] * (10 ** (k - 1)) - 1
up = (b[i] + 1) * (10 ** (k - 1)) - 1
t... | vfc_79785 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 2\n1 22 3 44\n5 4 3 2\n",
"output": "32400\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 2\n38 56 49\n7 3 4\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 616_E. Sum of Remainders | Solve the following coding problem using the programming language python:
Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 109 + 7 (the remainder when divided by 109 + 7).
The modulo operator a mod b stands for the remainde... | ```python
from math import floor
def range_sum(low, up):
return (up * (up + 1)) // 2 - (low * (low + 1)) // 2
# for _ in range(int(input())):
mod = int(1e9 + 7)
n,m=map(int,input().split())
ans, sqrt_n = m*n, int(floor(n**0.5))
temp = 0
for i in range(1, sqrt_n + 1):
up = n // i
low = n // (i + 1)
u... | vfc_79789 | {
"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 4\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n",... |
code_contests | verifiable_code | 635_F. Preorder Test | Solve the following coding problem using the programming language python:
For his computer science class, Jacob builds a model tree with sticks and balls containing n nodes in the shape of a tree. Jacob has spent ai minutes building the i-th ball in the tree.
Jacob's teacher will evaluate his model and grade Jacob ba... | vfc_79793 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 7, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n3 6 1 4 2\n1 2\n2 4\n2 5\n1 3\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n1 5 5 5\n1 2\n1 3\n1 4\n",
"output": "1",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | 664_E. 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_79797 | {
"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\n120 120 1\n61 61 120\n-61 61 120\n0 0 0\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0 119\n-3 -17 -42\n0 7 0\n51 0 0\n",
"output": "2\n",
"type": "... | |
code_contests | verifiable_code | 689_C. Mike and Chocolate Thieves | Solve the following coding problem using the programming language python:
Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible!
Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for... | ```python
def main():
m = int(input())
if m < 1000000:
lo = m*4
hi = m*8
else:
lo = int(4.949 * m)
hi = int(4.9492 * m)
while lo < hi - 1:
mid = (lo + hi)//2
nposs = countposs(mid)
if nposs < m:
lo = mid
else:
hi = m... | vfc_79801 | {
"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": "10\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 732_A. Buy a Shovel | Solve the following coding problem using the programming language python:
Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.
In his pocket Polycarp has an un... | ```python
price, change = map(int, input().split())
ans = 1
total = price
while not((total % 10 != 0 and change == total % 10) or (total % 10 == 0)):
total += price
ans += 1
print(ans)
``` | vfc_79809 | {
"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": "237 7\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 756_B. Travel Card | Solve the following coding problem using the programming language python:
A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.
The fare is construc... | ```python
def lower_bound(arr, left, right, target):
if arr[right]<target:
return right+1
while left < right:
mid = (left + right) >> 1
if arr[mid] >= target:
right = mid
else:
left = mid + 1
return left
T = int(input())
arr = [0] * T
dp = [0] * (T + ... | vfc_79813 | {
"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": "10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n",
"output": "20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n10\n20\n30\n",
"output": "20\n2... |
code_contests | verifiable_code | 777_C. Alyona and Spreadsheet | Solve the following coding problem using the programming language python:
During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables.
Now she has a table filled with integers. The table consists of n rows and m columns. By ai, j we will denote the integer loca... | ```python
import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
# region fastio
BUF... | vfc_79817 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\n1 2 3 5\n3 1 3 2\n4 5 2 3\n5 5 3 2\n4 4 3 4\n6\n1 1\n2 5\n4 5\n3 5\n1 3\n1 5\n",
"output": "Yes\nNo\nYes\nYes\nYes\nNo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\n523130301\... |
code_contests | verifiable_code | 802_A. Heidi and Library (easy) | Solve the following coding problem using the programming language python:
Your search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so that people can borrow and ... | ```python
n,k=map(int,input().split())
a=list(map(int,input().split()))
z=[0]*81
kz,ans=0,0
for i in range(n):
if z[a[i]]: continue
ans+=1
if k>kz:
z[a[i]]=1; kz+=1
else:
h=-1
for j in range(1,n+1):
if z[j]:
m=n+1
for p in range(i,n):
... | vfc_79821 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n1 2 3 1\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 822_C. Hacker, pack your bags! | Solve the following coding problem using the programming language python:
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha.
So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the ... | ```python
from bisect import bisect_left
f = lambda: map(int, input().split())
n, x = f()
s, t = {}, {}
for i in range(n):
l, r, c = f()
d = r - l
if d not in s: s[d] = []
s[d].append((l, c))
for d, p in s.items():
p.sort(key=lambda q: q[0])
q = t[d] = [[l, c] for l, c in p]
for i in range(1... | vfc_79825 | {
"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": "4 5\n1 3 4\n1 2 5\n5 6 1\n1 2 4\n",
"output": "5",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 847_H. Load Testing | Solve the following coding problem using the programming language python:
Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last n minutes and in the i-th minute friends will... | ```python
n = int(input())
a = list(map(int, input().split()))
lp,rp = [0 for i in range(n)],[0 for i in range(n)]
lnr, rnr = [a[i] for i in range(n)],[a[i] for i in range(n)]
mx = a[0]
for i in range(1,n):
if a[i] > mx:
mx = a[i]
lp[i] = lp[i-1]
else:
mx += 1
lp[i] = lp[i-1] +... | vfc_79829 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 4 3 2 5\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 869_C. The Intriguing Obsession | Solve the following coding problem using the programming language python:
— This is not playing but duty as allies of justice, Nii-chan!
— Not allies but justice itself, Onii-chan!
With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for s... | ```python
a,b,c = list(map(int, input().split(' ')))
MOD = 998244353
def d(a, b):
s = 1
for i in range(a, b+1):
s*=i
s%=MOD
return s
def cnk(n,k):
s = 1
for i in range(n-k+1, n+1):
s*=i
for i in range(1,k+1):
s/=i
return s
def factorial(n):
s = 1
for i in range(1, n+1):
s*=i
return s
de... | vfc_79833 | {
"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 3 5\n",
"output": "3264\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 1\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "... |
code_contests | verifiable_code | 895_B. XK Segments | Solve the following coding problem using the programming language python:
While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of differe... | ```python
from bisect import bisect_left
R=lambda:map(int,input().split())
n,x,k=R()
a=sorted(R())
z=zip(a,(((u-1)//x+k)*x for u in a))
print(sum(bisect_left(a,l+x)-bisect_left(a,max(u,l)) for u,l in z))
``` | vfc_79837 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 1\n1 3 5 7\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3 1\n3 3 3 3 3\n",
"output": "25",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 916_C. Jamie and Interesting Graph | Solve the following coding problem using the programming language python:
Jamie has recently found undirected weighted graphs with the following properties very interesting:
* The graph is connected and contains exactly n vertices and m edges.
* All edge weights are integers and are in range [1, 109] inclusive. ... | ```python
INF = 1000000
erast = [1] * INF
erast[1] = 0
primes = []
for i in range(2, INF):
if erast[i] == 1:
for j in range(i * 2, INF, i):
erast[j] = 0
primes.append(i)
# print(primes)
lastp = primes[-1]
n, m = map(int, input().split())
edges = set()
print(lastp, lastp)
for i in range(... | vfc_79841 | {
"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": "4 4\n",
"output": "3 3\n1 2 1\n2 3 1\n3 4 1\n1 3 1000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n",
"output": "5 5\n1 2 1\n2 3 1\n3 4 1\n4 5 2\n",
"type": "stdi... |
code_contests | verifiable_code | 939_D. Love Rescue | Solve the following coding problem using the programming language python:
Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with lettering that differs from lettering on her pullover. Now she doesn't want to see him and Tolya ... | ```python
length=int(input())
s1=input()
s2=input()
connect=[{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25}]
tot=0
spells=[]
for i in range(0, length):
l1=ord(s1[i])-97
l2=ord(s2[i])-97
if not (l1 in connect[l2]):
tot=tot+1
... | vfc_79845 | {
"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\nabb\ndad\n",
"output": "2\na d\nb a\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\ndrpepper\ncocacola\n",
"output": "7\nd c\nr o\np c\ne a\np o\ne l\nr a\n",
"type": "st... |
code_contests | verifiable_code | 965_A. Paper Airplanes | Solve the following coding problem using the programming language python:
To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make s airplanes.
A group of k people decided to make n airplanes each. They are going to buy several packs of paper, each of them cont... | ```python
k, n, s, p = map(int, input().split())
one = (n + s - 1) // s
print((one * k + p - 1) // p)
``` | vfc_79849 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3 2 3\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3 100 1\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | 992_A. Nastya and an Array | Solve the following coding problem using the programming language python:
Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties:
* In one second we can add an arbitrary (poss... | ```python
n=int(input())
l=list(map(int,input().split()))
l=set(l)
if 0 in l:
print(len(l)-1)
else:
print(len(l))
``` | vfc_79853 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5 -6 -5 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 1 1 1 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | arrow-and-the-echelon-2 | Solve the following coding problem using the programming language python:
Arrow is getting paranoid about Malcom merlyn, his arch-enemy. All his efforts to subdue Merlyn have been in vain. These days Arrow is working on a problem with John Diggle. Diggle mentioned that the Felicity has been facing weird problem with t... | ```python
t=input()
for i in range(0,t):
n=input()
if(n%3==0):
s="5"*n
print s
else:
if((n-5)%3==0 and (n-5)>=0):
s="5"*(n-5)
s=s+"3"*5
print s
else:
k=5
cnt=1
f=0
while(((n-k)%3)!=0):
cnt=cnt+1
k=5*cnt
if(k<=n):
f=1
else:
f=0
if(f==0):
print -1
else:
... | vfc_79857 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n3\n5\n11\n\nSAMPLE",
"output": "-1\n555\n33333\n55555533333\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | check-it | Solve the following coding problem using the programming language python:
Russian Translation Available
You have a graph with N vertices and M edges. Someone has chosen N-1 edges of these M and claims that they form a spanning tree. Just check whether it's true or not.
Input
The first line contains one integer T de... | ```python
try:
num_testcases=int(raw_input())
for tstcs in range(num_testcases):
vertex_edges=raw_input().split(' ')
num_vertices=int(vertex_edges[0])
num_edges=int(vertex_edges[1])
edges=[]
graph=[[]for i in range(num_vertices+1)]
for each_edg in range(num_edges)... | vfc_79861 | {
"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 4\n1 2\n1 3\n2 3\n1 4\n1 2 3\n4 4\n1 2\n1 3\n2 3\n1 4\n2 3 4\n\n\nSAMPLE",
"output": "NO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 4\n1 2\n1 3\n2 4\n1 4\n1 2 3\n4 4\n1... |
code_contests | verifiable_code | dont-jump | Solve the following coding problem using the programming language python:
Chandu and Kundu are bored of dramatic games around. As they are very good friends and scholars they decided to discover a new game.
In total they had N number of marbles with value inscribed on each of them from 1 to N.
Chandu being from roy... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import sys
while True:
line = sys.stdin.readline()
if not line:
break
marble_num = int(line.strip())
marble_stack = []
cont_stack = []
for i in range(1, marble_num):
... | vfc_79865 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "45\n14 13 2 4 6 5 7 22 8 9 11 18 3 10 17 21 20 16 12 1 19 15\n33\n28 10 9 14 15 20 27 22 21 4 13 30 17 18 6 2 1 5 8 12 3 26 11 24 23 19 25 16 29 7\n48\n21 38 16 23 32 5 27 19 9 28 17 35 30 20 43 11 42 15 39 8 22 31 36 34 18 29 25 1... |
code_contests | verifiable_code | grab-the-laddu | Solve the following coding problem using the programming language python:
On the eve of New Year in Dholakpur, Chota Bheem and Chutki are playing a game, described as follows.
There are two plates full of Laddus. Both can eat 'L' (L ≥ 1) laddus from any one plate or 'L' laddus from both the plates in each step. They... | ```python
ans = [0]*1000002
idx = 0
for i in xrange(1000001):
if ans[i]==0:
ans[i] = i + idx
if i + idx <= 1000000:
ans[i+idx] = i
idx = idx + 1
tc = int(raw_input())
while tc>0:
tc = tc - 1
a, b = map(int, raw_input().split())
if a>b:
a, b = b, a
if ans[a] != b:
print "Chutki"
else:
print "Bheem"
... | vfc_79869 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2\n1 3\n2 0\n\nSAMPLE",
"output": "Bheem\nChutki\nChutki",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "36\n27 13\n53 35\n96 96\n57 0\n25 88\n28 26\n77 80\n83 69\n63 0\n46 5\n34 87\n97... |
code_contests | verifiable_code | little-jhool-and-his-punishment | Solve the following coding problem using the programming language python:
Little Jhool was was the most intelligent kid of his school. But he did NOT like his class teacher, his school, and the way he was taught things in school. Well, he was a rebel, to say the least. Like most of us, he hated being punished by his ... | ```python
for i in range(int(raw_input())):
n = int(raw_input())
b, c = sorted([int(i) for i in raw_input().split()])
diff = c-b
if diff>1:
print "Little Jhool wins!"
else:
print "The teacher wins!"
``` | vfc_79873 | {
"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\n3 1\n3\n2 1\n\nSAMPLE",
"output": "Little Jhool wins!\nThe teacher wins!\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | mst-and-idc | Solve the following coding problem using the programming language python:
Mid semester exams are approaching and 'IDC' wants to study with the toppers of the batch.
So he decide to take a temporary room near all the toppers of the computer science batch.
All room are on a straight line and room numbers are integers. ... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
for tc in xrange(input()):
k = input()
n = map(int,raw_input().split())
n.sort()
ans=0
for i in range(1,k):
ans += n[i]-n[i-1]
print ans*2
``` | vfc_79877 | {
"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\n24 13 89 37\n6\n7 30 41 14 39 42\n\nSAMPLE",
"output": "152\n70\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n11\n81 79 91 64 24 32 75 29 51 26 62\n15\n51 3 37 48 8 14 97 73 9... |
code_contests | verifiable_code | pravin-saddam-and-their-aptitude-question | Solve the following coding problem using the programming language python:
Pravin and Saddam are room-mates.They always solve aptitude questions together. Once, they came across a problem stated as:
"Find the digit at the unit place that appears in sum of factorials of all numbers between A and B (both inclusive)."
T... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from math import factorial as fact
t=int(raw_input())
while(t):
sum=0
a,b=map(int,raw_input().split())
for i in range(a,b+1):
sum=sum+fact(i)
prin... | vfc_79881 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n3 5\n\nSAMPLE",
"output": "3\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n3 9\n4 8\n2 18\n6 13\n9 14\n8 16\n10 11\n11 15\n16 17\n16 18\n17 17\n18 18",
"output": "0\... |
code_contests | verifiable_code | samu-and-shooting-game | Solve the following coding problem using the programming language python:
Samu is playing a shooting game in play station. There are two apples to aim in this shooting game. Hitting first apple will provide her X points and hitting second apple will provide her Y points. And if she misses the apple she chose to hit, ... | ```python
# def score_enough(x, y, n, w, p1, p2):
# if not p1 and not p2: return
# if not p1:
# val = w / y + (1 if w % y else 0)
# if val <= n: yield (0, val)
# return
# if not p2:
# val = w / x + (1 if w % x else 0)
# if val <= n: yield (val, 0)
# return
# ... | vfc_79885 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 3 2 5 50 25\n\nSAMPLE",
"output": "12.500000\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | sunny-arpit-and-kunal | Solve the following coding problem using the programming language python:
Sunny, Arpit and Kunal are playing a game. All three of them are standing on a number line, each occupying a different integer.
The rules are as follows:
Two of them cannot be at the same integer at same time.
In one move, one of them, who is... | ```python
t=int(raw_input())
while t:
t-=1
l=[int(i) for i in raw_input().split()]
l.sort()
if(l[1]-l[0] > l[2]-l[1]):
print(l[1]-l[0]-1)
else:
print(l[2]-l[1]-1)
``` | vfc_79889 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 3 4\n0 3 5\n\nSAMPLE",
"output": "1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 3 5\n0 3 5\n\nSAMPLE",
"output": "1\n2\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | what-is-the-maximum-distance-that-you-can-cover-505 | Solve the following coding problem using the programming language python:
You have to go on a trip in your car which can hold a limited amount of fuel. You know how many liters of fuel your car uses per hour for certain speeds and you have to find out how far a certain amount of fuel will take you when travelling at t... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def find_max_fuel():
t= int(raw_input())
speed_arr= map(float,raw_input().split()[:t])
fuel_arr= map(float,raw_input().split()[:t])
max_fuel = int(raw_input())... | vfc_79893 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n250 240 230 220 210 211\n5000 4500 4000 3500 3000 3000\n50000\n\nSAMPLE",
"output": "3516.666\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n250 437 230 220 210 211\n5000 4500 4000 ... |
code_contests | verifiable_code | p00044 Prime Number II | Solve the following coding problem using the programming language python:
A prime number is an integer that is greater than 1 and can only be divided by itself or 1. For example, 2 is a prime number because it is divisible only by 2 and 1, but 12 is not a prime number because it is divisible by 2, 3, 4, 6 in addition ... | ```python
from math import sqrt, ceil
N = 53000
temp = [True]*(N+1)
temp[0] = temp[1] = False
for i in range(2, ceil(sqrt(N+1))):
if temp[i]:
temp[i+i::i] = [False]*(len(temp[i+i::i]))
while True:
try:
n = int(input())
print(n-1-temp[n-1:0:-1].index(True), n+1+temp[n+1:].index(True))
... | vfc_79937 | {
"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": "19\n3517",
"output": "17 23\n3511 3527",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19\n5214",
"output": "17 23\n5209 5227\n",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | p00176 What Color? | Solve the following coding problem using the programming language python:
Taro, who aims to become a web designer, is currently training. My senior at the office tells me that the background color of this page is # ffe085, which is a color number peculiar to web design, but I can't think of what kind of color it is.
... | ```python
COLOR = {
"000000": "black",
"0000ff": "blue",
"00ff00": "lime",
"00ffff": "aqua",
"ff0000": "red",
"ff00ff": "fuchsia",
"ffff00": "yellow",
"ffffff": "white"
}
while True:
input_data = input()
if len(input_data) == 1:
break
color_code = ""
for firs... | vfc_79941 | {
"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": "#ffe085\n#787878\n#decade\n#ff55ff\n0",
"output": "white\nblack\nwhite\nfuchsia",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ffe085\n787878\ndecade\nff55ff\n0",
"output": "white\nbl... |
code_contests | verifiable_code | p00513 Available Areas | Solve the following coding problem using the programming language python:
IOI Real Estate rents condominiums. The apartment room handled by this company is 1LDK, and the area is 2xy + x + y as shown in the figure below. However, x and y are positive integers.
Figure_Madori
In the IOI real estate catalog, the areas... | ```python
def check(a):
for i in range(2,int(a**(1/2))+1):
if a%i == 0:
return 1
return 0
n = int(input())
count = 0
for i in range(n):
num = int(input())
if check(2*num+1) == 0:
count += 1
print(count)
``` | vfc_79949 | {
"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": "None",
"output": "None",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n4\n7\n9\n10\n12\n13\n16\n17\n19\n20",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | p00831 Confusing Login Names | Solve the following coding problem using the programming language python:
Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers conn... | ```python
from collections import Counter
from itertools import permutations
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N = int(readline())
if N == 0:
return False
def dist(a, b):
LA = len(a); LB = len(b)
dp = [[10**18]*(LB+1) for i in range(LA+1)... | vfc_79957 | {
"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": "8\n2\nomura\ntoshio\nraku\ntanaka\nimura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqrst\nabdxcef\n0",
"output": "imura,miura\nimura,omura\nmiura,omura\ntoshio,yoshoi\n4\nt... |
code_contests | verifiable_code | p00962 Pizza Delivery | Solve the following coding problem using the programming language python:
Problem F Pizza Delivery
Alyssa is a college student, living in New Tsukuba City. All the streets in the city are one-way. A new social experiment starting tomorrow is on alternative traffic regulation reversing the one-way directions of street... | ```python
from heapq import heappush, heappop
from collections import deque
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
E = []
G = [[] for i in range(n)]
RG = [[] for i in range(n)]
for i in range(m):
a, b, c = map(int, input().split())
E.append((a-1, b-1, c))
G[a-1].append((b-1... | vfc_79961 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 12",
"output": "SAD\nSAD\nSAD\nSOSO\nHAPPY",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p01095 Bamboo Blossoms | Solve the following coding problem using the programming language python:
Bamboo Blossoms
The bamboos live for decades, and at the end of their lives, they flower to make their seeds. Dr. ACM, a biologist, was fascinated by the bamboos in blossom in his travel to Tsukuba. He liked the flower so much that he was tempt... | ```python
from bisect import bisect_left
def rwh_primes2(n):
# https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
""" Input n>=6, Returns a list of primes, 2 <= p < n """
correction = (n%6>1)
n = {0:n,1:n-1,2:n+4,3:n+3,4:n+2,5:n+1}[n%6]
siev... | vfc_79965 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 1\n3 4\n10 20\n100 50\n2 500000\n0 0",
"output": "4\n11\n47\n150\n7368791",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p01703 Speedrun | Solve the following coding problem using the programming language python:
Problem Statement
Infinite Chronicle -Princess Castle- is a simple role-playing game. There are $n + 1$ checkpoints, numbered $0$ through $n$, and for each $i = 1, 2, \ldots, n$, there is a unique one-way road running from checkpoint $i - 1$ to... | vfc_79981 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0.50 0.40\n2\n0.70 0.60\n4\n0.99 1.00 1.00 0.01\n0",
"output": "5.5000000000\n4.0476190476\n104.0101010101",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01847 Curtain | Solve the following coding problem using the programming language python:
curtain
Summer is coming soon. You decide to redecorate your room for the summer. It is expected that the sun will be very strong this summer, and it will be a difficult season for you who are not good at dazzling. So you thought about installi... | ```python
from collections import defaultdict
INF = 10**9
while 1:
N = int(input())
if N == 0:
break
P = [list(map(int, input().split())) for i in range(N)]
S = defaultdict(list)
X = set()
x0 = y0 = INF; x1 = y1 = -INF
for i in range(4):
x, y = map(int, input().split())
... | vfc_79985 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0 0\n10 0\n10 10\n0 10\n0 0\n5 0\n5 10\n0 10\n6\n0 0\n10 0\n10 5\n5 5\n5 10\n0 10\n2 0\n8 0\n8 10\n2 10\n12\n1 1\n1 3\n-1 3\n-1 1\n-3 1\n-3 -1\n-1 -1\n-1 -3\n1 -3\n1 -1\n3 -1\n3 1\n2 2\n-2 2\n-2 -2\n2 -2\n4\n20000 20000\n-20000 ... |
code_contests | verifiable_code | p01983 Proof of Knowledge | Solve the following coding problem using the programming language python:
Proof of knowledge
The entrance door of the apartment you live in has a password-type lock. This password consists of exactly four digits, ranging from 0 to 9, and you always use the password P given to you by the apartment manager to unlock th... | ```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in ... | vfc_79989 | {
"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": "[+c[+a[^bd]]]\n0404\n[*b[*[*cd]a]]\n7777\n[^[^ab][^cd]]\n1295\na\n9876\n[^dd]\n9090\n.",
"output": "0 10\n7 1\n15 544\n9 1000\n0 10000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "[+c[+a[... |
code_contests | verifiable_code | p02270 Allocation | Solve the following coding problem using the programming language python:
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zer... | ```python
from sys import stdin
def binSearch(k, p_min, p_max):
global w
while p_max-p_min > 1:
mid = p_min + (p_max-p_min)//2
if k >= countTrack(w, mid):
p_max = mid
else:
p_min = mid
return p_max
def countTrack(w, p):
rest = []
for wi in w:
... | vfc_79997 | {
"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\n8\n1\n7\n3\n9",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n1\n2\n2\n6",
"output": "6",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p02417 Counting Characters | Solve the following coding problem using the programming language python:
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
Constraints
* The number of characters in the sentence < 1200
Input
A sentence in English is given in several lines.
Output
Pri... | ```python
import sys
x=sys.stdin.read().lower()
for i in range(97,123):
print(chr(i),':',x.count(chr(i)))
``` | vfc_80001 | {
"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": "This is a pen.",
"output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0",
"type": ... |
code_contests | verifiable_code | amsgame1 | Solve the following coding problem using the programming language python:
Chef is playing a game on a sequence of N positive integers, say A1, A2, ... AN. The game is played as follows.
If all the numbers are equal, the game ends.
Otherwise
Select two numbers which are unequal
Subtract the smaller number from the la... | ```python
from fractions import gcd
t=int(raw_input())
while(t>0):
t-=1
n=input()
a=[int(i) for i in raw_input().split()]
ans=gcd(a[0],a[1])
for i in range(2,n):
ans=gcd(ans,a[i])
print ans
``` | vfc_80005 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n10 12\n2\n5 9\n3\n6 10 15",
"output": "2\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2\n10 12\n2\n5 9\n3\n8 10 15",
"output": "2\n1\n1\n",
"type": "stdin_std... |
code_contests | verifiable_code | chn15a | Solve the following coding problem using the programming language python:
Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which m... | ```python
import sys
t=int(raw_input(""))
while t:
m,n=map(int,sys.stdin.readline().split())
l=list(map(int,sys.stdin.readline().split()))
count=0
for i in range(len(l)):
if (l[i]+n)%7==0:
count+=1
print count
t-=1
``` | vfc_80009 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 10\n2 4 1 35 1",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n5 10\n2 4 1 62 1",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.