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 | 71_B. Progress Bar | Solve the following coding problem using the programming language python:
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. ... | ```python
from math import floor
n, k, t = map(int, input().split())
l = [0 for i in range(n)]
g = t / 100 * n
gl = floor(g)
for i in range(gl):
l[i] = k
if gl < n:
l[gl] = floor((g - gl) * k)
for item in l:
print(item, end = ' ')
``` | vfc_62313 | {
"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": "11 13 37\n",
"output": "13 13 13 13 0 0 0 0 0 0 0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 740_D. Alyona and a tree | Solve the following coding problem using the programming language python:
Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote ai. Moreover, the girl wrote a positive integer to every edge of the tree (possibly, different in... | vfc_62317 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n9 7 8 6 5\n1 1\n2 1\n3 1\n4 1\n",
"output": "4 3 2 1 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 5 1 4 6\n1 7\n1 1\n3 5\n3 6\n",
"output": "1 0 1 0 0\n",
"type": ... | |
code_contests | verifiable_code | 764_C. Timofey and a tree | Solve the following coding problem using the programming language python:
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.
Now it's time for Timofey birthday, and his mother asked him to remove t... | ```python
def main():
n = int(input())
pairs = []
for i in range(n-1):
a, b = list(map(int, input().split()))
pairs.append([a-1, b-1])
colors = list(map(int, input().split()))
bad_pairs_count = 0
bad_points_counts = {0:0}
for a,b in pairs:
if colors[a] != colors[b]:
bad_pairs_count += 1
def add(x)... | vfc_62321 | {
"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\n1 2\n2 3\n3 4\n1 2 1 2\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 787_E. Till I Collapse | Solve the following coding problem using the programming language python:
Rick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated n Mr. Meeseeks, standing in a line numbered from 1 to n. Each of them has his own color. i-th Mr. Meeseeks' color is ai.
Rick and... | vfc_62325 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 3 4 3 3\n",
"output": "4 2 1 1 1 \n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 809_B. Glad to see you! | Solve the following coding problem using the programming language python:
This is an interactive problem. In the output section below you will see the information about flushing the output.
On Sunday Leha the hacker took Nura from the house where she lives and went with her to one of the most luxurious restaurants in... | vfc_62329 | {
"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 2\nNIE\nTAK\nNIE\nTAK\nTAK\nTAK\n",
"output": "1 2 3\n1 1 2\n2 3 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100000 2\n2 99999\n",
"output": "1 50000 50001\n1 75000 75001\n1 ... | |
code_contests | verifiable_code | 833_E. Caramel Clouds | Solve the following coding problem using the programming language python:
<image>
It is well-known that the best decoration for a flower bed in Sweetland are vanilla muffins. Seedlings of this plant need sun to grow up. Slastyona has m seedlings, and the j-th seedling needs at least kj minutes of sunlight to grow up.... | vfc_62333 | {
"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 10\n3 7 9\n10 90 10\n2\n10\n100\n",
"output": "10\n104\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 15\n1 4 17\n2 8 6\n4 8 9\n2\n5\n1\n",
"output": "8\n1\n",
"type": "st... | |
code_contests | verifiable_code | 854_C. Planning | Solve the following coding problem using the programming language python:
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.
Metropolis airport is the main transport h... | ```python
from heapq import heappush,heappop,heapify
n,k=map(int,input().split())
*l,=map(int,input().split())
q=[(-l[i],i)for i in range(k)]
heapify(q)
a=[0]*n
s=0
for i in range(k,n) :
heappush(q,(-l[i],i))
x,j=heappop(q)
s-=x*(i-j)
a[j]=i+1
for i in range(n,n+k) :
x,j=heappop(q)
s-=x*(i-j)
... | vfc_62337 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n4 2 1 10 2\n",
"output": "20\n3 6 7 4 5 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n",
"output": "1\n2 \n",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 879_A. Borya's Diagnosis | Solve the following coding problem using the programming language python:
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first ... | ```python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
n = int(input())
r = 0
while n > 0:
s, d = list(map(int, input().split()))
r = max(r + 1, s)
if (r - s) % d != 0:
r += d - (r - s) % d
n -= 1
print(r)
``` | vfc_62341 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10 1\n6 5\n",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 2\n1 2\n2 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 902_C. Hashing Trees | Solve the following coding problem using the programming language python:
Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should mat... | ```python
h = int(input())
a = list(map(int, input().split()))
p, c, f = 0, 0, False
s1, s2 = [], []
for i in a:
for j in range(i):
s1.append(c)
if j==i-1 and not f and p>=2 and i>=2:
f = True
s2.append(c-1)
else:
s2.append(c)
p = i
c += i
print('p... | vfc_62345 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1 1\n",
"output": "perfect",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2 2\n",
"output": "ambiguous\n0 1 1 3 3 \n0 1 1 2 3 ",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 924_E. Wardrobe | Solve the following coding problem using the programming language python:
Olya wants to buy a custom wardrobe. It should have n boxes with heights a1, a2, ..., an, stacked one on another in some order. In other words, we can represent each box as a vertical segment of length ai, and all these segments should form a si... | vfc_62349 | {
"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 2 5\n3 6\n1 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3 6\n3 2 5 1 2\n1 1 0 1 0\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 952_G. Puzzling Language | Solve the following coding problem using the programming language python:
In this problem you will write a simple code generator for a 2D programming language derived from [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck).
The code in this language is a rectangular grid of characters '.' and 'X'. The code is conve... | ```python
# python3
WIDTH = 300
assert WIDTH >= 256
def add(n):
if n == 1:
add(2)
add(255)
elif n:
print('.' * WIDTH)
print('X' * (n - 1) + '.' * (WIDTH - n) + 'X')
print('X' * WIDTH)
def print_mem2():
print('.' * WIDTH)
print('XX' + '.' * (WIDTH - 2))
pr... | vfc_62353 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "$$$",
"output": "..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n... |
code_contests | verifiable_code | 97_D. Robot in Basement | Solve the following coding problem using the programming language python:
The Professor has lost his home robot yet again. After some thinking Professor understood that he had left the robot in the basement.
The basement in Professor's house is represented by a rectangle n × m, split into 1 × 1 squares. Some squares ... | vfc_62357 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 7\n#####\n#.#.#\n#...#\n#E..#\n#####\nUULLDDR\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3 2\n###\n#.#\n#.#\n#E#\n###\nDD\n",
"output": "2\n",
"typ... | |
code_contests | verifiable_code | 99_D. Help King | Solve the following coding problem using the programming language python:
This is the modification of the problem used during the official round. Unfortunately, author's solution of the original problem appeared wrong, so the problem was changed specially for the archive.
Once upon a time in a far away kingdom lived ... | ```python
from math import gcd
def PRINT(a, b) :
print(str(int(a)) + "/" + str(int(b)))
def solve(n) :
pre = 0
while(n > 1 and (n % 2 == 0)) :
pre = pre + 1
n = n // 2
if(n == 1) :
PRINT(pre, 1)
return
arr = []
... | vfc_62361 | {
"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\n",
"output": "8/3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "1/1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
... |
code_contests | verifiable_code | benny-and-triangle-marcheasy | Solve the following coding problem using the programming language python:
View Russian Translation
One day Benny decides to miss lessons. But as she is a very good pig she will do her homework anyway. She doesn't know anything about the content of this lessons. Your task is to help her.
The problem is following: you... | ```python
a,b,p=map(int,raw_input().split())
print('%.2f' % (b-b*((p**0.5)/10)))
``` | vfc_62365 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2 25\n\nSAMPLE",
"output": "1.00\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 0 25\n\nSAMPLE",
"output": "0.00\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
code_contests | verifiable_code | comrades-i-3 | Solve the following coding problem using the programming language python:
The Humans are at war against a very powerful alien race that invaded our solar system.
The human army has n soldiers. The soldiers are numbers from 1 to n. The army has a superiority hierarchy. Every soldier has one immediate superior. The sup... | ```python
def bfs(x):
b=[False]*(n+1)# an array of false flags to keep track of vertices visited
#memo=[-1]*(n+1)
global memo,component_id,root
#found=False
c=0
q=[]
q.append(x)
component_id[x]=c
#root=0
memo[x]=0
while len(q)!=0 :
#t=s[-1]
top=q.pop()
... | vfc_62369 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n10\n5 5 5 5 0 5 5 5 5 5\n5\n1 5\n5 1\n10 7\n7 10\n9 1\n10\n0 1 1 2 4 5 5 6 7 9 \n8\n10 1\n9 7\n4 6\n6 4\n7 4\n8 5\n6 5\n3 1\n10\n2 3 4 5 6 0 6 7 8 9\n7\n2 6\n5 6\n9 6\n8 6\n3 2\n6 9\n6 10\n15\n0 1 1 2 2 3 3 4 4 5 5 6 6 7 7\n20\n... |
code_contests | verifiable_code | find-factorial | Solve the following coding problem using the programming language python:
You have been given a positive integer N. You need to find and print the Factorial of this number. The Factorial of a positive integer N refers to the product of all number in the range from 1 to N. You can read more about the factorial of a nu... | ```python
import math
print math.factorial(int(raw_input()))
``` | vfc_62373 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n\nSAMPLE",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n\nELPMAS",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | illegible-string | Solve the following coding problem using the programming language python:
Your friend Max has written a string S in your textbook. The string consists of lowercase latin letters. The problem is that Max is not good at writing at all! Especially, you never know if he wanted to write "w" or two consecutive "v". Given th... | ```python
tc = input()
data = raw_input()
other = ""
max1 = 0
for char in data:
if char == 'w':
max1 += 2
other += 'vv'
elif char == 'v':
max1 += 1
other += 'v'
else:
other += char
max1 += 1
i = 1
min1 = max1
while i < max1:
if other[i-1] == "v" and other[i] =="v":
min1 -= 1
i += 2
else:
i+= 1
#... | vfc_62377 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\navwvb\n\nSAMPLE",
"output": "4 6\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | marut-vs-devil-army-1 | Solve the following coding problem using the programming language python:
Marut is great warrior. Marut loves his girlfriend Shizuka very much. Being jealous from Marut's love, the Devil kidnaps his girlfriend. Hence, Marut declares a war against the Devil. The devil decides to send his army men one by one to fight w... | ```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())
for i in range(t):
a=raw_input().strip().split(" ")
b=raw_input().strip().split(" ")
a=map(int,a)
b=map(int,b)
s=sum(b)
initial_energy=a[1]
code_ras=... | vfc_62381 | {
"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 5 3\n1 4 5 1 \n5 2 2\n5 1 3 1 2\n\nSAMPLE",
"output": "3\n6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n100 679 912\n3278 7762 4458 4699 3226 1541 2960 8012 2266 3931 7911 8214... |
code_contests | verifiable_code | numbers-of-interest-2-1 | Solve the following coding problem using the programming language python:
After solving Reese's first problem Harold thought he had proven himself. But Reese wasn't convinced so he gave Harold another query. He told Harold to find the nth term of the sequence given by the equation.
a[n]=( f[n] + g[n] ) % n
where, f... | ```python
arr = [0]*100005
f = [0]*100005
ans = [0]*100005
def mark(a):
i = 2
while i*a<=100002:
num = i*a
if arr[num]==0:
arr[num] += a
i += 1
def sieve():
for i in xrange(2,100002):
if arr[i]==0:
arr[i] = arr[i-1]+i
mark(i)
else:
arr[i] += arr[i-1]
sieve()
for i in xrange(1,100002//2+1):
fo... | vfc_62385 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n\n\nSAMPLE",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "400\n44\n18470\n6337\n26503\n19172\n15727\n11481\n29361\n26965\n24467\n5708\n28148\n23284\n16830\n9964\n494\n2... |
code_contests | verifiable_code | rahuls-shopping | Solve the following coding problem using the programming language python:
Rahul has to buy a few wooden planks ,the shop he visited has 50 different types of wooden planks available.Each type of plank is marked from 1-50.The rate(per square feet) of each plank is calculated as the number marked on the
plank multiplied... | ```python
raw_input()
typeofplanks = map(int, raw_input().split())
l,b = map(int, raw_input().split())
def sum_digits3(n):
r = 0
while n:
r, n = r + n % 10, n / 10
return r
total_price = 0
for p in typeofplanks:
price = (p * sum(int(digit) for digit in str(p)))
#price = (p * sum_digits3(p)... | vfc_62389 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n12 5 42\n2 3\n\nSAMPLE",
"output": "1472\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n12 1 42\n2 3\n\nSAMPLE",
"output": "1364\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | shooting-balls | Solve the following coding problem using the programming language python:
Abhikalpan the tech-fest of IIITDMJ brings an amazing
competition of breaking love triangles. So the coordinators of the
event invite all triples from all over the world.
A triple can have 2 boys and 1 girl or 2 girls and 1 bo... | ```python
t=int(raw_input())
for sdgdg in xrange(t):
a,b=(int(e) for e in raw_input().split(' '))
print b-1,a-1
``` | vfc_62393 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7 4\n\nSAMPLE",
"output": "3 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "383\n86 78\n15 94\n35 87\n92 50\n21 63\n27 91\n59 64\n26 41\n26 73\n36 12\n68 68\n29 83\n30 63\n23 68\n35 ... |
code_contests | verifiable_code | the-road-not-taken | Solve the following coding problem using the programming language python:
Robert Frost is standing on a cross-way with six roads diverging out. He decides to choose the road not taken. After travelling the pathway he reaches a similar but yet another cross-way with six another roads diverging out. He keeps on travelli... | ```python
a = [1, 0, 6, 12, 90, 360, 2040, 10080, 54810, 290640, 1588356, 8676360, 47977776, 266378112, 1488801600, 8355739392, 47104393050, 266482019232, 1512589408044, 8610448069080, 49144928795820, 281164160225520]
t = input()
while t:
n = input()
print a[n]
t -= 1
``` | vfc_62397 | {
"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\n2\n\nSAMPLE",
"output": "0\n6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "14\n1\n7\n2\n12\n6\n10\n3\n8\n11\n13\n4\n5\n9\n14",
"output": "0\n10080\n6\n47977776\n2040\n1588356\... |
code_contests | verifiable_code | p00094 Calculation of Area | Solve the following coding problem using the programming language python:
Have you ever heard of the unit "○○ tsubo" that expresses the area of land? Since ancient times, one samurai has said the area for making rice to eat in a day.
There is a land of a [m] x b [m]. Enter a and b and create a program that outputs ... | ```python
a, b = (int(x) for x in input().split())
s = a*b
S = s/3.305785
print('{0:.6f}'.format(S))
``` | vfc_62445 | {
"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": "15 25",
"output": "113.437508",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15 2",
"output": "9.07500034031\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | p00226 Hit and Blow | Solve the following coding problem using the programming language python:
Taro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows.
* Separated into questioners and respondents.
* The questioner decides a 4-digit number (correct answer) that does not include duplicate numbers.
* Respondents... | ```python
while 1:
x,y = map(list,input().split())
if x == ['0'] and y== ['0']: break
h = b = 0
for i in range(len(x)):
if x[i] == y[i]:
h += 1
elif y[i] in x:
b += 1
print ('%d %d' % (h,b))
``` | vfc_62449 | {
"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": "1234 5678\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0",
"output": "0 0\n2 1\n4 0\n1 3\n0 3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00604 Cheating on ICPC | Solve the following coding problem using the programming language python:
Peter loves any kinds of cheating. A week before ICPC, he broke into Doctor's PC and sneaked a look at all the problems that would be given in ICPC. He solved the problems, printed programs out, and brought into ICPC. Since electronic preparatio... | ```python
while True:
try:
n=int(input())
A=sorted(list(map(int,input().split())))
S=0
K=0
for i in range(n):
S+=A[i]*(n-i)
print(S)
except EOFError:
break
``` | vfc_62457 | {
"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\n10 20 30\n7\n56 26 62 43 25 80 7",
"output": "100\n873",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n10 20 30\n7\n56 26 62 43 38 80 7",
"output": "100\n939\n",
"type": "s... |
code_contests | verifiable_code | p01143 Princess's Gamble | Solve the following coding problem using the programming language python:
Princess'Gamble
Princess gambling
English text is not available in this practice contest.
One day, a brave princess in a poor country's tomboy broke the walls of her room, escaped from the castle, and entered the gambling hall where horse rac... | ```python
while True:
n, m, p = map(int, input().split())
if n == 0:
break
players = [int(input()) for _ in range(n)]
gold_div = sum(players) * (100 - p)
winner = players[m - 1]
print(int(gold_div / winner) if winner > 0 else 0)
``` | vfc_62473 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 50\n1\n2\n3\n4 4 75\n1\n2\n3\n0\n3 1 10\n8\n1\n1\n0 0 0",
"output": "150\n0\n112",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p01282 Revenge of the Round Table | Solve the following coding problem using the programming language python:
Two contries A and B have decided to make a meeting to get acquainted with each other. n ambassadors from A and B will attend the meeting in total.
A round table is prepared for in the meeting. The ambassadors are getting seated at the round ta... | vfc_62477 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 1\n3 2\n3 3\n4 2\n10 5\n1000 500\n0 0",
"output": "0\n2\n4\n2\n90\n570682",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n3 2\n3 3\n4 2\n7 5\n1000 500\n0 0",
"output": "0\n2\n4\... | |
code_contests | verifiable_code | p01452 10-Year-Old Dynamic Programming | Solve the following coding problem using the programming language python:
<image>
One evening. As usual, when you were watching TV in the living room, my sister in fifth grade offered me a consultation. When I listened to the story, I couldn't understand the math problem that was presented at school today, so I want ... | ```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in ... | vfc_62481 | {
"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": "6 4 0",
"output": "210",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "124 218 367",
"output": "817857665",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | p01602 Parentheses | Solve the following coding problem using the programming language python:
()
Problem Statement
There is a string S. Initially, S is an empty string.
Perform the following processing in order of n.
* Add x_i p_i (=" (" or") ") to the end of S.
After processing, determine if S is a well-balanced string.
"The stri... | ```python
n = int(input())
s = 0
f = 0
for i in range(n):
p,x = input().split()
x = int(x)
if p == "(":
s += x
else:
s -= x
if s < 0:
f = 1
if f or s != 0:
print("NO")
else:
print("YES")
``` | vfc_62485 | {
"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\n) 1\n( 1",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n( 5\n) 4\n) 1",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | p01898 Taking a Seat | Solve the following coding problem using the programming language python:
A: Taking a Seat-Taking a Seat-
story
Mr. A entered the classroom at the examination site to take an examination. However, Mr. A is a very nervous type. Therefore, depending on the situation, there may be seats that Mr. A does not want to sit ... | ```python
m,n = map(int,input().split())
seat = [list(input()) for i in range(m)]
dummy = ["0" for i in range(n+2)]
for i in range(m):
seat[i].insert(0,"0")
seat[i].append("0")
seat.insert(0,dummy)
seat.append(dummy)
for i in range(1,m + 1):
for j in range(1,n + 1):
if seat[i][j] == "o":
... | vfc_62493 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n--o--\n--xo-\n--x--\no---x\n--xoo",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n--o,-\n--xo-\n--x--\no---x\n--xoo",
"output": "3\n",
"type": "stdin_std... |
code_contests | verifiable_code | p02035 Red-Black Soul Gem | Solve the following coding problem using the programming language python:
F: Red-Black Soul Gem
problem
Homu-chan has the mysterious power to change the soul game to red or black, and to connect two different soul games with a magic thread. By using this power, Homu-chan can create a magic square by Sorujemu.
Homu-... | vfc_62497 | {
"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": "3 310779401",
"output": "12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 310779401",
"output": "232\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... | |
code_contests | verifiable_code | p02178 Walking | Solve the following coding problem using the programming language python:
problem
There are $ N $ islands numbered from $ 1 $ to $ N $.
Each island has $ N-1 $ bridges, allowing any $ 2 $ island to move to each other across several bridges.
Each bridge has durability, and the durability of the $ i $ th bridge given t... | ```python
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline(... | vfc_62501 | {
"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": "4 10 1 4\n1 2 52\n1 3 68\n3 4 45",
"output": "Yes",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p02321 Huge Knapsack Problem | Solve the following coding problem using the programming language python:
You have N items that you want to put them into a knapsack. Item i has value vi and weight wi.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at mos... | ```python
from bisect import bisect_right
def main():
N,W = map(int, input().split())
wv = []
for _ in range(N):
v,w = map(int, input().split())
wv.append([w,v])
d1 = [[0,0]]
d2 = [[0,0]]
half = N // 2
for i in range(half):
w,v = wv[i]
size = len(d1)
... | vfc_62505 | {
"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\n4 2\n5 2\n2 1\n8 3",
"output": "13",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 20\n5 9\n4 10",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": null... |
code_contests | verifiable_code | cballs | Solve the following coding problem using the programming language python:
Little Churu is a naughty child, who likes to play with balls. He has N buckets. Each bucket contains one or more balls. He has numbered his buckets 1 to N (both inclusive). He has an infinite supply of extra balls, apart from the ones already i... | ```python
T = int(raw_input())
n = []
a = []
m = []
for t in xrange(T):
n.append(int(raw_input()))
a.append(map(int, raw_input().split()))
m.append(max(a[-1]))
M = max(m)
l = [False, False] + [True] * (M-1)
for i in xrange(2,M+1):
if (l[i]):
for j in range(2*i, M+1, i):
l[j]=False
for t in xrange(T):
x = ... | vfc_62513 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n11 13 15",
"output": "3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | cs05 | Solve the following coding problem using the programming language python:
Problem text...
Many persons are familiar with the Roman numerals for relatively small
numbers. The symbols i, v, x, l and c represent the decimal values 1, 5, 10, 50 and
100 respectively. To represent other values, these symbols, and multiples ... | ```python
def toroman(N):
R = []
for D in [100,50,10,5,1]:
R.append(N / D)
N %= D
R = ''.join(map(lambda x: x[0]*x[1], zip('clxvi', R)))
R = R.replace('lxxxx', 'xc')
R = R.replace('xxxx', 'xl')
R = R.replace('viiii', 'ix')
R = R.replace('iiii', 'iv')
return R
def proce... | vfc_62517 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n20\n99\n0",
"output": "3 0 0 0 0\n28 10 14 0 0\n140 50 150 50 10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n35\n99\n0",
"output": "3 0 0 0 0\n49 17 51 0 0\n140 50 150 50 10\... |
code_contests | verifiable_code | hatfact | Solve the following coding problem using the programming language python:
In mathematics, the factorial of a non-negative integer N, denoted by N!, is the product of all positive integers less than or equal to N. The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, an... | ```python
import math
t = input();
while(t > 0):
print math.factorial(input());
t -= 1;
``` | vfc_62521 | {
"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\n6\n7",
"output": "120\n720\n5040",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | recmsg | Solve the following coding problem using the programming language python:
Problem description
Ravi has fallen in love with Riya. As he is my best friend, I am the only person who knows it and of course I am not going to tell you how this happened :DHe starts messaging Riya as everyone does and soon realizes that his f... | ```python
t=input()
s="abcdefghijklmnopqrstuvwxyz"
d={}
count=1
for i in s:
d[i]=count
count+=1
for kk in range(0,t):
s=raw_input()
ans=0
for i in s:
ans+=d[i]
print ans
``` | vfc_62529 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nacd\nabcde",
"output": "8\n15\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | treeroot | Solve the following coding problem using the programming language python:
Chef has a binary tree. The binary tree consists of 1 or more nodes. Each node has a unique integer id. Each node has up to 2 children, which are identified by their ids, and each node is the child of at most 1 other node. A node X is considered... | ```python
t=input()
for i in range(t):
n=input()
a=0
b=0
for j in range(n):
x,y=map(int,raw_input().split())
a+=x
b+=y
print a-b
``` | vfc_62533 | {
"difficulty": "3",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n4 0\n6\n1 5\n2 0\n3 0\n4 0\n5 5\n6 5",
"output": "4\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1\n4 0\n6\n1 8\n2 0\n3 0\n4 0\n5 5\n6 5",
"output": "4\n3\n",
"t... |
code_contests | verifiable_code | 103_E. Buying Sets | Solve the following coding problem using the programming language python:
The Hexadecimal virus loves playing with number sets — intersecting them, uniting them. One beautiful day she was surprised to find out that Scuzzy, her spherical pet cat, united all sets in one and ate the result! Something had to be done quick... | vfc_62541 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2 1 2\n2 2 3\n2 3 4\n2 4 5\n2 5 1\n1 -1 1 -1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 1 2\n2 2 3\n2 3 4\n2 4 5\n2 5 1\n-1 1 -1 1 -1\n",
"output": "-... | |
code_contests | verifiable_code | 1062_F. Upgrading Cities | Solve the following coding problem using the programming language python:
There are n cities in the kingdom X, numbered from 1 through n. People travel between cities by some one-way roads. As a passenger, JATC finds it weird that from any city u, he can't start a trip in it and then return back to it using the roads ... | vfc_62545 | {
"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": "6 7\n1 2\n2 3\n3 4\n1 5\n5 3\n2 6\n6 4\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 7\n1 2\n2 3\n3 4\n4 7\n2 5\n5 4\n6 4\n",
"output": "4\n",
"type": "std... | |
code_contests | verifiable_code | 1104_B. Game with string | Solve the following coding problem using the programming language python:
Two people are playing a game with a string s, consisting of lowercase latin letters.
On a player's turn, he should choose two consecutive equal letters in the string and delete them.
For example, if the string is equal to "xaax" than there ... | ```python
s = input()
stack = []
l = ""
t = 0
for x in s:
if x == l:
t += 1
stack.pop(-1)
if len(stack) > 0:
l = stack[-1]
else:
l = ""
else:
stack.append(x)
l = x
if t % 2 == 0:
print("No")
else:
print("Yes")
``` | vfc_62553 | {
"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": "iiq\n",
"output": "Yes\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1131_G. Most Dangerous Shark | Solve the following coding problem using the programming language python:
Semyon participates in the most prestigious competition of the world ocean for the title of the most dangerous shark. During this competition sharks compete in different subjects: speed swimming, masking, map navigation and many others. Now Semy... | vfc_62557 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 768000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n1\n1\n100000\n1\n1 100000\n",
"output": "10000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 7\n3\n1 2 2\n1 2 1\n1\n3\n2\n3\n2 2\n1 3\n1 1\n",
"output": "5\n",
"... | |
code_contests | verifiable_code | 1152_C. Neko does Maths | Solve the following coding problem using the programming language python:
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.
Neko has two integers a and b. His goal is to find a non-negative integer k such that the least common multiple of a+k and b+k is... | ```python
a, b = map(int, input().split())
q = abs(a-b)
if q == 0:
print(0)
else:
dq = []
dq2 = []
for i in range(1, int(q**0.5)+1):
if not q%i:
dq.append(i)
if i != q//i:
dq2 = [q//i] + dq2
dq = dq + dq2
dq = dq[::-1]
if a < b:
a, b = ... | vfc_62561 | {
"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": "6 10\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1174_A. Ehab Fails to Be Thanos | Solve the following coding problem using the programming language python:
You're given an array a of length 2n. Is it possible to reorder it in such way so that the sum of the first n elements isn't equal to the sum of the last n elements?
Input
The first line contains an integer n (1 ≤ n ≤ 1000), where 2n is the nu... | ```python
n = int(input())
a = list(map(int, input().split()))
a.sort()
if sum(a[:n]) < sum(a[n:]):
print(*a)
else:
print(-1)
``` | vfc_62565 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 2 1 3 1\n",
"output": "1 1 1 2 2 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1 1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null... |
code_contests | verifiable_code | 1191_F. Tokitsukaze and Strange Rectangle | Solve the following coding problem using the programming language python:
There are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.
The strange area is enclosed by three lines, x = l, y = a and x = r, as its left side... | ```python
from sys import stdin, stdout
from collections import defaultdict
n = int(input())
pts = []
for i in range(n):
x, y = map(int, stdin.readline().split())
pts.append((x, y))
pts.sort()
cts = [0]*(n+1)
x_map = {}
ctr = 0
for p in pts:
if p[0] not in x_map:
ctr += 1
x_map[p[0]] = ctr... | vfc_62569 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1\n1 2\n1 3\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 1\n2 2\n3 1\n3 2\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
code_contests | verifiable_code | 120_F. Spiders | Solve the following coding problem using the programming language python:
One day mum asked Petya to sort his toys and get rid of some of them. Petya found a whole box of toy spiders. They were quite dear to him and the boy didn't want to throw them away. Petya conjured a cunning plan: he will glue all the spiders tog... | vfc_62573 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 1 2 2 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5 1 2 2 3 3 4 3 5\n7 3 4 1 2 2 4 4 6 2 7 6 5\n",
"output": "7\n",
"type": "stdin_stdout"
},... | |
code_contests | verifiable_code | 1251_F. Red-White Fence | Solve the following coding problem using the programming language python:
Polycarp wants to build a fence near his house. He has n white boards and k red boards he can use to build it. Each board is characterised by its length, which is an integer.
A good fence should consist of exactly one red board and several (pos... | vfc_62581 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n3 3 1 1 1\n2 4\n7\n6 8 10 12 14 16 18\n",
"output": "1\n2\n2\n4\n6\n4\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n1 2 3 4 5\n1 2 3 4 5\n4\n4 8 10 14\n",
"output": "1... | |
code_contests | verifiable_code | 1271_E. Common Number | Solve the following coding problem using the programming language python:
At first, let's define function f(x) as follows: $$$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} x/2 & \mbox{if } x is even \\\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$$
We can see that if we choose some value v and ... | ```python
n, k = map(int,input().split())
p = 1
w = 0
while p * 2 <= k:
p *= 2
w += 1
kk = k - p
#2**w * tr <= n - kk
odd = (n-kk)//2**w
if odd % 2 == 0:
odd -= 1
p = 1
w = 0
while 2 * (2*p - 1) < k:
p *= 2
w += 1
poz = k - 2*(p-1)
if poz == 0:
#2**(w-1) * strzal + (2**w-1) <= n
even = (n-(2**w-1))//2**(w-1)
... | vfc_62585 | {
"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": "11 3\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000 100\n",
"output": "31248\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1315_F. Au Pont Rouge | Solve the following coding problem using the programming language python:
VK just opened its second HQ in St. Petersburg! Side of its office building has a huge string s written on its side. This part of the office is supposed to be split into m meeting rooms in such way that meeting room walls are strictly between le... | vfc_62593 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 1\nabac\n",
"output": "aba",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19 5 1821\naupontrougevkoffice\n",
"output": "au",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1337_B. Kana and Dragon Quest game | Solve the following coding problem using the programming language python:
Kana was just an ordinary high school girl before a talent scout discovered her. Then, she became an idol. But different from the stereotype, she is also a gameholic.
One day Kana gets interested in a new adventure game called Dragon Quest. In... | ```python
import math
t=int(input())
for i in range(t):
x,n,m=map(int,input().split())
if(x-m*10<=0):
print("YES")
else:
s=x
for i in range(n):
j=math.floor(s/2)+10
# print(x," ",j)
if(j>s):
break
else:
s=j
if(s-(m*10)<=0):
print("YES")
else:
print("NO")
``` | vfc_62597 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n100 3 4\n189 3 4\n64 2 3\n63 2 3\n30 27 7\n10 9 1\n69117 21 2\n",
"output": "Yes\nNo\nNo\nYes\nYes\nYes\nYes\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 137_A. Postcards and photos | Solve the following coding problem using the programming language python:
Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects co... | ```python
import math
l = list(map(str, input()))
t = 0
while len(l) != 0:
c = 0
b = l[0]
x = 1
while True:
if x == len(l):
t += math.ceil(x / 5)
l = []
break
elif b == l[x]:
x += 1
else:
t += math.ceil(x/5)
... | vfc_62605 | {
"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": "CPCPCPC\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 13_A. Numbers | Solve the following coding problem using the programming language python:
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of sum of digits o... | ```python
import math
def sumInBase(num, base):
ans = 0
while num != 0:
ans += num % base
num //= base
return ans
A = int(input())
sumofAll = 0
for i in range(2, A):
sumofAll += sumInBase(A, i)
temp = math.gcd(sumofAll, A - 2)
print('{}/{}'.format(sumofAll // temp, (A - 2) // temp))
... | vfc_62609 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "2/1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1423_J. Bubble Cup hypothesis | Solve the following coding problem using the programming language python:
The Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem:
Given ... | ```python
T = input()
mod = int(1e9 + 7)
a = map(int, input().split())
c = []
for n in a:
b = (n // 2 + 2)
b = b * b
b //= 4
c.append(str(b % mod))
print(' '.join(c))
``` | vfc_62613 | {
"difficulty": "16",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 4\n",
"output": "2\n4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1468_L. Prime Divisors Selection | Solve the following coding problem using the programming language python:
Suppose you have a sequence of k integers A = [a_1, a_2, ... , a_k] where each a_i ≥ 2. A sequence of prime integers P = [p_1, p_2, ..., p_k] is called suitable for the sequence A if a_1 is divisible by p_1, a_2 is divisible by p_2 and so on.
... | ```python
from math import gcd
def t_prime(n):
if n == 1: return False
for p in [2,3,5,7,11,13,17,19,23]:
if p < n and pow(p,n-1,n) != 1: return False
return True
primes = [i for i in range(2,10**5) if t_prime(i)];pset = set(primes);n, k = map(int, input().split());l = list(map(int... | vfc_62621 | {
"difficulty": "19",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n2 4 6\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n2 4 6 16\n",
"output": "2 4 16 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1493_F. Enchanted Matrix | Solve the following coding problem using the programming language python:
This is an interactive problem.
There exists a matrix a of size n × m (n rows and m columns), you know only numbers n and m. The rows of the matrix are numbered from 1 to n from top to bottom, and columns of the matrix are numbered from 1 to m ... | ```python
import sys
input = sys.stdin.readline
flush = sys.stdout.flush
from collections import Counter
from math import sqrt
def query(h, w, i1, j1, i2, j2):
print("? {} {} {} {} {} {}".format(h, w, i1, j1, i2, j2))
flush()
return int(input())
def fac(x):
cnt = Counter()
if not x % 2:
wh... | vfc_62625 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n1\n1\n1\n0",
"output": "\n? 1 2 1 1 1 3\n? 1 2 2 1 2 3\n? 1 2 3 1 3 3\n? 1 1 1 1 1 2\n! 2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1516_C. Baby Ehab Partitions Again | Solve the following coding problem using the programming language python:
Baby Ehab was toying around with arrays. He has an array a of length n. He defines an array to be good if there's no way to partition it into 2 subsequences such that the sum of the elements in the first is equal to the sum of the elements in th... | ```python
import collections
import itertools
from functools import reduce
mod = (10 ** 9) + 7
def permutationbysum():
for _ in range(int(input())):
num, l, r, achieve = map(int, input().split())
k = r - l + 1
if (k * (k + 1)) // 2 <= achieve <= (k * (num * 2 + 1 - k)) // 2:
o... | vfc_62629 | {
"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\n6 3 9 12\n",
"output": "\n1\n2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2\n",
"output": "\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 171_E. MYSTERIOUS LANGUAGE | Solve the following coding problem using the programming language python:
You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this language.
Input
This program has ... | ```python
n=input()
print("INTERCAL")
``` | vfc_62637 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "INTERCAL",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 239_C. Not Wool Sequences | Solve the following coding problem using the programming language python:
A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive... | ```python
n, m = map(int, input().split())
MOD = 10 ** 9 + 9
ans = pow(2, m, MOD) - 1
step = pow(2, m, MOD) - 2
for i in range(n - 1):
ans = (ans * step) % MOD
step -= 1
while ans < 0:
ans += MOD
while ans >= MOD:
ans -= MOD
print(ans)
``` | vfc_62649 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "86232 41348\n",
"output": "77566161\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
code_contests | verifiable_code | 288_A. Polo the Penguin and Strings | Solve the following coding problem using the programming language python:
Little penguin Polo adores strings. But most of all he adores strings of length n.
One day he wanted to find a string that meets the following conditions:
1. The string consists of n lowercase English letters (that is, the string's length eq... | ```python
a,b=[int(i) for i in input().split()]
if b>a:
print(-1)
else:
if b==1:
if a>1:
print(-1)
else:print('a')
else:
b-=2
for i in range(0,a-b):
if i%2==0:print('a',end='')
else:print('b',end='')
for i in range(b):
p... | vfc_62657 | {
"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 7\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 4\n",
"output": "ababacd",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "68... |
code_contests | verifiable_code | 313_A. Ilya and Bank Account | Solve the following coding problem using the programming language python:
Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank ac... | ```python
n=int(input())
if n>=0:
print(n)
else:
r=n+(2*n)
n=str(n)
k=len(n)
ones=int(n[k-1])
huns=int(n[k-2])
if ones>=huns:
print(int(n[:k-1]))
else:
f=n[:k-2]+n[k-1]
print(int(f))
``` | vfc_62661 | {
"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": "2230\n",
"output": "2230\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-100003\n",
"output": "-10000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | 335_D. Rectangles and Square | Solve the following coding problem using the programming language python:
You are given n rectangles, labeled 1 through n. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points th... | vfc_62665 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0 0 1 9\n1 0 9 1\n1 8 9 9\n8 1 9 8\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n0 0 1 9\n1 0 9 1\n1 8 9 9\n8 1 9 8\n2 2 3 6\n3 2 7 3\n2 6 7 7\n5 3 7 6\n3 3 5 6\n... | |
code_contests | verifiable_code | 358_D. Dima and Hares | Solve the following coding problem using the programming language python:
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more.
Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, n... | ```python
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
'''
for CASES in range(int(input())):
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
sys.stdout.write(" ".join(map(str,ANS))+"\n")
'''
inf = 10... | vfc_62669 | {
"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": "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3\n",
"output": "44\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 3 4\n4 3 2 1\n0 1 1 0\n",
"output": "13\n",
"type": "std... |
code_contests | verifiable_code | 402_B. Trees in a Row | Solve the following coding problem using the programming language python:
The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height ai meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the conditi... | ```python
n, k = map(int, input().split())
a = list(map(int, input().split()))
tmp = {}
for i in range(n):
x = a[i] - i * k
if x > 0:
tmp[x] = tmp.get(x, 0) + 1
x = max(tmp, key = lambda x: tmp[x])
print(n - tmp[x])
if tmp[x] == n:
exit(0)
for i in range(n):
if x + i * k > a[i]:
print('+... | vfc_62677 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 1\n1 2 1 5\n",
"output": "2\n+ 3 2\n- 4 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n1 2 3 4\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 42_C. Safe cracking | Solve the following coding problem using the programming language python:
Right now you are to solve a very, very simple problem — to crack the safe. Four positive integers stand one by one on a circle protecting the safe. You know that to unlock this striking safe you have to make all four numbers equal to one. Opera... | ```python
ring = list(map(int, input().split()))
n = len(ring)
record = []
def halve(pos):
a, b = pos % n, (pos + 1) % n
ring[a] //= 2
ring[b] //= 2
record.append('/%d' % (a + 1))
def increment(pos):
a, b = pos % n, (pos + 1) % n
ring[a] += 1
ring[b] += 1
record.append('+%d' % (a + 1))
while True:
... | vfc_62681 | {
"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 3 1 1\n",
"output": "+1\n/1\n/1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 452_A. Eevee | Solve the following coding problem using the programming language python:
You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokem... | ```python
n = int(input())
s = input()
evol = ['vaporeon', 'jolteon', 'flareon', 'espeon', 'umbreon', 'leafeon', 'glaceon', 'sylveon']
for e in evol :
if len(e) != n :
continue
for i in range(n):
if s[i] != e[i] and s[i] != '.':
break
if i == n-1 :
print(e)
break... | vfc_62685 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\nj......\n",
"output": "jolteon\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n...feon\n",
"output": "leafeon\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | 474_E. Pillars | Solve the following coding problem using the programming language python:
Marmot found a row with n pillars. The i-th pillar has the height of hi meters. Starting from one pillar i1, Marmot wants to jump on the pillars i2, ..., ik. (1 ≤ i1 < i2 < ... < ik ≤ n). From a pillar i Marmot can jump on a pillar j only if i <... | vfc_62689 | {
"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": "5 2\n1 3 6 7 4\n",
"output": "4\n1 2 4 5 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 3\n2 1 3 6 9 11 7 3 20 18\n",
"output": "6\n3 4 6 7 8 9 ",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | 498_D. Traffic Jams in the Land | Solve the following coding problem using the programming language python:
Some country consists of (n + 1) cities, located along a straight highway. Let's number the cities with consecutive integers from 1 to n + 1 in the order they occur along the highway. Thus, the cities are connected by n segments of the highway, ... | vfc_62693 | {
"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": "10\n2 5 3 2 3 5 3 4 2 4\n10\nC 10 6\nA 2 6\nA 1 3\nC 3 4\nA 3 11\nA 4 9\nA 5 6\nC 7 3\nA 8 10\nA 2 5\n",
"output": "5\n3\n14\n6\n2\n4\n4\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 549_B. Looksery Party | Solve the following coding problem using the programming language python:
The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts about... | ```python
n=int(input().strip())
nums=['']+[' '+input().strip() for _ in range(n)]
a=[0]+list(map(int,input().split()))
def send(x):
for i in range(1,n+1):
if nums[x][i]=='1':
a[i]-=1
vis=[0]*(n+1)
while True:
for i in range(1,n+1):
if not vis[i] and not a[i]:
vis[i]=... | vfc_62701 | {
"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\n101\n010\n001\n0 1 2\n",
"output": "1\n1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1111\n0101\n1110\n0001\n1 0 1 0\n",
"output": "1\n2 ",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 575_D. Tablecity | Solve the following coding problem using the programming language python:
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can be ... | ```python
print(2001)
for i in range(1 , 1001):
print(f"{i} 1 {i} 2")
print(f"1 1 1 2")
for i in range(1 , 1001):
print(f"{i} 1 {i} 2")
``` | vfc_62705 | {
"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": "В этой задаче нет примеров ввода-вывода.\nThis problem doesn't have sample input and output.",
"output": "2000\n1 1 1 2\n2 1 2 2\n3 1 3 2\n4 1 4 2\n5 1 5 2\n6 1 6 2\n7 1 7 2\n8 1 8 2\n9 1 9 2\n10 1 10 2\n11 1 11 2\n12 1 12 2\... |
code_contests | verifiable_code | 618_D. Hamiltonian Spanning Tree | Solve the following coding problem using the programming language python:
A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are <image> roads in total. It takes exactly y seconds to traverse any single road.
A spanning tree is a set of roads con... | ```python
from collections import defaultdict
from collections import deque
from functools import reduce
n, x, y = [int(x) for x in input().split()]
E = defaultdict(set)
for i in range(n-1):
u, v = [int(x) for x in input().split()]
E[u].add(v)
E[v].add(u)
if x > y:
for v in E:
if len(E[v]) == n... | vfc_62713 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3 2\n1 2\n1 3\n3 4\n5 3\n",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2 3\n1 2\n1 3\n3 4\n5 3\n",
"output": "9",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 639_B. Bear and Forgotten Tree 3 | Solve the following coding problem using the programming language python:
A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.
Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad no... | ```python
n, d, h = list(map(int, input().split()))
if h < (d + 1) // 2 or (h == d == 1 and n > 2):
print(-1)
exit()
i = 1
while i <= h:
print(i, i + 1)
i += 1
if i <= d:
print(1, h + 2)
i = h + 2
while i <= d:
print(i, i + 1)
i += 1
i += 1
while i <= n:
if h == d:
print(2, ... | vfc_62717 | {
"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": "8 4 2\n",
"output": "1 2\n2 3\n1 4\n4 5\n1 6\n1 7\n1 8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 5 2\n",
"output": "-1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 666_D. Chain Reaction | Solve the following coding problem using the programming language python:
Group of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a plate, can run a powerful c... | vfc_62721 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1\n1 -1\n-1 1\n-1 -1\n1 1\n2 2\n4 4\n6 6\n",
"output": "0\n1 1\n1 -1\n-1 1\n-1 -1\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n183 65\n100 121\n138 31\n81 31\n",
"outp... | |
code_contests | verifiable_code | 713_A. Sonya and Queries | Solve the following coding problem using the programming language python:
Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:
1. + ai — add non-negative integer ai t... | ```python
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192
class FastIO(IOBase):
newli... | vfc_62729 | {
"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\n+ 200\n+ 200\n- 200\n? 0\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n+ 1\n+ 241\n? 1\n+ 361\n- 241\n? 0101\n+ 101\n? 101\n- 101\n? 101\n+ 4000\n? 0\n",
"o... |
code_contests | verifiable_code | 733_E. Sleep in Class | Solve the following coding problem using the programming language python:
The academic year has just begun, but lessons and olympiads have already occupied all the free time. It is not a surprise that today Olga fell asleep on the Literature. She had a dream in which she was on a stairs.
The stairs consists of n ste... | ```python
n=int(input())
string = input()
q1,q2,B,C=[],[],[],[]
A=0
for i in range(n):
if string[i] == "D":
q1.append(i)
else:
q2.append(n-1-i)
for i in range(len(q1)):
A+=(q1[i]-i)*2+1
B.append(A)
A=0
temp = []
for i in range(len(q2)):
A+=(q2[len(q2)-1-i]-i)*2+1
C.append(A)
C.... | vfc_62733 | {
"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\nUUD\n",
"output": "5 6 3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 757_F. Team Rocket Rises Again | Solve the following coding problem using the programming language python:
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other citi... | vfc_62737 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7\n",
... | |
code_contests | verifiable_code | 779_C. Dishonest Sellers | Solve the following coding problem using the programming language python:
Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is ai, and after a week of discounts its price will be bi.
Not all of sellers are hones... | ```python
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=list(map(int,input().split()))
c=0
s=0
for i in range(n):
if(l[i]<=m[i]):
s+=l[i]
c+=1
if(c>=k):
for i in range(n):
if(l[i]>m[i]):
s+=m[i]
print(s)
else:
r=k-c
p=[]
for i in range(n):... | vfc_62741 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n3 4 7 10 3\n4 5 5 12 5\n",
"output": "25\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n5 4 6\n3 1 5\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 802_K. Send the Fool Further! (medium) | Solve the following coding problem using the programming language python:
Thank you for helping Heidi! It is now the second of April, but she has been summoned by Jenny again. The pranks do not seem to end...
In the meantime, Heidi has decided that she does not trust her friends anymore. Not too much, anyway. Her rel... | vfc_62745 | {
"difficulty": "17",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11 6\n1 0 7932\n2 1 1952\n3 2 2227\n4 0 9112\n5 4 6067\n6 0 6786\n7 6 3883\n8 4 7137\n9 1 2796\n10 5 6200\n",
"output": "54092\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 5\n0 1 1\n0... | |
code_contests | verifiable_code | 848_E. Days of Floral Colours | Solve the following coding problem using the programming language python:
The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days.
On the rim of the Floral Clock are 2n flowers, numbered from 1 to 2n clockwise,... | ```python
#https://codeforces.com/problemset/problem/848/E
f = [0, 4, 8, -1, 16, -10, 4, -12, -48, 26, -44, 15, -16, -4, -4, -1]
jly = 998244353
t = 0
x = [0, 0, 0, 24, 4, 240, 204, 1316, 2988, 6720, 26200, 50248, 174280, 436904, 1140888, 3436404]
n = int(input())
for i in range(16, n + 1):
t = 0
for j in range... | vfc_62753 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 7, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n",
"output": "3436404\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n"... |
code_contests | verifiable_code | 870_C. Maximum splitting | Solve the following coding problem using the programming language python:
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such split... | ```python
solve = lambda n: -1 if n in {1, 2, 3, 5, 7, 11} else n // 4 - n % 2
print(*[solve(int(input())) for i in range(int(input()))])
``` | vfc_62757 | {
"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\n2\n3\n",
"output": "-1\n-1\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n12\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 897_B. Chtholly's request | Solve the following coding problem using the programming language python:
— Thanks a lot for today.
— I experienced so many great things.
— You gave me memories like dreams... But I have to leave now...
— One last request, can you...
— Help me solve a Codeforces problem?
— ......
— What?
Chtholly has been think... | ```python
import itertools as it
k, p = [int(elem) for elem in input().split()]
def build_palindroms(digits):
global k
global val
n = digits // 2
values = [10 ** (digits - 1 - i) + 10 ** i for i in range(n)]
for comb in it.product(range(1, 10), *[range(0, 10) for i in range(n - 1)]):
if not... | vfc_62761 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 100\n",
"output": "33\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 30\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "77... |
code_contests | verifiable_code | 918_C. The Monster | Solve the following coding problem using the programming language python:
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Ups... | ```python
s = input()
res, n = 0, len(s)
for i in range(n-1):
j, c, q = i , 0, 0
while j < n and c + q >= 0:
if(s[j] == '('): c += 1
elif(s[j] == ')'): c -= 1
else: q += 1
if(c < q):
c, q = q, c
res += (c == q)
j += 1
print(res)
``` | vfc_62765 | {
"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": "((?))\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "??()??\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 967_F. Aztec Catacombs | Solve the following coding problem using the programming language python:
Indiana Jones found ancient Aztec catacombs containing a golden idol. The catacombs consists of n caves. Each pair of caves is connected with a two-way corridor that can be opened or closed. The entrance to the catacombs is in the cave 1, the id... | vfc_62773 | {
"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 4\n1 2\n2 3\n1 3\n3 4\n",
"output": "2\n1 3 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n1 2\n2 3\n",
"output": "4\n1 2 3 1 4\n",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | 993_F. The Moral Dilemma | Solve the following coding problem using the programming language python:
Hibiki and Dita are in love with each other, but belong to communities that are in a long lasting conflict. Hibiki is deeply concerned with the state of affairs, and wants to figure out if his relationship with Dita is an act of love or an act o... | vfc_62777 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 2\nand xx. nor .xx\nand xx nor xx\n",
"output": "-1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | autocorrect | Solve the following coding problem using the programming language python:
Rachel, being an awesome android programmer, just finished an App that will let us draw a triangle by selecting three points on the touch-plane.Now She asks her friend Bruce to draw a Right-Angled Triangle (we'll call it RAT) by selecting 3 inte... | ```python
def dist(x1,y1,x2,y2):
return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)
def is_RAT(a):
ab = dist(a[0],a[1],a[2],a[3])
bc = dist(a[4],a[5],a[2],a[3])
ca = dist(a[0],a[1],a[4],a[5])
if ab == bc+ca or ca == bc+ab or bc == ab+ca:
return True
return False
def samepoint(a):
if a[0]==a[2] and a[1] == a[3]:
return... | vfc_62781 | {
"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-1 0 2 0 0 1\n2 3 4 5 6 6\n0 0 2 0 10 10\n\nSAMPLE",
"output": "YES\nNO\nNO",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | chocolate | Solve the following coding problem using the programming language python:
In a coordinate system,There are 3 chocolate which will be placed at three random position (x1,y1),(x2,y2) and (x3,y3).Ramesh loves Chocolates. Ramesh always moves along a straight line. your task is to find out whether he can have all the choco... | ```python
for _ in xrange(input()):
ax, ay, bx, by, cx, cy = map(int, raw_input().split())
area = abs(ax*(by-cy) + bx*(cy-ay) + cx*(ay-by))
if area:
print "NO"
else:
print "YES"
``` | vfc_62785 | {
"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 1 2 2 3 3\n1 2 5 4 10 15\n\nSAMPLE",
"output": "YES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n4 9 0 4 7 1\n5 5 4 2 8 8\n2 5 1 1 7 1\n3 2 4 1 6 7\n5 8 6 1 2 2\n2 9 8 1 6 ... |
code_contests | verifiable_code | dummy-8 | Solve the following coding problem using the programming language python:
As Valentines Day was approaching, some couples on the campus are upto some mischief and are sneaking around in the Campus Building. But the building has teachers roaming inside it. The teacher both blocks the way and will catch you if you fall ... | ```python
from collections import *
for T in range(input()):
m,n=map(int,raw_input().split())
board=[list(raw_input()) for i in range(m)]
for i in range(m):
for j in range(n):
if board[i][j] == 'S':
start = i,j
board[i][j] = '.'
elif board[i][j... | vfc_62789 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2 5\n##^##\nS...G\n2 5\n##v##\nS...G\n1 5\nS..G<\n1 6\nS...G<\n5 5\nS....\n.....\n.>v..\n.^<..\n....G\n\nSAMPLE",
"output": "Case #1: 6\nCase #2: 4\nCase #3: 3\nCase #4: impossible\nCase #5: 8",
"type": "stdin_stdout... |
code_contests | verifiable_code | guruji-and-hearts-2 | Solve the following coding problem using the programming language python:
My good friend Guruji once submitting his code on forum mistakenly forgot to check language option. His code got pasted in general editor. Due to this many portion of his code got changed. One funny thing which happened was that sub-string "<3" ... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
s=raw_input()
l=len(s)
c=0
for i in range(0,l-1):
if s[i] == '<':
if s[i+1] == '3':
c=c+1
print c
``` | vfc_62793 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abcd<3abc<3ab<3ab\n\nSAMPLE",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abcd<3<bca3ab<3ab\n\nSAMPLE",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | logical-ops | Solve the following coding problem using the programming language python:
Gwen is good in hacking. She helps Ben and Kevin in many missions. This time the boys need CCTV recordings of a particular area. The security network is secured by a special keyless encryption. When she tries to access the tapes remotely, she se... | ```python
t=input()
i=0
while i<t:
n=input()
x=raw_input().split(' ')
cnt=0
j=0
while j<n:
el=int(x[j])
if j==0:
sm=int(x[1])
else:
sm=int(x[0])
k=0
while k<n:
if k!=j:
sm=sm&int(x[k])
k=k+1
... | vfc_62797 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n2 3 7\n4\n3 9 5 1\n\nSAMPLE",
"output": "-1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3\n31 7 7\n34\n1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 1",... |
code_contests | verifiable_code | mystery-15 | Solve the following coding problem using the programming language python:
Solve the Mystery.
Input :
First line contains T - No. of Test cases.
Each Test case consists of 2 lines.
First line contains K.
Second line contains 3 space separated Integers A1 ,A2 ,A3.
Output :
Print required answers in separate lines.
... | ```python
t = input()
while t > 0:
n = input()
a,b,c = map(int,raw_input().split())
print (a+b+c)**n
t = t-1
``` | vfc_62801 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n5 4 3\n3\n1 2 2\n\nSAMPLE",
"output": "144\n125\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n5\n3 10 3\n8\n0 0 0\n2\n7 0 8\n5\n1 9 0\n10\n10 10 10\n3\n0 4 8\n7\n10 9 10\n9\n0... |
code_contests | verifiable_code | pro-and-con-list | Solve the following coding problem using the programming language python:
Ted: Robin, get me my legal pad. It's Pros and Cons Time!
There is a long list of n girls in front of Barney, and he is to calculate the optimal "happiness" he can find by selecting exactly 2 girls. (Why 2? No one knows!)
Ted, as a fan of pros... | ```python
t = input()
for _ in range(t):
n = input()
h = [0]*n
s = [0]*n
c = []
ans = 0
for i in range(n):
h[i], s[i] = map(int,raw_input().split())
c.append(h[i]+s[i])
for i in range(2):
temp = -1
ind = -1
for j in range(n):
if c[j]>temp:
temp = c[j]
ind = j
ans += h[ind]
h[ind] = -1
... | vfc_62805 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n2 3\n10 2\n11 5\n4 1\n\nSAMPLE",
"output": "17\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4\n0 3\n10 2\n11 5\n4 1\n\nSAMPLE",
"output": "17\n",
"type": "stdin_std... |
code_contests | verifiable_code | scheduling-war | Solve the following coding problem using the programming language python:
Prateek and Chintu are working on different projects both with equal priority. They both need to run some batches of processes. A batch has processes which need some systems to run them irrespective of the number of process running on each depen... | ```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!'
nOfS = int(raw_input())
pOnS = raw_input().split()
nOfB = int(raw_input())
bs = []
pOfB = []
count = 0
pbCount = 0
bsset = []
bsCount = []
for i in range... | vfc_62809 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 1 5 2\n3\n2 1 2 1\n2 2 3 7\n1 4 3\n\nSAMPLE",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n56 45 40 59 29 \n1\n1 4 8",
"output": "0",
"type": "stdin_stdou... |
code_contests | verifiable_code | taxi-please | Solve the following coding problem using the programming language python:
Today, you have been given the task of handling the entire Taxi Network of Berland City. Berland city has a huge number of taxi travellers, and you need to help them in transportation in the most efficient manner.
To be precise, this city cons... | ```python
try:
M, N = map(int, raw_input().split())
taxis = [0 for i in range(N)]
users = []
for i in range(M):
S, J = map(int, raw_input().split())
users.append([S,J, i])
users = sorted(users, key = lambda user: user[0])
ans = [0]*M
for user in users:
flag = False
for i in range(N):
if taxis[i]... | vfc_62813 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n1 100\n2 100\n3 100\n4 100\n5 100\n\nSAMPLE",
"output": "1 2 3 4 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000 100\n899 100000\n202 100000\n401 100000\n45 100000\n389 100000\... |
code_contests | verifiable_code | will-you-be-my-friend-pledge-easy | Solve the following coding problem using the programming language python:
Max feels lonely after shifting to a new locality, as he does not have any friend there. So his parents bought him a new number from the Integers SuperMarket! Every child in the locality has bought a number from the same market.
He takes the ... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
from fractions import gcd
a=int(input())
n=int(input())
arr=map(int,raw_input().split())
count=0
for i in arr:
if gcd(i,a)!=1:
count+=1
print count
``` | vfc_62817 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n3\n4 7 12\n\nSAMPLE",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "507\n887\n778 916 794 336 387 493 650 422 363 28 691 60 764 927 541 427 173 737 212 369 568 430 783 53... |
code_contests | verifiable_code | p00056 Goldbach's Conjecture | Solve the following coding problem using the programming language python:
It is known that even numbers greater than or equal to 4 can be represented by the sum of two prime numbers. This is called the Goldbach's conjecture, and computer calculations have confirmed that it is correct up to a fairly large number. For e... | ```python
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
for x in map(int,sys.stdin):
if x:print(sum(1 for d in compress(n[:x//2+1],a[:x//2+1])if a[x-d]))
``` | vfc_62861 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n11\n0",
"output": "2\n0",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00187 Stoning Fortune | Solve the following coding problem using the programming language python:
With the motto "Creating your own path," a shrine created a fortune-telling fortune with its own hands. Ask the person who draws the lottery to throw six stones first, then the line segment connecting the first and second of the thrown stones, t... | ```python
# Aizu Problem 0187: Stoning Fortune
#
import sys, math, os, bisect
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def on_segment(p, q, r):
# Given three colinear points p, q, r, the function checks if
# point q lies on line segment 'pr... | vfc_62865 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "-3 -2 9 6\n3 -2 7 6\n-1 0 5 0\n2 2 -1 -1\n0 1 2 1\n-3 -1 3 1\n0 0 0 0",
"output": "syo-kichi\nkyo",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-3 -2 9 6\n3 -2 7 6\n-1 0 5 0\n2 2 0 -1\n0 1... |
code_contests | verifiable_code | p00538 Cake 2 | Solve the following coding problem using the programming language python:
Carving the cake 2 (Cake 2)
JOI-kun and IOI-chan are twin brothers and sisters. JOI has been enthusiastic about making sweets lately, and JOI tried to bake a cake and eat it today, but when it was baked, IOI who smelled it came, so we decided t... | ```python
import sys
sys.setrecursionlimit(100000)
N, *A = map(int, open(0).read().split())
memo = [[-1]*N for i in range(N)]
for i in range(N):
memo[i][i] = A[i] if N % 2 else 0
def dfs(p, q, t):
if memo[p][q] != -1:
return memo[p][q]
if t:
memo[p][q] = r = max(A[p] + dfs((p+1)%N, q, 0), A[... | vfc_62873 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2\n8\n1\n10\n9",
"output": "18",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00700 Exploring Caves | Solve the following coding problem using the programming language python:
There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots... | ```python
for _ in range(int(input())):
m=dx=dy=0
while 1:
x,y=map(int,input().split())
if x==y==0:break
dx+=x
dy+=y
l=dx*dx+dy*dy
if (m==l and mx<dx) or m<l:m,mx,my=l,dx,dy
print(mx,my)
``` | vfc_62877 | {
"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\n1 0\n0 1\n-1 0\n1 0\n0 5\n-1 0\n0 -1\n5 0\n0 1\n0 -1\n1 0\n0 -4\n-3 0\n0 3\n2 0\n0 -2\n-1 0\n0 1\n0 -1\n1 0\n0 2\n-2 0\n0 -3\n3 0\n0 4\n-4 0\n0 -5\n-2 0\n0 0\n1 0\n-1 0\n0 0\n2 0\n0 1\n-1 0\n0 1\n-1 0\n0 -2\n0 0",
"output"... |
code_contests | verifiable_code | p00841 Atomic Car Race | Solve the following coding problem using the programming language python:
In the year 2020, a race of atomically energized cars will be held. Unlike today’s car races, fueling is not a concern of racing teams. Cars can run throughout the course without any refueling. Instead, the critical factor is tire (tyre). Teams ... | ```python
def solve():
from bisect import bisect
from itertools import accumulate
from sys import stdin
f_i = stdin
while True:
n = int(f_i.readline())
if n == 0:
break
a = list(map(int, f_i.readline().split()))
b = float(f_i.readline())
... | vfc_62881 | {
"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\n2 3\n1.0\n1 1.0 0.1 0.3\n5\n5 10 15 20 25\n0.15\n1 1.0 0.04 0.5\n10\n1783 3640 3991 4623 5465 5481 6369 6533 6865 8425\n4.172\n72 59.4705 0.0052834 0.0611224\n0",
"output": "3.5397\n31.9249\n168.6682",
"type": "stdin... |
code_contests | verifiable_code | p00973 Fair Chocolate-Cutting | Solve the following coding problem using the programming language python:
Fair Chocolate-Cutting
You are given a flat piece of chocolate of convex polygon shape. You are to cut it into two pieces of precisely the same amount with a straight knife.
Write a program that computes, for a given convex polygon, the maximu... | ```python
#!/usr/bin/python3
from decimal import Decimal
from fractions import Fraction
import math
import os
import sys
def main():
N = read_int()
A = [Vec(*read_ints()) for _ in range(N)]
print(*solve(N, A), sep='\n')
def solve(N, Points):
if DEBUG:
dprint('polygon({!r}, fill=False)'.form... | vfc_62885 | {
"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\n0 0\n10 0\n10 10\n0 10",
"output": "10\n14.142135623730950488",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0\n10 0\n10 4\n0 10",
"output": "7.3178024859\n12.2065556157\n",
... |
code_contests | verifiable_code | p01105 Boolean Expression Compressor | Solve the following coding problem using the programming language python:
Boolean Expression Compressor
You are asked to build a compressor for Boolean expressions that transforms expressions to the shortest form keeping their meaning.
The grammar of the Boolean expressions has terminals `0` `1` `a` `b` `c` `d` `-` ... | ```python
a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
base = [a, b, c, d, e, 0]
Q = [(1, el) for el in base]
L = {el: 1 for el in base}
H = []
get = L.get
push = H.append
while Q:
l, p = heappop(Q)
if L[p] < l: continue
if l+1 < get(p ^ e, 17):
L[p ^ e] = l+1
... | vfc_62889 | {
"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": "0\n(a*(1*b))\n(1^a)\n(-(-a*-b)*a)\n(a^(b^(c^d)))\n.",
"output": "1\n5\n2\n1\n13",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0\n(a*(1*b))\n(1^a)\n(-(-a*-b)*a)\nca^(b^((^d)))\n.",
"o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.