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 | p01876 Arai's | Solve the following coding problem using the programming language python:
E: Arai's --Arai's-
problem
Arai's is a female idol group that has been popular since the school idol era. Nowadays, it is active at the world level as a large group to which many "Arai" belong. And today, it was decided to start a new project... | vfc_61241 | {
"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 3 4\n111\n111\n111\n111\n111\n111",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 4\n111\n111\n111\n111\n111\n011",
"output": "2\n",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | p02012 Sum of QQ | Solve the following coding problem using the programming language python:
You received a card with an integer $S$ and a multiplication table of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i \times j$ ($i,j \g... | ```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_61245 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "25",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1",
"output... |
code_contests | verifiable_code | p02296 Distance | Solve the following coding problem using the programming language python:
For given two segments s1 and s2, print the distance between them.
s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.
Constraints
* 1 ≤ q ≤ 1000
* -10000 ≤ xpi, ypi ≤ 10000
* p0 ≠ p1 and p2 ≠ p3.
Input
The entir... | ```python
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def ccw(p0, p1, p2):
a = p1-p0
b = p2-p0
if cross(a,b) > 0:
return 1 #couner_clockwise
elif cross(a,b) <0:
return -1 #clockwise
elif dot(a,b) < 0:
return 2 #online_back... | vfc_61253 | {
"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\n0 0 1 0 0 1 1 1\n0 0 1 0 2 1 1 2\n-1 0 1 0 0 1 0 -1",
"output": "1.0000000000\n1.4142135624\n0.0000000000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n0 0 1 0 0 1 1 1\n0 0 1 0 2 1 1... |
code_contests | verifiable_code | cdva1605 | Solve the following coding problem using the programming language python:
The auditorium of Stanford University is made up of L*R matrix (assume each coordinate has a chair). On the occasion of an event Chef was called as a chief guest. The auditorium was filled with males (M) and females (F), occupying one chair each... | ```python
# cook your code here
n,m,t=map(int,raw_input().split())
a=[[0 for i in range(m)]for i in range(n)]
b=[[0 for i in range(m)]for i in range(n)]
q=[]
m_max=0
f_max=0
for i in range(n):
q.append(raw_input())
for j in range(m):
if i==0 or j==0:
if q[i][j]=='M':
a[i][j]... | vfc_61261 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3 3\nMMF\nMMM\nFFM\nFFM\n2 F\n3 M\n1 M",
"output": "yes\nno\nyes",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | dce04 | Solve the following coding problem using the programming language python:
The Titanic ship is sinking. The nearest ship has answered the SOS call, and come to rescue the people. Everyone is anxious to get to safety. Unfortunately, the new ship may not have enough room to take everyone to safe land. This adds to the an... | ```python
#!/usr/bin/python
"Solve the Rescue problem at CodeChef"
def main():
testcases = int(raw_input())
for testcase in xrange(testcases):
capacity, men, women, children = map(int, raw_input().split())
max_women = min(women, (men << 1))
max_children = min((men + max_women) << 2, int(capacity * 0.8))
child... | vfc_61265 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n17 5 10 19\n18 2 6 10\n20 5 2 23",
"output": "2 2 13\n2 4 10\n2 2 16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n17 5 10 19\n18 2 6 10\n20 5 4 23",
"output": "2 2 13\n2 4 1... |
code_contests | verifiable_code | multisrm | Solve the following coding problem using the programming language python:
Problem description.
Jojo is so good at multiplying that she can multiply two 15-digits integers within 5 seconds. After practicing for years, she decided to approach the Limca Book of Records. As a jury member you are given the task to decide i... | ```python
print input() * input()
``` | vfc_61273 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "111111\n111111",
"output": "12345654321\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "111111\n111011",
"output": "12334543221\n",
"type": "stdin_stdout"
},
{
"f... |
code_contests | verifiable_code | rrfrnds | Solve the following coding problem using the programming language python:
After IOI Ilya decided to make a business. He found a social network called "TheScorpyBook.com". It currently has N registered users. As in any social network two users can be friends. Ilya wants the world to be as connected as possible, so he ... | ```python
a = int (raw_input())
c= []
d= []
for i in range(a):
now = raw_input()
c.append(now)
d.append(int(now,2))
i=0
for k in xrange(a):
for j in xrange(k+1,a):
if c[k][j]!='1':
if int(d[k])&int(d[j]):
i= i+2
print i
``` | vfc_61277 | {
"difficulty": "3",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0111\n1000\n1000\n1000",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1111\n1000\n1000\n1000",
"output": "6\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | window2 | Solve the following coding problem using the programming language python:
After Chef successfully built a modern (L, K)-window on the attic wall he decided to expand the notion of the (L, K)-window in some other areas. Now he considers a rectangular grid that contains only zeroes and ones and has size N x M. He consid... | ```python
#!/usr/bin/python
mainlis=[]
maxv=1000000080798150871
for i in range(0,1000,1):
mainlis.append([])
varlis=mainlis[i]
for j in range(0,3,1):
varlis.append(0)
test=input()
while test >0:
string=raw_input()
lis=string.split()
n=int(lis[0])
m=int(lis[1])
l=int(lis[2])
k=int(lis[3])
for i... | vfc_61281 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 2 2 1\n11\n01\n10\n3 3 2 2\n111\n101\n111",
"output": "2\n5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 2 1 1\n11\n01\n10\n3 3 2 2\n111\n101\n111",
"output": "4\n5\n",
... |
code_contests | verifiable_code | 1020_A. New Building for SIS | Solve the following coding problem using the programming language python:
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from t... | ```python
t,f,lw,hw,q = map(int,input().split())
while(q):
t1,f1,t2,f2=map(int,input().split())
if(t1==t2):
print(abs(f1-f2))
else:
ans=abs(t1-t2)
if((f1>=lw and f1<=hw) or (f2>=lw and f2<=hw)):
ans+=abs(f1-f2)
print(ans)
elif(f1<lw and f2 <lw) :
ans+=(abs(lw-f1)+abs(lw-f2))
... | vfc_61285 | {
"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 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3\n",
"output": "1\n4\n2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1043_D. Mysterious Crime | Solve the following coding problem using the programming language python:
Acingel is a small town. There was only one doctor here — Miss Ada. She was very friendly and nobody has ever said something bad about her, so who could've expected that Ada will be found dead in her house? Mr Gawry, world-famous detective, is a... | ```python
n, m = map(int, input().split())
a = []
for i in range(m):
a.append(list(map(int, input().split())))
b = [set([]) for i in range(n)]
for i in range(n):
for j in range(m):
ya = a[j][i]
if i == n-1:
b[ya-1].add(100000000)
else:
b[ya-1].add(a[j][i+1])
class UnionFind():
def __init... | vfc_61289 | {
"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": "2 2\n1 2\n2 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1 2 3\n2 3 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
code_contests | verifiable_code | 1066_B. Heaters | Solve the following coding problem using the programming language python:
Vova's house is an array consisting of n elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The i-th element of the array is 1 if there is a heater in the posi... | ```python
n,r=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
i=ans=0
while i<n:
pointer=i
f=0
while pointer<n:
if pointer-r+1>i:
break
if a[pointer]==1:
j=pointer
f=1
pointer+=1
if f==0:
pointer=i-1
whil... | vfc_61293 | {
"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": "5 10\n0 0 0 0 0\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n1 0 0 0 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
code_contests | verifiable_code | 1089_A. Alice the Fan | Solve the following coding problem using the programming language python:
Alice is a big fan of volleyball and especially of the very strong "Team A".
Volleyball match consists of up to five sets. During each set teams score one point for winning a ball. The first four sets are played until one of the teams scores at... | vfc_61297 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n75 0\n90 90\n20 0\n0 75\n78 50\n80 100\n",
"output": "3:0\n25:0 25:0 25:0 \n3:1\n40:38 25:23 0:25 25:4 \nImpossible\n0:3\n0:25 0:25 0:25 \n3:0\n28:26 25:23 25:1 \n3:2\n40:38 25:12 0:25 0:25 15:0 \n",
"type": "stdin_s... | |
code_contests | verifiable_code | 1107_G. Vasya and Maximum Profit | Solve the following coding problem using the programming language python:
Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit.
Vasya has n problems to choose from. They are numbered from 1 to n. The difficulty of the i-th prob... | ```python
import sys
it = iter(sys.stdin.readlines())
input = it.__next__
n, k = map(int, input().split())
d, c = [0] * n, [0] * n
for i in range(n):
a, b = map(int, input().split())
d[i], c[i] = a, k - b
p, r, pre, suf, sm, mx = list(range(n)), [0] * n, c[:], c[:], c[:], c[:]
def find(x):
if x != p[x]:
... | vfc_61301 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 10\n1 15\n5 3\n6 11\n7 2\n11 22\n",
"output": " 13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 5\n1 8\n2 19\n3 11\n",
... |
code_contests | verifiable_code | 1137_B. Camp Schedule | Solve the following coding problem using the programming language python:
The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp's schedule. After some continuous discussion, they came up with a sche... | ```python
def findNeedSubstring(s):
n = len(s)
rst = ''
tmp = 0
for i in range(1, n-1, 1):
if(s[0:i] == s[n-i:n]):
rst = s[0:i] # this is the longest substring that prefix = suffix
tmp = i
return s[tmp: n]
def polyHash(s):
rst = [0] * (len(s) + 1)
... | vfc_61305 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n11100\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10010110\n100011\n",
"output": "10001101\n",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
code_contests | verifiable_code | 1155_D. Beautiful Array | Solve the following coding problem using the programming language python:
You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the ... | ```python
import sys
#Library Info(ACL for Python/Pypy) -> https://github.com/not522/ac-library-python
def input():
return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1,0), (0, 1), (-1,0)] #L,D,R,Uの順番
INF = 1 << 64
def main():
n,x = map(int,input().split())
a = list(map(int,input().split()))
A =... | vfc_61309 | {
"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 10\n-1 -2 -3 -4 -5\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n",
"output": "42",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1213_C. Book Reading | Solve the following coding problem using the programming language python:
Polycarp is reading a book consisting of n pages numbered from 1 to n. Every time he finishes the page with the number divisible by m, he writes down the last digit of this page number. For example, if n=15 and m=5, pages divisible by m are 5, 1... | ```python
q = int(input())
for i in range(q):
n, m = input().split(" ")
n = int(n)
m = int(m)
if n == m:
print(m%10)
continue
inicial = m
aux = (m%10)
m += inicial
while (m%10) != (inicial%10) and m <= n:
aux += (m%10)
m += inicial
m = m-ini... | vfc_61321 | {
"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": "7\n1 1\n10 1\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 13\n",
"output": "1\n45\n153\n294\n3359835\n0\n427262129093995\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1236_D. Alice and the Doll | Solve the following coding problem using the programming language python:
Alice got a new doll these days. It can even walk!
Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the cell i... | ```python
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
DBG = True and False
BIG = 999999999
R = 10**9 + 7
def ddprint(x):
if DBG:
print(x)
n,m,k = inm()
hx = {}
hy = {}
cnt ... | vfc_61325 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 2\n3 1\n2 2\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 2\n2 2\n2 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
code_contests | verifiable_code | 1254_B2. Send Boxes to Alice (Hard Version) | Solve the following coding problem using the programming language python:
This is the harder version of the problem. In this version, 1 ≤ n ≤ 10^6 and 0 ≤ a_i ≤ 10^6. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems
Christmas is coming, and our protago... | ```python
# 素因数分解
def prime_decomposition(n):
i = 2
table = []
while i * i <= n:
while n % i == 0:
n //= i
table.append(i)
i += 1
if n > 1:
table.append(n)
return table
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().sp... | vfc_61329 | {
"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\n4 8 5\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n3 10 2 1 5\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1297_H. Paint the String | Solve the following coding problem using the programming language python:
You are given a string s of lowercase Latin letters. It is required to paint each letter of the string in one of two colors (red or blue) so that if you write all the red letters from left to right and write all the blue letters from left to rig... | vfc_61337 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nkotlin\ncodeforces\nabacaba\nffccgc\nyz\n",
"output": "\nRRRRBB\nRRRRRRRBBB\nRRRRBBB\nRBBBBR\nRR\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1340_B. Nastya and Scoreboard | Solve the following coding problem using the programming language python:
Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya d... | ```python
import sys
def f():
n, k = map(int, input().split())#2000, 2000
ch = {0:'1110111',1:'0010010',2:'1011101',3:'1011011',4:'0111010',5:'1101011',6:'1101111',7:'1010010',8:'1111111',9:'1111011'}
l = []
for _ in range(n):
l.append(sys.stdin.readline().rstrip())
def tr(s1, s2):
... | vfc_61345 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n0100001\n1001001\n1010011\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 5\n0010010\n0010010\n",
"output": "97\n",
"type": "stdin_stdout"
},
{... |
code_contests | verifiable_code | 1403_A. The Potion of Great Power | Solve the following coding problem using the programming language python:
Once upon a time, in the Land of the Shamans, everyone lived on the Sky-High Beanstalk. Each shaman had a unique identifying number i between 0 and N-1, and an altitude value H_i, representing how high he lived above ground level. The distance b... | vfc_61357 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 5 11 4\n2 42 1000 54 68 234\n0 1\n2 0\n3 4\n3 5\n3 5\n1 3\n5 3\n0 5\n3 0\n1 3\n3 5\n0 3 4\n3 0 8\n0 5 5\n3 0 11",
"output": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n26\n0\n1000000000\n14",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1425_C. Captain of Knights | Solve the following coding problem using the programming language python:
Mr. Chanek just won the national chess tournament and got a huge chessboard of size N × M. Bored with playing conventional chess, Mr. Chanek now defines a function F(X, Y), which denotes the minimum number of moves to move a knight from square (... | vfc_61361 | {
"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\n3 4 5 6\n5 5 8 8\n",
"output": "27\n70\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 4 5 6\n5 8 8 8\n",
"output": "27\n20\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 1447_A. Add Candies | Solve the following coding problem using the programming language python:
There are n bags with candies, initially the i-th bag contains i candies. You want all the bags to contain an equal amount of candies in the end.
To achieve this, you will:
* Choose m such that 1 ≤ m ≤ 1000
* Perform m operations. In the... | ```python
a=int(input())
for i in range(a):
b=int(input())
arr=[str(i) for i in range(b,1,-1)]
arr=arr[::-1]
print(len(arr))
print(' '.join(arr))
``` | vfc_61365 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n3\n",
"output": "2\n1 2 \n3\n1 2 3 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n100\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n... |
code_contests | verifiable_code | 1471_B. Strange List | Solve the following coding problem using the programming language python:
You have given an array a of length n and an integer x to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be q. If q is divisible by x, the robot adds x copies of the i... | ```python
t=int(input())
for _ in range(t):
n,x=[int(z) for z in input().split()]
a=[int(x) for x in input().split()]
minCycles=float('inf')
minCycIdx=-1
for i,z in enumerate(a):
nCycles=0
while z%x==0:
nCycles+=1
z//=x
if nCycles<minCycles:
... | vfc_61369 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n12\n4 2\n4 6 8 2\n",
"output": "\n36\n44\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 3\n1 12\n4 2\n4 6 8 9\n5 7\n49 49 49 7 49\n",
"output": "13\n45\n553\n",
"... |
code_contests | verifiable_code | 1520_A. Do Not Be Distracted! | Solve the following coding problem using the programming language python:
Polycarp has 26 tasks. Each task is designated by a capital letter of the Latin alphabet.
The teacher asked Polycarp to solve tasks in the following way: if Polycarp began to solve some task, then he must solve it to the end, without being dist... | ```python
def solve(task):
unique = set(task)
segments = 0
prev = ' '
for letter in task:
if letter != prev:
segments+=1
prev = letter
return "YES" if len(unique) == segments else "NO"
if __name__ == '__main__':
T = int(input().strip())
for _ in range(T):
... | vfc_61377 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3\nABA\n11\nDDBBCCCBBEZ\n7\nFFGZZZY\n1\nZ\n2\nAB\n",
"output": "\nNO\nNO\nYES\nYES\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n14\nVORISLOVEELINA\n",
"output": "NO\n",... |
code_contests | verifiable_code | 175_C. Geometry Horse | Solve the following coding problem using the programming language python:
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are n types of ge... | ```python
n = int(input())
figures = []
for _ in range(n):
amount, cost = map(int, input().split())
figures += [(cost, amount)]
figures.sort()
t = int(input())
T = list(map(int, input().split()))
result = 0
destructed = 0
i, j = 0, 0
while i < len(figures):
if j < len(T) and destructed + figures[i][... | vfc_61385 | {
"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\n3 8\n5 10\n1\n20\n",
"output": "74\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n5 10\n2\n3 6\n",
"output": "70\n",
"type": "stdin_stdout"
},
{
"fn_name":... |
code_contests | verifiable_code | 219_D. Choosing Capital for Treeland | Solve the following coding problem using the programming language python:
The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are n - 1 roads in the country. We know that if we don't take the direction of the roads into consideration, we can get from any... | ```python
#More es mi pastor nada me faltara
import sys
from collections import defaultdict
from typing import NamedTuple
class EdgeNode(NamedTuple):
vertex: int
weight: int
class Graph:
def __init__(self, n):
self.graph = d = {i: [] for i in range(n + 1)}
self.distance = [0] * (n ... | vfc_61393 | {
"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": "3\n2 1\n2 3\n",
"output": "0\n2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 243_A. The Brand New Function | Solve the following coding problem using the programming language python:
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 ≤ l ≤ r ≤ n) for sequence a as an operation of bitwise OR of all the sequence elements with indexes from l to ... | ```python
n, a, b = input(), set(), set()
for i in map(int, input().split()):
b = set(i | j for j in b)
b.add(i)
a.update(b)
print(len(a))
``` | vfc_61397 | {
"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": "10\n1 2 3 4 5 6 1 2 9 10\n",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2 0\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
code_contests | verifiable_code | 268_D. Wall Bars | Solve the following coding problem using the programming language python:
Manao is working for a construction company. Recently, an order came to build wall bars in a children's park. Manao was commissioned to develop a plan of construction, which will enable the company to save the most money.
After reviewing the fo... | vfc_61401 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3\n",
"output": "256\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n",
"output": "148\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2... | |
code_contests | verifiable_code | 291_A. Spyke Talks | Solve the following coding problem using the programming language python:
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke n... | ```python
n=int(input())
l=list(map(int,input().split()))
ans=0
repeat={}
for i in l:
if i in repeat:
repeat[i]+=1
if i==0:
pass
elif repeat[i]>2:
ans=-1
break
else:
ans+=1
else:
repeat[i]=1
print(ans)
``` | vfc_61405 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1 1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n0\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "... |
code_contests | verifiable_code | 316_D1. PE Lesson | Solve the following coding problem using the programming language python:
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is thro... | ```python
m = 1000000007
n = int(input())
a = map(int, input().split())
t1, t2 = 0, 0
for i in a:
if i == 1:
t1 += 1
else:
t2 += 1
a = [1, 2]
for i in range(3, t1+1):
a = a[::-1]
a[1] = (a[0]+(i-1)*a[1])%m
if not t1 or t1 == 1:
a[1] = 1
for i in range(t1+1, n+1):
a[1] = a[1]*i%m
print(a[1])
``` | vfc_61409 | {
"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": "5\n1 2 2 1 2\n",
"output": "120",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n1 2 2 1 2 1 1 2\n",
"output": "16800",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | 339_D. Xenia and Bit Operations | Solve the following coding problem using the programming language python:
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.
Namely, it ... | ```python
from operator import or_, xor
import sys
greg=1
#Stolen from tchr to test Xenia and Bit Operations speed.
n, m = map(int, input().split())
t = [list(map(int, input().split()))]
for i in range(n):
t += [[(or_, xor)[i & 1](*t[i][j: j + 2]) for j in range(0, len(t[i]), 2)]]
for s in sys.stdin:
p, b =... | vfc_61413 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2\n",
"output": "1\n3\n3\n3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 362_A. Two Semiknights Meet | Solve the following coding problem using the programming language python:
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2... | ```python
t = int(input())
for _ in range(t):
s = [input() for i in range(8)]
oh = True
flag = True
for i in range(8):
for j in range(8):
if(s[i][j] == 'K'):
if(flag):
pos1x = i
pos1y = j
flag = False
... | vfc_61417 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n........\n........\n......#.\nK..##..#\n.......#\n...##..#\n......#.\nK.......\n\n........\n........\n..#.....\n..#..#..\n..####..\n...##...\n........\n....K#K#\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}... |
code_contests | verifiable_code | 385_D. Bear and Floodlight | Solve the following coding problem using the programming language python:
One day a bear lived on the Oxy axis. He was afraid of the dark, so he couldn't move at night along the plane points that aren't lit. One day the bear wanted to have a night walk from his house at point (l, 0) to his friend's house at point (r, ... | vfc_61421 | {
"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": "1 0 1\n1 1 30\n",
"output": "0.732050807569\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0 2\n0 2 90\n",
"output": "2.000000000000\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 456_A. Laptops | Solve the following coding problem using the programming language python:
One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is l... | ```python
n = int(input())
for _ in range(n):
a,b = map(int,input().split())
if a!=b:
print ('Happy Alex')
exit()
print ('Poor Alex')
``` | vfc_61433 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n2 1\n",
"output": "Happy Alex\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2\n2 3\n3 1\n",
"output": "Happy Alex\n",
"type": "stdin_stdout"
},
{
"... |
code_contests | verifiable_code | 478_D. Red-Green Towers | Solve the following coding problem using the programming language python:
There are r red and g green blocks for construction of the red-green tower. Red-green tower can be built following next rules:
* Red-green tower is consisting of some number of levels;
* Let the red-green tower consist of n levels, then th... | ```python
"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import os
import sys
from io import BytesIO, IOBase
import heapq as h
import bisect
from types import GeneratorType
BUFSIZE = 8192
class SortedList:
def __init__(self, iterable=[], _load=... | vfc_61437 | {
"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": "1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 6\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 7\n",... |
code_contests | verifiable_code | 500_F. New Year Shopping | Solve the following coding problem using the programming language python:
Dohyun is running a grocery store. He sells n items numbered by integers from 1 to n. The i-th (1 ≤ i ≤ n) of them costs ci dollars, and if I buy it, my happiness increases by hi. Each item can be displayed only for p units of time because of fr... | vfc_61441 | {
"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": "5 4\n3 2 1\n7 4 4\n2 1 2\n6 3 5\n3 2 2\n10\n1 5\n2 5\n4 8\n4 9\n4 10\n5 8\n5 9\n5 10\n8 4\n7 9\n",
"output": "2\n3\n5\n5\n6\n4\n5\n6\n0\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4... | |
code_contests | verifiable_code | 526_D. Om Nom and Necklace | Solve the following coding problem using the programming language python:
One day Om Nom found a thread with n beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly.
<image>
Om Nom knows that his girlfriend loves beauti... | vfc_61445 | {
"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": "21 2\nababaababaababaababaa\n",
"output": "000110000111111000011",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 2\nbcabcab\n",
"output": "0000011",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | 551_E. GukiZ and GukiZiana | Solve the following coding problem using the programming language python:
Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. For given array a, indexed with integers from 1 to n, and number y, GukiZiana(a, y) represents maximum value of j - i, such that a... | vfc_61449 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 10, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 2\n1 2 2 1\n2 3\n2 4\n",
"output": "0\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n1 2 3 4\n1 1 2 1\n1 1 1 1\n2 3\n",
"output": "2\n",
"type": "stdin_stdout"... | |
code_contests | verifiable_code | 578_F. Mirror Box | Solve the following coding problem using the programming language python:
You are given a box full of mirrors. Box consists of grid of size n × m. Each cell of the grid contains a mirror put in the shape of '\' or ' / ' (45 degree to the horizontal or vertical line). But mirrors in some cells have been destroyed. You ... | vfc_61453 | {
"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": "2 2 1000000007\n*/\n/*\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2 1000000007\n**\n\\\\",
"output": "1\n",
"type": "stdin_stdout"
},
{
"f... | |
code_contests | verifiable_code | 5_D. Follow Traffic Rules | Solve the following coding problem using the programming language python:
Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland ar... | ```python
"""
Codeforces
5D - Follow Traffic Rules
http://codeforces.com/contest/5/problem/D
Héctor González Belver
../07/2018
"""
import sys
def time_distance(v0, a, d):
#quadratic equation. Time is positive ==> root with (+discriminant) in quadratic formula
#d = v0*t + (a/2)*t^2
return (-v0 + (v0**2 + 2*a*d)*... | vfc_61457 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 70\n200 170 40\n",
"output": "8.965874696353\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n2 1 3\n",
"output": "2.500000000000\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 622_B. The Time | Solve the following coding problem using the programming language python:
You are given the current time in 24-hour format hh:mm. Find and print the time after a minutes.
Note that you should find only the time after a minutes, see the examples to clarify the problem statement.
You can read more about 24-hour format... | ```python
#!/usr/bin/env python3
import datetime
def main(args):
hh, mm = list(map(int, input().split(':')))
a = int(input())
mm += a
hh += (mm // 60)
mm %= 60
hh %= 24
print(f"{hh:02d}:{mm:02d}")
return 0
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))
``` | vfc_61461 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10:10\n0\n",
"output": "10:10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "23:59\n10\n",
"output": "00:09\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 696_A. Lorenzo Von Matterhorn | Solve the following coding problem using the programming language python:
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. Y... | ```python
def find_path(x,y):
p1,p2 = [],[]
while x!=0:
p1.append(x)
x = x//2
while y!=0:
p2.append(y)
y = y//2
p1 = p1[::-1]
p2 = p2[::-1]
# print (p1,p2)
for i in range(min(len(p1),len(p2))):
if p1[i]==p2[i]:
ind = i
else:
break
path = []
for i in range(ind,len(p1)):
path.append(p1[i])
p... | vfc_61473 | {
"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\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4\n",
"output": "94\n0\n32\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 100000000000000 200000000000000 1\n2 276447232 55... |
code_contests | verifiable_code | 717_B. R3D3’s Summer Adventure | Solve the following coding problem using the programming language python:
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listenin... | ```python
import sys,heapq
#sys.stdin=open("data.txt")
input=sys.stdin.readline
n,a,b=map(int,input().split())
if a<b: a,b=b,a
if b==0:
# 1 01 001 0001 ... is optimal, plus a long series of 0's
print((n-1)*a)
else:
# pascal's triangle thing
pascal=[[1]*20005]
for i in range(20004):
... | vfc_61477 | {
"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 2\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8954 4025 7157\n",
"output": "641304164\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 737_D. Financiers Game | Solve the following coding problem using the programming language python:
This problem has unusual memory constraint.
At evening, Igor and Zhenya the financiers became boring, so they decided to play a game. They prepared n papers with the income of some company for some time periods. Note that the income can be posi... | vfc_61481 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n-4 -2 4 5\n",
"output": "-13",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n-1 -2 -1 -2 -1\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | 761_C. Dasha and Password | Solve the following coding problem using the programming language python:
After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements:
* There is at least one digit in the string,
* There i... | ```python
n,m=map(int,input().split())
m1,m2,m3=[m+1]*n,[m+1]*n,[m+1]*n
for i in range(n):
s=input()
for j, c in enumerate(s):
z=min(j, m-j)
if c>='0' and c<='9':
m1[i]=min(m1[i],z)
else:
if c>='a' and c<='z':
m2[i]=min(m2[i],z)
else:
... | vfc_61485 | {
"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 4\n1**2\na3*0\nc4**\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n#*&#*\n*a1c&\n&q2w*\n#a3c#\n*&#*&\n",
"output": "3\n",
"type": "... |
code_contests | verifiable_code | 784_E. Twisted Circuit | Solve the following coding problem using the programming language python:
<image>
Input
The input consists of four lines, each line containing a single digit 0 or 1.
Output
Output a single digit, 0 or 1.
Example
Input
0
1
1
0
Output
0
The input will be given via stdin and the output should be printed to std... | ```python
import collections as col
import itertools as its
import sys
import operator
from bisect import bisect_left, bisect_right
from copy import copy, deepcopy
class Solver:
def __init__(self):
pass
def solve(self):
a = int(input())
b = int(input())
c = int(input())
... | vfc_61489 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0\n1\n1\n0\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 805_D. Minimum number of steps | Solve the following coding problem using the programming language python:
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the mi... | ```python
def mess():
String=input()
count_it=0
Counter=0
for i in String:
if i=='a':
count_it = (count_it * 2) % Modulo
count_it+=1
elif i=='b':
Counter+=count_it
#count_it =(count_it* 2)%Modulo
return Counter
if __name__ == "__main... | vfc_61493 | {
"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": "aab\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ab\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabbaababbab... |
code_contests | verifiable_code | 830_D. Singer House | Solve the following coding problem using the programming language python:
It is known that passages in Singer house are complex and intertwined. Let's define a Singer k-house as a graph built by the following process: take complete binary tree of height k and add edges from each vertex to all its successors, if they a... | ```python
print([0,1,9,245,126565,54326037,321837880,323252721,754868154,328083248,838314395,220816781,893672292,166441208,251255697,114256285,118775501,482714697,11784725,460862131,550384565,106742050,425241115,626692854,674266678,320014275,345949512,527320049,897822749,137190263,491039182,810384961,482023334,65809986... | vfc_61497 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "245\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 851_E. Arpa and a game with Mojtaba | Solve the following coding problem using the programming language python:
Mojtaba and Arpa are playing a game. They have a list of n numbers in the game.
In a player's turn, he chooses a number pk (where p is a prime number and k is a positive integer) such that pk divides at least one number in the list. For each nu... | vfc_61501 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1 1 1\n",
"output": "Arpa\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 876_A. Trip For Meal | Solve the following coding problem using the programming language python:
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length o... | ```python
# 876A
def main():
n, a, b, c = int(input()), int(input()), int(input()), int(input())
if n == 1:
return 0
n -= 1
count = 0
state = 0
while n:
if state == 0:
if a > b:
count += b
state = 2
else:
count += a
state = 1
elif state == 1:
if a > c:
count += c
state = 2
... | vfc_61505 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2\n3\n5\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 8_A. Train and Peter | Solve the following coding problem using the programming language python:
Peter likes to travel by train. He likes it so much that on the train he falls asleep.
Once in summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he woke up, started to look through the window and noticed t... | ```python
import re
I = input
s, first, second = I(), I(), I()
forward = re.fullmatch('\w*' + first + '\w*' + second + '\w*', s)
backward = re.fullmatch('\w*' + first + '\w*' + second + '\w*', s[::-1])
if forward:
print('both' if backward else 'forward')
else:
print('backward' if backward else 'fantasy')
``... | vfc_61509 | {
"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": "atob\na\nb\n",
"output": "forward\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaacaaa\naca\naa\n",
"output": "both\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 94_A. Restoring Password | Solve the following coding problem using the programming language python:
Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain "some real funny stuff about swine influenza". Th... | ```python
s = input()
a = []
for i in range(10):
a.append(input())
p = 0
while(p < 80):
for i in range(10):
if a[i] == s[p:p+10]:
print(i, end='')
p += 10
break
``` | vfc_61517 | {
"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": "10101101111001000010100100011010101101110010110111011000100011011110010110001000\n1001000010\n1101111001\n1001000110\n1010110111\n0010110111\n1101001101\n1011000001\n1110010101\n1011011000\n0110001000\n",
"output": "30234919"... |
code_contests | verifiable_code | 997_C. Sky Full of Stars | Solve the following coding problem using the programming language python:
On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.
It is well known that one month on this planet consists of n^2 days, so calendars, represented as square matrix n by n are extremely popular.... | vfc_61525 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "9933\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "63\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
... | |
code_contests | verifiable_code | bbq-sticks | Solve the following coding problem using the programming language python:
Our Tom is doing what he is best at, COOKING A BARBECUE for his guests. He has invited all of us, and taking the help of his apprentice to smoke the barbecues. The Tom has got BBQ sticks, each can take N fillings, and he presents N distinctly fi... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n=int(raw_input())
while(n>0):
n-=1
a=int(raw_input())
ans=2**(a-2)+1
print ans
``` | vfc_61529 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5\n8\n9\n12\n\nSAMPLE",
"output": "9\n65\n129\n1025\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n5\n8\n9\n12\n\nPAMSLE",
"output": "9\n65\n129\n1025\n",
"type": "stdin... |
code_contests | verifiable_code | execute-the-prisoners | Solve the following coding problem using the programming language python:
Chandu has been appointed as the superintendent of a jail having N prisoners .
Prisoner are numbered form 1 to N.
Today he has been specially invited to execute the prisoners.
All the prisoners are arranged in circle and he starts executing th... | ```python
st1=int(raw_input())
while(st1!=0):
ans=1
n=int(raw_input())
k=2
for i in range(n):
ans=(ans+k-1)%(i+1)+1
print(ans)
st1=st1-1
``` | vfc_61537 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n6\n\nSAMPLE",
"output": "3\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n3003\n4638\n1156\n4277\n1903\n1654\n1306\n3643\n4615\n2707\n1861\n2651\n1617\n1686\n2909\n3456\n10... |
code_contests | verifiable_code | highest-points | Solve the following coding problem using the programming language python:
As the league stage of the world cup has come to its end, its time to calculate the highest points earned in the league stage by a team.
There are many teams playing in the world cup. A team is awarded 3 points for a win, 1 point for a tie and ... | ```python
res = list()
n = int(raw_input())
for i in range(n):
num = list(map(int, raw_input().split()))
res.append(num[0]*3+num[1]*1-num[2])
print(max(res))
``` | vfc_61541 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 0 1\n2 1 3\n1 1 1\n\nSAMPLE",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3 0 1\n2 1 3\n1 0 1\n\nSAMPLE",
"output": "8\n",
"type": "stdin_stdout"
}... |
code_contests | verifiable_code | magic-pass-code-1 | Solve the following coding problem using the programming language python:
Problem Description
Apparently, the key that would take Alice home from her Wonderland adventure is a magic pass code hidden in numbers.
Help her find it! It's the one with the highest sum of its digits!
Input Format
Input consists of severa... | ```python
alls = []
while True:
failed = False
try:
s = raw_input()
except:
failed = True
break
if len(s.rstrip().lstrip())==0:
failed = True
break
alls.append(s)
if len(alls)> 0:
winner = ''
maxs = 0
for y in alls:
csum = sum(in... | vfc_61545 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "23\n496\n\nSAMPLE",
"output": "496",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | nice-arches-1 | Solve the following coding problem using the programming language python:
Nikki's latest work is writing an story of letters. However, she finds writing story so boring that, after working for three hours, she realized that all she has written are M long words consisting entirely of letters A and B. Having accepted th... | ```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!'
n = int(raw_input())
count = 0
for i in range(n):
inputStr = raw_input()
inputStrArr = inputStr.split()
stack = []
for j in inputStr:
#print j
... | vfc_61549 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nABAB\nAABB\nABBA\n\nSAMPLE",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\nABBABAAAAAAAAB\nABBBBBABBB\nBAAAAB\nABABAA\nBBBBBBBBBBBBBB\nBBBBABABAABABA\nABBABBBABA\nBBB... |
code_contests | verifiable_code | promotion-1 | Solve the following coding problem using the programming language python:
Ramesh is a hard-working employee.Seeing his dedication towards his work his boss decided to promote him. Ramesh was overjoyed on getting to know this.But soon he realized he needed to shift to another Town X. Ramesh needed to transport his n bo... | ```python
import sys
n, m = [int(x) for x in sys.stdin.readline().split()]
weights = [int(x) for x in sys.stdin.readline().split()]
trucks = [int(x) for x in sys.stdin.readline().split()]
weights.sort(reverse=True)
trucks.sort(reverse=True)
w = 0
t = 0
count = 1
while (weights):
#print(w, len(weights))
if t =... | vfc_61553 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 2\n10 2 16 19 6 11 5\n29 25\n\nSAMPLE",
"output": "7",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | the-enlightened-ones | Solve the following coding problem using the programming language python:
There are N temples in a straight line and K monks who want to spread their enlightening power to the entire road of temples. All the monks have an enlightenment value, which denotes the range of enlightenment which they can spread in both the ... | ```python
def is_enlightened(xs, k, power):
last_position = xs[0] + power
k -= 1
for x in xs:
if x > last_position + power:
last_position = x + power
k -= 1
return k >= 0
def solve(xs, k):
xs.sort()
start = 0
end = ((xs[0] + xs[-1]) / 2) + 1
found = end
... | vfc_61561 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1 5 20\n\nSAMPLE",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n1 57",
"output": "28\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | xsquare-and-coin-collection-2 | Solve the following coding problem using the programming language python:
Xsquare loves to play with the coins very much. Today , he has N stacks of coins . Each stack of coins has some non zero height Hi equal to the number of coins on that stack ( considering all the coins are identical and each coin has a height of... | ```python
t = int(raw_input())
for i in range(t):
(n, k) = map(int, raw_input().strip().split(' '))
arr = map(int, raw_input().strip().split(' '))
mask = [0]*n
for i in range(n):
if arr[i]<=k:
mask[i]=1
i=0
ans=0
while i<n:
if mask[i]==0:
i+=1
else:
temp=0
while i<n and mask[i]!=0:
temp+=... | vfc_61565 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n8 1\n3 2 2 3 1 1 1 3\n8 2\n3 2 2 3 1 1 1 3\n\nSAMPLE",
"output": "3\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n8 1\n3 2 2 3 1 1 1 3\n8 2\n3 2 2 3 1 2 1 3\n\nSAMPLE",
"o... |
code_contests | verifiable_code | p00077 Run Length | Solve the following coding problem using the programming language python:
If the strings are consecutive, you can replace the characters with a rule to shorten the string. For example, for the string AAAA, the expression @ 4A will compress one character. Create a program that restores the character string compressed b... | ```python
while True:
try:
s = input()
except EOFError:
break
r = ''
n = 1
for c in s:
if n < 0:
n = int(c)
elif c == '@':
n = -1
else:
r += c * n
n = 1
print(r)
``` | vfc_61609 | {
"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": "ab@5C1@8050\n@99+1=1@90",
"output": "abCCCCC10000000050\n999999999+1=1000000000",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00586 A + B Problem | Solve the following coding problem using the programming language python:
Compute A + B.
Constraints
* -1000 ≤ A, B ≤ 1000
Input
The input will consist of a series of pairs of integers A and B separated by a space, one pair of integers per line. The input will be terminated by EOF.
Output
For each pair of input ... | ```python
ans=""
while True:
try:
info=input()
except:
break
if ans!="":
ans+="\n"
info_2=info.split()
ans+=str(int(info_2[0])+int(info_2[1]))
print(ans)
``` | vfc_61621 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2\n10 5\n100 20",
"output": "3\n15\n120",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2\n10 5\n101 20",
"output": "3\n15\n121\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | p00723 Organize Your Train part II | Solve the following coding problem using the programming language python:
RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in Figure B-1.
<image>
Figure B-1: Layout of the exchange lines
A freight train consis... | ```python
import itertools
def main():
n = int(input())
for _ in range(n):
s = input()
ssum = set()
for i in range(len(s)):
l = s[:i]
rl = l[::-1]
r = s[i:]
rr = r[::-1]
ssum.add(l+r)
ssum.add(r+l)
ssum.... | vfc_61625 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\naa\nabba\nabcd\nabcde",
"output": "1\n6\n12\n18",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\naa\nabba\nbbcd\nabcde",
"output": "1\n6\n8\n18\n",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | p00863 The Teacher's Side of Math | Solve the following coding problem using the programming language python:
One of the tasks students routinely carry out in their mathematics classes is to solve a polynomial equation. It is, given a polynomial, say X2 - 4X + 1, to find its roots (2 ± √3).
If the students’ task is to find the roots of a given polynomi... | vfc_61629 | {
"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 2 2\n3 2 2 3\n2 2 3 4\n31 4 2 3\n3 2 2 7\n0 0 0 0",
"output": "1 0 -10 0 1\n1 0 -9 -4 27 -36 -23\n1 0 -8 0 18 0 -104 0 1\n1 0 0 -8 -93 0 24 -2976 2883 -32 -3720 -23064 -29775\n1 0 -21 0 189 0 -945 -4 2835 -252 -5103 -1260... | |
code_contests | verifiable_code | p01126 Amida | Solve the following coding problem using the programming language python:
The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates f... | ```python
while True:
n, m, a = map(int, input().split(' '))
if n == 0 and m == 0 and a == 0:
break
hl = [list(map(int, input().split(' '))) for i in range(m)]
hl.sort(key=lambda x: x[0], reverse=True)
vl = a
for l in hl:
if l[1] == vl:
vl = l[2]
elif l[2] == ... | vfc_61637 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 1\n3 1 2\n2 2 3\n3 3 4\n1 3 4\n0 0 0",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4 1\n3 1 2\n2 2 4\n3 3 4\n1 3 4\n0 0 0",
"output": "3\n",
"type": "stdin... |
code_contests | verifiable_code | p01265 Ninja Legend | Solve the following coding problem using the programming language python:
Ninjas are professional spies in the Middle Age of Japan. They have been popular in movies and games as they have been described with extraordinary physical abilities and unrealistic abilities.
You are absorbed in one of ninja games, Ninja Lege... | vfc_61641 | {
"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 23\n#######################\n#%.^.^#################\n#^^^^^######^^^^^^^^^^#\n#^^^...^^^^...^^*^^..*#\n#^^^^^^^^^^^^^^^^^^^^^#\n#######################\n5 16\n################\n#^^^^^^^^^^^^^^#\n#*..^^^.%.^^..*#\n#^^#####^^^^^^^... | |
code_contests | verifiable_code | p01425 White Bird | Solve the following coding problem using the programming language python:
Angry Birds is a mobile game of a big craze all over the world. You were convinced that it was a waste of time to play the game, so you decided to create an automatic solver.
<image>
You are describing a routine that optimizes the white bird's... | ```python
# aoj 2308
import sys
input = sys.stdin.readline
def calc_y(vy, t):
return vy*t - g/2*t*t
def loc(y, b, t):
if y < b+eps:
return -1
if y > t-eps:
return 1
return 0
def can_hit(x, y):
if x == 0:
return False
a = g*g/4
b = g*y-V*V
c = x*x+y*y
D =... | vfc_61645 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 7 3 1",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 7 2 2\n0 1 1 2",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | p01581 Cache Control | Solve the following coding problem using the programming language python:
Mr. Haskins is working on tuning a database system. The database is a simple associative storage that contains key-value pairs. In this database, a key is a distinct identification (ID) number and a value is an object of any type.
In order to b... | vfc_61649 | {
"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": "",
"output": "",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01741 Manhattan | Solve the following coding problem using the programming language python:
In Manhattan, roads run where the x or y coordinate is an integer. Both Sunuke-kun's house and Sumeke-kun's house are on the road, and the straight line distance (Euclidean distance) is just d. Find the maximum value that can be considered as th... | ```python
#!/usr/bin/env python3
d = float(input())
ans = max(2**0.5 * d, int(d) + 1)
print(ans)
``` | vfc_61653 | {
"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": "1.000",
"output": "2.000000000000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2.345",
"output": "3.316330803765",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | p01881 Help the Princess! | Solve the following coding problem using the programming language python:
Example
Input
2 4
%.@\$
..\$\$
Output
Yes
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | ```python
import queue
di = [0,1,0,-1]
dj = [1,0,-1,0]
h, w = map(int, input().split())
field = [input() for i in range(h)]
pdist = [[1000]*w for i in range(h)]
sdist = [[1000]*w for i in range(h)]
pque = queue.Queue()
sque = queue.Queue()
for i,row in enumerate(field):
for j in range(w):
if row[j] is '@... | vfc_61657 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\n%.@\\$\n..\\$\\$",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 4\n%.\\@$\n..\\$\\$",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | p02018 Surmise | Solve the following coding problem using the programming language python:
D: Sontaku (Surmise)
Some twins like even numbers.
Count how many even numbers are in $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $.
input
The integer $ N $ is given on the first line.
On the second line, $ N $ integers $ A_1, A_2, A_3, \ d... | ```python
N = int(input())
A = [int(x)%2 for x in input().split()]
ans = N - sum(A)
print(ans)
``` | vfc_61661 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4 3 5 2 6",
"output": "3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p02301 Diameter of a Convex Polygon | Solve the following coding problem using the programming language python:
Find the diameter of a convex polygon g. In other words, find a pair of points that have maximum distance between them.
Constraints
* 3 ≤ n ≤ 80000
* -100 ≤ xi, yi ≤ 100
* No point in the g will occur more than once.
Input
n
x1 y1
x2 y2
:
x... | ```python
#!/usr/bin/python3
import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys
def main():
N = read_int()
P = []
for _ in range(N):
x, y = [Fraction(s) for s in inp().split()]
P.append(Vec(x, y))
print(solve(N, P))
def lcm... | vfc_61669 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0.0 0.0\n1.0 0.0\n1.0 1.0\n0.0 1.0",
"output": "1.414213562373",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n0.0 0.0\n4.0 0.0\n2.0 2.0",
"output": "4.00",
"type": "stdin_... |
code_contests | verifiable_code | altaray | Solve the following coding problem using the programming language python:
There's an array A consisting of N non-zero integers A1..N. A subarray of A is called alternating if any two adjacent elements in it have different signs (i.e. one of them should be negative and the other should be positive).
For each x from 1 ... | ```python
def opposite(a,b):
if(a<0):
return b>=0
else:
return b<0
def func(a):
a2 = [1]*len(a)
count = 1
for i in range(len(a)):
if(count>1):
count = count-1
a2[i] = count
else:
j = i
while(j<len(a)-1 and opposite(a[j]... | vfc_61677 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n1 2 3 4\n4\n1 -5 1 -5\n6\n-5 -1 -1 2 -2 -3",
"output": "1 1 1 1\n4 3 2 1\n1 1 3 2 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4\n1 2 3 7\n4\n1 -5 1 -5\n6\n-5 -1 -1 2 -2 -3... |
code_contests | verifiable_code | cheftr | Solve the following coding problem using the programming language python:
The chef is fond of triangles. He has a task for you. You are given n point out of which only k are collinear. Find the number of triangles that can be formed from these n points.
You have to perform the above task for a number of test cases.
... | ```python
T = (int)(raw_input())
while T:
n,k=map(int,raw_input().split())
print n*(n-1)*(n-2)/6-k*(k-1)*(k-2)/6
T-=1
``` | vfc_61681 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n30 5",
"output": "4050",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | dspatna1 | Solve the following coding problem using the programming language python:
One of the most fundamental concepts learnt by a novice programmer is generation of Fibonacci Series. The Fibonacci Series is known to be of the form 0 1 1 2 3 5 8 13... etc. Usually a recursive approach to solve the problems is applied. The pro... | ```python
import sys
t=int(sys.stdin.readline())
while t!=0:
x=raw_input().split()
f1=int(x[0])
f2=int(x[1])
n=int(x[2])
if n==1:
print f1
else:
if n==2:
print f2
else:
for i in range (2,n):
f=f1+f2
f1=f2
... | vfc_61685 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n0 1 10\n2 3 5\n67 101 9\n23 46 35\n45 37 24\n45 27 1\n45 46 2",
"output": "34\n13\n2992\n343398096\n1857304\n45\n46\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n0 1 10\n2 3 5\n67 ... |
code_contests | verifiable_code | kfunc | Solve the following coding problem using the programming language python:
Eugene loves sequences, especially arithmetic progressions. One day he was asked to solve a difficult problem.
If a sequence of numbers A1, A2, ... , AN form an arithmetic progression A, he was asked to calculate sum of F(Ai), for L ≤ i ≤ R.
F(... | ```python
'''
Created on 21-Nov-2015
@author: Lenovo
'''
def F(x):
return (x-1)%9+1
T =input()
for t in range(T):
A, D, L, R = map(int, raw_input().split())
L-=1;R-=1;
sum_per9 =0;
for i in range(1,10): sum_per9 +=F(A+D*i)
ans =0
while (R-L+1)%9 != 0:
ans +=F(A+D*R)
R -=... | vfc_61689 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1 1 3\n14 7 2 4",
"output": "6\n12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1 1 2\n14 7 2 4",
"output": "3\n12\n",
"type": "stdin_stdout"
},
{
"f... |
code_contests | verifiable_code | oddevenx | Solve the following coding problem using the programming language python:
Given a sequence of numbers, find the absolute difference between the number of odd numbers and number of even numbers in a given sequence.
Input
The first line will contain the number of numbers in the sequence. And the second line will cont... | ```python
#!/usr/bin/python
count = int(raw_input())
nums = raw_input().split()
odd = 0
even = 0
for n in nums:
if int(n) % 2 == 0:
even = even + 1
else:
odd = odd + 1
print abs(odd - even)
``` | vfc_61693 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n 72 33 76 514 985",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | sncht2 | Solve the following coding problem using the programming language python:
For Turbo C++ Users : Read the following document before attempting the question :
Problem description.
HM has a tree-cutting facility. He also paint logs to sell them for treehouse-making. His assistant Deepsaggas is a student of IIIT-Delh... | ```python
#Enter your code here
a=raw_input().split()
n=int(a[0])
q=int(a[1])
a=raw_input().split()
for i in xrange(n):
a[i]=int(a[i])
hola=[0]
hola.append(a[0])
for i in range(1,n):
a[i]+=a[i-1]
hola.append(a[i])
#print hola
for i in xrange(q):
ra=raw_input().split()
l=int(ra[0])
r=int(ra[1])
... | vfc_61697 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n1 2 3 4 5\n2 3\n4 4\n4 5",
"output": "10\n11\n6",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1005_C. Summarize to the Power of Two | Solve the following coding problem using the programming language python:
A sequence a_1, a_2, ..., a_n is called good if, for each element a_i, there exists an element a_j (i ≠ j) such that a_i+a_j is a power of two (that is, 2^d for some non-negative integer d).
For example, the following sequences are good:
* [... | ```python
from collections import*
input()
arr = Counter(map(int,input().split()))
binpow = [2**i for i in range(31)]
deleted = 0
for item in list(arr.elements()):
flag = True
for bp in binpow:
if (arr.get(bp - item) != None):
if (bp - item == item):
if (arr.get(bp - item) > ... | vfc_61701 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n4 7 1 5 4 9\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n",
"output": "2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1029_A. Many Equal Substrings | Solve the following coding problem using the programming language python:
You are given a string t consisting of n lowercase Latin letters and an integer number k.
Let's define a substring of some string s with indices from l to r as s[l ... r].
Your task is to construct such string s of minimum possible length that... | ```python
n, k = map(int, input().split())
s = input()
ans = None
for i in range(1, n):
prefix = s[0:n-i]
suffix = s[i:n]
if prefix == suffix:
ans = prefix
ans += s[n-i:n] * k
break
if ans is None:
ans = s * k
print (ans)
``` | vfc_61705 | {
"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 2\ncat\n",
"output": "catcat\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\naba\n",
"output": "ababababa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1071_A. Cram Time | Solve the following coding problem using the programming language python:
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today ... | ```python
def get_out(list):
print(len(list))
out=' '.join(list)
print(out)
arr = input().split()
a = int(arr[0])
b = int(arr[1])
s=a+b
temp=0
i=0
while(temp<=s):
i+=1
temp+=i
i-=1
list_a=[]
list_b=[]
for x in range(i,0,-1):
if(a-x>=0):
a-=x
list_a.append(str(x... | vfc_61713 | {
"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": "9 12\n",
"output": "2\n6 3 \n4\n5 4 2 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n",
"output": "1\n3 \n2\n2 1 \n",
"type": "stdin_stdout"
},
{
"fn_nam... |
code_contests | verifiable_code | 1093_C. Mishka and the Last Exam | Solve the following coding problem using the programming language python:
Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.
There were n classes of that subject durin... | ```python
n = int(input())
b = input().split()
b = [int(x) for x in b]
a = [0 for x in range(n)]
a[0] = 0
a[n - 1] = b[0]
for i in range(1, n//2):
left = i
right = n - i - 1
a[left] = 0
a[right] = b[i]
if a[right] > a[right + 1]:
diff = a[right] - a[right + 1]
a[right] -= diff
... | vfc_61717 | {
"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": "6\n2 1 2\n",
"output": "0 0 1 1 1 2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1113_C. Sasha and a Bit of Relax | Solve the following coding problem using the programming language python:
Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve uns... | ```python
n = int(input())
a = [int(x) for x in input().split()]
pref = [0]
for i in range(n):
pref.append(pref[-1] ^ a[i])
dp = [[0 for i in range(2**20 + 5)] for j in range(2)]
ans = 0
for i in range(len(pref)):
ans += dp[i % 2][pref[i]]
dp[i % 2][pref[i]] += 1
#print(ans, pref[i])
print(ans)
``` | vfc_61721 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1141_F1. Same Sum Blocks (Easy) | Solve the following coding problem using the programming language python:
This problem is given in two editions, which differ exclusively in the constraints on the number n.
You are given an array of integers a[1], a[2], ..., a[n]. A block is a sequence of contiguous (consecutive) elements a[l], a[l+1], ..., a[r] (1 ... | ```python
import time
def index(key, item, index):
if key in index:
index[key].append(item)
else:
index[key] = [item]
def schedule2(times):
# print(times)
result = []
a_min = 0
for s, e in times:
if s >= a_min:
result.append((s, e))
a_min = e
... | vfc_61725 | {
"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": "7\n4 1 2 2 1 5 3\n",
"output": "3\n2 3\n4 5\n7 7\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 115_E. Linear Kingdom Races | Solve the following coding problem using the programming language python:
You are a car race organizer and would like to arrange some races in Linear Kingdom.
Linear Kingdom has n consecutive roads spanning from left to right. The roads are numbered from 1 to n from left to right, thus the roads follow in the order o... | vfc_61729 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 4\n3\n2\n3\n2\n1\n2\n3\n1 2 5\n2 3 5\n3 5 3\n7 7 5\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n10\n10\n10\n1 3 10\n",
"output": "0",
"type": "stdin_st... | |
code_contests | verifiable_code | 1182_E. Product Oriented Recurrence | Solve the following coding problem using the programming language python:
Let f_{x} = c^{2x-6} ⋅ f_{x-1} ⋅ f_{x-2} ⋅ f_{x-3} for x ≥ 4.
You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7).
Input
The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 ≤ n ≤ 10^{18}, 1 ≤ f_{... | ```python
mod = 1000000007
X = [[1,1,1],
[1,0,0],
[0,1,0]]
def mul(A, B):
return [[sum(a*b for a,b in zip(X_row,Y_col)) % ( mod-1 ) for Y_col in zip(*B)] for X_row in A]
def pow_n(A, n):
if n == 1:
return A
A_ = pow_n(A, n // 2)
if n % 2 == 0:
return A_ * A_... | vfc_61733 | {
"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 1 2 5 3\n",
"output": "72900",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "17 97 41 37 11\n",
"output": "317451037",
"type": "stdin_stdout"
},
{
"fn_name": null... |
code_contests | verifiable_code | 11_E. Forward, march! | Solve the following coding problem using the programming language python:
Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in which he sometimes makes ... | ```python
def solve():
original = input()
temp = [original[0]]
for i in range(1, len(original)):
if original[i] == original[i - 1] != 'X':
temp.append('X')
temp.append(original[i])
augmented = ''.join(temp)
answer = 0
if augmented[0] == augmented[-1] != 'X':
a... | vfc_61737 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "LXRR\n",
"output": "50.000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "X\n",
"output": "0.000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 1218_B. Guarding warehouses | Solve the following coding problem using the programming language python:
Bob Bubblestrong just got a new job as security guard. Bob is now responsible for safety of a collection of warehouses, each containing the most valuable Bubble Cup assets - the high-quality bubbles. His task is to detect thieves inside the ware... | vfc_61741 | {
"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": "5\n4 1 1 1 3 3 3 3 1\n4 4 3 6 2 6 0 4 0\n6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2\n3 0 -1 1 -3 -1 -3\n4 1 -4 1 -6 -1 -6 -1 -4\n",
"output": "13.33333249365046439209\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | 1240_E. Wooden Raft | Solve the following coding problem using the programming language python:
Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've already cut several trees and prepared it to the poi... | vfc_61745 | {
"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": "9\n9 10 9 18 9 9 9 28 9\n",
"output": "90\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1260_F. Colored Tree | Solve the following coding problem using the programming language python:
You're given a tree with n vertices. The color of the i-th vertex is h_{i}.
The value of the tree is defined as ∑_{h_{i} = h_{j}, 1 ≤ i < j ≤ n}{dis(i,j)}, where dis(i,j) is the number of edges on the shortest path between i and j.
The color ... | vfc_61749 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1\n1 2\n1 1\n1 2\n1 2\n1 3\n3 4\n",
"output": "22\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 4\n2 5\n1 4\n1 2\n2 5\n3 1\n2 4\n5 2\n1 4\n",
"output": "1576\n",
"t... | |
code_contests | verifiable_code | 1302_G. Keep talking and nobody explodes – medium | Solve the following coding problem using the programming language python:
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543)
You have the safe lock which consists of 5 decimal digits. If you rotate some digit, it incr... | vfc_61757 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "00000\n",
"output": "\n43266\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12345\n",
"output": "\n87229\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1326_F1. Wise Men (Easy Version) | Solve the following coding problem using the programming language python:
This is the easy version of the problem. The difference is constraints on the number of wise men and the time limit. You can make hacks only if all versions of this task are solved.
n wise men live in a beautiful city. Some of them know each ot... | ```python
from sys import stdout
n = int(input())
class Person:
num = n - 1
def __init__(self, rel):
self.relationship = int(rel, 2)
def __getitem__(self, k):
return (self.relationship >> Person.num - k) & 1
rel = [Person(input()) for _ in range(n)]
dp = [[0] * n for _ in range(1 <<... | vfc_61761 | {
"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\n0101\n1000\n0001\n1010\n",
"output": "2 2 6 2 2 6 2 2 ",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1345_F. Résumé Review | Solve the following coding problem using the programming language python:
Uh oh! Applications to tech companies are due soon, and you've been procrastinating by doing contests instead! (Let's pretend for now that it is actually possible to get a job in these uncertain times.)
You have completed many programming proje... | ```python
import sys
import heapq as hq
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
eps = 10**-7
def solve():
n, k = nm()
a = nl()
ans = [0]*n
ok = 10**9... | vfc_61765 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 32\n1 2 3 4 5 5 5 5 5 5\n",
"output": "1 2 3 3 3 4 4 4 4 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 8\n4 4 8 2 1\n",
"output": "2 2 2 1 1\n",
"type": "stdin_stdout"... |
code_contests | verifiable_code | 1367_E. Necklace Assembly | Solve the following coding problem using the programming language python:
The store sells n beads. The color of each bead is described by a lowercase letter of the English alphabet ("a"–"z"). You want to buy some beads to assemble a necklace from them.
A necklace is a set of beads connected in a circle.
For example,... | ```python
from collections import Counter
from math import ceil, sqrt
class DisjSet:
def __init__(self, n):
# Constructor to create and
# initialize sets of n items
self.rank = [1] * n
self.parent = [i for i in range(n)]
self.extra = []
# Finds set of given item x
... | vfc_61769 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n6 3\nabcbac\n3 6\naaa\n7 1000\nabczgyo\n5 4\nababa\n20 10\naaebdbabdbbddaadaadc\n20 5\necbedececacbcbccbdec\n",
"output": "6\n3\n5\n4\n15\n10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | 1409_C. Yet Another Array Restoration | Solve the following coding problem using the programming language python:
We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array:
* The array consists of n distinct positive (greater than 0) integers.
* The array contains two elements x and y (... | ```python
T = int(input())
for t in range(T):
n, x, y = [int(i) for i in input().split()]
found_flag = False
for d in range(1,51):
if (y-x) % d == 0:
for a in range(1, x+1):
if (x-a) % d == 0 and (y-a) % d == 0 and a + (n-1)* d >= y:
ans = [a+i*d for i... | vfc_61777 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2 1 49\n5 20 50\n6 20 50\n5 3 8\n9 13 22\n",
"output": "1 49\n10 20 30 40 50\n20 26 32 38 44 50\n3 8 13 18 23\n1 4 7 10 13 16 19 22 25\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\... |
code_contests | verifiable_code | 1430_A. Number of Apartments | Solve the following coding problem using the programming language python:
Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each room ... | ```python
for _ in range(int(input())):
n = int(input())
if n%3==0:print(n//3,0,0)
elif n%5==0:print(0,n//5,0)
elif n%7==0:print(0,0,n//7)
elif n%3==1 and n>7:print((n-7)//3,0,1)
elif n%3==2 and n>7:print((n-5)//3,1,0)
else:print(-1)
``` | vfc_61781 | {
"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\n30\n67\n4\n14\n",
"output": "10 0 0\n20 0 1\n-1\n3 1 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"... |
code_contests | verifiable_code | 1477_A. Nezzar and Board | Solve the following coding problem using the programming language python:
n distinct integers x_1,x_2,…,x_n are written on the board. Nezzar can perform the following operation multiple times.
* Select two integers x,y (not necessarily distinct) on the board, and write down 2x-y. Note that you don't remove selected... | ```python
import os
import sys
from io import BytesIO, IOBase
from math import gcd
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "... | vfc_61789 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n2 1\n1 2\n3 0\n2 3 7\n2 -1\n31415926 27182818\n2 1000000000000000000\n1 1000000000000000000\n2 -1000000000000000000\n-1000000000000000000 123\n6 80\n-5 -20 13 -14 -2 -11\n",
"output": "\nYES\nYES\nNO\nYES\nYES\nNO\n",
... |
code_contests | verifiable_code | 1503_E. 2-Coloring | Solve the following coding problem using the programming language python:
There is a grid with n rows and m columns. Every cell of the grid should be colored either blue or yellow.
A coloring of the grid is called stupid if every row has exactly one segment of blue cells and every column has exactly one segment of ye... | ```python
M=998244353;N=4042
try:
import __pypy__
int_add=__pypy__.intop.int_add
int_sub=__pypy__.intop.int_sub
int_mul=__pypy__.intop.int_mul
def make_mod_mul(mod=M):
fmod_inv=1.0/mod
def mod_mul(a,b,c=0):
res=int_sub(
int_add(int_mul(a,b),c),
... | vfc_61793 | {
"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 2\n",
"output": "\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n",
"output": "\n294\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.