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 | 187_B. AlgoRace | Solve the following coding problem using the programming language python:
PMP is getting a warrior. He is practicing a lot, but the results are not acceptable yet. This time instead of programming contests, he decided to compete in a car racing to increase the spirit of victory. He decides to choose a competition that... | vfc_30569 | {
"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 2 3\n0 1 5 6\n2 0 3 6\n1 3 0 1\n6 6 7 0\n0 3 5 6\n2 0 1 6\n1 3 0 2\n6 6 7 0\n1 4 2\n1 4 1\n1 4 3\n",
"output": "3\n4\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2 3\n0 7 3 3\n8 ... | |
code_contests | verifiable_code | 207_D9. The Beaver's Problem - 3 | Solve the following coding problem using the programming language python:
The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:
Y... | vfc_30573 | {
"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": "42000\nLAWSON SEES NO CHANGE IN U.K. MONETARY POLICY\nWASHINGTON, April 9 - British Chancellor of the Exchequer\nNigel Lawson said he saw no immediate implications for British\nmonetary policy arising from the Group of Seven meetin... | |
code_contests | verifiable_code | 233_C. Cycles | Solve the following coding problem using the programming language python:
John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3.
A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, s... | ```python
n, k = 0, int(input())
p = [['0'] * 100 for i in range(100)]
while k:
for i in range(n):
if i > k: break
p[n][i] = p[i][n] = '1'
k -= i
n += 1
print(n)
for i in range(n): print(''.join(p[i][:n]))
``` | vfc_30577 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n",
"output": "5\n01111\n10111\n11011\n11101\n11110\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "3\n011\n101\n110\n",
"type": "stdin_stdout"
},
{... |
code_contests | verifiable_code | 282_B. Painting Eggs | Solve the following coding problem using the programming language python:
The Bitlandians are quite weird people. They have very peculiar customs.
As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.
The kids are excited because just ... | ```python
import sys
input = lambda: sys.stdin.readline()
n = int(input())
S = 0
ans = ''
for i in range(n):
a, g = [int(x) for x in input().split(' ')]
if abs(S + a) <= 500:
S += a
ans += 'A'
else:
S -= g
ans += 'G'
print(ans)
``` | vfc_30585 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 999\n999 1\n",
"output": "AG\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n400 600\n400 600\n400 600\n",
"output": "AGA\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 305_A. Strange Addition | Solve the following coding problem using the programming language python:
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4.
Vasya has a set of k distinct n... | ```python
n = int(input())
arr = list(map(int,input().split()))
t = []
flag = 0
if(0 in arr):
t.append(0)
if(100 in arr):
t.append(100)
for i in range(n):
if(arr[i]>0 and arr[i]<10):
t.append(arr[i])
flag = 1
break
for i in range(n):
if(arr[i]%10 == 0 and arr[i]>0 and arr[i]<100)... | vfc_30589 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n100 10 1 0\n",
"output": "4\n100 10 1 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 70 3\n",
"output": "2\n2 70\n",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | 331_A2. Oh Sweet Beaverette | Solve the following coding problem using the programming language python:
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everything s... | ```python
n, t = int(input()), list(map(int, input().split()))
a, b = {}, {}
for i, j in enumerate(t):
if not j in a: a[j] = i
else: b[j] = i
p = [(a[j], b[j] - 1) for j in b]
s = [j if j > 0 else 0 for j in t]
u = v = 2 * t[p[0][0]] - 1
for i in range(n - 1): s[i + 1] += s[i]
for i, j in p:
u = 2 * t[i] + ... | vfc_30593 | {
"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": "5\n1 2 3 1 2\n",
"output": "8 1\n1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 -2 3 1 -2\n",
"output": "5 2\n2 5 ",
"type": "stdin_stdout"
},
{
"fn_name":... |
code_contests | verifiable_code | 352_E. Jeff and Brackets | Solve the following coding problem using the programming language python:
Jeff loves regular bracket sequences.
Today Jeff is going to take a piece of paper and write out the regular bracket sequence, consisting of nm brackets. Let's number all brackets of this sequence from 0 to nm - 1 from left to right. Jeff knows... | vfc_30597 | {
"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": "1 10000000\n2\n3\n",
"output": "25000000\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 377_A. Maze | Solve the following coding problem using the programming language python:
Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.
Pavel drew a grid maze with all empty cells f... | ```python
from collections import defaultdict
from sys import stdin
def put(): return map(int, stdin.readline().split())
def find():
for i in range(n):
for j in range(m):
if mat[i][j]=='.':
return i,j
return -1,-1
def dfs(i,j):
s = [(i,j)]
t = 1
vis[i][j]=1
... | vfc_30601 | {
"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 4 2\n#..#\n..#.\n#...\n",
"output": "#..#\n..#X\n#..X\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4 5\n#...\n#.#.\n.#..\n...#\n.#.#\n",
"output": "#...\n#.#.\nX#..\nXX.#\nX#X... |
code_contests | verifiable_code | 399_C. Cards | Solve the following coding problem using the programming language python:
User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.
1. At first, the score is 0.
2. For eac... | ```python
a, b = map(int, input().split())
sx = lambda p: (a - p + 1) ** 2 + p - 1
sy = lambda q: (b % q) * (1 + b // q) ** 2 + (b // q) ** 2 * (q - b % q)
n = min(a, b)
if a == 0:
print( -b ** 2)
print( b * "x" )
elif b <= 1:
print( a ** 2 - b ** 2 )
print ( a * "o" + b * "x" )
else:
res = - (a ... | vfc_30605 | {
"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": "0 4\n",
"output": "-16\nxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n",
"output": "-1\nxxoox\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 421_D. Bug in Code | Solve the following coding problem using the programming language python:
Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting sa... | ```python
from collections import defaultdict
from bisect import bisect_left as lower
import sys
input = sys.stdin.readline
def put():
return map(int, input().split())
try:
n,m = put()
cnt, mp, ans = [0]*n, defaultdict(), [0]*n
for _ in range(n):
x,y = put()
x,y = x-1,y-1
key = ... | vfc_30609 | {
"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": "8 6\n5 6\n5 7\n5 8\n6 2\n2 1\n7 3\n1 3\n1 4\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 448_B. Suffix Structures | Solve the following coding problem using the programming language python:
Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.
At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and t. You need to transform word s in... | ```python
s = input()
t = input()
ind = 0
for x in t:
ind = s.find(x, ind) + 1
if ind <= 0:
break
if ind > 0 or len(t) == 0:
print('automaton')
else:
ss = list(s)
tt = list(t)
bb1 = True
if len(ss) >= len(tt):
for x in tt:
bb = False
for y in ss:
... | vfc_30613 | {
"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": "need\ntree\n",
"output": "need tree\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 46_C. Hamsters and Tigers | Solve the following coding problem using the programming language python:
Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so ... | ```python
n=int(input())
s=input()
h=0
for i in s:
if i=='H':h+=1
r=[]
t=0
for i in range(0,n):
if s[i]=='H':
for b in range((i+1)%n,min(((i+1)%n+h-1),n)):
if s[b]=='T':
t+=1
if ((i+1)%n+(h-1))>n:
for q in range(0,(((i+1)%n+(h-1))%n)):
if ... | vfc_30617 | {
"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\nHTH\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\nHTHTHTHHT\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
code_contests | verifiable_code | 492_D. Vanya and Computer Game | Solve the following coding problem using the programming language python:
Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each ... | ```python
n, x, y = map(int, input().split())
for _ in range(n):
a = int(input())
c1, c2 = ((a + 1) * x // (x + y)) / x, ((a + 1) * y // (x + y)) / y
if c1 == c2:
print('Both')
elif c1 > c2:
print('Vanya')
else:
print('Vova')
``` | vfc_30621 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1 1\n1\n2\n",
"output": "Both\nBoth\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3 2\n1\n2\n3\n4\n",
"output": "Vanya\nVova\nVanya\nBoth\n",
"type": "stdin_stdout"
}... |
code_contests | verifiable_code | 516_C. Drazil and Park | Solve the following coding problem using the programming language python:
Drazil is a monkey. He lives in a circular park. There are n trees around the park. The distance between the i-th tree and (i + 1)-st trees is di, the distance between the n-th tree and the first tree is dn. The height of the i-th tree is hi.
D... | vfc_30625 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n2 2 2 2 2\n3 5 2 1 4\n1 3\n2 2\n4 5\n",
"output": " 12\n 16\n ... | |
code_contests | verifiable_code | 56_E. Domino Principle | Solve the following coding problem using the programming language python:
Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis s... | ```python
from typing import TypeVar, Generic, Callable, List
import sys
from array import array # noqa: F401
from bisect import bisect_left, bisect_right
def input():
return sys.stdin.buffer.readline().decode('utf-8')
T = TypeVar('T')
class SegmentTree(Generic[T]):
__slots__ = ["size", "tree", "identity... | vfc_30633 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n16 5\n20 5\n10 10\n18 2\n",
"output": "3 1 4 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 10\n1 5\n9 10\n15 10\n",
"output": "4 1 2 1 ",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 591_C. Median Smoothing | Solve the following coding problem using the programming language python:
A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya... | ```python
def main():
n = int(input())
a = [int(i) for i in input().split()]
flag = 0
now_begin = 0
kek = 0
ans = [[-1] * 2 for i in range(n)]
for i in range(1, n - 1):
if a[i] != a[i - 1] and a[i] != a[i + 1]:
kek += 1
else:
flag = max((kek + 1) // 2,... | vfc_30637 | {
"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\n0 1 0 1 0\n",
"output": "2\n0 0 0 0 0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0 1 1\n",
"output": "0\n0 0 1 1",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 633_A. Ebony and Ivory | Solve the following coding problem using the programming language python:
Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.
For every bullet that hits ... | ```python
a, b, c = map(int, input().split())
h = 0
if c % a == 0:
k = c // a
else:
k = c // a + 1
if c % b == 0:
m = c // b
else:
m = c // b + 1
if c - a*k < 0 and c - b*m < 0 and ((c < 2 * a) and c < 2*b):
print('No')
else:
for i in range(k+1):
if (c - a*i) % b == 0 and (h == 0):
... | vfc_30645 | {
"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": "6 11 6\n",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 7\n",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 ... |
code_contests | verifiable_code | 661_D. Maximal Difference | Solve the following coding problem using the programming language python:
You are given an array of integers ai. Find the largest absolute value of difference between adjacent elements of the array max(abs(ai - ai + 1)).
Input
The only line of the input contains a list of space-separated integers ai (1 ≤ ai ≤ 100) —... | vfc_30649 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 10 4 8 6 12\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 685_D. Kay and Eternity | Solve the following coding problem using the programming language python:
Snow Queen told Kay to form a word "eternity" using pieces of ice. Kay is eager to deal with the task, because he will then become free, and Snow Queen will give him all the world and a pair of skates.
Behind the palace of the Snow Queen there ... | vfc_30653 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n4 5\n4 6\n5 5\n5 6\n7 7\n",
"output": " 10 8 ... | |
code_contests | verifiable_code | 72_I. Goofy Numbers | Solve the following coding problem using the programming language python:
The non-negative integer a is a divisor of the non-negative integer b if and only if there exists a positive integer c such that a × c = b.
Some numbers are really interesting. Commander Surena defines some interesting properties for non-negat... | vfc_30661 | {
"difficulty": "15",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "99\n",
"output": "happier\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "29994\n",
"output": "happy\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... | |
code_contests | verifiable_code | 750_F. New Year and Finding Roots | Solve the following coding problem using the programming language python:
This is an interactive problem. In the interaction section below you will find the information about flushing the output.
The New Year tree of height h is a perfect binary tree with vertices numbered 1 through 2h - 1 in some order. In this prob... | vfc_30665 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n3\n4 5 7\n2\n1 2\n1\n2\n",
"output": "? 1\n? 4\n! 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n1\n3\n2\n1 2\n2\n1 2\n4\n3\n3 12 13\n",
"output": "? 1\n! 3\n? 1\n! 2\... | |
code_contests | verifiable_code | 799_D. Field expansion | Solve the following coding problem using the programming language python:
In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there a... | ```python
def mp(): return map(int,input().split())
def lt(): return list(map(int,input().split()))
def pt(x): print(x)
def ip(): return input()
def it(): return int(input())
def sl(x): return [t for t in x]
def spl(x): return x.split()
def aj(liste, item): liste.append(item)
def bin(x): return "{0:b}".format(x)... | vfc_30673 | {
"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": "5 5 1 2 3\n2 2 3\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 3 3 5\n2 3 5 4 2\n",
"output": "0",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 819_D. Mister B and Astronomers | Solve the following coding problem using the programming language python:
After studying the beacons Mister B decided to visit alien's planet, because he learned that they live in a system of flickering star Moon. Moreover, Mister B learned that the star shines once in exactly T seconds. The problem is that the star i... | vfc_30677 | {
"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": "4 2\n2 3\n",
"output": "3 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n1 1 1 1\n",
"output": "2 1 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | 845_B. Luba And The Ticket | Solve the following coding problem using the programming language python:
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticket is... | ```python
def main():
s = input()
print(solver(s))
def solver(s):
L1 = [int(x) for x in s[0:3]]
L2 = [int(x) for x in s[3:6]]
diff = sum(L2) - sum(L1)
if diff == 0:
return 0
elif diff < 0:
L1, L2 = L2, L1
diff = -diff
changes = [9 - L1[i] for i in range(3)] + [L2[i] - 0 for i in range(3)]
changes.sort... | vfc_30681 | {
"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": "111000\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "000000\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1... |
code_contests | verifiable_code | 891_D. Sloth | Solve the following coding problem using the programming language python:
Sloth is bad, mkay? So we decided to prepare a problem to punish lazy guys.
You are given a tree, you should count the number of ways to remove an edge from it and then add an edge to it such that the final graph is a tree and has a perfect mat... | vfc_30689 | {
"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": "4\n1 2\n2 3\n3 4\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2\n2 3\n3 4\n3 5\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name"... | |
code_contests | verifiable_code | 913_G. Power Substring | Solve the following coding problem using the programming language python:
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Here le... | ```python
import sys
#sys.stdout = open('output.txt', 'w')
#sys.stdin = open('input.txt', 'r')
#for line in sys.stdin:
#while 1:
# line = sys.stdin.readline()
# if line:
# print (line,end="")
def phi(p,i):
if i == 0:
return 1
return p**i - p**(i-1)
def pwr(x,p,mod):
if p == 0:
ret... | vfc_30693 | {
"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": "2\n8\n2\n",
"output": "3\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3\n4857\n",
"output": "5\n20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 936_A. Save Energy! | Solve the following coding problem using the programming language python:
Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on.
During cooking, Julia goes to the kitchen every d minutes and turns on the stov... | ```python
from math import ceil
k , d , t = [int(x) for x in input().split()]
n = ceil(k/d)*d
diff = n - k
new_k = k+(diff/2)
res = (t//new_k)*n
if t%new_k <= k :
res += t%new_k
else :
res += k+(t%new_k- k)*2
print(res)
``` | vfc_30697 | {
"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 2 20\n",
"output": "20.000000000000000",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | anagrams-1 | Solve the following coding problem using the programming language python:
Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams.
In this problem you’ll be given two strings. Your job is to find... | ```python
from string import ascii_lowercase,ascii_uppercase
alp=ascii_lowercase+ascii_uppercase
def lpalin(S):
l=list(S)
one,two=0,0
d=set(l);ch=''
for i in d:
if l.count(i)%2==0:two+=1
else:one+=1;ch=i
if one>1:
return '0'
else:
f='';g=ch
sx=list(set(l))... | vfc_30709 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nComputer programmer\nmature germ romp crop\nAwaaay\naway\ninternet\nweb\nabc221\nabcdede\nthe terminator\nI?m rotten hater\n\nSAMPLE",
"output": "YES\naa\nNO LUCK\ndeed\nYES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | castles-stones-1 | Solve the following coding problem using the programming language python:
Phineas is Building a castle in his backyard to impress Isabella ( strange, isn't it? ). He has got everything delivered and ready. Even the ground floor has been finished. Now is time to make the upper part. This is where the things become inte... | ```python
T = int(raw_input())
for i in range(0,T):
M = int(raw_input())
lst = map(int, raw_input().split())
N= lst.pop(0)
"""
s = raw_input()
lst = s.split()
N = int(lst[0])
lst.pop(0)
"""
lst.sort()
j = N - 1
i = 0
res = 0
while ( i <= j):
if(int(lst[j]) > M):
j -= 1
elif(int(lst[i]) + int(l... | vfc_30713 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n50\n3 28 22 48\n\nSAMPLE",
"output": "2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | diamonds-4 | Solve the following coding problem using the programming language python:
Roman loved diamonds. Monica decided to give him a beautiful gift on Valentine's Day. Her idea of diamonds was different though. She lit up all the windows of her rectangular building with N floors and M windows on each floor, with 2 shapes - / ... | ```python
p=input()
s=range(1000)
import string
for i in range(p):
d=0
n,m= map(int, raw_input().split())
for i in range(n):
s[i]=string.split(raw_input())
for i in range(n-1):
for j in range(m-1):
if s[i][j]=="/" and s[i][j+1]=="\\" :
if s[i+1][j]=="\\" and s[i+1][j+1]=="/":
d=d+1
print d
``... | vfc_30717 | {
"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 4\n/ \\ / \\\n\\ / \\ /\n\nSAMPLE",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n2 4\n/ \\ / \\\n\\ / \\ /\n\nELPMAS",
"output": "2\n",
"type": "stdin_s... |
code_contests | verifiable_code | geeky-alice-and-naughty-bob | Solve the following coding problem using the programming language python:
One day Alice was experimenting with the numbers to make new algorithms. He introduce a new term Rsum.
Rsum of any number is defined as number obtained by iterative summing of digits of the given number until single digit number is obtained.
Fo... | ```python
facts = [0, 1, 2, 6, 6, 3]
for _ in range(input()):
ans = 0
a, b = map(int, raw_input().split())
if a >=6:
ans = 9 * (b - a + 1)
elif a < 6 and b >=6:
ans = 9 * (b - 6 + 1)
for i in range(a, 6):
ans += facts[i]
elif b < 6:
for i in range(a, b+1)... | vfc_30721 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 3\n3 4\n\nSAMPLE",
"output": "9\n12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 3\n3 4\n\nSAMPLF",
"output": "9\n12\n",
"type": "stdin_stdout"
},
{
"f... |
code_contests | verifiable_code | lazy-boy-off-to-class-i | Solve the following coding problem using the programming language python:
All the students in NIT are very lazy. They want to have maximum time for rest. But due to college rules, they must maintain 75% attendance at the end of every week.
Given the schedule of a week, tell them what is the maximum amount of time the... | ```python
from math import ceil
for i in range(int(raw_input())):
clas=[]
total=0
for k in range(7):
arr=map(int,raw_input().strip().split())
total+=arr[0]
for j in range(1,arr[0]+1):
clas.append(arr[2*j]-arr[2*j-1])
atte=int(ceil(total*3.0/4))
nota=total-atte
for k in range(nota):
max=0
for j in... | vfc_30725 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 60 70 80 90 100 200\n3 50 70 100 120 150 200\n3 50 80 90 100 200 220\n3 80 100 110 115 200 210\n3 10 20 40 50 60 100\n3 10 50 60 80 90 100\n3 50 80 90 100 200 300\n\nSAMPLE",
"output": "604555\n",
"type": "stdin_st... |
code_contests | verifiable_code | permutation-again | Solve the following coding problem using the programming language python:
Given an integer N. Find out the PermutationSum where PermutationSum for integer N is defined as the maximum sum of difference of adjacent elements in all arrangement of numbers from 1 to N.
NOTE: Difference between two elements A and B will ... | ```python
'''
from itertools import permutations
def abs_sum(l):
res = 0
for i in range(len(l)-1):
res += abs(l[i] - l[i+1])
return res
def all_perms(l):
a = permutations(l)
return map(list, a)
for i in range(2, 12):
l = range(1, i)
ap = all_perms(l)
print l, max(map(a... | vfc_30733 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10000\n30001\n30002\n30003\n30004\n30005\n30006\n30007\n30008\n30009\n30010\n30011\n30012\n30013\n30014\n30015\n30016\n30017\n30018\n30019\n30020\n30021\n30022\n30023\n30024\n30025\n30026\n30027\n30028\n30029\n30030\n30031\n30032\n... |
code_contests | verifiable_code | roy-and-profile-picture | Solve the following coding problem using the programming language python:
Roy wants to change his profile picture on Facebook. Now Facebook has some restriction over the dimension of picture that we can upload.
Minimum dimension of the picture can be L x L, where L is the length of the side of square.
Now Roy has N... | ```python
import sys
l= raw_input().strip()
l=int(l)
n=raw_input().strip()
n=int(n)
for i in xrange(n):
w, h=raw_input().strip().split()
w, h=[int(w), int(h)]
if w<l or h<l:
print 'UPLOAD ANOTHER'
elif w==h:
print 'ACCEPTED'
else:
print 'CROP IT'
``` | vfc_30737 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "180\n3\n640 480\n120 300\n180 180\n\nSAMPLE",
"output": "CROP IT\nUPLOAD ANOTHER\nACCEPTED\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "180\n3\n640 480\n120 300\n180 180\n\nSAMELP",
... |
code_contests | verifiable_code | studious-little-jhool | Solve the following coding problem using the programming language python:
Yes, you read it right - Little Jhool is back, but no, he's not over his break up, still. And he's sad, broken and depressed; thus, he decided to visit a psychologist. She tells him to think about his pleasant memories of childhood, and stay bus... | ```python
for i in range(input()):
n = input()
ans = 1000000
for i in xrange(113):
for j in xrange(113):
if (i*10 + j*12 == n):
ans = min (ans, i+j)
if (ans==1000000):
print -1
else:
print ans
``` | vfc_30741 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n23\n32\n\nSAMPLE",
"output": "-1\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n10\n113\n34\n82\n82\n94\n86\n9\n52\n64",
"output": "1\n-1\n3\n7\n7\n8\n8\n-1\n5\n6\n",
... |
code_contests | verifiable_code | valentine-shopping-4 | Solve the following coding problem using the programming language python:
As it is the Valentines month, Puchi's girlfriend asks him to take her shopping. He, being the average bloke, does not have a lot of money to spend. Hence, decides to buy each item from the shop that offers the best price on it.
His girlfriend ... | ```python
import sys
t = int(raw_input())
for i in range(0,t):
products,shops = map(int,raw_input().split())
for prod in range(0,products):
bestShop=1;
bestPrice=101;
for m in range(1,shops+1):
basePrice=100.00;
for discount in raw_input().split():
if(int(discount)==100):
basePrice=0;
brea... | vfc_30745 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 3\n20 20 50\n30 20 0\n60 50 0\n2 2\n20 20 20\n30 20 40\n10 100 90\n35 60 50\n\nSAMPLE",
"output": "3\n2 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 3\n20 20 50\n30 20 0\n60... |
code_contests | verifiable_code | p00025 Hit and Blow | Solve the following coding problem using the programming language python:
Let's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:
* The number of numbers which have the same place with numbers A imagined (Hit)
* The number of numbers included (but di... | ```python
import sys
e=iter(map(lambda a:a.split(),sys.stdin))
for a,b in zip(e,e):
h=sum([1 for i in range(4)if a[i]==b[i]])
w=4-len(set(a)-set(b))-h
print(h,w)
``` | vfc_30789 | {
"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": "9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2",
"output": "1 1\n3 0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 0",
"output": "1 1\n2 0\n",
"type": "std... |
code_contests | verifiable_code | p00483 Planetary Exploration | Solve the following coding problem using the programming language python:
After a long journey, the super-space-time immigrant ship carrying you finally discovered a planet that seems to be habitable. The planet, named JOI, is a harsh planet with three types of terrain, "Jungle," "Ocean," and "Ice," as the name implie... | ```python
from itertools import accumulate
from operator import add
line, row = [int(x) for x in input().split()]
k = int(input())
L=[]
J=[[0]*(row+1) for _ in range(line+1)]
O=[[0]*(row+1) for _ in range(line+1)]
I=[[0]*(row+1) for _ in range(line+1)]
for _ in range(line):
L.append(input())
for i in range(line):... | vfc_30801 | {
"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 7\n4\nJIOJOIJ\nIOJOIJO\nJOIJOOI\nOOJJIJO\n3 5 4 7\n2 2 3 6\n2 2 2 2\n1 1 4 7",
"output": "1 3 2\n3 5 2\n0 1 0\n10 11 7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 7\n4\nJIOJOIJ\nIOJO... |
code_contests | verifiable_code | p00669 K Cards | Solve the following coding problem using the programming language python:
One day, the teacher came up with the following game.
The game uses n cards with one number from 1 to 10 and proceeds as follows.
1. The teacher pastes n cards on the blackboard in a horizontal row so that the numbers can be seen, and declares... | ```python
from functools import reduce
from collections import Counter
while True:
n, k = map(int, input().split())
if n == 0:
break
clst = [int(input()) for _ in range(n)]
acc = reduce(lambda x, y:x* y, clst[:k])
scores = [acc]
for i in range(n - k):
acc = acc // clst[i] * clst[i + k]
scores.ap... | vfc_30805 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n2\n3\n7\n5\n0 0",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n4\n3\n7\n5\n0 0",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
code_contests | verifiable_code | p00812 Equals are Equals | Solve the following coding problem using the programming language python:
Mr. Simpson got up with a slight feeling of tiredness. It was the start of another day of hard work. A bunch of papers were waiting for his inspection on his desk in his office. The papers contained his students' answers to questions in his Math... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
from string import digits
def convert(S):
S = S + "$"
cur = 0
def expr():
nonlocal cur
res = []
op = '+'
while 1:
r = fact()
if op == '-':
for e in r:
... | vfc_30809 | {
"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": "a+b+c\n(a+b)+c\na- (b-c)+2\n.\n4ab\n(a - b) (0-b+a) - 1a ^ 2 - b ^ 2\n2 b 2 a\n.\n108 a\n2 2 3 3 3 a\n4 a^1 27\n.\n.",
"output": "yes\nno\n.\nno\nyes\n.\nyes\nyes\n.",
"type": "stdin_stdout"
},
{
"fn_name"... |
code_contests | verifiable_code | p00943 Routing a Marathon Race | Solve the following coding problem using the programming language python:
Example
Input
6 6
3
1
9
4
3
6
1 2
1 4
2 6
5 4
6 5
3 2
Output
17
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_30813 | {
"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": "6 6\n3\n1\n9\n4\n3\n6\n1 2\n1 4\n2 6\n5 4\n6 5\n3 2",
"output": "17",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 6\n3\n1\n7\n4\n3\n6\n1 2\n1 4\n2 6\n5 4\n6 5\n3 2",
"output": "17\... | |
code_contests | verifiable_code | p01076 Graph Making | Solve the following coding problem using the programming language python:
Problem
There are n vertices that are not connected to any of the vertices.
An undirected side is stretched between each vertex.
Find out how many sides can be stretched when the diameter is set to d.
The diameter represents the largest of the ... | ```python
# AOJ 1591 Graph Making
# Python3 2018.7.13 bal4u
n, d = map(int, input().split())
if d == 1: print(n*(n-1)//2)
else: print((n-1)+(n-d-1)*n-((n-d-1)*(n+d-2)//2))
``` | vfc_30817 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3",
"o... |
code_contests | verifiable_code | p01210 Speed | Solve the following coding problem using the programming language python:
Do you know Speed? It is one of popular card games, in which two players compete how quick they can move their cards to tables.
To play Speed, two players sit face-to-face first. Each player has a deck and a tableau assigned for him, and betwee... | vfc_30821 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nSA\n1\nC2\n2\nSA HA\n2\nC2 C3\n5\nS3 S5 S8 S9 S2\n3\nH7 H3 H4\n10\nH7 CJ C5 CA C6 S2 D8 DA S6 HK\n10\nC2 D6 D4 H5 DJ CX S8 S9 D3 D5\n0",
"output": "A wins.\nB wins.\nB wins.\nA wins.",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | p01346 Ropeway | Solve the following coding problem using the programming language python:
On a small island, there are two towns Darkside and Sunnyside, with steep mountains between them. There’s a company Intertown Company of Package Conveyance; they own a ropeway car between Darkside and Sunnyside and are running a transportation b... | vfc_30825 | {
"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 3 2 1\n1 1 4",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 2 1\n1 4 1",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
code_contests | verifiable_code | p01516 Milky Way | Solve the following coding problem using the programming language python:
Milky Way
Milky Way
English text is not available in this practice contest.
The Milky Way Transportation Corporation is a travel agency that plans and manages interstellar travel tours. The Milky Way Transportation Corporation is planning a p... | vfc_30829 | {
"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 | p01684 Venn Diagram | Solve the following coding problem using the programming language python:
Problem Statement
Alice is a private teacher. One of her job is to prepare the learning materials for her student. Now, as part of the materials, she is drawing a Venn diagram between two sets $A$ and $B$.
Venn diagram is a diagram which illus... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
from math import pi, sqrt, acos, sin
def solve():
EPS = 1e-9
W, H, A, B, C = map(int, readline().split())
if W == 0:
return False
a = sqrt(A / pi); b = sqrt(B / pi)
mx = max(a, b)
if 2*mx > min(W, H) - EPS:
... | vfc_30833 | {
"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": "10 5 1 1 0\n10 5 2 2 1\n10 10 70 70 20\n0 0 0 0 0",
"output": "1 1 0.564189584 3 1 0.564189584\n1 1 0.797884561 1.644647246 1 0.797884561\nimpossible",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
code_contests | verifiable_code | p01828 M and A | Solve the following coding problem using the programming language python:
Example
Input
acmicpc
tsukuba
Output
No
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
def f(s,t):
j=0;i=0
while i<len(t) and j<len(s):
if t[i]==s[j]:j+=2
i+=1
return j>=len(s)
I=input
s=I()
t=I()
print(['No','Yes'][f(s,t) or f(s[1:],t)])
``` | vfc_30837 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "acmicpc\ntsukuba",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "acmicpc\nttukuba",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | p01963 Separate String | Solve the following coding problem using the programming language python:
You are given a string $t$ and a set $S$ of $N$ different strings. You need to separate $t$ such that each part is included in $S$.
For example, the following 4 separation methods satisfy the condition when $t = abab$ and $S = \\{a, ab, b\\}$.
... | ```python
from collections import defaultdict
import sys
def solve():
readline = sys.stdin.readline
write = sys.stdout.write
mod = 10**9 + 9
base = 37
ca = ord('a')
N = int(readline())
SS = [readline().strip() for i in range(N)]
SS.sort(key = len)
T = readline().strip()
L = len... | vfc_30841 | {
"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": "3\na\nb\nab\nabab",
"output": "4",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | p02250 Multiple String Matching | Solve the following coding problem using the programming language python:
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters... | ```python
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + ... | vfc_30849 | {
"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": "aabaaa\n4\naa\nba\nbb\nxyz",
"output": "1\n1\n0\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabaaa\n4\nab\nba\nbb\nxyz",
"output": "1\n1\n0\n0\n",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | p02398 How Many Divisors? | Solve the following coding problem using the programming language python:
How Many Divisors?
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
Constraints
* 1 ≤ a, b, c ≤ 10000
* a ≤ b
Input
Three integers a, b and c are given in a line separated by a s... | ```python
a, b, c = map(int, input().split())
ans = 0
for i in range(a, b + 1):
if c % i == 0:
ans += 1
print(ans)
``` | vfc_30853 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 14 80",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 14 80",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 4 8... |
code_contests | verifiable_code | cb03 | Solve the following coding problem using the programming language python:
The problem is very simple. For every string given as input, you need to tell us the number of subsequences of it that are palindromes (need not necessarily be distinct). Note that the empty string is not a palindrome.
For example, the palindr... | ```python
T = int(raw_input())
for z in xrange(T):
s = raw_input().strip()
cache = [ [0 for j in xrange(55)] for i in xrange(55) ]
N = len(s)
for l in xrange(N,0,-1):
for i in xrange(N-l+1):
j = i+l
if i == 0 or j == N:
cache[i][j] = 0
... | vfc_30857 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\naab\ndddd\nthisisapalindromeemordnilapasisiht",
"output": "4\n15\n814157",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | crypt05 | Solve the following coding problem using the programming language python:
Problem Statement
A Mathematics professor walked into her class. She wanted to test her students’ abilities and hence, gave them a series:
1,1,2,3,5,8….
And asked them to predict the number at a given position.
Write a program to do exactly tha... | ```python
#! /usr/bin/env python
def genFibo(n):
fibo=list()
fibo.append(1)
fibo.append(1)
for i in range(2,n):
fibo.append(fibo[i-1]+fibo[i-2])
print fibo[n-1]
def main():
sm=0
n=input()
while n:
genFibo(n)
n=input()
if __name__=="__main__":
main()
``` | vfc_30861 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n99\n0",
"output": "5\n218922995834555169026",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n92\n0",
"output": "5\n7540113804746346429\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | guess | Solve the following coding problem using the programming language python:
Alice and Bob, both have to drink water. But they both don't want to go, so they will play a game to decide who will fetch water for both of them. Alice will choose a number randomly between 1 and N (both inclusive) and Bob will choose a number ... | ```python
import fractions as fs
N = input()
A = []
for i in range(N):
t = raw_input().split()
t2=[]
t2.append(int(t[0]))
t2.append(int(t[1]))
A.append(t2)
def getOdd(n,m):
if (n*m)&1 :
return n*m/2
else:
return ((n*m-1)/2)+1
def solve(x):
n = x[0]
m = x[1]
odd = getOdd(n,m)
tot = n*m
c = fs.gcd(od... | vfc_30865 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1\n1 2\n2 3",
"output": "0/1\n1/2\n1/2\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | mes | Solve the following coding problem using the programming language python:
Problem description
One of the Engineer friends of John, Mr. Dev tried to develop an encryption algorithm which can send strings of words wirelessly between two devices connected through Wi-Fi. On completing the design of algorithm, John decides... | ```python
def d(s1,s2):
if len(s1) > len(s2):
s1,s2 = s2,s1
distances = range(len(s1) + 1)
for index2,char2 in enumerate(s2):
newDistances = [index2+1]
for index1,char1 in enumerate(s1):
if char1 == char2:
newDistances.append(distances[index1])
... | vfc_30869 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nHe is a good programmer\nhp is a pool Probgrammer\nProgram\nprpgreamp",
"output": "4\n3",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | reciicha | Solve the following coding problem using the programming language python:
Help Saurabh with his Chemistry Assignment.
Saurabh has been given a chemistry assignment by Ruby Mam. Though the assignment is simple but
Saurabh has to watch India vs Pakistan Match and he has no time to do the assignment by himself.
So Saurab... | ```python
l=[0]*1000003
l[0]=1
for i in range(1,len(l)):
l[i]=i*l[i-1]%1000003
for i in range(input()):
n,x=map(int,raw_input().split())
if n>=1000003:
print "0"
else:
print ((l[n])*x)%1000003
``` | vfc_30873 | {
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n2 1",
"output": "2\n2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | traveler | Solve the following coding problem using the programming language python:
Chef likes to travel very much. He plans some travel routes and wants to know their lengths. He hired you to make these calculations. But be careful, some of the routes are incorrect. There may be some misspelling in city names or there will be ... | ```python
def main():
#read no of cities
n = input()
#read cities
city = raw_input().split()
#read no of routes
m = input()
mapp = {}
#zero out map of routes
for c in city:
mapp[c] = [0]*n
#populate map with available routes by index
while m:
m -= 1
ro... | vfc_30877 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nDonetsk Kiev New-York Miami Hollywood\n9\nDonetsk Kiev 560\nKiev New-York 7507\nNew-York Miami 1764\nMiami Hollywood 28\nHollywood Miami 30\nMiami New-York 1764\nKiev Donetsk 550\nHollywood New-York 1736\nNew-York Hollywood 1738... |
code_contests | verifiable_code | 1016_C. Vasya And The Mushrooms | Solve the following coding problem using the programming language python:
Vasya's house is situated in a forest, and there is a mushroom glade near it. The glade consists of two rows, each of which can be divided into n consecutive cells. For each cell Vasya knows how fast the mushrooms grow in this cell (more formall... | ```python
n = int(input())
u1 = list(map(int, input().split()))
u2 = list(map(int, input().split()))
a1 = u1[:n]
a2 = u2[:n]
for i in range(1, n):
a1[i] += a1[i - 1]
a2[i] += a2[i - 1]
q1 = [0] * (2 * n)
q2 = [0] * (2 * n)
for i in range(1, n):
q1[i] = u1[i] * (i) + q1[i - 1]
q2[i] = u2[i] * (i) + q2[i ... | vfc_30881 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 3\n6 5 4\n",
"output": "70\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1000 10000\n10 100 100000\n",
"output": "543210\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 103_C. Russian Roulette | Solve the following coding problem using the programming language python:
After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now... | ```python
#!/usr/bin/env python3
n, k, p = map(int, input().strip().split())
if k == 0:
ak = 0
an = n
else:
ak = k - 1 if n % 2 == 1 else k
an = n - (n % 2)
ans = ''
for i in range(p):
v = int(input().rstrip())
if k == 0:
print('.', end='')
else:
if v == n:
pri... | vfc_30885 | {
"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 5\n1\n2\n3\n4\n5\n",
"output": "...XX\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 3 6\n1\n2\n3\n4\n5\n6\n",
"output": ".X.X.X\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1084_C. The Fair Nut and String | Solve the following coding problem using the programming language python:
The Fair Nut found a string s. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences p_1, p_2, …, p_k, such that:
1. For each i (1 ≤ i ≤ k), s_{p_i} = 'a'.
... | ```python
s=input()
sss=''
for i in s:
if i in ['a','b']:
sss+=i
from itertools import groupby
xxx=[''.join(g) for _, g in groupby(sss)]
xxx=[len(i)+1 for i in xxx if 'a' in i]
ans=1
if len(xxx)==1:
print((xxx[0]-1)%1000000007)
else:
for i in xxx:
ans*=i
print((ans-1)%1000000007)
``... | vfc_30893 | {
"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": "agaa\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "baaaa\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abba... |
code_contests | verifiable_code | 1103_E. Radix sum | Solve the following coding problem using the programming language python:
Let's define radix sum of number a consisting of digits a_1, … ,a_k and number b consisting of digits b_1, … ,b_k(we add leading zeroes to the shorter number to match longer length) as number s(a,b) consisting of digits (a_1+b_1)mod 10, … ,(a_k+... | vfc_30897 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 6\n",
"output": "1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n5 7 5 7\n",
"output": "16\n0\n64\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... | |
code_contests | verifiable_code | 1131_E. String Multiplication | Solve the following coding problem using the programming language python:
Roman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string multiplication. According t... | ```python
ALPH = 'abcdefghijklmnopqrstuvwxyz'
MAX = 10 ** 9
def cnt(s):
c = {ch : 0 for ch in ALPH}
i = 0
while i < len(s):
j = i + 1
while j < len(s) and s[i] == s[j]:
j += 1
c[s[i]] = max(c[s[i]], j - i)
i = j
return c
def nxt(c, t):
nc = cnt(t)
fo... | vfc_30901 | {
"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\nbnn\na\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\na\nb\na\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
code_contests | verifiable_code | 1152_A. Neko Finds Grapes | Solve the following coding problem using the programming language python:
On a random day, Neko found n treasure chests and m keys. The i-th chest has an integer a_i written on it and the j-th key has an integer b_j on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as... | ```python
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aeven = 0
aodd = 0
beven = 0
bodd = 0
for i in range(n):
if a[i] % 2 == 0:
aeven += 1
else:
aodd += 1
for i in range(m):
if b[i] % 2 == 0:
beven += 1
else:
... | vfc_30905 | {
"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": "5 1\n2 4 6 8 10\n5\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1173_E2. Nauuo and Pictures (hard version) | Solve the following coding problem using the programming language python:
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exac... | vfc_30909 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n0 1 1\n4 3 5\n",
"output": "160955686\n185138929\n974061117\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2\n1\n1\n",
"output": "3\n",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | 1191_C. Tokitsukaze and Discard Items | Solve the following coding problem using the programming language python:
Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1 ≤ m ≤ n) special items of them.
These n items are marked wi... | ```python
from collections import deque
n,m,k=list(map(int,input().split()))
arr=list(map(int,input().split()))
d=deque()
for i in arr:
d.append(i)
chances=curr=tot=0
# print("WORKING")
while tot<m:
# print("S")
if (d[0]-curr)%k==0:
p=(d[0]-curr)//k
else:p=((d[0]-curr)//k)+1
temp=curr
w... | vfc_30913 | {
"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": "13 4 5\n7 8 9 10\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4 5\n3 5 7 10\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... |
code_contests | verifiable_code | 120_C. Winnie-the-Pooh and honey | Solve the following coding problem using the programming language python:
As we all know, Winnie-the-Pooh just adores honey. Ones he and the Piglet found out that the Rabbit has recently gotten hold of an impressive amount of this sweet and healthy snack. As you may guess, Winnie and the Piglet asked to come at the Ra... | vfc_30917 | {
"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 3\n15 8 10\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 1\n85 75 55 65 39 26 47 16 9 11 3 4 70 23 56 64 36 34 16 13 18 28 32 80 8 79 76 4 21 75 93 51 85 86 100 88... | |
code_contests | verifiable_code | 1230_A. Dawid and Bags of Candies | Solve the following coding problem using the programming language python:
Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amoun... | ```python
list1 = list(map(int, input().split()))
list1.sort()
if list1[0] + list1[3] == list1[1] + list1[2]:
print("YES")
elif list1[0] + list1[2] +list1[1] == list1[3]:
print("YES")
else:
print("NO")
``` | vfc_30921 | {
"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 7 11 5\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 3 2 5\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | 1251_E1. Voting (Easy Version) | Solve the following coding problem using the programming language python:
The only difference between easy and hard versions is constraints.
Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.
There are n voters, and two ways to convince each of them to vote... | ```python
import sys
from heapq import *
#sys.stdin = open('in', 'r')
t = int(input())
for ti in range(t):
n = int(input())
a = []
for i in range(n):
mi, pi = map(int, input().split())
a.append((mi, -pi))
a.sort()
c = 0
h = []
res = 0
for i in reversed(range(n)):
... | vfc_30925 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1 5\n2 10\n2 8\n7\n0 1\n3 1\n1 1\n6 1\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 8\n2 7\n4 4\n5 5\n",
"output": "8\n0\n7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3\n1 5\n2 10\n2 4\n7\n... |
code_contests | verifiable_code | 1271_C. Shawarma Tent | Solve the following coding problem using the programming language python:
The map of the capital of Berland can be viewed on the infinite coordinate plane. Each point with integer coordinates contains a building, and there are streets connecting every building to four neighbouring buildings. All streets are parallel t... | ```python
n,x,y=map(int,input().split())
lu=0
ld=0
ru=0
rd=0
u=0
d=0
l=0
r=0
for i in range(n):
a,b=map(int,input().split())
if(a<x and b<y):
ld+=1
elif(a<x and b>y):
lu+=1
elif(a==x and b!=y):
if(b>y):
u+=1
else:
d+=1
elif(a>x and b<y):
... | vfc_30929 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 10 12\n5 6\n20 23\n15 4\n16 5\n4 54\n12 1\n4 15\n",
"output": "4\n11 12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3 2\n1 3\n4 2\n5 1\n4 1\n",
"output": "3\n4 2",
"type"... |
code_contests | verifiable_code | 1294_D. MEX maximizing | Solve the following coding problem using the programming language python:
Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:
* for the array [0, 0, 1, 0, 2] MEX equals to 3 because numbers 0, 1 and 2 are presented in the array and 3 is the minimum non-negative... | ```python
import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf,gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit
def main():
q, x = m... | vfc_30933 | {
"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": "4 3\n1\n2\n1\n2\n",
"output": "0\n0\n0\n0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1315_D. Recommendations | Solve the following coding problem using the programming language python:
VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.
The latest A/B t... | ```python
# Код программы написал на языке Python 3
import sys
from heapq import heappush, heappop
def main():
n = int(sys.stdin.readline())
h = sorted(list(zip([int(i) for i in sys.stdin.readline().split()], [int(i) for i in sys.stdin.readline().split()])))
z, w, o, res = [], 0, 0, 0
while o... | vfc_30937 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 7 9 7 8\n5 2 5 7 5\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n1 1 1 1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1336_F. Journey | Solve the following coding problem using the programming language python:
In the wilds far beyond lies the Land of Sacredness, which can be viewed as a tree — connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n.
There are m travelers attracted by its prosperity and beau... | vfc_30941 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "13 8 3\n7 6\n9 11\n5 6\n11 3\n9 7\n2 12\n4 3\n1 2\n5 8\n6 13\n5 10\n3 1\n10 4\n10 11\n8 11\n4 9\n2 5\n3 5\n7 3\n8 10\n",
"output": "14",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 4 1\n... | |
code_contests | verifiable_code | 1359_D. Yet Another Yet Another Task | Solve the following coding problem using the programming language python:
Alice and Bob are playing yet another card game. This time the rules are the following. There are n cards lying in a row in front of them. The i-th card has value a_i.
First, Alice chooses a non-empty consecutive segment of cards [l; r] (l ≤ r... | ```python
import math
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(31):
s = 0
for j in a:
if j <= i:
s = max(0, s + j)
else:
s = 0
ans = max(ans, s - i)
print(ans)
``` | vfc_30945 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n-10 6 -15\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n5 2 5 3 -30 -30 6 9\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": ... |
code_contests | verifiable_code | 1379_F1. Chess Strikes Back (easy version) | Solve the following coding problem using the programming language python:
Note that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if all versions are solved.
Ildar and Ivan are tired of chess, but t... | vfc_30949 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 3 3\n1 1\n1 5\n2 4\n",
"output": "YES\nYES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 7\n4 2\n6 4\n1 3\n2 2\n2 4\n4 4\n3 1\n",
"output": "YES\nYES\nNO\nNO\nNO\nNO\nNO\... | |
code_contests | verifiable_code | 139_D. Digits Permutations | Solve the following coding problem using the programming language python:
Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.
Then Andrey got bored from looking at the same number and he started to swap digits firs... | ```python
import itertools
def countZeroes(s):
ret = 0
for i in s:
if i != '0':
break
ret += 1
return ret
def stupid(n):
ansMax = 0
bn1 = n
bn2 = n
for n1 in itertools.permutations(n):
for n2 in itertools.permutations(n):
val = str(int(''.joi... | vfc_30953 | {
"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": "500\n",
"output": "500\n500",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "198\n",
"output": "981\n819",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
code_contests | verifiable_code | 1423_H. Virus | Solve the following coding problem using the programming language python:
In Bubbleland a group of special programming forces gets a top secret job to calculate the number of potentially infected people by a new unknown virus. The state has a population of n people and every day there is new information about new cont... | vfc_30957 | {
"difficulty": "14",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 25 2\n1 9 3\n2 5\n1 1 3\n1 3 1\n2 2\n1 8 3\n1 5 6\n3\n1 9 2\n1 8 3\n2 9\n1 3 1\n2 5\n1 6 4\n3\n3\n2 4\n3\n1 10 9\n1 1 7\n3\n2 2\n3\n1 5 6\n1 1 4\n",
"output": "1\n1\n5\n2\n1\n1\n",
"type": "stdin_stdout"
},
{... | |
code_contests | verifiable_code | 1443_A. Kids Seating | Solve the following coding problem using the programming language python:
Today the kindergarten has a new group of n kids who need to be seated at the dinner table. The chairs at the table are numbered from 1 to 4n. Two kids can't sit on the same chair. It is known that two kids who sit on chairs with numbers a and b... | ```python
# cook your dish here
for _ in range(int(input())):
n=int(input())
s=4*n-2
for i in range(n):
print(s,end=" ")
s-=2
print()
``` | vfc_30961 | {
"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\n2\n3\n4\n",
"output": "8 6\n12 10 8\n16 14 12 10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2\n3\n4\n",
"output": "8 6\n12 10 8\n16 14 12 10\n",
"type": "stdin_stdou... |
code_contests | verifiable_code | 1515_I. Phoenix and Diamonds | Solve the following coding problem using the programming language python:
Phoenix wonders what it is like to rob diamonds from a jewelry store!
There are n types of diamonds. The i-th type has weight w_i and value v_i. The store initially has a_i diamonds of the i-th type.
Each day, for q days, one of the following ... | vfc_30973 | {
"difficulty": "15",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n2 3 4\n1 5 1\n0 2 4\n3 6\n1 3 3\n3 10\n2 2 3\n3 30\n",
"output": "\n8\n16\n13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 8\n2 15 400\n1 13 100\n3 26\n3 27\n3 28\n3 29\n3 30\n3 ... | |
code_contests | verifiable_code | 171_C. A Piece of Cake | Solve the following coding problem using the programming language python:
How to make a cake you'll never eat.
Ingredients.
* 2 carrots
* 0 calories
* 100 g chocolate spread
* 1 pack of flour
* 1 egg
Method.
1. Put calories into the mixing bowl.
2. Take carrots from refrigerator.
3. Chop carrot... | ```python
a = input().split()
s = 0
for i in range(int(a[0])):
s += (i + 1) * int(a[i + 1])
print(s)
``` | vfc_30981 | {
"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 1 2 3 4\n",
"output": "30",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 191_A. Dynasty Puzzles | Solve the following coding problem using the programming language python:
The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of thei... | ```python
from sys import stdin, stdout
fst = 97
sze = 26
values = [[0 for i in range(sze)] for j in range(sze)]
n = int(stdin.readline())
challengers = []
for i in range(n):
s = stdin.readline().strip()
challengers.append((ord(s[0]) - fst, ord(s[-1]) - fst))
for i in range(sze):
if values[i... | vfc_30985 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nvvp\nvvp\ndam\nvvp\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 215_A. Bicycle Chain | Solve the following coding problem using the programming language python:
Vasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.
We know that the i-th star on t... | ```python
n = int(input())
a = list(map(int,input().split()))
m = int(input())
b = list(map(int,input().split()))
count = []
for i in range(n):
for j in range(m):
if((b[j]/a[i])==int(b[j]/a[i])):
count.append(int(b[j]/a[i]))
o = max(count)
print(count.count(o))
``` | vfc_30989 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 2 3 4\n5\n10 11 12 13 14\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 5\n3\n12 13 15\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 239_A. Two Bags of Potatoes | Solve the following coding problem using the programming language python:
Valera had two bags of potatoes, the first of these bags contains x (x ≥ 1) potatoes, and the second — y (y ≥ 1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains x potatoes) Valera lost. Valera remembers that the ... | ```python
"""
author - Sayan Bose
Brooklyn 99 is love!
"""
y, k, n = map(int, input().split())
if n-y == 0:
print(-1)
else:
y1 = y
res = []
f, f1 = 0, 0
while y <= n:
if not y%k:
f = 1
if y-y1:
f1 = 1
print(y-y1, end = ' ')
if not f:
temp = y//k + 1
y = k * temp
else:
y += k
... | vfc_30993 | {
"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": "10 6 40\n",
"output": "2 8 14 20 26\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1 10\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 263_D. Cycle in Graph | Solve the following coding problem using the programming language python:
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is to f... | ```python
n, m, k = map(int, input().split())
d = {}
for _ in range(m):
u, v = map(int, input().split())
if u not in d:
d[u] = [v]
else:
d[u].append(v)
if v not in d:
d[v] = [u]
else:
d[v].append(u)
# print(d)
stack = []
not_visited = set(range(1, n+1))
while not_v... | vfc_30997 | {
"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": "4 6 3\n4 3\n1 2\n1 3\n1 4\n2 3\n2 4\n",
"output": "4\n1 2 3 4 ",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 287_D. Shifting | Solve the following coding problem using the programming language python:
John Doe has found the beautiful permutation formula.
Let's take permutation p = p1, p2, ..., pn. Let's define transformation f of this permutation:
<image>
where k (k > 1) is an integer, the transformation parameter, r is such maximum integ... | vfc_31001 | {
"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": "4\n",
"output": "4 2 3 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "2 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3... | |
code_contests | verifiable_code | 312_D. Cats Transport | Solve the following coding problem using the programming language python:
Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance between hill i and (i - 1) is di meters. Th... | vfc_31005 | {
"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": "4 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 10\n2 10\n3 12\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 6 2\n1 3 5\n1 0\n2 1\n4 4\n1 10\n2 10\n3 12\n",
"output": "8\n",
... | |
code_contests | verifiable_code | 335_B. Palindrome | Solve the following coding problem using the programming language python:
Given a string s, determine if it contains any palindrome of length exactly 100 as a subsequence. If it has any, print any one of them. If it doesn't have any, print a palindrome that is a subsequence of s and is as long as possible.
Input
The... | ```python
def p2(a):
n = len(a)
last = [[0] * 26 for _ in range(n)]
last[0][ord(a[0])-97] = 0
for i in range(1, n):
for j in range(26):
last[i][j] = last[i-1][j]
last[i][ord(a[i])-97] = i
dp = [''] * n
for i in range(n-1, -1, -1):
for j in range(n-1, i, -1):
k = last[j][ord(a[i])-9... | vfc_31009 | {
"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": "rquwmzexectvnbanemsmdufrg\n",
"output": "rumenanemur",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bbbabcbbb\n",
"output": "bbbcbbb",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 358_B. Dima and Text Messages | Solve the following coding problem using the programming language python:
Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to ... | ```python
def werify_message(words, message):
true_message = ''.join(['<3', '<3'.join(words), '<3'])
# index in true_message
i = 0
for litera in message:
if len(true_message) != i:
if litera == true_message[i]:
i += 1
else:
# Дошли до конца исходн... | vfc_31013 | {
"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": "7\ni\nam\nnot\nmain\nin\nthe\nfamily\n<3i<>3am<3the<3<main<3in<3the<3><3family<3\n",
"output": "no\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\ni\... |
code_contests | verifiable_code | 381_A. Sereja and Dima | Solve the following coding problem using the programming language python:
Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can t... | ```python
n = int(input(""))
cards=list(map(int,input().split()))
sereja = 0
dima = 0
temp = 0
turn = 1
while cards != []:
nMax=max(cards[0],cards[-1])
if turn==1:
temp = sereja + nMax
sereja+=nMax
turn=2
else:
temp = dima + nMax
dima+=nMax
turn=1
... | vfc_31017 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n1 2 3 4 5 6 7\n",
"output": "16 12\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 401_E. Olympic Games | Solve the following coding problem using the programming language python:
This problem was deleted from the contest, because it was used previously at another competition.
Input
Output
Examples
Input
1 1
1 2 100
Output
6
The input will be given via stdin and the output should be printed to stdout by your code... | vfc_31021 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n1 2 100\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 42_A. Guilty — to the kitchen! | Solve the following coding problem using the programming language python:
It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills.
According to the ... | ```python
n,v=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
mini=10**9
for i in range(n):
mini=min(mini,b[i]/a[i])
sm=0
for i in range(n):
sm=sm+mini*a[i]
print(min(sm,v))
``` | vfc_31025 | {
"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": "1 100\n1\n40\n",
"output": "40.0000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 100\n1 1\n60 60\n",
"output": "100.0000",
"type": "stdin_stdout"
},
{
"fn_name... |
code_contests | verifiable_code | 451_D. Count Good Substrings | Solve the following coding problem using the programming language python:
We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after the merging step it will become "aba".
Given a string, you have to find two values:
... | ```python
s = input()
blocks = []
evenA = [0]
oddA = [0]
evenB = [0]
oddB = [0]
even = True
for x in s:
evenA.append(evenA[-1])
oddA.append(oddA[-1])
evenB.append(evenB[-1])
oddB.append(oddB[-1])
if x == 'a':
if even:
evenA[-1] += 1
else:
oddA[-1] += 1
... | vfc_31029 | {
"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": "babaa\n",
"output": "2 7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bb\n",
"output": "1 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ba... |
code_contests | verifiable_code | 474_C. Captain Marmot | Solve the following coding problem using the programming language python:
Captain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this battle he has n regiments, each consisting of 4 moles.
Initially, each mole i (1 ≤ i ≤ 4n) is placed at some position (xi, yi) in the Cartesi... | ```python
#a+b-y
#x+b-a
#1 -
import sys
input=sys.stdin.readline
def distSq(p1,p2):
return (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1])
def isSquare(p1, p2, p3, p4):
d2 = distSq(p1, p2) # from p1 to p2
d3 = distSq(p1, p3) # from p1 to p3
d4 = distSq(p1, p4) # from p1 to p4
#... | vfc_31033 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1 0 0\n-1 1 0 0\n-1 1 0 0\n1 -1 0 0\n1 1 0 0\n-2 1 0 0\n-1 1 0 0\n1 -1 0 0\n1 1 0 0\n-1 1 0 0\n-1 1 0 0\n-1 1 0 0\n2 2 0 1\n-1 0 0 -2\n3 0 0 -2\n-1 1 -2 0\n",
"output": "1\n-1\n3\n3\n",
"type": "stdin_stdout"
}... |
code_contests | verifiable_code | 521_C. Pluses everywhere | Solve the following coding problem using the programming language python:
Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses ("+") in the line between certain digits in the... | ```python
n, k = map(int, input().split())
t = list(map(int, input()))
p, d = 1, 10 ** 9 + 7
s, f = 0, [1] * n
for i in range(2, n): f[i] = (i * f[i - 1]) % d
c = lambda a, b: 0 if a > b else (f[b] * pow(f[a] * f[b - a], d - 2, d)) % d
if k:
u = [0] * (n + 1)
p = [1] * (n + 1)
for i in range(n):
... | vfc_31041 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 1\n108\n",
"output": "27\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n108\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
code_contests | verifiable_code | 548_E. Mike and Foam | Solve the following coding problem using the programming language python:
Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's numbered from 1 to n. i-th kind of beer has ai milliliters of foam on it.
<image>
Maxim is Mike's boss. Today he told M... | vfc_31045 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 6\n1 2 3 4 6\n1\n2\n3\n4\n5\n1\n",
"output": "0\n1\n3\n5\n6\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 10\n1 1 1 1 1\n1\n2\n3\n4\n5\n5\n4\n3\n2\n1\n",
"output": "0\n1\n3\... | |
code_contests | verifiable_code | 575_B. Bribes | Solve the following coding problem using the programming language python:
Ruritania is a country with a very badly maintained road network, which is not exactly good news for lorry drivers that constantly have to do deliveries. In fact, when roads are maintained, they become one-way. It turns out that it is sometimes ... | vfc_31049 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 0\n2 3 0\n5 1 1\n3 4 1\n5\n5 4 5 2 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 1\n3 2 0\n2 4 0\n10\n3 4 1 3 1 4 2 3 1 4\n",
"output": "7\n",
... | |
code_contests | verifiable_code | 618_B. Guess the Permutation | Solve the following coding problem using the programming language python:
Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as pi. For all pairs of distinct integers i, j between 1 and n, he wrote the number ai, j = min(pi, pj). He writes ai, i = 0 for a... | ```python
# from pprint import pprint
n = int(input())
a = []
for i in range(n):
row = [int(k) for k in input().split()]
a.append(row)
result = [0] * n
for k in range(1, n):
# print('k=', k)
for i in range(n):
countK = 0
countNonK = 0
for j in range(n):
if a[i][j] =... | vfc_31057 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0 1\n1 0\n",
"output": "1 2 ",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 638_D. Three-dimensional Turtle Super Computer | Solve the following coding problem using the programming language python:
A super computer has been built in the Turtle Academy of Sciences. The computer consists of n·m·k CPUs. The architecture was the paralellepiped of size n × m × k, split into 1 × 1 × 1 cells, each cell contains exactly one CPU. Thus, each CPU can... | ```python
def main():
s = input().split()
n, m, k = int(s[0]), int(s[1]), int(s[2])
processor = []
for x in range(n):
for y in range(m):
s = input()
for z in s:
processor.append(int(z) == 1)
if x < n - 1:
emptyLine = input()
counter... | vfc_31061 | {
"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": "1 1 10\n0101010101\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 690_A1. Collective Mindsets (easy) | Solve the following coding problem using the programming language python:
Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she ... | ```python
n = int(input())
print(n // 2 + n % 2)
``` | vfc_31069 | {
"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": "4\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000\... |
code_contests | verifiable_code | 712_D. Memory and Scores | Solve the following coding problem using the programming language python:
Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer a... | ```python
mod=10**9+7
f=[0]*500000
def POW(a,b):
if(b==0):
return 1
if(b&1):
return POW(a,b//2)**2*a%mod
else:
return POW(a,b//2)**2
def C(n,m):
if(m>n):
return 0
t=f[n]*POW(f[m],mod-2)%mod*POW(f[n-m],mod-2)%mod
return t
f[0]=1
for i in range(1,500000):
f[i]=f[i-1]*i%mod
a,b,k,t=map(int,input().split... | vfc_31073 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2 2 1\n",
"output": " 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 1 2\n",
"output": " ... |
code_contests | verifiable_code | 733_C. Epidemic in Monstropolis | Solve the following coding problem using the programming language python:
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.
Soon, monsters became hungry and began to eat each other.
One monster can eat ot... | ```python
def main():
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
sum1, sum2 = 0, 0
for i in a:
sum1 += i
for i in b:
sum2 += i
# validar que podemos obtener solucion
if sum1 != sum2:
print('NO')
... | vfc_31077 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 1 1 3 3\n3\n2 1 6\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 2 2 2 1 2\n2\n5 5\n",
"output": "YES\n2 L\n1 R\n2 R\n2 R\n",
"type": "stdin_stdout... |
code_contests | verifiable_code | 757_D. Felicity's Big Secret Revealed | Solve the following coding problem using the programming language python:
The gym leaders were fascinated by the evolutions which took place at Felicity camp. So, they were curious to know about the secret behind evolving Pokemon.
The organizers of the camp gave the gym leaders a PokeBlock, a sequence of n ingredien... | ```python
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys, math, random, operator
MOD = 10**9 + 7
INF = 10**9
pr = lambda *args: sys.stdout.write(" ".join(str(x) for x in args) + "\n")
epr = lambda *args: sys.stderr.write(" ".join(str(x) for x in args) + "\n")
die = lambda *args: pr(*args) ^ exit(0)
read_str... | vfc_31081 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1011\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n10\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.