source stringclasses 1
value | task_type stringclasses 1
value | in_source_id stringlengths 1 4 | problem stringlengths 488 6.07k | gold_standard_solution stringlengths 19 30.1k | verification_info dict | metadata dict | problem_id stringlengths 5 9 |
|---|---|---|---|---|---|---|---|
apps | verifiable_code | 74 | Solve the following coding problem using the programming language python:
Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.
More formally, you are given an odd num... | ```python
import math
n=int(input())
def prime(p):
if p == 1:
return False
fl=True
for i in range(2,math.ceil(p**0.5) + 1):
if p % i == 0:
fl=False
return fl
def sum_of_primes(k):
fl=True
for i in range((k // 2) + 1):
if prime(i) and prime(k-i):
... | {
"language": "python",
"test_cases": [
{
"input": "27\n",
"output": "3\n2 2 23",
"type": "stdin_stdout"
},
{
"input": "3\n",
"output": "1\n3",
"type": "stdin_stdout"
},
{
"input": "25\n",
"output": "2\n2 23",
"type": "stdin_stdout"
},
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/584/D"
} | vfc_10050 |
apps | verifiable_code | 75 | Solve the following coding problem using the programming language python:
You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").
You have one bomb. If you lay the bomb at the cell (x, y), then after tri... | ```python
n, m = list(map(int, input().split()))
p = []
ans = 0
for i in range(n):
s = input()
ans += s.count('*')
p.append(s)
dp = []
for i in range(n):
dp.append([0] * m)
for i in range(n):
col = p[i].count('*')
for t in range(m):
dp[i][t] = col
for i in range(m):
col = 0
for t... | {
"language": "python",
"test_cases": [
{
"input": "3 4\n.*..\n....\n.*..\n",
"output": "YES\n1 2\n",
"type": "stdin_stdout"
},
{
"input": "3 3\n..*\n.*.\n*..\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "6 5\n..*..\n..*..\n*****\n..*..\n..... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/699/B"
} | vfc_10054 |
apps | verifiable_code | 76 | Solve the following coding problem using the programming language python:
Berland Football Cup starts really soon! Commentators from all over the world come to the event.
Organizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation should get the same number of t... | ```python
n, m, a, b = list(map(int, input().split()))
k = n%m
print(min(k*b, (m - k)*a))
``` | {
"language": "python",
"test_cases": [
{
"input": "9 7 3 8\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"input": "2 7 3 7\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"input": "30 6 17 19\n",
"output": "0\n",
"type": "stdin_stdout"... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/990/A"
} | vfc_10058 |
apps | verifiable_code | 78 | Solve the following coding problem using the programming language python:
The only difference between easy and hard versions is constraints.
Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in e... | ```python
from math import factorial
def lol(n):
if n == 1:
yield [0]
yield [1]
else:
for p in lol(n - 1):
p.append(0)
yield p
p[-1] = 1
yield p
p.pop()
def sp(g1, g2, g3, f):
if g1 == 0:
if g2 == g3:
... | {
"language": "python",
"test_cases": [
{
"input": "3 3\n1 1\n1 2\n1 3\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"input": "3 3\n1 1\n1 1\n1 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "4 10\n5 3\n2 1\n3 2\n5 1\n",
"output": "... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1185/G1"
} | vfc_10066 |
apps | verifiable_code | 79 | Solve the following coding problem using the programming language python:
Vivek initially has an empty array $a$ and some integer constant $m$.
He performs the following algorithm: Select a random integer $x$ uniformly in range from $1$ to $m$ and append it to the end of $a$. Compute the greatest common divisor of ... | ```python
big = 100010
def gen_mu():
mu = [1]*big
mu[0] = 0
P = [True]*big
P[0] = P[1] = False
for i in range(2,big):
if P[i]:
j = i
while j<big:
P[j] = False
mu[j] *= -1
j += i
j = i*i
while j<bi... | {
"language": "python",
"test_cases": [
{
"input": "1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "4\n",
"output": "333333338\n",
"type": "stdin_stdout"
},
{
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1139/D"
} | vfc_10070 |
apps | verifiable_code | 81 | Solve the following coding problem using the programming language python:
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.
Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ an... | ```python
from math import gcd
a, b = list(map(int, input().split()))
if b < a:
a, b = b, a
if a == b:
print(0)
return
c = b - a
i = 1
ans = a * b // gcd(a, b)
def get(x):
A = (a + x - 1) // x * x
B = A - a + b
return A * B // gcd(A, B), A
r = 0
while i * i <= c:
if c % i == 0:
A, ... | {
"language": "python",
"test_cases": [
{
"input": "6 10\n",
"output": "2",
"type": "stdin_stdout"
},
{
"input": "21 31\n",
"output": "9",
"type": "stdin_stdout"
},
{
"input": "5 10\n",
"output": "0",
"type": "stdin_stdout"
},
{
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1152/C"
} | vfc_10078 |
apps | verifiable_code | 82 | Solve the following coding problem using the programming language python:
Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.
In school, where Noora is... | ```python
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
ans = 0
c = k - 0.5
while s / n < c:
s += k
n += 1
ans += 1
print(ans)
``` | {
"language": "python",
"test_cases": [
{
"input": "2 10\n8 9\n",
"output": "4",
"type": "stdin_stdout"
},
{
"input": "3 5\n4 4 4\n",
"output": "3",
"type": "stdin_stdout"
},
{
"input": "3 10\n10 8 9\n",
"output": "3",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/810/A"
} | vfc_10082 |
apps | verifiable_code | 83 | Solve the following coding problem using the programming language python:
You are given an array of $n$ integers: $a_1, a_2, \ldots, a_n$. Your task is to find some non-zero integer $d$ ($-10^3 \leq d \leq 10^3$) such that, after each number in the array is divided by $d$, the number of positive numbers that are prese... | ```python
n=int(input())
ar=list(map(int,input().split()))
pos=0
neg=0
for a in ar:
if(a>0):pos+=1
elif a<0:neg+=1
if(pos*2>=n):
print(1)
elif neg*2>=n:
print(-1)
else:
print(0)
``` | {
"language": "python",
"test_cases": [
{
"input": "5\n10 0 -7 2 6\n",
"output": "1",
"type": "stdin_stdout"
},
{
"input": "7\n0 0 1 -1 0 0 2\n",
"output": "0",
"type": "stdin_stdout"
},
{
"input": "5\n0 0 0 1 1\n",
"output": "0",
"type": "st... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1130/A"
} | vfc_10086 |
apps | verifiable_code | 84 | Solve the following coding problem using the programming language python:
There are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs.
Visitors ar... | ```python
from sys import stdin as cin
from sys import stdout as cout
def main():
n = int(cin.readline())
o = 0
for x in range(9, 0, -1):
if 10 ** x // 2 <= n:
##print(x)
for i in range(9):
q = 10 ** x * (i + 1) // 2 - 1
if q <= n:
... | {
"language": "python",
"test_cases": [
{
"input": "7\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"input": "14\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"input": "50\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/899/D"
} | vfc_10090 |
apps | verifiable_code | 85 | Solve the following coding problem using the programming language python:
Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a_1 × b_1 segments large and the second one is a_2 × b_2 segments large.
Polycarpus wants to ... | ```python
a,b=list(map(int,input().split()))
c,d=list(map(int,input().split()))
e=a*b
f=c*d
n=0
while e%2==0:e=e//2
while e%3==0:e=e//3
while f%2==0:f=f//2
while f%3==0:f=f//3
if e!=f:print("-1")
else:
i=0
j=0
e=a*b
f=c*d
while e%3==0:
e=e//3
i+=1
while f%3==0:
f=f//3
j+=1
k... | {
"language": "python",
"test_cases": [
{
"input": "2 6\n2 3\n",
"output": "1\n1 6\n2 3\n",
"type": "stdin_stdout"
},
{
"input": "36 5\n10 16\n",
"output": "3\n16 5\n5 16\n",
"type": "stdin_stdout"
},
{
"input": "3 5\n2 1\n",
"output": "-1\n",
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/490/D"
} | vfc_10094 |
apps | verifiable_code | 86 | Solve the following coding problem using the programming language python:
Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1... | ```python
a, b, x, y = map(int, input().split())
if a >= x:
if b >= y:
print('Vasiliy')
else:
z = y - b
t = max(x - z, 0)
if a - z <= t:
print('Polycarp')
else:
print('Vasiliy')
else:
if b <= y:
print('Polycarp')
else:
z = x... | {
"language": "python",
"test_cases": [
{
"input": "2 1 2 2\n",
"output": "Polycarp\n",
"type": "stdin_stdout"
},
{
"input": "4 7 7 4\n",
"output": "Vasiliy\n",
"type": "stdin_stdout"
},
{
"input": "20 0 7 22\n",
"output": "Polycarp\n",
"type... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/532/C"
} | vfc_10098 |
apps | verifiable_code | 87 | Solve the following coding problem using the programming language python:
Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a... | ```python
import sys
arr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ctr = 1
for i in range(arr[a] - 1):
b += 1
if (b == 7):
b = 0
ctr += 1
print(ctr)
``` | {
"language": "python",
"test_cases": [
{
"input": "1 7\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"input": "1 1\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"input": "11 6\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/760/A"
} | vfc_10102 |
apps | verifiable_code | 88 | Solve the following coding problem using the programming language python:
The year 2015 is almost over.
Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 2015_10 = 11111011111_2. Note that he... | ```python
def zero(strx):
k = []
str2 = list(strx)
for i in range(1, len(str2)):
str3 = str2[:]
str3[i] = '0'
k.append(''.join(str3))
return k
a = []
for i in range(1, 64):
a += zero('1'*i)
ct = 0
x, y = list(map(int, input().split(' ')))
for i in a:
if x <= int(i, 2) <=... | {
"language": "python",
"test_cases": [
{
"input": "5 10\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "2015 2015\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "100 105\n",
"output": "0\n",
"type": "stdin_stdout"
}... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/611/B"
} | vfc_10106 |
apps | verifiable_code | 89 | Solve the following coding problem using the programming language python:
You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be $\frac{n(n + 1)}{2}$ of them.
You want to draw these segments in sever... | ```python
n=int(input())
print(max((i+1)*(n-i)for i in range(n)))
``` | {
"language": "python",
"test_cases": [
{
"input": "2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "3\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"input": "4\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"in... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/909/B"
} | vfc_10110 |
apps | verifiable_code | 90 | Solve the following coding problem using the programming language python:
Anya loves to fold and stick. Today she decided to do just that.
Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that th... | ```python
fact = [ 1 ]
for i in range( 1, 20, 1 ):
fact.append( fact[ i - 1 ] * i )
from collections import defaultdict
N, K, S = list(map( int, input().split() ))
A = list( map( int, input().split() ) )
ldp = [ [ defaultdict( int ) for i in range( K + 1 ) ] for j in range( 2 ) ]
ldp[ 0 ][ 0 ][ 0 ] = 1
for i in ra... | {
"language": "python",
"test_cases": [
{
"input": "2 2 30\n4 3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "2 2 7\n4 3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "3 1 1\n1 1 1\n",
"output": "6\n",
"type": "stdin_... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/525/E"
} | vfc_10114 |
apps | verifiable_code | 91 | Solve the following coding problem using the programming language python:
Suppose you are performing the following algorithm. There is an array $v_1, v_2, \dots, v_n$ filled with zeroes at start. The following operation is applied to the array several times — at $i$-th step ($0$-indexed) you can: either choose posit... | ```python
t = int(input())
for _ in range(t):
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(60, -1, -1):
m = k ** i
for j in range(n):
if a[j] >= m:
a[j] -= m
break
if all(i == 0 for i in a):
pri... | {
"language": "python",
"test_cases": [
{
"input": "5\n4 100\n0 0 0 0\n1 2\n1\n3 4\n1 4 1\n3 2\n0 1 3\n3 9\n0 59049 810\n",
"output": "YES\nYES\nNO\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"input": "3\n5 2\n1 2 4 8 17\n2 3\n1 2\n4 3\n10 4 13 12\n",
"output": "NO\nNO\nNO\n",... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1312/C"
} | vfc_10118 |
apps | verifiable_code | 92 | Solve the following coding problem using the programming language python:
Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:
$\sum_{i = 1}^{a} \sum_{j = 1}^{b} \sum_{k = 1}^{c} d(i \cdot j \cdot k)$
Find the sum m... | ```python
a, b, c = map(int, input().split())
d = 1073741824
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
t = [{} for i in range(101)]
ans = {}
for i in p:
j = i
m = 1
while j < 101:
for k in range(j, 101, j):
t[k][i] = m
j ... | {
"language": "python",
"test_cases": [
{
"input": "2 2 2\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"input": "5 6 7\n",
"output": "1520\n",
"type": "stdin_stdout"
},
{
"input": "91 42 25\n",
"output": "3076687\n",
"type": "stdin_stdou... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/236/B"
} | vfc_10122 |
apps | verifiable_code | 93 | Solve the following coding problem using the programming language python:
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 × 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a mo... | ```python
a, b, c, d = input(), input(), input(), input()
a = a + b[::-1]
x = "X"
for i in range(4):
if a[i] == x:
a = a[:i] + a[i + 1:]
break
c = c + d[::-1]
for i in range(4):
if c[i] == x:
c = c[:i] + c[i + 1:]
break
flag = False
for i in range(4):
if a == c:
flag... | {
"language": "python",
"test_cases": [
{
"input": "AB\nXC\nXB\nAC\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "AB\nXC\nAC\nBX\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "XC\nBA\nCB\nAX\n",
"output": "NO\n",
"t... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/645/A"
} | vfc_10126 |
apps | verifiable_code | 94 | Solve the following coding problem using the programming language python:
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thu... | ```python
n=int(input())
s=input()
pw=[1]
last=1
for i in range(70):
if (last>1e19):
break
pw.append(last*n)
last=last*n
dp=[1e19]*100
for i in range(100):
dp[i]=[1e19]*100
dp[len(s)][0]=0
for i in range(len(s),-1,-1):
for power in range(0,len(pw)):
cur=''
for j in range(i-1,... | {
"language": "python",
"test_cases": [
{
"input": "13\n12\n",
"output": "12",
"type": "stdin_stdout"
},
{
"input": "16\n11311\n",
"output": "475",
"type": "stdin_stdout"
},
{
"input": "20\n999\n",
"output": "3789",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/758/D"
} | vfc_10130 |
apps | verifiable_code | 95 | Solve the following coding problem using the programming language python:
Array of integers is unimodal, if:
it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing.
The first block (increasing) and the last block (decreasing) may be absent. It is allowed that... | ```python
n = int(input())
L = list(map(int, input().split()))
i = 0
a = 0
while i < n and L[i] > a:
a = L[i]
i += 1
while i < n and L[i] == a:
i += 1
while i < n and L[i] < a:
a = L[i]
i += 1
if i == n:
print("YES")
else:
print("NO")
``` | {
"language": "python",
"test_cases": [
{
"input": "6\n1 5 5 5 4 2\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "5\n10 20 30 20 10\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "4\n1 2 1 2\n",
"output": "NO\n",
"t... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/831/A"
} | vfc_10134 |
apps | verifiable_code | 96 | Solve the following coding problem using the programming language python:
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose som... | ```python
def gg(n,lol):
ans = 0
cur = 1
lol2 = lol
while(2*lol+1<=n):
cur *= 2
ans += cur
lol = 2*lol+1
lol2 *= 2
if lol2*2 <= n:
ans += n-lol2*2+1
return ans
n,k = list(map(int,input().split()))
low = 1
high = n//2
res = 1
while low <= high:
mid = (low+high)//2
if gg(n,mid) >= k:
res = mid
low... | {
"language": "python",
"test_cases": [
{
"input": "11 3\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"input": "11 6\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"input": "20 20\n",
"output": "1\n",
"type": "stdin_stdout"
},
{... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1271/E"
} | vfc_10138 |
apps | verifiable_code | 97 | Solve the following coding problem using the programming language python:
Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image]
There is one ball at the point $(x, y)$ currently. Max comes... | ```python
def INV(a, m) :
m0 = m
y = 0
x = 1
if (m == 1) :
return 0
while (a > 1) :
q = a // m
t = m
m = a % m
a = t
t = y
y = x - q * y
x = t
if (x < 0) :
x = x + m0
return x
def GCD(a, b):
if a == 0: return b
... | {
"language": "python",
"test_cases": [
{
"input": "4 3 2 2 -1 1\n",
"output": "0 0",
"type": "stdin_stdout"
},
{
"input": "4 4 2 0 1 1\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"input": "10 10 10 1 -1 0\n",
"output": "-1",
"type": "std... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/982/E"
} | vfc_10142 |
apps | verifiable_code | 98 | Solve the following coding problem using the programming language python:
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a_1 × b_1 recta... | ```python
a, b = [int(i) for i in input().split()]
c, d = [int(i) for i in input().split()]
e, f = [int(i) for i in input().split()]
if c+e <=a and max(d,f) <=b:
print("YES")
elif c+e <=b and max(d,f) <=a:
print("YES")
elif c+f <=a and max(d,e) <=b:
print("YES")
elif c+f <=b and max(d,e) <=a:
print("YES... | {
"language": "python",
"test_cases": [
{
"input": "3 2\n1 3\n2 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "5 5\n3 3\n3 3\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "4 2\n2 3\n1 2\n",
"output": "YES\n",
"typ... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/560/B"
} | vfc_10146 |
apps | verifiable_code | 99 | Solve the following coding problem using the programming language python:
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.
You are given geometric progression b defined by two integers b_1 and q. Remind that a geometric progression is a sequence of integers b_1, b_2, b... | ```python
def main():
(b1, q, l, m) = list(map(int, input().split()))
a = set(map(int, input().split()))
if abs(b1) > l:
print(0)
else:
if b1 == 0:
if 0 in a:
print(0)
else:
print("inf")
elif q == 0:
if 0 not in ... | {
"language": "python",
"test_cases": [
{
"input": "3 2 30 4\n6 14 25 48\n",
"output": "3",
"type": "stdin_stdout"
},
{
"input": "123 1 2143435 4\n123 11 -5453 141245\n",
"output": "0",
"type": "stdin_stdout"
},
{
"input": "123 1 2143435 4\n54343 -13 6 1... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/789/B"
} | vfc_10150 |
apps | verifiable_code | 100 | Solve the following coding problem using the programming language python:
Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his y... | ```python
3
def readln(): return list(map(int, input().split()))
import sys
def return:
print(-1)
return
n, m = readln()
mon = [list(input()) for _ in range(n)]
hor = [i for i in range(n) if mon[i] != ['.'] * m]
rmon = list(zip(*mon))
ver = [j for j in range(m) if rmon[j] != ('.',) * n]
mini = hor[0]
maxi = h... | {
"language": "python",
"test_cases": [
{
"input": "4 8\n..w..w..\n........\n........\n..w..w..\n",
"output": "..w++w..\n..+..+..\n..+..+..\n..w++w..\n",
"type": "stdin_stdout"
},
{
"input": "5 6\n......\n.w....\n......\n..w...\n......\n",
"output": "......\n+w+...\n+.+...\... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/370/D"
} | vfc_10154 |
apps | verifiable_code | 101 | Solve the following coding problem using the programming language python:
Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.
Find out if it's possible to buy some... | ```python
def egcd(a, b):
x,y, u,v = 0,1, 1,0
while a != 0:
q, r = b//a, b%a
m, n = x-u*q, y-v*q
b,a, x,y, u,v = a,r, u,v, m,n
gcd = b
return gcd, x, y
import math
n=int(input())
a=int(input())
b=int(input())
gcd,x,y=(egcd(a,b))
status=0
if((n%gcd)!=0):
print("NO")
#p... | {
"language": "python",
"test_cases": [
{
"input": "7\n2\n3\n",
"output": "YES\n2 1\n",
"type": "stdin_stdout"
},
{
"input": "100\n25\n10\n",
"output": "YES\n0 10\n",
"type": "stdin_stdout"
},
{
"input": "15\n4\n8\n",
"output": "NO\n",
"type"... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/898/B"
} | vfc_10158 |
apps | verifiable_code | 102 | Solve the following coding problem using the programming language python:
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.
His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he ha... | ```python
n = int(input())
if n == 0:
print('zero')
elif n == 1:
print('one')
elif n == 2:
print('two')
elif n == 3:
print('three')
elif n == 4:
print('four')
elif n == 5:
print('five')
elif n == 6:
print('six')
elif n == 7:
print('seven')
elif n == 8:
print('eight')
elif n == 9:
print('nine')
elif n == 10:
... | {
"language": "python",
"test_cases": [
{
"input": "6\n",
"output": "six\n",
"type": "stdin_stdout"
},
{
"input": "99\n",
"output": "ninety-nine\n",
"type": "stdin_stdout"
},
{
"input": "20\n",
"output": "twenty\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/535/A"
} | vfc_10162 |
apps | verifiable_code | 103 | Solve the following coding problem using the programming language python:
JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \le a_1 < a_2 < \ldots < a_n \le 10^3$, and then went to the bathroom.
... | ```python
n = int(input())
a = [0] + list(map(int, input().split())) + [1001]
mx = 1
p = 1
for i in range(1, n + 2):
if a[i] == a[i - 1] + 1:
p += 1
mx = max(p, mx)
else:
p = 1
print(max(0, mx - 2))
``` | {
"language": "python",
"test_cases": [
{
"input": "6\n1 3 4 5 6 9\n",
"output": "2",
"type": "stdin_stdout"
},
{
"input": "3\n998 999 1000\n",
"output": "2",
"type": "stdin_stdout"
},
{
"input": "5\n1 2 3 4 5\n",
"output": "4",
"type": "stdi... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1062/A"
} | vfc_10166 |
apps | verifiable_code | 104 | Solve the following coding problem using the programming language python:
Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first.
On the $i$-th day Polycarp will necessarily solve $a_i$ problems. O... | ```python
def main():
n = int(input())
a = list(int(x) for x in input().split())
s = sum(a)
t = 0
for i in range(n):
t += a[i]
if 2 * t >= s:
print(i + 1)
return
main()
``` | {
"language": "python",
"test_cases": [
{
"input": "4\n1 3 2 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "6\n2 2 2 2 2 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"input": "1\n10000\n",
"output": "1\n",
"type": "stdin_s... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/962/A"
} | vfc_10170 |
apps | verifiable_code | 105 | Solve the following coding problem using the programming language python:
You stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily $8 \times 8$, but it still is $N \times N$. Each square has some number written on it, all the numbers are from $1$ to $N^2$ and all the numbers are p... | ```python
n=int(input())
graph=[{},{},{}]
for i in range(n):
for j in range(n):
graph[0][(i,j)]=[(k,j) for k in range(n)]+[(i,k) for k in range(n)]
graph[0][(i,j)].remove((i,j))
graph[0][(i,j)].remove((i,j))
graph[1][(i,j)]=[]
for k in range(n):
for l in range(n):... | {
"language": "python",
"test_cases": [
{
"input": "3\n1 9 3\n8 6 7\n4 2 5\n",
"output": "12 1\n",
"type": "stdin_stdout"
},
{
"input": "3\n1 5 8\n9 2 4\n3 6 7\n",
"output": "12 1\n",
"type": "stdin_stdout"
},
{
"input": "4\n5 4 1 13\n8 3 6 16\n15 9 14 1... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1065/D"
} | vfc_10174 |
apps | verifiable_code | 106 | Solve the following coding problem using the programming language python:
Есть n-подъездный дом, в каждом подъезде по m этажей, и на каждом этаже каждого подъезда ровно k квартир. Таким образом, в доме всего n·m·k квартир. Они пронумерованы естественным образом от 1 до n·m·k, то есть первая квартира на первом этаже в ... | ```python
n, m, k = map(int, input().split())
a, b = map(int, input().split())
a -= 1
b -= 1
def p(x):
return x // (m * k)
def e(x):
return (x - p(x) * m * k) // k
def lift(x):
return min(5 * x, 10 + x)
if p(a) == p(b):
dif = abs(e(a) - e(b))
print(lift(dif))
else:
print(lift(e(a)) + 15 * min((p(a) - p(b) + n) ... | {
"language": "python",
"test_cases": [
{
"input": "4 10 5\n200 6\n",
"output": "39\n",
"type": "stdin_stdout"
},
{
"input": "3 1 5\n7 2\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"input": "100 100 100\n1 1000000\n",
"output": "124\n",
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/649/B"
} | vfc_10178 |
apps | verifiable_code | 107 | Solve the following coding problem using the programming language python:
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way,... | ```python
s = input()
i = 0
while i < len(s) and s[i] == '0':
i += 1
cnt = 0
while i < len(s):
if s[i] == '0':
cnt += 1
i += 1
if cnt >= 6:
print('yes')
else:
print('no')
``` | {
"language": "python",
"test_cases": [
{
"input": "100010001\n",
"output": "yes",
"type": "stdin_stdout"
},
{
"input": "100\n",
"output": "no",
"type": "stdin_stdout"
},
{
"input": "0000001000000\n",
"output": "yes",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/887/A"
} | vfc_10182 |
apps | verifiable_code | 109 | Solve the following coding problem using the programming language python:
While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!).
The gi... | ```python
import heapq as hq
from queue import PriorityQueue
import math
n,m,r, k= input().split()
N = int(n)
M = int(m)
R = int(r)
K = int(k)
q = PriorityQueue()
for i in range(1,math.floor((N+1)/2) + 1):
maxi = min(min(i,N-i+1),min(R,N-R+1)) * min(min(R,M-R+1),math.ceil(M/2))
num = M - (2 * min(min(R,M-R... | {
"language": "python",
"test_cases": [
{
"input": "3 3 2 3\n",
"output": "2.0000000000\n",
"type": "stdin_stdout"
},
{
"input": "12 17 9 40\n",
"output": "32.8333333333\n",
"type": "stdin_stdout"
},
{
"input": "1 1 1 1\n",
"output": "1.0000000000\... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/912/D"
} | vfc_10190 |
apps | verifiable_code | 110 | Solve the following coding problem using the programming language python:
Nick had received an awesome array of integers $a=[a_1, a_2, \dots, a_n]$ as a gift for his $5$ birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product $a... | ```python
n = int(input())
A = list(map(int, input().split()))
if n == 1:
if A[0] >= 0:
print(A[0])
else:
print(-A[0]-1)
return
for i in range(n):
if A[i] < 0:
pass
else:
A[i] = -A[i]-1
if n % 2 == 0:
print(*A)
return
mim = 0
indmim = 0
for i in range(n):
... | {
"language": "python",
"test_cases": [
{
"input": "4\n2 2 2 2\n",
"output": "-3 -3 -3 -3 ",
"type": "stdin_stdout"
},
{
"input": "1\n0\n",
"output": "0 ",
"type": "stdin_stdout"
},
{
"input": "3\n-3 -3 2\n",
"output": "-3 -3 2 ",
"type": "st... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1180/B"
} | vfc_10194 |
apps | verifiable_code | 111 | Solve the following coding problem using the programming language python:
You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.
Divisor of n is any such natural number, that n can be divided by it without remainder.
-----Input-----
The first line contains two integer... | ```python
import sys
import math
def factorization(n):
res = []
limit = math.ceil(math.sqrt(n))
p = 2
cnt = 0
while n % p == 0:
cnt += 1
n //= p
if cnt > 0:
res.append((p, cnt))
cnt = 0
for p in range(3, limit + 1, 2):
if n % p == 0:
while ... | {
"language": "python",
"test_cases": [
{
"input": "4 2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "5 3\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"input": "12 5\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/762/A"
} | vfc_10198 |
apps | verifiable_code | 113 | Solve the following coding problem using the programming language python:
For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n.
For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such ... | ```python
def main():
n, k = map(int, input().split())
num_2 = 0
num_5 = 0
x = n
while (x % 2 == 0):
num_2 += 1
x //= 2
while (x % 5 == 0):
num_5 += 1
x //= 5
num_2 = k - min(num_2, k)
num_5 = k - min(num_5, k)
print(n * 5 ** num_5 * 2 ** num_2)
main()
``` | {
"language": "python",
"test_cases": [
{
"input": "375 4\n",
"output": "30000\n",
"type": "stdin_stdout"
},
{
"input": "10000 1\n",
"output": "10000\n",
"type": "stdin_stdout"
},
{
"input": "38101 0\n",
"output": "38101\n",
"type": "stdin_st... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/858/A"
} | vfc_10206 |
apps | verifiable_code | 115 | Solve the following coding problem using the programming language python:
The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, then one... | ```python
r, s, p = list(map(int, input().split()))
dp = [[[0] * (p+1) for _ in range(s+1)] for _ in range(r+1)]
dp[r][s][p] = 1
def nCk(n, k):
if n <= k:
return 1
res = 1
for i in range(k):
res *= n-i
for i in range(k):
res //= (i+1)
return res
C = [nCk(i, 2) for i in range... | {
"language": "python",
"test_cases": [
{
"input": "2 2 2\n",
"output": "0.333333333333 0.333333333333 0.333333333333\n",
"type": "stdin_stdout"
},
{
"input": "2 1 2\n",
"output": "0.150000000000 0.300000000000 0.550000000000\n",
"type": "stdin_stdout"
},
{
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/540/D"
} | vfc_10214 |
apps | verifiable_code | 116 | Solve the following coding problem using the programming language python:
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute l_1 to minute r_1 inclusive. Also, during the minute k she p... | ```python
read = lambda: list(map(int, input().split()))
l1, r1, l2, r2, k = read()
R = min(r1, r2)
L = max(l1, l2)
ans = max(R - L + 1, 0)
if L <= k <= R: ans = max(ans - 1, 0)
print(ans)
``` | {
"language": "python",
"test_cases": [
{
"input": "1 10 9 20 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "1 100 50 200 75\n",
"output": "50\n",
"type": "stdin_stdout"
},
{
"input": "6 6 5 8 9\n",
"output": "1\n",
"type": "std... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/714/A"
} | vfc_10218 |
apps | verifiable_code | 118 | Solve the following coding problem using the programming language python:
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t +... | ```python
t, s, x = list(map(int, input().split()))
f = False
if x - 1 > t and (x - 1 - t) % s == 0:
f = True
if x >= t and (x - t) % s == 0:
f = True
if f:
print('YES')
else:
print('NO')
``` | {
"language": "python",
"test_cases": [
{
"input": "3 10 4\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "3 10 3\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "3 8 51\n",
"output": "YES\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/697/A"
} | vfc_10226 |
apps | verifiable_code | 119 | Solve the following coding problem using the programming language python:
You are given a sequence a_1, a_2, ..., a_{n} of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment a_{i} lies within segment a_{j}.
Segment [l_1, r_1] lies within segment [l_2, r_... | ```python
n = int(input())
a = []
for i in range(1, n + 1):
l, r = list(map(int, input().split()))
a.append([l, -r, i])
a.sort()
hh = a[0][1]
wahh = max(-1, a[0][2])
for i in range(1, n):
if a[i][1] >= hh:
print(a[i][2], wahh)
return
else:
hh = a[i][1]
wahh = a[i][2]
prin... | {
"language": "python",
"test_cases": [
{
"input": "5\n1 10\n2 9\n3 9\n2 3\n2 9\n",
"output": "2 1\n",
"type": "stdin_stdout"
},
{
"input": "3\n1 5\n2 6\n6 20\n",
"output": "-1 -1\n",
"type": "stdin_stdout"
},
{
"input": "1\n1 1000000000\n",
"outpu... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/976/C"
} | vfc_10230 |
apps | verifiable_code | 120 | Solve the following coding problem using the programming language python:
The process of mammoth's genome decoding in Berland comes to its end!
One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or... | ```python
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
n=int(input())
if n%4: print("===")
else:
t=input().strip()
a=[n//4]*4
for i in t:
if i=='A': a[0]-=1
elif i=='C': a[1]-=1
elif i=='G': a[2]-=1
elif i=='T': a[3]-=1
if min(a)<0: print("===")
e... | {
"language": "python",
"test_cases": [
{
"input": "8\nAG?C??CT\n",
"output": "AGACGTCT\n",
"type": "stdin_stdout"
},
{
"input": "4\nAGCT\n",
"output": "AGCT\n",
"type": "stdin_stdout"
},
{
"input": "6\n????G?\n",
"output": "===\n",
"type": "... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/747/B"
} | vfc_10234 |
apps | verifiable_code | 121 | Solve the following coding problem using the programming language python:
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game ... | ```python
def chk(l):
for i in range(4):
for j in range(2):
if l[i][j]==l[i][j+1]==l[i][j+2]=='x':
return True
for i in range(2):
for j in range(4):
if l[i][j]==l[i+1][j]==l[i+2][j]=='x':
return True
for i in range(2):
for j in range(2):
if l[i][j]==l[i+1][j+1]==l[i+2][j+2]=='x':
return Tr... | {
"language": "python",
"test_cases": [
{
"input": "xx..\n.oo.\nx...\noox.\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "x.ox\nox..\nx.o.\noo.x\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "x..x\n..oo\no...\nx.xo\n",
"o... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/754/B"
} | vfc_10238 |
apps | verifiable_code | 122 | Solve the following coding problem using the programming language python:
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the... | ```python
def solve(n,a):
tot=0
for i in range(n):
tot+=a[i]
diffs = [] #alla suffix - prefix diffs[i]=prefix-suffix om delas innan element i
diffs.append(-tot)
for i in range(n):
tot-=2*a[i]
diffs.append(-tot)
if tot==0:
return ("YES")
for i in range(... | {
"language": "python",
"test_cases": [
{
"input": "3\n1 3 2\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "5\n1 2 3 4 5\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "5\n2 2 3 4 5\n",
"output": "YES\n",
"type": "st... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/808/D"
} | vfc_10242 |
apps | verifiable_code | 123 | Solve the following coding problem using the programming language python:
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of the oddity and recover her weight, a special... | ```python
import sys
n, k = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
b.sort(reverse=True)
res = []
cur_b = 0
for a_i in a:
if a_i != 0:
res.append(a_i)
else:
res.append(b[cur_b])
cur_b += 1
if res != list(sorted(res))... | {
"language": "python",
"test_cases": [
{
"input": "4 2\n11 0 0 14\n5 4\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"input": "6 1\n2 3 0 8 9 10\n5\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"input": "4 1\n8 94 0 4\n89\n",
"output": "Y... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/814/A"
} | vfc_10246 |
apps | verifiable_code | 124 | Solve the following coding problem using the programming language python:
The Duck song
For simplicity, we'll assume that there are only three types of grapes: green grapes, purple grapes and black grapes.
Andrew, Dmitry and Michal are all grapes' lovers, however their preferences of grapes are different. To make al... | ```python
x,y,z = list(map(int,input().split()))
a,b,c = list(map(int,input().split()))
if a < x:
print("NO")
return
x -= a
y += x
if b < y:
print("NO")
return
y -= b
z += y
if c < z:
print("NO")
return
print("YES")
``` | {
"language": "python",
"test_cases": [
{
"input": "1 6 2\n4 3 3\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "5 1 1\n4 3 2\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "1 1 100000\n4 2 99995\n",
"output": "NO\n",
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1114/A"
} | vfc_10250 |
apps | verifiable_code | 126 | Solve the following coding problem using the programming language python:
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the... | ```python
# A
input()
l = list(map(int, list(input())))
if (1 in l or 4 in l or 7 in l or 0 in l) and (1 in l or 2 in l or 3 in l) and (3 in l or 6 in l or 9 in l or 0 in l) and (7 in l or 0 in l or 9 in l):
print("YES")
else:
print("NO")
``` | {
"language": "python",
"test_cases": [
{
"input": "3\n586\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "2\n09\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "9\n123456789\n",
"output": "YES\n",
"type": "stdin_stdout... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/689/A"
} | vfc_10258 |
apps | verifiable_code | 127 | Solve the following coding problem using the programming language python:
Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.
Shop, where Noora... | ```python
n, f = list(map(int, input().split(' ')))
res = 0
wow = []
for a0 in range(n):
k, l = list(map(int, input().split(' ')))
res += min(k, l)
wow.append(min(2*k, l) - min(k, l))
wow = sorted(wow)
i = len(wow)-1
for a0 in range(f):
res += wow[i]
i -= 1
print(res)
``` | {
"language": "python",
"test_cases": [
{
"input": "4 2\n2 1\n3 5\n2 3\n1 5\n",
"output": "10",
"type": "stdin_stdout"
},
{
"input": "4 1\n0 2\n0 3\n3 5\n0 6\n",
"output": "5",
"type": "stdin_stdout"
},
{
"input": "1 1\n5 8\n",
"output": "8",
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/810/B"
} | vfc_10262 |
apps | verifiable_code | 128 | Solve the following coding problem using the programming language python:
It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing... | ```python
# You lost the game.
n,k = map(int, input().split())
r = 0
for i in range(min(k,n//2)):
r += (n-2*i-1) + (n-2*i-2)
print(r)
``` | {
"language": "python",
"test_cases": [
{
"input": "5 2\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"input": "1 10\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"input": "100000 2\n",
"output": "399990\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/645/B"
} | vfc_10266 |
apps | verifiable_code | 129 | Solve the following coding problem using the programming language python:
Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as ma... | ```python
n, m, k, l = map(int, input().split())
cnt = (k + l + m - 1) // m
if cnt * m > n:
print(-1)
else:
print(cnt)
``` | {
"language": "python",
"test_cases": [
{
"input": "20 15 2 3\n",
"output": "1",
"type": "stdin_stdout"
},
{
"input": "10 11 2 4\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"input": "2 1 1 1\n",
"output": "2",
"type": "stdin_stdout"
}... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1068/A"
} | vfc_10270 |
apps | verifiable_code | 130 | Solve the following coding problem using the programming language python:
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that... | ```python
h, w = map(int, input().split())
x0, y0, x1, y1, c = 1000, 1000, -1, -1, 0
for i in range(h):
row = str(input())
for j in range(w):
if row[j] == 'B':
x0, y0, x1, y1, c = min(x0, i), min(y0, j), max(x1, i), max(y1, j), c + 1
ln = max(x1 - x0 + 1, y1 - y0 + 1)
if ln > min(h, w):
print(-1)
elif x... | {
"language": "python",
"test_cases": [
{
"input": "5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"input": "1 2\nBB\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"input": "3 3\nWWW\nWWW\nWWW\n",
"output": "1... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/828/B"
} | vfc_10274 |
apps | verifiable_code | 131 | Solve the following coding problem using the programming language python:
There is a beautiful garden of stones in Innopolis.
Its most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.
EJOI participants have visited this place twice.
When they first visited it, the number of stones in piles wa... | ```python
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sum(a)
d = sum(b)
if c >= d:
print('Yes')
else:
print('No')
``` | {
"language": "python",
"test_cases": [
{
"input": "5\n1 2 3 4 5\n2 1 4 3 5\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"input": "5\n1 1 1 1 1\n1 0 1 0 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"input": "3\n2 3 9\n1 7 9\n",
"outpu... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1013/A"
} | vfc_10278 |
apps | verifiable_code | 132 | Solve the following coding problem using the programming language python:
Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece... | ```python
n = int(input())
a = list(map(int, input().split()))
mn = 360
for i in range(n):
x = 0
for j in range(i, n):
x += a[j]
mn = min(mn, abs(x - (360 - x)))
print(mn)
``` | {
"language": "python",
"test_cases": [
{
"input": "4\n90 90 90 90\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"input": "3\n100 100 160\n",
"output": "40\n",
"type": "stdin_stdout"
},
{
"input": "1\n360\n",
"output": "360\n",
"type": "st... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/895/A"
} | vfc_10282 |
apps | verifiable_code | 133 | Solve the following coding problem using the programming language python:
Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.
There are $n$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Prese... | ```python
# Contest: Codeforces Round #593 (Div. 2) (https://codeforces.com/contest/1236)
# Problem: B: Alice and the List of Presents (https://codeforces.com/contest/1236/problem/B)
def rint():
return int(input())
def rints():
return list(map(int, input().split()))
M = 10**9 + 7
n, m = rints()
print(pow((... | {
"language": "python",
"test_cases": [
{
"input": "1 3\n",
"output": "7",
"type": "stdin_stdout"
},
{
"input": "2 2\n",
"output": "9",
"type": "stdin_stdout"
},
{
"input": "1000000000 1000000000\n",
"output": "751201557",
"type": "stdin_stdo... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1236/B"
} | vfc_10286 |
apps | verifiable_code | 134 | Solve the following coding problem using the programming language python:
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding ... | ```python
n = int(input())
if n % 4 == 0:
temp = n // 4
m = temp * 3
k = temp * 5
elif n % 2 == 0:
n //= 2
m = n**2 // 2
k = m + 1
m *= 2
k *= 2
else:
m = n**2 // 2
k = m + 1
if 3 > n:
print("-1")
else:
print(m,k)
``` | {
"language": "python",
"test_cases": [
{
"input": "3\n",
"output": "4 5",
"type": "stdin_stdout"
},
{
"input": "6\n",
"output": "8 10",
"type": "stdin_stdout"
},
{
"input": "1\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"in... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/707/C"
} | vfc_10290 |
apps | verifiable_code | 135 | Solve the following coding problem using the programming language python:
Imp is watching a documentary about cave painting. [Image]
Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1... | ```python
def main():
n, k = map(int, input().split())
for i in range(1, k + 1):
if (n % i != (i - 1)):
print("No")
return
print("Yes")
main()
``` | {
"language": "python",
"test_cases": [
{
"input": "4 4\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"input": "5 3\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"input": "1 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/922/C"
} | vfc_10294 |
apps | verifiable_code | 136 | Solve the following coding problem using the programming language python:
You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of tha... | ```python
a = input()
b = input()
n, m = len(a), len(b)
if n > m: b = '0' * (n - m) + b
else: a = '0' * (m - n) + a
i = 0
while i < max(n, m) and a[i] == b[i]:
i += 1
print('=' if i == max(n, m) else '<' if int(a[i]) < int(b[i]) else '>')
``` | {
"language": "python",
"test_cases": [
{
"input": "9\n10\n",
"output": "<\n",
"type": "stdin_stdout"
},
{
"input": "11\n10\n",
"output": ">\n",
"type": "stdin_stdout"
},
{
"input": "00012345\n12345\n",
"output": "=\n",
"type": "stdin_stdout"... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/616/A"
} | vfc_10298 |
apps | verifiable_code | 137 | Solve the following coding problem using the programming language python:
Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to crea... | ```python
n,p=list(map(int,input().split()))
nums=[0]+list(map(int,input().split()))
mod=10**9+7
f=[[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(n+1)]
_2=[0]*(n+1)
_2[0]=1
for i in range(1,n+1):
_2[i]=(_2[i-1]<<1)%mod
f[0][0][0][0]=1
if nums[1]!=0:
f[1][1][0][1]+=1
if nums[1]!=1:
f[1]... | {
"language": "python",
"test_cases": [
{
"input": "3 1\n-1 0 1\n",
"output": "6",
"type": "stdin_stdout"
},
{
"input": "2 1\n1 0\n",
"output": "1",
"type": "stdin_stdout"
},
{
"input": "1 1\n-1\n",
"output": "2",
"type": "stdin_stdout"
}... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/979/E"
} | vfc_10302 |
apps | verifiable_code | 138 | Solve the following coding problem using the programming language python:
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one c... | ```python
n, a, b, c = map(int, input().split())
res = 10 ** 100
for i in range(50):
for j in range(50):
for k in range(50):
if (n + i + 2 * j + 3 * k) % 4 == 0:
res = min(res, a * i + b * j + c * k)
print(res)
``` | {
"language": "python",
"test_cases": [
{
"input": "1 1 3 4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"input": "6 2 1 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "4 4 4 4\n",
"output": "0\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/740/A"
} | vfc_10306 |
apps | verifiable_code | 139 | Solve the following coding problem using the programming language python:
You are given a directed graph consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.
Can you make this graph acyclic by removing at most o... | ```python
n,m = map(int, input().split())
g = [[] for i in range(n)]
for _ in range(m):
u,v = map(int, input().split())
g[u-1].append(v-1)
st = []
vis = [0 for _ in range(n)]
nxt = [0 for _ in range(n)]
es = set()
cycle=False
for i in range(n):
if cycle:
break
if vis[i] != 0:
continue
... | {
"language": "python",
"test_cases": [
{
"input": "3 4\n1 2\n2 3\n3 2\n3 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "5 6\n1 2\n2 3\n3 2\n3 1\n2 1\n4 5\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "2 2\n1 2\n2 1\n",
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/915/D"
} | vfc_10310 |
apps | verifiable_code | 140 | Solve the following coding problem using the programming language python:
The mayor of the Central Town wants to modernize Central Street, represented in this problem by the $(Ox)$ axis.
On this street, there are $n$ antennas, numbered from $1$ to $n$. The $i$-th antenna lies on the position $x_i$ and has an initial ... | ```python
import sys
input = sys.stdin.readline
n,m=list(map(int,input().split()))
A=[]
COVERED=[0]*(m+1)
for i in range(n):
x,y=list(map(int,input().split()))
A.append((x-y,x+y))
for j in range(max(0,x-y),min(m+1,x+y+1)):
COVERED[j]=1
if min(COVERED[1:])==1:
print(0)
return
A.sort()
... | {
"language": "python",
"test_cases": [
{
"input": "3 595\n43 2\n300 4\n554 10\n",
"output": "281\n",
"type": "stdin_stdout"
},
{
"input": "1 1\n1 1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"input": "2 50\n20 0\n3 1\n",
"output": "30\n",
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1253/E"
} | vfc_10314 |
apps | verifiable_code | 142 | Solve the following coding problem using the programming language python:
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity.
Your favorite store sells lemonade in bottles of n different volumes at differe... | ```python
3
# Copyright (C) 2017 Sayutin Dmitry.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 3
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY... | {
"language": "python",
"test_cases": [
{
"input": "4 12\n20 30 70 90\n",
"output": "150\n",
"type": "stdin_stdout"
},
{
"input": "4 3\n10000 1000 100 10\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"input": "4 3\n10 100 1000 10000\n",
"output... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/913/C"
} | vfc_10322 |
apps | verifiable_code | 143 | Solve the following coding problem using the programming language python:
Someone gave Alyona an array containing n positive integers a_1, a_2, ..., a_{n}. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona c... | ```python
x=int(input())
l=list(map(int, input().split(' ')))
l.sort()
a=1
for i in l:
if i>=a:
a+=1
print(a)
``` | {
"language": "python",
"test_cases": [
{
"input": "5\n1 3 3 3 6\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"input": "2\n2 1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"input": "1\n1\n",
"output": "2\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/682/B"
} | vfc_10326 |
apps | verifiable_code | 144 | Solve the following coding problem using the programming language python:
Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ ... | ```python
n = int(input())
a = list(map(int, list(input())))
for i in range(n - 1):
sm = sum(a[:i + 1])
tn = 0
res = True
has = False
for j in range(i + 1, n):
tn += a[j]
if (tn == sm):
tn = 0
has = True
elif tn > sm:
res = False
... | {
"language": "python",
"test_cases": [
{
"input": "5\n73452\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "4\n1248\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "2\n00\n",
"output": "YES\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1030/C"
} | vfc_10330 |
apps | verifiable_code | 145 | Solve the following coding problem using the programming language python:
Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they... | ```python
s = input()
q = set()
for i in range(0, len(s)):
q.add(s[i])
print("IGNORE HIM!" if len(q) % 2 == 1 else "CHAT WITH HER!")
``` | {
"language": "python",
"test_cases": [
{
"input": "wjmzbmr\n",
"output": "CHAT WITH HER!\n",
"type": "stdin_stdout"
},
{
"input": "xiaodao\n",
"output": "IGNORE HIM!\n",
"type": "stdin_stdout"
},
{
"input": "sevenkplus\n",
"output": "CHAT WITH HER... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/236/A"
} | vfc_10334 |
apps | verifiable_code | 146 | Solve the following coding problem using the programming language python:
This morning, Roman woke up and opened the browser with $n$ opened tabs numbered from $1$ to $n$. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too... | ```python
n, k = list(map(int, input().split()))
t = list(map(int, input().split()))
d = [0 for _ in range(n)]
for _ in range(n):
for i in range(n):
if i % k != _ % k:
d[_] += t[i]
print(max(abs(d[_]) for _ in range(n)))
``` | {
"language": "python",
"test_cases": [
{
"input": "4 2\n1 1 -1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "14 3\n-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"input": "4 2\n1 1 1 -1\n",
"ou... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1100/A"
} | vfc_10338 |
apps | verifiable_code | 147 | Solve the following coding problem using the programming language python:
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listenin... | ```python
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
n,a,b=map(int,input().split())
if a<b: a,b=b,a
if b==0:
# 1 01 001 0001 ... is optimal, plus a long series of 0's
print((n-1)*a)
else:
# pascal's triangle thing
pascal=[[1]*20005]
for i in range(20004):
newrow=[1]
... | {
"language": "python",
"test_cases": [
{
"input": "4 1 2\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"input": "2 1 5\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"input": "3 1 1\n",
"output": "5\n",
"type": "stdin_stdout"
},
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/717/B"
} | vfc_10342 |
apps | verifiable_code | 148 | Solve the following coding problem using the programming language python:
The circle line of the Roflanpolis subway has $n$ stations.
There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(... | ```python
n, a, x, b, y = map(int, input().split())
while a != x and b != y and a != b:
if a == b:
break
a = a % n + 1
b = b - 1 if b - 1 else n
print("YNEOS"[a != b::2])
``` | {
"language": "python",
"test_cases": [
{
"input": "5 1 4 3 2\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"input": "10 2 1 9 10\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"input": "4 3 4 2 1\n",
"output": "NO\n",
"type": "stdin_... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1169/A"
} | vfc_10346 |
apps | verifiable_code | 149 | Solve the following coding problem using the programming language python:
Unlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers.
For example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 2^0 + 3^1, 17 = 2^3 + 3^... | ```python
x,y,l,r=list(map(int,input().split()))
b=set()
a=0
b.add(l-1)
b.add(r+1)
for i in range(100):
xx=x**i
if xx>r: break
for j in range(100):
rr=xx+(y**j)
if rr>r: break
if rr>=l:
b.add(rr)
b=sorted(list(b))
for i in range(1,len(b)):
a=max(a,b[i]-b[i-1]-1)
print(a)
``` | {
"language": "python",
"test_cases": [
{
"input": "2 3 1 10\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "3 5 10 22\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"input": "2 3 3 5\n",
"output": "0\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/813/B"
} | vfc_10350 |
apps | verifiable_code | 150 | Solve the following coding problem using the programming language python:
Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). ... | ```python
def is_izi(k):
i = 2
while (i * i <= k):
if (k % i == 0):
return 0
i += 1
return 1
n = int(input())
if (is_izi(n)):
print(1)
elif n % 2 == 0:
print(2)
elif n % 2 == 1:
if (is_izi(n - 2)):
print(2)
else:
print(3)
``` | {
"language": "python",
"test_cases": [
{
"input": "4\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"input": "27\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"input": "3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"i... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/735/D"
} | vfc_10354 |
apps | verifiable_code | 151 | Solve the following coding problem using the programming language python:
Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.
Beroffice works only with small English letters (i.e. with 26 letters from ... | ```python
s = input()
st = {'a', 'e', 'i', 'o', 'u', ' '}
res = ""
def check(s):
if (len(s) < 3):
return True
if (s[-1] not in st and s[-2] not in st and s[-3] not in st) and (s[-1] != s[-2] or s[-2] != s[-3] or s[-1] != s[-3]):
return False
return True
for item in s:
if not check(res + item):
res += " "
r... | {
"language": "python",
"test_cases": [
{
"input": "hellno\n",
"output": "hell no \n",
"type": "stdin_stdout"
},
{
"input": "abacaba\n",
"output": "abacaba \n",
"type": "stdin_stdout"
},
{
"input": "asdfasdf\n",
"output": "asd fasd f \n",
"ty... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/858/C"
} | vfc_10358 |
apps | verifiable_code | 152 | Solve the following coding problem using the programming language python:
Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions.
Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of ... | ```python
n, m, k = list(map(int, input().split()))
x, s = list(map(int, input().split()))
t = list(map(int, input().split()))
pr = list(map(int, input().split()))
t2 = list(map(int, input().split()))
pr2 = list(map(int, input().split()))
mass1 = []
minans = 10**20
for i in range(m):
mass1.append((pr[i], t[i]))
mas... | {
"language": "python",
"test_cases": [
{
"input": "20 3 2\n10 99\n2 4 3\n20 10 40\n4 15\n10 80\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"input": "20 3 2\n10 99\n2 4 3\n200 100 400\n4 15\n100 800\n",
"output": "200\n",
"type": "stdin_stdout"
},
{
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/734/C"
} | vfc_10362 |
apps | verifiable_code | 153 | Solve the following coding problem using the programming language python:
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but n... | ```python
n, k, m = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
s = sum(l)
ans = 0
for i in range(n + 1):
mi = m - s * i
if mi < 0:
break
cnt = (k + 1) * i
for j in range(k):
x = min(mi // l[j], n - i)
cnt += x
mi -= l[j] * x
ans = ma... | {
"language": "python",
"test_cases": [
{
"input": "3 4 11\n1 2 3 4\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"input": "5 5 10\n1 2 4 8 16\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"input": "1 1 0\n2\n",
"output": "0\n",
"type":... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/846/B"
} | vfc_10366 |
apps | verifiable_code | 154 | Solve the following coding problem using the programming language python:
Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than ... | ```python
N = int(input())
if N in [1, 2, 4, 5, 9, 10, 20, 21, 41, 42, 84, 85, 169, 170, 340, 341, 681, 682, 1364, 1365, 2729, 2730, 5460, 5461, 10921, 10922, 21844, 21845, 43689, 43690, 87380, 87381, 174761, 174762, 349524, 349525, 699049, 699050]:
print(1)
else:
print(0)
``` | {
"language": "python",
"test_cases": [
{
"input": "4\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"input": "3\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"input": "2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"in... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/1237/E"
} | vfc_10370 |
apps | verifiable_code | 155 | Solve the following coding problem using the programming language python:
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.
Lara is going to explore... | ```python
n, m, k = map(int, input().split())
ans = 0, 0
if k < n:
ans = k + 1, 1
else:
k -= n
r = n - k // (m - 1)
if r % 2:
c = m - k % (m - 1)
else:
c = 2 + k % (m - 1)
ans = r, c
print(*ans)
``` | {
"language": "python",
"test_cases": [
{
"input": "4 3 0\n",
"output": "1 1\n",
"type": "stdin_stdout"
},
{
"input": "4 3 11\n",
"output": "1 2\n",
"type": "stdin_stdout"
},
{
"input": "4 3 7\n",
"output": "3 2\n",
"type": "stdin_stdout"
... | {
"difficulty": "interview",
"problem_url": "https://codeforces.com/problemset/problem/976/B"
} | vfc_10374 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.