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 | students-score-3 | Solve the following coding problem using the programming language python:
Subodh's CS department has been continuously organizing mock placement drives for students. If a student under-performs negative point is rewarded otherwise positive points is rewarded. The HOD wants to find consistency of a student. So, he want... | ```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!'
def mssl(l):
best = cur = 0
for i in l:
cur = max(cur + i, 0)
best = max(best, cur)
return best
n = int(raw_input())
a... | vfc_77809 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n-1 -4 4 -2 0 1 4 -5\n\nSAMPLE",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8943\n-91 -11 -31 50 12 26 27 -51 -37 83 49 37 -52 -55 12 19 -14 17 -42 -48 82 92 98 96 -86... |
code_contests | verifiable_code | vaishnav-and-pizzas | Solve the following coding problem using the programming language python:
As we have seen that Vaishnav was a smart kid and today he has grown up(but he is still childish)
and he is in High school.
Today he was back from school and found that 4 pieces of Pizza was
ordered- one for his father, one for this mother, and... | ```python
# http://www.hackerearth.com/tcetcyphers-2/algorithm/vaishnav-and-pizzas/
LIMIT = 10010
phi = [i for i in xrange(LIMIT)]
for i in xrange(2, LIMIT):
if phi[i] == i:
j = i
while j < LIMIT:
phi[j] = phi[j] / i * (i - 1)
j += i
phi[1] = 0
for i in xrange(2, LIMIT):
... | vfc_77813 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n5\n6\n\nSAMPLE",
"output": "5\n9\n11",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00024 Physical Experiments | Solve the following coding problem using the programming language python:
Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented by the following formulas:
$ v = 9.8 t $
$ y = 4.9 t^2 $
A person is trying to drop down a glass ball and c... | ```python
import math
while 1:
try:
print(math.ceil(float(input())**2/98)+1)
except:break
``` | vfc_77857 | {
"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": "25.4\n25.4",
"output": "8\n8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "26.000450676027395\n25.4",
"output": "8\n8\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p00155 Spider Jin | Solve the following coding problem using the programming language python:
The hero of justice, the Spider, can pull a rope out of his arm and jump from building to building. However, due to the short rope, you can only move to buildings that are less than 50 distances from you. To move to a building farther away, you ... | ```python
import heapq
def dijkstra(G, s, g, n):
cost = [10**9] * n
cost[s] = 0
pre = [-1] * n
q = []
heapq.heappush(q, (0, s))
while q:
d, to = heapq.heappop(q)
if to == g:
break
if cost[to] < d:
continue
for n, dist in G[to]:
... | vfc_77861 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 0 0\n2 30 0\n3 60 40\n4 0 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 144 131\n13 130 64\n14 80 140\n15 38 117\n16 190 90\n17 60 100\n18 1... |
code_contests | verifiable_code | p00476 Dungeon | Solve the following coding problem using the programming language python:
problem
You want to get a treasure on the Nth basement floor of a dungeon. First, you are on the 1st basement floor and your health is H (H is a positive integer). Go downstairs. Sometimes physical strength is consumed. The physical strength co... | vfc_77869 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 10\n4 2\n2 5\n6 1\n7 3\n6 4\n9 6\n0 8\n4 1\n9 4",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\n4 3\n2 5\n6 1\n7 3\n6 4\n9 6\n0 8\n4 1\n9 4",
"output": "10\n"... | |
code_contests | verifiable_code | p00668 The Incubator | Solve the following coding problem using the programming language python:
The morning of office workers is early. When I went through the elite course, joined a first-class company, and graduated from the title of newcomer, the resignation I received was a business activity on an undeveloped planet. I have been forced... | vfc_77873 | {
"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": "22 5\n0 0\n0 1\n0 2\n0 3\n0 4\n2 1\n2 2\n2 3\n2 4\n2 5\n0 5\n2 1\n0 6\n2 2\n3 3\n2 2\n2 2\n1 2\n2 2\n2 1\n2 2\n2 3\n30 5\n0 383594529\n1 1\n0 868094164\n0 708344471\n0 4102559\n0 944076771\n0 320398558\n1 1\n0 949521499\n0 10354995... | |
code_contests | verifiable_code | p00811 Calling Extraterrestrial Intelligence Again | Solve the following coding problem using the programming language python:
A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November l6, l974. The message consisted of l679 bits and was meant to be translated to a rectangular... | ```python
answer = []
def prime(n):
prime_flag = [0 for i in range(n + 1)]
prime_list = []
for i in range(2, n + 1):
if prime_flag[i] == 0:
prime_list.append(i)
temp = 1
while temp * i <= n:
prime_flag[temp * i] = 1
temp += 1
... | vfc_77877 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 1 2\n99999 999 999\n1680 5 16\n1970 1 1\n2002 4 11\n0 0 0",
"output": "2 2\n313 313\n23 73\n43 43\n37 53",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1 2\n99999 999 999\n1680 5 16\n19... |
code_contests | verifiable_code | p00942 Rotating Cutter Bits | Solve the following coding problem using the programming language python:
Example
Input
4 6 5
-2 5
-2 -1
2 -1
2 5
-2 1
-2 0
0 0
0 -2
2 -2
2 1
Output
8
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | vfc_77881 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 6 5\n-2 5\n-2 -1\n2 -1\n2 5\n-2 1\n-2 0\n0 0\n0 -2\n2 -2\n2 1",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 9 5\n-2 5\n-2 -1\n2 -1\n2 5\n-2 1\n-2 0\n0 0\n0 -2\n2 -2\n2 1... | |
code_contests | verifiable_code | p01209 ! | Solve the following coding problem using the programming language python:
You are one of ICPC participants and in charge of developing a library for multiprecision numbers and radix conversion. You have just finished writing the code, so next you have to test if it works correctly. You decided to write a simple, well-... | ```python
import string
INF = 1 << 30
def conv(base, num):
ret = 0
for n in str(num):
if n in string.ascii_letters:
n = ord(n) - ord("A") + 10
else:
n = int(n)
ret = ret * base + n
return ret
def get_fact(n):
ret = []
for i in xrange(2, n + 1):
... | vfc_77889 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 500\n16 A\n0 0",
"output": "124\n2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 500\n11 A\n0 0",
"output": "124\n0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p01345 DON'T PANIC! | Solve the following coding problem using the programming language python:
Arthur is an innocent man who used to live on the Earth. He had lived a really commonplace life, until the day when the Earth was destroyed by aliens, who were not evil invaders but just contractors ordered to build a hyperspace bypass. In the m... | vfc_77893 | {
"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\n89 0\n0 0\n0 -90\n0 180\n0 90",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0\n10 10\n10 -10\n-10 -10\n-10 10",
"output": "Yes",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | p01515 Equation | Solve the following coding problem using the programming language python:
Equation
Identity
English text is not available in this practice contest.
In logical operations, only two types of values, T and F, are handled.
Let "-" be a unary operator (a symbol whose input represents one operation) and "*", "+", "->" b... | vfc_77897 | {
"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 | p01683 Floating Islands | Solve the following coding problem using the programming language python:
Problem Statement
You have just arrived in a small country. Unfortunately a huge hurricane swept across the country a few days ago.
The country is made up of $n$ islands, numbered $1$ through $n$. Many bridges connected the islands, but all th... | vfc_77901 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1\n8 2\n9 1\n14 2\n4\n181 4\n815 4\n634 4\n370 4\n4\n52 1\n40 1\n81 2\n73 1\n10\n330 1\n665 3\n260 1\n287 2\n196 3\n243 1\n815 1\n287 3\n330 1\n473 4\n0",
"output": "18\n634\n-1\n916",
"type": "stdin_stdout"
},... | |
code_contests | verifiable_code | p01827 Black Company | Solve the following coding problem using the programming language python:
Example
Input
3
1 3 3
2
1 2
1 3
Output
5
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code. | ```python
from collections import deque
import sys
def main():
readline = sys.stdin.readline
write = sys.stdout.write
def root(x):
if x == p[x]:
return x
p[x] = y = root(p[x])
return y
def unite(x, y):
px = root(x)
py = root(y)
if px < py:
... | vfc_77905 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3 3\n2\n1 2\n1 3",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 3 1\n2\n1 2\n1 3",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name":... |
code_contests | verifiable_code | p01962 Coin Slider | Solve the following coding problem using the programming language python:
You are playing a coin puzzle. The rule of this puzzle is as follows:
There are $N$ coins on a table. The $i$-th coin is a circle with $r_i$ radius, and its center is initially placed at ($sx_i, sy_i$). Each coin also has a target position: you... | vfc_77909 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 0 0 5 0\n1 0 5 0 0\n1 5 5 0 5\n1 5 0 0 0",
"output": "0",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p02249 Pattern Search | Solve the following coding problem using the programming language python:
Find places where a R × C pattern is found within a H × W region. Print top-left coordinates (i, j) of sub-regions where the pattern found. The top-left and bottom-right coordinates of the region is (0, 0) and (H-1, W-1) respectively.
Constrain... | ```python
from typing import List
def calc_hash(tab: List[List[int]], row_num: int, col_num: int) -> None:
global hash_table, R, C, baes1, base2, mask
tmp_table = [[0] * col_num for _ in range(row_num)]
diff_row, diff_col = row_num - R, col_num - C
bit_mask = 1
for _ in range(C):
bit_mask... | vfc_77917 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10",
"output": "0 3\n1 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5\n00010\n00101\n00010\n00100\n2 2\n10\n01\n10",
"output": "0 3... |
code_contests | verifiable_code | p02397 Swapping Two Numbers | Solve the following coding problem using the programming language python:
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y... | ```python
while True:
ans = list(map(int, input().split()))
if ans[0] ==0 and ans[1] ==0:
break
print(*sorted(ans))
``` | vfc_77921 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n2 2\n5 3\n0 0",
"output": "2 3\n2 2\n3 5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n2 2\n5 3\n0 0",
"output": "1 3\n2 2\n3 5\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | bycd1602 | Solve the following coding problem using the programming language python:
Problem Statement
A mountain hiker is descending from the mountain ranges. There are many mountains along his way each with it's own height. He will descend from
mountain only if the mountains' height ahead of him are Non Increasing.
You are... | ```python
import sys
T = int(raw_input())
while T > 0:
N = int(raw_input())
ans = 0
prev = None
#l = map(int, raw_input().split())
l = list(map(int,sys.stdin.readline().split()))
for i in range(N):
curr = l[i]
if i>0 and curr>prev:
ans += curr-prev
cu... | vfc_77925 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n3 2 4 1 2",
"output": "3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | cookmach | Solve the following coding problem using the programming language python:
Chef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks.
Today's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The machine is pretty universal - it can make lots of dish... | ```python
test_cases = int(raw_input())
for i in range(test_cases):
AB = raw_input().split()
A = int(AB[0])
B = int(AB[1])
counter = 0
while (A != B):
if (B%A == 0):
A=A*2
counter += 1
else:
A=A/2
counter += 1
print counter
``` | vfc_77929 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n1 1\n2 4\n3 8\n4 16\n4 1\n1 4",
"output": "0\n1\n4\n2\n2\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 1\n2 4\n3 1\n4 16\n4 1\n1 4",
"output": "0\n1\n1\n2\n2\n2\n",
... |
code_contests | verifiable_code | gerald08 | Solve the following coding problem using the programming language python:
Chef has a rooted tree G, consisting of N vertices. Each edge of the tree has a color black or white.
Once Chef's friend Ksen offered Chef to play a game on the tree G. The game has very simple rule:
The players make moves in the game alternate... | ```python
import random
class Ordinal(object):
def __init__(self, v, r = 0):
while (v&1)==0 and r > 0:
v >>= 1
r -= 1
self.v, self.r = v, r
def __repr__(self):
return '%d / 2^%d' % (self.v, self.r)
def __add__(self, o):
if isinstance(o, int):
... | vfc_77933 | {
"difficulty": "4",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1\n2\n1 2 0\n2\n1 2 1\n3\n1 2 0\n1 3 1\n3\n1 2 0\n2 3 1",
"output": "Ksen Chef\nChef Chef\nKsen Ksen\nKsen Chef\nChef Chef",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | manychef | Solve the following coding problem using the programming language python:
Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - ... | ```python
for t in xrange(int(raw_input())):
line = list(raw_input())
length = len(line)
x = length-1
while x > 2:
tmp = [line[x], line[x-1], line[x-2], line[x-3]]
if (
(tmp[0] == '?' or tmp[0] == 'F') and
(tmp[1] == '?' or tmp[1] == 'E') and
(tmp[2] =... | vfc_77937 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n???C???",
"output": "CHEFCIELISACHEF\nCHEFCIELISOURCHEF\nTAKEITEASY\nCHEFCHEF\nAAACHEF\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
code_contests | verifiable_code | qcj2 | Solve the following coding problem using the programming language python:
There is a war going on between two countries and the enemy of your country depends heavily on the transportation of Weapons between two strategic points A and B. Point A and point B along with other points (C,D, etc... ) are connected by a netw... | ```python
#!/usr/bin/env python
MAXN = 26
parent = [0] * MAXN
rank = [0] * MAXN
def UF_MakeSet():
for x in xrange(MAXN):
parent[x] = x
rank[x] = 0
def UF_Union(x, y):
xRoot = UF_Find(x)
yRoot = UF_Find(y)
if xRoot == yRoot:
return
if rank[xRoot] < rank[yRoot]:
... | vfc_77941 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "AC\nAD\nAE\nCE\nCF\nED\nGF\nBG\nHB\nGH\nEND",
"output": "CF\nGF",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | tlg | Solve the following coding problem using the programming language python:
The game of billiards involves two players knocking 3 balls around
on a green baize table. Well, there is more to it, but for our
purposes this is sufficient.
The game consists of several rounds and in each round both players
obtain a score, ba... | ```python
t = int(raw_input())
scr1=0
scr2=0
ma = 0
flag = 0
for i in xrange(t):
s1,s2 = map(int,raw_input().split(' '))
scr1+=s1
scr2+=s2
if(scr1>scr2):
temp = scr1-scr2
if(temp > ma):
ma = temp
flag = 1
else:
temp = scr2-scr1
if(temp > ma):
ma = temp
flag = 2
print flag,ma
``` | vfc_77945 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n140 82\n89 134\n90 110\n112 106\n88 90",
"output": "1 58\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n140 82\n89 134\n90 110\n177 106\n88 90",
"output": "1 64\n",
"typ... |
code_contests | verifiable_code | 1013_E. Hills | Solve the following coding problem using the programming language python:
Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.
From the window in your room, you see the sequence of n hills, where i-th of them has height ai. The Innopolis administration w... | vfc_77949 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 2 2\n",
"output": "0 1 3 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2 3\n",
"output": "0 2 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | 1038_C. Gambling | Solve the following coding problem using the programming language python:
Two players A and B have a list of n integers each. They both want to maximize the subtraction between their score and their opponent's score.
In one turn, a player can either add to his score any element from his list (assuming his list is no... | ```python
N = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
arr1.sort()
arr2.sort()
max1 = N-1
max2 = N-1
A = 0
B = 0
turn = 0
while(max1>=0 or max2>=0):
if turn == 0:
if arr1[max1]>=arr2[max2]:
if max1>=0:
A+=arr1[max1]
max1-=1
else:
... | vfc_77953 | {
"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\n100 100 100\n100 100 100\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 4\n5 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 1082_E. Increasing Frequency | Solve the following coding problem using the programming language python:
You are given array a of length n. You can choose one segment [l, r] (1 ≤ l ≤ r ≤ n) and integer value k (positive, negative or even zero) and change a_l, a_{l + 1}, ..., a_r by k each (i.e. a_i := a_i + k for each l ≤ i ≤ r).
What is the maxim... | ```python
import sys
input=sys.stdin.readline
n,c=map(int,input().split())
ar=list(map(int,input().split()))
br=[]
count=0
for i in range(n):
if(ar[i]==c):
count+=1
br.append(count)
dic={}
for i in range(n):
if(ar[i]!=c):
if(ar[i] in dic):
dic[ar[i]].append(i)
else:
... | vfc_77961 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n6 2 6\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 9\n9 9 9 9 9 9\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1101_G. (Zero XOR Subset)-less | Solve the following coding problem using the programming language python:
You are given an array a_1, a_2, ..., a_n of integer numbers.
Your task is to divide the array into the maximum number of segments in such a way that:
* each element is contained in exactly one segment;
* each segment contains at least on... | ```python
import sys
from math import *
from fractions import gcd
readints=lambda:map(int, input().strip('\n').split())
n=int(input())
arr = list(readints())
arr.sort()
pref=0
basis=[]
for v in arr:
pref = pref^v
for b in basis:
v = min(v, v^b)
if v>0:
basis.append(v)
if pref==0:
pr... | vfc_77965 | {
"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": "3\n1 2 3\n",
"output": "-1",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 112_E. Petya and Spiders | Solve the following coding problem using the programming language python:
Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. Ther... | vfc_77969 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 3\n",... | |
code_contests | verifiable_code | 1150_A. Stock Arbitraging | Solve the following coding problem using the programming language python:
Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!
In the morning, there are n opportunities to buy shares. The... | ```python
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
m=a[2]//(min(b))
p=m*max(c)+a[2]%min(b)
if(p>=a[2]):
print(p)
else:
print(a[2])
``` | vfc_77973 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4 11\n4 2 5\n4 4 5 4\n",
"output": "26\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2 50\n5 7\n4 2\n",
"output": "50\n",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | 1172_B. Nauuo and Circle | Solve the following coding problem using the programming language python:
Nauuo is a girl who loves drawing circles.
One day she has drawn a circle and wanted to draw a tree on it.
The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n.
Nauuo wants to draw a... | ```python
from math import *
from collections import *
import sys
sys.setrecursionlimit(10**9)
mod = 998244353
n = int(input())
a = [0 for i in range(n+1)]
ans = n
for i in range(n-1):
u,v = map(int,input().split())
a[u] += 1
a[v] += 1
ans *= a[u]
ans %= mod
ans *= a[v]
ans %= mod
print(ans%mod)
``` | vfc_77977 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 2\n1 3\n1 4\n",
"output": "24",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 118_C. Fancy Number | Solve the following coding problem using the programming language python:
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has ... | ```python
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt'... | vfc_77981 | {
"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 2\n533\n",
"output": "0\n533\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 6\n0001112223\n",
"output": "3\n0000002223\n",
"type": "stdin_stdout"
},
{
"fn_n... |
code_contests | verifiable_code | 1209_B. Koala and Lights | Solve the following coding problem using the programming language python:
It is a holiday season, and Koala is decorating his house with cool lights! He owns n lights, all of which flash periodically.
After taking a quick glance at them, Koala realizes that each of his lights can be described with two parameters a_i ... | ```python
import sys
input = sys.stdin.readline
n=int(input())
s=input().strip()
AB=[tuple(map(int,input().split())) for i in range(n)]
ANS=[[0]*n for i in range(3000)]
for i in range(n):
k=int(s[i])
a,b=AB[i]
t=0
while t<3000:
if t>=b and (t-b)%a==0:
k=1-k
... | vfc_77985 | {
"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\n1111\n3 4\n5 2\n3 1\n3 2\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1228_A. Distinct Digits | Solve the following coding problem using the programming language python:
You have two integers l and r. Find an integer x which satisfies the conditions below:
* l ≤ x ≤ r.
* All digits of x are different.
If there are multiple answers, print any of them.
Input
The first line contains two integers l and r... | ```python
l, r =map(int, input().split())
for i in range(l,r+1):
n = 0
a = str(i)
for j in a:
if a.count(j) == 1:
n = n+1
else:
pass
if n == len(a):
break
if n == len(a):
print(a)
else:
print('-1')
``` | vfc_77989 | {
"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": "98766 100000\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "121 130\n",
"output": "123\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 1270_A. Card Game | Solve the following coding problem using the programming language python:
Two players decided to play one interesting card game.
There is a deck of n cards, with values from 1 to n. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the... | ```python
T = int(input())
for _ in range(T) :
in_li = list(map(int,input().split()))
n = in_li[0]
k1 = in_li[1]
k2 = in_li[2]
one = list(map(int,input().split()))
two = list(map(int,input().split()))
max1 = max(one)
max2 = max(two)
count1 = 0
count2 = 0
for num in one :
... | vfc_77997 | {
"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 1 1\n2\n1\n5 2 3\n2 3\n1 4 5\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 1 1\n2\n1\n5 2 3\n2 3\n1 7 5\n",
"output": "YES\nNO\n",
"type": "s... |
code_contests | verifiable_code | 1292_E. Rin and The Unknown Flower | Solve the following coding problem using the programming language python:
[MisoilePunch♪ - 彩](https://www.youtube.com/watch?v=5VleIdkEeak)
This is an interactive problem!
On a normal day at the hidden office in A.R.C. Markland-N, Rin received an artifact, given to her by the exploration captain Sagar.
After much an... | vfc_78001 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n\n2 1 2\n\n1 2\n\n0\n\n1",
"output": "\n\n\n? C\n\n? CH\n\n? CCHO\n\n! CCHH\n\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5\n\n0\n\n2 2 3\n\n1\n8\n\n1 5\n\n1 5\n\n1 3\n\n2 1 2... | |
code_contests | verifiable_code | 1312_F. Attack on Red Kingdom | Solve the following coding problem using the programming language python:
The Red Kingdom is attacked by the White King and the Black King!
The Kingdom is guarded by n castles, the i-th castle is defended by a_i soldiers. To conquer the Red Kingdom, the Kings have to eliminate all the defenders.
Each day the White ... | ```python
T = int(input())
def findPeriod(DP):
for offset in range(0, len(DP)):
for period in range(1, 500):
is_period = True
for j in range(offset, len(DP) - period):
if (DP[j][0] == DP[j + period][0] and DP[j][1] == DP[j + period][1] and DP[j][2] == DP[j + period]... | vfc_78005 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n6 5 4 5\n2 3 2 3 1 3\n1 5 2 3\n10\n4 4 2 3\n8 10 8 5\n2 2 1 4\n8 5\n3 5 3 5\n9 2 10\n4 5 5 5\n2 10 4 2\n2 3 1 4\n1 10\n3 1 5 3\n9 8 7\n2 5 4 5\n8 8\n3 5 1 4\n5 5 10\n",
"output": "0\n2\n1\n2\n5\n12\n5\n0\n0\n2\n",
"... |
code_contests | verifiable_code | 1355_E. Restorer Distance | Solve the following coding problem using the programming language python:
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.
Yo... | ```python
#!/usr/bin/env python3
import io
import os
from bisect import bisect
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def get_str():
return input().decode().strip()
def rint():
return map(int, input().split())
def oint():
return int(input())
def find_lu_value(th):
hi = bisect(h, t... | vfc_78013 | {
"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": "3 1 100 100\n1 3 8\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1 2 4\n5 5 3 6 5\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1398_G. Running Competition | Solve the following coding problem using the programming language python:
A running competition is going to be held soon. The stadium where the competition will be held can be represented by several segments on the coordinate plane:
* two horizontal segments: one connecting the points (0, 0) and (x, 0), the other c... | vfc_78021 | {
"difficulty": "13",
"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 10 5\n0 3 5 10\n6\n24 30 14 16 18 10\n",
"output": "24 30 14 16 -1 -1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 10 3\n0 3 5 10\n6\n24 30 14 16 18 10\n",
"output": "12 10 -... | |
code_contests | verifiable_code | 1422_C. Bargain | Solve the following coding problem using the programming language python:
Sometimes it is not easy to come to an agreement in a bargain. Right now Sasha and Vova can't come to an agreement: Sasha names a price as high as possible, then Vova wants to remove as many digits from the price as possible. In more details, Sa... | ```python
s = [int(c) for c in input()][::-1]
n = len(s)
mod = 1000000007
def inv(x):
return pow(x, mod - 2, mod)
teninv = inv(10)
P = [0]
p = 1
for x in s:
P.append((P[-1] + x*p) % mod)
p = p*10 % mod
Q = [0]
for i in range(n+1):
Q.append((Q[-1] + P[i]*pow(teninv, i, mod))%mod)
s = 0
for l in rang... | vfc_78025 | {
"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": "107\n",
"output": "42\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100500100500\n",
"output": "428101984\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1467_C. Three Bags | Solve the following coding problem using the programming language python:
You are given three bags. Each bag contains a non-empty multiset of numbers. You can perform a number of operations on these bags. In one operation, you can choose any two non-empty bags, and choose one number from each of the bags. Let's say th... | ```python
n1,n2,n3=map(int,input().split())
val=[]
def func(a,b,c,d,e,f):
dd=d-a[0]
v1=b[0]-dd
ff=f-c[-1]
v2=a[0]-ff-(e-b[0])
if v1<0:
return (c[-1]-v1)-v2
else:
v2-=v1
return (c[-1]-v2)
one=(list(map(int,input().split())))
two=(list(map(int,input().split())))
three=(l... | vfc_78033 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 2\n7 5 4\n2 9\n7 1\n",
"output": "\n29",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 4 1\n1 2\n6 3 4 5\n5\n",
"output": "\n20",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1514_C. Product 1 Modulo N | Solve the following coding problem using the programming language python:
Now you get Baby Ehab's first words: "Given an integer n, find the longest subsequence of [1,2, …, n-1] whose product is 1 modulo n." Please solve the problem.
A sequence b is a subsequence of an array a if b can be obtained from a by deleting ... | ```python
import math
n=int(input())
ans=[]
prod=1
count=0
for i in range(1,n-1):
if math.gcd(n,i)==1:
ans.append(str(i))
prod=(prod*i)%n
count+=1
if n==2:
print(1)
print(1)
else:
if prod % n == 1:
print(count)
print(" ".join(ans))
else:
print(count+1)
print(" ".join(ans),n-1)
``` | vfc_78041 | {
"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\n",
"output": "\n3\n1 2 3 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "\n4\n1 3 5 7 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 169_B. Replacing Digits | Solve the following coding problem using the programming language python:
You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1 ≤ j ≤ m) of sequence s means that you can choose an arbitrary position i (1 ≤ i ≤ n) in a and replace the dig... | ```python
n = str(input())
s = str(input())
ref = 10 * [0]
for j in range(len(s)):
index = ord(s[j]) - 48
ref[index] += 1
for j in range(len(n)):
output = n[j]
num = ord(n[j]) - 48
for k in range(9, num, -1):
if ref[k] > 0:
output = str(k)
ref[k] -= 1
brea... | vfc_78049 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "987\n1234567\n",
"output": "987\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1024\n010\n",
"output": "1124\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 236_E. Cyclical Quest | Solve the following coding problem using the programming language python:
Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in a string s" quickly by preprocessing the string s. But now he wants to make it harder.
So he wants to ask "how many consecutive substrings of s are ... | vfc_78061 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "baabaabaaa\n5\na\nba\nbaa\naabaa\naaba\n",
"output": "7\n5\n7\n3\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabbaa\n3\naa\naabb\nabba\n",
"output": "2\n3\n3\n",
"type":... | |
code_contests | verifiable_code | 261_C. Maxim and Matrix | Solve the following coding problem using the programming language python:
Maxim loves to fill in a matrix in a special manner. Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1):
<image>
Maxim asks you to count, how many numbers m (1 ≤ m ≤ n) are there, such that the sum of values in the cells in ... | ```python
n, t = map(int, input().split())
s = bin(n + 2)[2:]
l = len(s)
if t & (t - 1):
ans = 0
else:
t = t.bit_length()
f = [[0] * (l + 1) for i in range(l + 1)]
for i in range(l + 1):
f[i][0] = f[i][i] = 1
for j in range(1, i):
f[i][j] = f[i - 1][j - 1] + f[i - 1][j]
... | vfc_78065 | {
"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 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000... |
code_contests | verifiable_code | 285_C. Building Permutation | Solve the following coding problem using the programming language python:
Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutati... | ```python
n = int(input())
nums = sorted(list(map(int, input().split())))
score = 0
for i in range(n):
score+=abs(nums[i]-i-1)
print(score)
``` | vfc_78069 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n-1 -1 2\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 0\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | 30_C. Shooting Gallery | Solve the following coding problem using the programming language python:
One warm and sunny day king Copa decided to visit the shooting gallery, located at the Central Park, and try to win the main prize — big pink plush panda. The king is not good at shooting, so he invited you to help him.
The shooting gallery is ... | ```python
##########################################################
from collections import Counter
def nCk(n, k):
res = 1
for i in range(1, k + 1):
res = res * (n - i + 1) // i
return res
import math
inf=10**20
n=int(input())
c=[]
dp=[0]*(n+1)
for i in range(n):
x,y, t,p = map(float, input().s... | vfc_78073 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n0 0 0 0.5\n",
"output": "0.5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n0 0 0 0.6\n5 0 5 0.7\n",
"output": "1.3",
"type": "stdin_stdout"
},
{
"fn_name": ... |
code_contests | verifiable_code | 333_A. Secrets | Solve the following coding problem using the programming language python:
Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of thr... | ```python
import math
n = int(input())
a=1
while n%a==0:
a*=3
print(n//a +1)
``` | vfc_78077 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n",
"output": " 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": " ... |
code_contests | verifiable_code | 356_A. Knight Tournament | Solve the following coding problem using the programming language python:
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're just a simple peasant. There'... | ```python
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.writ... | vfc_78081 | {
"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": "4 3\n1 2 1\n1 3 3\n1 4 4\n",
"output": "3 1 4 0 \n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 379_G. New Year Cactus | Solve the following coding problem using the programming language python:
Jack and Jill are tired of the New Year tree, now they've got a New Year cactus at home! A cactus is a connected undirected graph where any two simple cycles have at most one common vertex. In other words, this graph doesn't have any edges that ... | vfc_78085 | {
"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": "1 0\n",
"output": "1 0 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16 20\n1 2\n3 4\n5 6\n6 7\n7 8\n9 10\n10 11\n11 12\n13 14\n15 16\n1 5\n9 13\n14 10\n10 6\n6 2\n15 11\n11 7\n7 3\n16 12... | |
code_contests | verifiable_code | 3_C. Tic-tac-toe | Solve the following coding problem using the programming language python:
Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing th... | ```python
first_row = input()
second_row = input()
third_row = input()
c = 0
o = 0
for i in range(0,3):
if first_row[i] == 'X':
c = c + 1
elif first_row[i] == '0':
o = o + 1
for i in range(0,3):
if second_row[i] == 'X':
c = c + 1
elif second_row[i] == '0':
o = o + 1
for i... | vfc_78089 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "X0X\n.0.\n.X.\n",
"output": "second\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0X0\nX0X\n0X.\n",
"output": "the second player won\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 426_E. Sereja and Two Sequences | Solve the following coding problem using the programming language python:
Sereja has two sequences a1, a2, ..., an and b1, b2, ..., bm, consisting of integers. One day Sereja got bored and he decided two play with them. The rules of the game was very simple. Sereja makes several moves, in one move he can perform one o... | vfc_78093 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 100000 1000\n1 2 3 4 5\n3 2 4 5 1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4 3006 1000\n1 2 3\n1 2 4 3\n",
"output": "2\n",
"type": "stdin_stdout"... | |
code_contests | verifiable_code | 44_H. Phone Number | Solve the following coding problem using the programming language python:
Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy.
The phone number is divined like that. First... | ```python
# import sys
# input=sys.stdin.readline
a=input()
dp=[]
for i in range(len(a)):
dp.append([0]*10)
for i in range(10):
dp[0][i]=1
for i in range(len(a)-1):
for j in range(10):
if dp[i][j]!=0:
c=(int(a[i+1])+j)//2
d=(int(a[i+1])+j+1)//2
if c!=d:
... | vfc_78097 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "09\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12345\n",
"output": "48\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 51_C. Three Base Stations | Solve the following coding problem using the programming language python:
The New Vasjuki village is stretched along the motorway and that's why every house on it is characterized by its shift relative to some fixed point — the xi coordinate. The village consists of n houses, the i-th house is located in the point wit... | ```python
n = int(input())
houses = sorted(set(map(int, input().split())))
if len(houses) <= 3:
print(0)
result = houses[:]
while len(result) < 3:
result.append(result[-1])
print('%.6f %.6f %.6f' % tuple(result))
import sys; sys.exit()
span = 0
left = 1
right = len(houses) - 2
#print(house... | vfc_78109 | {
"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\n10003 10004 10001 10002 1\n",
"output": "0.500000\n1.500000 10001.500000 10003.500000 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 3 4\n",
"output": "0.500000\n1.500000 3... |
code_contests | verifiable_code | 546_D. Soldier and Number Game | Solve the following coding problem using the programming language python:
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive inte... | vfc_78113 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 1\n6 3\n",
"output": "2\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1\n5000000 1\n5000000 5000000\n",
"output": "0\n18703742\n0\n",
"type": "stdin_stdout"
... | |
code_contests | verifiable_code | 573_A. Bear and Poker | Solve the following coding problem using the programming language python:
Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars.
Each play... | ```python
import sys
import math
import collections
import bisect
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(1):
n=int(input())
arr=get_list... | vfc_78117 | {
"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\n100 150 250\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n75 150 75 50\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | 616_B. Dinner with Emma | Solve the following coding problem using the programming language python:
Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.
Munhattan consists of n streets and m avenues. There is exactly ... | ```python
print(max([min(elm) for elm in [map(int, input().split()) for _ in range(int(input().split()[0]))]]))
``` | vfc_78125 | {
"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 3\n1 2 3\n2 3 1\n3 1 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n4 1 3 5\n2 2 2 2\n5 4 5 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 635_C. XOR Equation | Solve the following coding problem using the programming language python:
Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?
Input
The first line of the input contains two integers s and x (2 ≤ s ≤ 1012, 0 ≤ x ≤ 1012), the sum and bit... | ```python
def solve(s, x):
d = (s - x)
if x << 1 & d or d%2 or d<0: return 0
return 2 ** (bin(x).count('1')) - (0 if d else 2)
s, x = map(int, input().split())
print(solve(s, x))
``` | vfc_78129 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 5\n",... |
code_contests | verifiable_code | 664_B. Rebus | Solve the following coding problem using the programming language python:
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n,... | ```python
s = input().split("=")
v = int(s[1])
qs = s[0].split()
pos =0
neg =0
if len(qs) > 0:
pos += 1
signs = []
for i in qs:
if i == '+':
pos+=1
signs.append(1)
else:
if i == '-':
neg +=1
signs.append(0)
if pos == 0 and neg == 0 and v == 0:
print("Possi... | vfc_78133 | {
"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": "? + ? - ? + ? + ? = 42\n",
"output": "Possible\n40 + 1 - 1 + 1 + 1 = 42\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "? = 1000000\n",
"output": "Possible\n1000000 = 1000000\n",
... |
code_contests | verifiable_code | 688_E. The Values You Can Make | Solve the following coding problem using the programming language python:
Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.
Looking at her coins, a que... | ```python
from sys import stdin,stdout
n,m=map(int,input().split())
s=[0]+list(map(int,stdin.readline().strip().split()))
dp=[[[False for i in range(m+1)] for j in range(m+1)] for k in range(2)]
dp[0][0][0]=True
cur=0
for i in range(1,n+1):
cur+=1
cur%=2
last=(cur+1)%2
for j in range(m+1):
for k... | vfc_78137 | {
"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 18\n5 6 1 10 12 2\n",
"output": "16\n0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 ",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 710_D. Two Arithmetic Progressions | Solve the following coding problem using the programming language python:
You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R and x = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0.
Input
The only line contains six integers a1, b1, a2, b2, L, R (0 ... | ```python
import sys
import bisect
from bisect import bisect_left as lb
input_=lambda: sys.stdin.readline().strip("\r\n")
from math import log
from math import gcd
from math import atan2,acos
from random import randint
sa=lambda :input_()
sb=lambda:int(input_())
sc=lambda:input_().split()
sd=lambda:list(map(int,input_(... | vfc_78141 | {
"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 0 3 3 5 21\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 4 3 0 6 17\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 776_G. Sherlock and the Encrypted Data | Solve the following coding problem using the programming language python:
Sherlock found a piece of encrypted data which he thinks will be useful to catch Moriarty. The encrypted data consists of two integer l and r. He noticed that these integers were in hexadecimal form.
He takes each of the integers from l to r, a... | vfc_78153 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1e\n1 f\n",
"output": " 1\n 0\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... | |
code_contests | verifiable_code | 821_E. Okabe and El Psy Kongroo | Solve the following coding problem using the programming language python:
Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different walks he can take in his city safely. Okabe's city can be represented as all points (x, y) such that x and y a... | ```python
def mul(a, b):
n = len(a)
c = [[0] * n for i in xrange(n)]
for k in xrange(n):
for i in xrange(n):
for j in xrange(n):
c[i][j] += a[i][k] * b[k][j]
c[i][j] %= 1000000007
return c
def mulv(a, v):
l = len(v)
n = len(a)
r = [0] * l
... | vfc_78161 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 6\n0 3 0\n3 10 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3\n0 3 3\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 847_E. Packmen | Solve the following coding problem using the programming language python:
A game field is a strip of 1 × n square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty.
Packman can move to neighboring cell in 1 time unit. If there is an asterisk in the target cell then Packman eats ... | ```python
import bisect
n = int(input())
s = input()
packmans = []
stars = []
for i in range(n):
if s[i] == '*':
stars.append(i)
elif s[i] == 'P':
packmans.append(i)
if len(stars) == 0:
print(0)
exit()
def check(t):
first_to_eat = 0
for i in range(len(packmans)):
x = ... | vfc_78165 | {
"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": "10\n.**PP.*P.*\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n*..P*P*\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 868_G. El Toll Caves | Solve the following coding problem using the programming language python:
The prehistoric caves of El Toll are located in Moià (Barcelona). You have heard that there is a treasure hidden in one of n possible spots in the caves. You assume that each of the spots has probability 1 / n to contain a treasure.
You cannot ... | vfc_78169 | {
"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": "3\n1 1\n2 1\n3 2\n",
"output": "2\n500000007\n777777786\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n433494437 267914296\n",
"output": "281638715\n",
"type": "stdin_stdou... | |
code_contests | verifiable_code | 894_D. Ralph And His Tour in Binary Country | Solve the following coding problem using the programming language python:
Ralph is in the Binary Country. The Binary Country consists of n cities and (n - 1) bidirectional roads connecting the cities. The roads are numbered from 1 to (n - 1), the i-th road connects the city labeled <image> (here ⌊ x⌋ denotes the x rou... | vfc_78173 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 4\n2\n1\n1\n3\n2\n2 4\n1 3\n3 2\n1 7\n",
"output": "11\n6\n3\n28\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n5\n1 8\n2 4\n",
"output": "11\n4\n",
"type": "stdin_stdo... | |
code_contests | verifiable_code | 915_G. Coprime Arrays | Solve the following coding problem using the programming language python:
Let's call an array a of size n coprime iff gcd(a1, a2, ..., an) = 1, where gcd is the greatest common divisor of the arguments.
You are given two numbers n and k. For each i (1 ≤ i ≤ k) you have to determine the number of coprime arrays a of s... | vfc_78177 | {
"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": "2000000 8\n",
"output": "339310063\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n",
"output": "82\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... | |
code_contests | verifiable_code | 939_A. Love Triangle | Solve the following coding problem using the programming language python:
As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes the plane with number fi, where 1 ≤ fi ≤ n an... | ```python
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
if a[a[a[i]-1]-1]==i+1:
print('YES')
exit(0)
print('NO')
``` | vfc_78181 | {
"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\n2 4 5 1 3\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n5 5 5 5 1\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 991_D. Bishwock | Solve the following coding problem using the programming language python:
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bi... | ```python
def main():
a, b = [i for i in input()], [i for i in input()]
l = len(a)
c = 0
for i in range(l - 1):
if a[i] == '0':
if b[i] == '0':
if a[i + 1] == '0':
c += 1
a[i], b[i], a[i + 1] = 1, 1, 1
elif b[i +... | vfc_78189 | {
"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": "0XXX0\n00000\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0X0X0\n0X0X0\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | arjit-and-apex | Solve the following coding problem using the programming language python:
Arjit, Protector of The Realm, has an important task at hand. M new subjects are soon going to become a part of The Realm. The Realm, though, already has N subjects who are well skilled in the ways of The Realm. He wants the new subjects too to ... | ```python
T = int(raw_input())
for _ in xrange(T):
M, N = map(int,raw_input().split())
A = [0]*M
B = [0]*N
for i in xrange(M):
u,v = map(int,raw_input().split())
A[i] = (u,v)
for i in xrange(N):
w,x = map(int,raw_input().split())
B[i] = (w,x)
g,h = map(int,raw_input().split())
aa = a1 = dict()
bb = b1 =... | vfc_78193 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 2\n1 1\n2 3\n1 1\n2 3\n2 2\n\nSAMPLE",
"output": "Great\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n87 45\n20 17\n17 50\n22 21\n22 80\n94 67\n69 78\n90 22\n92 85\n76 82\n47 17... |
code_contests | verifiable_code | change-in-money-1 | Solve the following coding problem using the programming language python:
How many different ways can you make change for an amount, given a list of coins? In this problem, your code will need to efficiently compute the answer.
Task
Write a program that, given
An amount N and types of infinite available coins M.
A... | ```python
sl = raw_input().split()
N,M = (int(sl[0]),int(sl[1]))
lis = map(int,raw_input().split())
arr = [[0]*M for _ in xrange(N+1)]
for i in xrange(M):
arr[0][i] = 1
for i in range(1,N+1):
for j in xrange(M):
x = arr[i-lis[j]][j] if i-lis[j] >=0 else 0
y = arr[i][j-1] if j>0 else 0
arr[i][j] = x+y
print arr[... | vfc_78197 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3\n1 2 3\n\nSAMPLE",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "240 23\n23 20 35 42 19 3 34 9 28 38 13 41 26 14 27 39 24 37 46 29 43 1 21",
"output": "127101770\n... |
code_contests | verifiable_code | divisors-3 | Solve the following coding problem using the programming language python:
Nimbus, the techical festival of NIT Hanirpur is coming and thus Arun, the core-cordinator of departmental team of CSE, decided a conduct a game. In this game, the participant will be given a natural number N and will be asked T questions of for... | ```python
import math
N, noOfQueries = raw_input().split(" ")
N, noOfQueries = int(N), int(noOfQueries)
upperLimit = int(math.sqrt(N))
divisors = []
for i in range(1, upperLimit + 1):
if(N % i == 0):
divisors.append(N/i)
divisors.append(i)
for q in range(1, noOfQueries + 1):
t, k = raw_input().split(" ")
t,... | vfc_78201 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "12 6\n1 6\n1 14\n2 4\n2 3\n3 12\n3 14\n\nSAMPLE",
"output": "4\n2\n2\n3\n5\n6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12 6\n1 6\n1 14\n4 4\n2 3\n3 12\n3 14\n\nSAMPLE",
"output"... |
code_contests | verifiable_code | gopals-rectangles | Solve the following coding problem using the programming language python:
Ramesh and Suresh are best friends. But they are fighting over money now. Suresh has given some money to Ramesh but he has forgotten how much money he had given. So Ramesh made a plan that he will give Re. 1 to every rectangle Suresh makes in a ... | ```python
t=input()
while t:
n,m=map(int,raw_input().split())
print ((n*(n+1))/2)*(m*(m+1)/2)
t-=1
``` | vfc_78205 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n3 3",
"output": "3\n36\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | little-jhool-and-brute-force-18 | Solve the following coding problem using the programming language python:
Little Syed loves brute force. He thinks that brute force can be the solution to any problem in the world. You give him any question, and he'll have a brute force answer ready for you, almost all the time. His good friend Little Jhool (Like, alw... | ```python
tc = input()
sloane_list = [1729, 4104, 13832, 20683, 32832, 39312, 40033, 46683, 64232, 65728, 110656, 110808, 134379, 149389, 165464, 171288, 195841, 216027, 216125, 262656, 314496, 320264, 327763, 373464, 402597, 439101, 443889, 513000, 513856, 515375, 525824, 558441, 593047, 684019, 704977]
for i in range... | vfc_78209 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n100\n4150\n\nSAMPLE",
"output": "-1\n4104\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n101\n4150\n\nSAMPLE",
"output": "-1\n4104\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | most-powerful-xor | Solve the following coding problem using the programming language python:
Given two integers, L and R, find the maximal value of A xor B,
where A and B satisfy the following condition:
L ≤ A ≤ B ≤ R
Input Format:
First line contains T,number of test cases
following T lines containing 2 intergers L and R ; L is pre... | ```python
t=int(raw_input())
while t:
t-=1
m=0
l,r=map(int,raw_input().split())
for i in xrange(l,r+1):
for j in xrange(i,r+1):
m=max(m,i^j)
print m
``` | vfc_78213 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10 15\n\nSAMPLE",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n255 500\t\t\t\n25 50\t\t\n50 75\t\t\t\n100 175\t\t\t\n160 180",
"output": "511\n63\n127\n255\n31\... |
code_contests | verifiable_code | pranav-and-tle | Solve the following coding problem using the programming language python:
Pranav just learned about Modulus(%) and trying to solve a problem on Modulus but he always get TLE. Your task is to help him. Problem is simple, you have been given two numbers A and M and you have to find A%M and print it.
Input Format
Firs... | ```python
t=int(raw_input())
while t>0:
m,n=map(int,raw_input().split())
print(m%n)
t-=1
``` | vfc_78217 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n12344 12\n12 123\n\nSAMPLE",
"output": "8\n12\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | samu-and-card-game-20 | Solve the following coding problem using the programming language python:
One day Samu went out for a walk in the park but there weren't any of her friends with her. So she decided to enjoy by her own. Samu noticed that she was walking in rectangular field of size N x M (units). So field can be divided into N horizont... | ```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!'
'''
t = int(raw_input())
for i in range (t):
n,m=map(int,raw_input().split())
k=int(raw_input())
res=0
x,y=1,1
for j in range(k):
a,b=map(int,raw_inp... | vfc_78221 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 6\n3\n1 1\n1 1\n0 -4\n\nSAMPLE",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10 6\n3\n1 1\n1 1\n0 -4\n\nSAMPLE",
"output": "6\n",
"type": "stdin_stdout... |
code_contests | verifiable_code | sum-of-series-5 | Solve the following coding problem using the programming language python:
Calculate the sum of the series :
INPUT:
First line contains the number of test cases t, for each test case a single line representing m and n with two space separated integers.
OUTPUT:
For each test case, a single line representing thee sum... | ```python
def gcd(x, y):
while y != 0:
(x, y) = (y, x % y)
return x
t=(int)(raw_input())
for i in range(t):
m, n = [int(x) for x in raw_input().split()]
result=pow(2,m+n)
result1=(pow(2,n)-1)*(result);
result-=1
print str(result)+str('/')+str(result1)
``` | vfc_78225 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 3\n\nSAMPLE",
"output": "31/224\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "17\n27 23\n3 21\n27 7\n1 3\n5 1\n3 13\n12 10\n15 29\n8 13\n4 7\n15 18\n18 23\n2 14\n16 5\n20 4\n17 4\n2... |
code_contests | verifiable_code | weird-multiplayer-scoring | Solve the following coding problem using the programming language python:
As the students are back in hostel after a long time, the gamers have decided to have a LAN gaming competition to find out who has utilized his time in gaming during vacations. They play "Counter ATOD". However, the scoring of this game is weird... | ```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,m=raw_input().split()
n=int(n)
m=int(m)
x=[]
y=[]
M=0
for i in range(m):
name,pt=raw_input().split()
pt=int(pt)
if name not in x:
#print(name,pt)
... | vfc_78229 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\nMurliwala 5\nMithaiwala 4\nMithaiwala 4\nMithaiwala -2\nMirchiwala 8\n\nSAMPLE",
"output": "Mithaiwala",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\nvinay 1\nvinay 2\nvinay -4\nS... |
code_contests | verifiable_code | p00041 Expression | Solve the following coding problem using the programming language python:
Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. ... | ```python
from itertools import permutations, product
import sys
readline = sys.stdin.readline
write = sys.stdout.write
P = [
"((%d %s %d) %s (%d %s %d))",
"(%d %s (%d %s (%d %s %d)))",
"(((%d %s %d) %s %d) %s %d)",
"((%d %s (%d %s %d)) %s %d)",
"(%d %s ((%d %s %d) %s %d))",
]
def solve():
*X, =... | vfc_78273 | {
"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": "8 7 9 9\n4 4 4 4\n5 5 7 5\n0 0 0 0",
"output": "((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 5))",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 7 9 9\n4 4 4 4\n5 5 3 5\n0 0 0 0",
"output... |
code_contests | verifiable_code | p00502 Hot days | Solve the following coding problem using the programming language python:
problem
During this time of winter in Japan, hot days continue in Australia in the Southern Hemisphere. IOI, who lives in Australia, decided to plan what clothes to wear based on the weather forecast for a certain D day. The maximum temperature... | ```python
def solve():
from sys import stdin
f_i = stdin
D, N = map(int, f_i.readline().split())
T = tuple(int(f_i.readline()) for i in range(D))
clothes = [tuple(map(int, f_i.readline().split())) for i in range(N)]
clothes.sort(key=lambda x: x[2])
candidate = []
for t in ... | vfc_78285 | {
"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 4\n31\n27\n35\n20 25 30\n23 29 90\n21 35 60\n28 33 40",
"output": "80",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n34\n27\n35\n20 25 30\n23 29 90\n21 35 60\n28 33 40",
"outpu... |
code_contests | verifiable_code | p00686 Where's Your Robot? | Solve the following coding problem using the programming language python:
You have full control over a robot that walks around in a rectangular field paved with square tiles like a chessboard. There are m columns of tiles from west to east, and n rows of tiles from south to north (1 <= m, n <= 100). Each tile is given... | ```python
while True:
col, row = map(int, input().split())
if col == 0:
break
else:
robot = [1, 1]
direction = "up"
while True:
str = input()
if str == "STOP":
print(robot[0], robot[1])
break
elif str == "LEF... | vfc_78289 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 5\nFORWARD 3\nRIGHT\nFORWARD 5\nLEFT\nBACKWARD 2\nSTOP\n3 1\nFORWARD 2\nSTOP\n0 0",
"output": "6 2\n1 1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 5\nFORWARD 3\nRIGHT\nFORWARD 5\nLE... |
code_contests | verifiable_code | p00959 Medical Checkup | Solve the following coding problem using the programming language python:
Problem C Medical Checkup
Students of the university have to go for a medical checkup, consisting of lots of checkup items, numbered 1, 2, 3, and so on.
Students are now forming a long queue, waiting for the checkup to start. Students are also... | ```python
n, t = map(int, input().split())
s = x = y = 0
for i in range(n):
h = int(input())
s, x, y = s+x, h, max(h, y)
print(max((t-x-s)//y+2,1))
``` | vfc_78297 | {
"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 20\n5\n7\n3",
"output": "5\n3\n2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 20\n5\n11\n3",
"output": "5\n2\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": nu... |
code_contests | verifiable_code | p01092 Development of Small Flying Robots | Solve the following coding problem using the programming language python:
Development of Small Flying Robots
<image>
You are developing small flying robots in your laboratory.
The laboratory is a box-shaped building with K levels, each numbered 1 through K from bottom to top. The floors of all levels are square-sha... | vfc_78301 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2 8\n1 1 1\n8 8 1\n3 3 3 3 2\n3\n3 2 3\n1 1 2\n1 1 2\n1 1 2\n1 1 1 1 2\n1 2 1 2 2\n2 1 2 1 2\n2\n2 3 100\n100 50 1\n1 50 3\n100 1 100 100 3\n1 1 1 100 2\n5\n6 7 60\n11 11 1\n11 51 1\n51 11 1\n51 51 1\n31 31 1\n11 11 51 51 2\n1... | |
code_contests | verifiable_code | p01228 Rhythm Machine | Solve the following coding problem using the programming language python:
Advanced Computer Music (ACM) sold a rhythm machine that plays music according to a pre-programmed rhythm. At one point, ACM was trying to develop and sell a new rhythm machine. While ACM's old product could only play one sound at a time, the ne... | ```python
def shorten(s):
f = 1
while f:
l = len(s) // 2
while f:
f = 0
if l % 2 == 0:
for i in range(l):
if s[2 * i:2 * i + 2] != "00" and i % 2:break
else:
f = 1
t = ""
... | vfc_78305 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2\n01000100\n00020202\n2\n0102\n00000810\n1\n0200020008000200\n5\n0001\n000001\n0000000001\n00000000000001\n0000000000000000000001\n1\n000000",
"output": "01020302\n01000A10\n02020802\nToo complex.\n00",
"type": "std... |
code_contests | verifiable_code | p01362 Dice Room | Solve the following coding problem using the programming language python:
You are playing a popular video game which is famous for its depthful story and interesting puzzles. In the game you were locked in a mysterious house alone and there is no way to call for help, so you have to escape on yours own. However, almos... | ```python
from collections import deque
def main():
I = {
1: ((6, 0), (2, 1), (5, 2), (4, 3)),
2: ((6, 3), (3, 1), (5, 3), (1, 3)),
3: ((6, 2), (4, 1), (5, 0), (2, 3)),
4: ((6, 1), (1, 1), (5, 1), (3, 3)),
5: ((1, 0), (2, 0), (3, 0), (4, 0)),
6: ((1, 2), (2, 2), (3, 2... | vfc_78309 | {
"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": "...\n...\n.*.\n...\n...\n.*.\n...\n...\n...\n...\n...\n.*.\n...\n...\n.*.\n...\n...\n...\n\n...\n.*.\n...\n*..\n...\n..*\n*.*\n*.*\n*.*\n*.*\n.*.\n*.*\n*..\n.*.\n..*\n*.*\n...\n*.*\n\n...\n.*.\n.*.\n...\n.**\n*..\n...\n...\n.*.\n.*... |
code_contests | verifiable_code | p01544 Longest Increasing Sequence | Solve the following coding problem using the programming language python:
Time passed and Taro became a high school student. Under the influence of my older brother who was a college student, I began to be interested in computer science. Taro read through computer science textbooks and learned that there was a famous ... | vfc_78313 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 204472320,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n2\n1",
"output": "1\n(空行)",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1\n2\n4",
"output": "3\n1 2",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01700 Golf | Solve the following coding problem using the programming language python:
golf
Croce is a battle programmer with top-notch skills, and no one in the programming contest neighborhood knows his name. Algorithms, data mining, hacking, AI, ... I've swept all kinds of competitions. The competition that Kurose set as his n... | vfc_78317 | {
"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": "117649\n1\n125000\n1610612736\n68719476636\n-1",
"output": "3\n1\n4\n6\n11",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "117649\n1\n125000\n3124994554\n68719476636\n-1",
"output": "3... | |
code_contests | verifiable_code | p01980 Elevator | Solve the following coding problem using the programming language python:
problem
AOR Co., Ltd. is a $ N $ story building. There is no basement floor.
AOR Ika-chan is a squid, so she can go down the stairs, but not up.
I decided to install $ M $ elevators in the building because it would be inconvenient if I couldn'... | vfc_78325 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 1 2\n3 1 5\n3 1 5\n4 1 5",
"output": "No\nYes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1 2\n3 1 5\n3 1 5\n4 1 5",
"output": "No\nYes\n",
"type": "stdin_stdout"
},... | |
code_contests | verifiable_code | p02266 Areas on the Cross-Section Diagram | Solve the following coding problem using the programming language python:
Areas on the Cross-Section Diagram
Your task is to simulate a flood damage.
For a given cross-section diagram, reports areas of flooded sections.
<image>
Assume that rain is falling endlessly in the region and the water overflowing from th... | ```python
def cross_section_diagram():
down = []
edge = []
pool = []
for i, c in enumerate(input()):
if c == '\\':
down.append(i)
elif c == '/' and down:
left = down.pop()
area = i - left
while edge:
if edge[-1] < left:
break
edge.pop()
area += pool.pop()
edge.append(left)
... | vfc_78333 | {
"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": "\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\",
"output": "35\n5 4 2 1 19 9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "\\\\//",
"output": "4\n1 4",
"type": "stdin_s... |
code_contests | verifiable_code | p02414 Matrix Multiplication | Solve the following coding problem using the programming language python:
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:
\\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\]
... | ```python
n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j in range(m)]
C = [[0 for k in range(l)]for i in range(n)]
for i in range(n) :
for k in range(l) :
for j in range(m) :
C[i][k] = C[i][k] + A[i][j] * B[j][k]
for i in r... | vfc_78337 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 3\n1 2\n0 3\n4 5\n1 2 1\n0 3 2",
"output": "1 8 5\n0 9 6\n4 23 14",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 3\n1 2\n0 3\n4 5\n1 2 1\n1 3 2",
"output": "3 8 5\n3 9 6\n9 23... |
code_contests | verifiable_code | cdsw153 | Solve the following coding problem using the programming language python:
Virat is a guy who likes solving problems very much. Today Virat’s friend Jadega gave him a problem to solve. Jadeja gives Virat three numbers: N, L and R and Virat has to find out the count of numbers between L and R (both inclusive) which are ... | ```python
from itertools import combinations as c
def primes(n):
""" Returns a list of primes < n """
sieve = [True] * n
for i in xrange(3,int(n**0.5)+1,2):
if sieve[i]:
sieve[i*i::2*i]=[False]*((n-i*i-1)/(2*i)+1)
return [2] + [i for i in xrange(3,n,2) if sieve[i]]
for i in range(i... | vfc_78341 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6 1 15\n10 17 29",
"output": "11\n9",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | cysm | Solve the following coding problem using the programming language python:
Since the finance department of MAKAUT has lots of bills to pass and funds to allocate for puja and freshers so there is a mess in Finance Officer's office. Although he has numbered all type of files from 0-9, all his files got jumbled up. Aarot... | ```python
t=int(raw_input())
for i in range(t):
n=raw_input()
q=raw_input()
print n.count(q)
``` | vfc_78345 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n12\n1",
"output": "1",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | icq4 | Solve the following coding problem using the programming language python:
It was exam time in pesce, mandya and Rubal was feeling hungry.However being late night and exam time he decided to look for snacks in every room.However because of his bad luck he missed the room which actually had snacks.Help him to find the r... | ```python
import sys
t=int(sys.stdin.readline())
for k in xrange(t):
n=int(sys.stdin.readline())
s=(n*(n+1))/2
a=map(int,sys.stdin.readline().split())
s=s-sum(a)
sys.stdout.write("%d\n"%s)
``` | vfc_78349 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n9\n5 4 2 8 3 1 7 9\n5\n1 5 2 4",
"output": "6\n3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n9\n5 4 2 8 3 1 7 9\n5\n1 5 2 3",
"output": "6\n4\n",
"type": "stdin_stdout"... |
code_contests | verifiable_code | mstep | Solve the following coding problem using the programming language python:
You have a matrix of size N * N with rows numbered through 1 to N from top to bottom and columns through 1 to N from left to right. It contains all values from 1 to N^2, i.e. each value from 1 to N^2 occurs exactly once in the matrix.
Now, you... | ```python
t = input()
for _ in xrange(t):
n = input()
loc = {}
for i in xrange(n):
row = map(int, raw_input().split())
k = 0
for j in row:
loc[j] = i, k
k += 1
steps = 0
r, c = loc[1]
for i in xrange(2, n * n + 1):
rw, cl = loc[i]
s... | vfc_78353 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n1 3\n2 4\n3\n1 7 9\n2 4 8\n3 6 5",
"output": "4\n12\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | rmath | Solve the following coding problem using the programming language python:
Little Ron of Byteland was poor at mathematics. He always used to get zero marks in mathematics test. One evening when he showed his result to his father, his father scolded him badly. So, he thought if zeroes were not there in this world how go... | ```python
t=input()
while t:
x,y=map(int,raw_input().split())
res=x+y
res=list(str(res))
while '0' in res:
res.remove('0')
x=list(str(x))
y=list(str(y))
while '0' in x:
x.remove('0')
while '0' in y:
y.remove('0')
res1=int(''.join(x))+int(''.join(y))
res1=s... | vfc_78357 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n205 402",
"output": "YES",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | vcs | Solve the following coding problem using the programming language python:
A version control system(VCS) is a repository of files, often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, why they made it, and references... | ```python
for i in range(input()):
a,b,c=map(int,raw_input().split())
count = [0]*(a+1)
ar1 = map(int,raw_input().split())
ar2=map(int,raw_input().split())
for i in ar1:
count[i]+=1
for i in ar2:
count[i]+=1
trig =0
untunig = 0
for i in range(1,a+1):
if(count[i]==2):
trig+=1
if(count[i]==0):
untu... | vfc_78361 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7 4 6\n1 4 6 7\n1 2 3 4 6 7\n4 2 2\n1 4\n3 4",
"output": "4 1\n1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n7 4 6\n1 4 6 7\n1 2 3 5 6 7\n4 2 2\n1 4\n3 4",
"output": "3 0... |
code_contests | verifiable_code | 1042_D. Petya and Array | Solve the following coding problem using the programming language python:
Petya has an array a consisting of n integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to anoth... | ```python
maxn = 2*10**5 + 5
bit = [0]*(maxn)
def add(idx):
idx += 1
while idx < maxn:
bit[idx] += 1
idx += idx & -idx
def sm(idx):
idx += 1
tot = 0
while idx > 0:
tot += bit[idx]
idx -= idx & -idx
return tot
n,t = map(int,input().split())
a = list(map(int,in... | vfc_78369 | {
"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 4\n5 -1 3 4 -1\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 0\n-1 2 -3\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1065_C. Make It Equal | Solve the following coding problem using the programming language python:
There is a toy building consisting of n towers. Each tower consists of several cubes standing on each other. The i-th tower consists of h_i cubes, so it has height h_i.
Let's define operation slice on some height H as following: for each tower ... | ```python
#########################################################################################################\
#########################################################################################################
###################################The_Apurv_Rathore#############################################... | vfc_78373 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n2 3 4 5\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n3 1 2 2 4\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1088_A. Ehab and another construction problem | Solve the following coding problem using the programming language python:
Given an integer x, find 2 integers a and b such that:
* 1 ≤ a,b ≤ x
* b divides a (a is divisible by b).
* a ⋅ b>x.
* a/b<x.
Input
The only line contains the integer x (1 ≤ x ≤ 100).
Output
You should output two integers a and... | ```python
n=int(input())
if n>=3 and n%2==1:
print(n-1,2)
elif n>=2 and n%2==0:
print(n,2)
else:
print(-1)
``` | vfc_78377 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "4 4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1107_A. Digits Sequence Dividing | Solve the following coding problem using the programming language python:
You are given a sequence s consisting of n digits from 1 to 9.
You have to divide it into at least two segments (segment — is a consecutive sequence of elements) (in other words, you have to place separators between some digits of the sequence)... | ```python
for _ in range(int(input())):
n = int(input())
z = input()
if n==2 and z[0]>=z[1]:
print("NO")
else:
print("YES")
print(2)
print(z[0],z[1::])
``` | vfc_78381 | {
"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\n6\n654321\n4\n1337\n2\n33\n4\n2122\n",
"output": "YES\n2\n6 54321\nYES\n2\n1 337\nNO\nYES\n2\n2 122\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n45\n2\n67\n",
"output": "... |
code_contests | verifiable_code | 1136_A. Nastya Is Reading a Book | Solve the following coding problem using the programming language python:
After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.
Yesterday evening Nastya did not manage... | ```python
n=int(input())
p=[]
for x in range(n):
a,b=list(map(int,input().split()))
sam=list(range(a,b+1))
p.append(sam)
kam=int(input())
for x in p:
if kam in x:
print(n-p.index(x))
break
``` | vfc_78385 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 4\n5 9\n10 12\n9\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1 7\n4\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.