source stringclasses 4
values | task_type stringclasses 1
value | in_source_id stringlengths 0 112 | prompt stringlengths 219 13.2k | gold_standard_solution stringlengths 22 413k | verification_info stringlengths 91 74M | metadata stringlengths 19 190 | problem_id stringlengths 5 10 | program stringlengths 22 413k | inputs stringlengths 0 889k | output stringlengths 0 168k | actual_output stringlengths 0 168k | execution_success bool 1
class | sample_index int64 2 31.8k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
apps | verifiable_code | 65 | Solve the following coding problem using the programming language python:
You are given an array of n integer numbers a_0, a_1, ..., a_{n} - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.
-----Input-----
The first line conta... | ```python
n = int(input())
A = [int(x) for x in input().split()]
mn = min(A)
I = [i for i in range(len(A)) if A[i] == mn]
mindiff = min(I[i]-I[i-1] for i in range(1,len(I)))
print(mindiff)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n3 3\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '3\n5 6 5\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '9\n2 1 3 5 4 1 2 3 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '6\n4 6 7 8 6 4\n', 'output': '5\n'}, {'type': 'stdin_stdout',... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/911/A'} | vfc_10014 | ```python
n = int(input())
A = [int(x) for x in input().split()]
mn = min(A)
I = [i for i in range(len(A)) if A[i] == mn]
mindiff = min(I[i]-I[i-1] for i in range(1,len(I)))
print(mindiff)
``` | 2
3 3
| 1
| 1
| true | 1,635 |
apps | verifiable_code | 67 | Solve the following coding problem using the programming language python:
Nauuo is a girl who loves writing comments.
One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.
It's known that there were $x$ persons who would upvote, $y$ persons who would downvote, and there w... | ```python
x, y, z = map(int, input().split())
if z == 0:
if x == y:
print('0')
elif x > y:
print('+')
else:
print('-')
else:
if x > y + z:
print('+')
elif x + z < y:
print('-')
else:
print('?')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 7 0\n', 'output': '-'}, {'type': 'stdin_stdout', 'input': '2 0 1\n', 'output': '+'}, {'type': 'stdin_stdout', 'input': '1 1 0\n', 'output': '0'}, {'type': 'stdin_stdout', 'input': '0 0 1\n', 'output': '?'}, {'type': 'stdin_stdout', 'input': '12 1 11\n', 'output': '?'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1173/A'} | vfc_10022 | ```python
x, y, z = map(int, input().split())
if z == 0:
if x == y:
print('0')
elif x > y:
print('+')
else:
print('-')
else:
if x > y + z:
print('+')
elif x + z < y:
print('-')
else:
print('?')
``` | 3 7 0
| - | -
| true | 1,636 |
apps | verifiable_code | 69 | Solve the following coding problem using the programming language python:
You are given string $s$ of length $n$ consisting of 0-s and 1-s. You build an infinite string $t$ as a concatenation of an infinite number of strings $s$, or $t = ssss \dots$ For example, if $s =$ 10010, then $t =$ 100101001010010...
Calculate... | ```python
t=int(input())
for i in ' '*t:
n,x=map(int,input().split())
s=input()
L=[0]
for i in s:
if i=='0':L.append(L[-1]+1)
else:L.append(L[-1]-1)
L.pop(0)
k=L[-1]
c=0
if x==0:c+=1
if k>0:
for i in L:
if i%k==x%k and i<=x:c+=1
print(c)
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n6 10\n010010\n5 3\n10101\n1 0\n0\n2 0\n01\n', 'output': '3\n0\n1\n-1\n'}, {'type': 'stdin_stdout', 'input': '2\n1 -548706795\n0\n1 -735838406\n1\n', 'output': '0\n1\n'}, {'type': 'stdin_stdout', 'input': '1\n5 5\n00000\n', 'output': '1\n'}, {'type': 'stdin_stdout', ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1295/B'} | vfc_10030 | ```python
t=int(input())
for i in ' '*t:
n,x=map(int,input().split())
s=input()
L=[0]
for i in s:
if i=='0':L.append(L[-1]+1)
else:L.append(L[-1]-1)
L.pop(0)
k=L[-1]
c=0
if x==0:c+=1
if k>0:
for i in L:
if i%k==x%k and i<=x:c+=1
print(c)
... | 4
6 10
010010
5 3
10101
1 0
0
2 0
01
| 3
0
1
-1
| 3
0
1
-1
| true | 1,637 |
apps | verifiable_code | 71 | Solve the following coding problem using the programming language python:
On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.
Seating in the class looks like a rectangle, where n rows with m pupils in each.
The teacher asks pupils in the followin... | ```python
n, m, k, x, y = list(map(int, input().split()))
ans = [[0] * m for x in range(n)]
onebig = (2*n-2)*m or m
oo = k // onebig
for i in range(n):
for j in range(m):
if i == 0 or i == n-1:
ans[i][j] += oo
k -= oo
else:
ans[i][j] += 2*oo
k -= 2... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 3 8 1 1\n', 'output': '3 2 3'}, {'type': 'stdin_stdout', 'input': '4 2 9 4 2\n', 'output': '2 1 1'}, {'type': 'stdin_stdout', 'input': '5 5 25 4 3\n', 'output': '1 1 1'}, {'type': 'stdin_stdout', 'input': '100 100 1000000000000000000 100 100\n', 'output': '1010101010... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/758/C'} | vfc_10038 | ```python
n, m, k, x, y = list(map(int, input().split()))
ans = [[0] * m for x in range(n)]
onebig = (2*n-2)*m or m
oo = k // onebig
for i in range(n):
for j in range(m):
if i == 0 or i == n-1:
ans[i][j] += oo
k -= oo
else:
ans[i][j] += 2*oo
k -= 2... | 1 3 8 1 1
| 3 2 3 | 3 2 3
| true | 1,638 |
apps | verifiable_code | 72 | Solve the following coding problem using the programming language python:
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they... | ```python
turns = int(input())
s0 = input()
s1 = input()
s2 = input()
d0 = dict()
d1 = dict()
d2 = dict()
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
for char in alphabet:
d0[char] = 0
d1[char] = 0
d2[char] = 0
for char in s0:
d0[char] += 1
for char in s1:
d1[char] += 1
for char in s2:
d2... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\nKuroo\nShiro\nKatie\n', 'output': 'Kuro\n'}, {'type': 'stdin_stdout', 'input': '7\ntreasurehunt\nthreefriends\nhiCodeforces\n', 'output': 'Shiro\n'}, {'type': 'stdin_stdout', 'input': '1\nabcabc\ncbabac\nababca\n', 'output': 'Katie\n'}, {'type': 'stdin_stdout', 'inp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/979/B'} | vfc_10042 | ```python
turns = int(input())
s0 = input()
s1 = input()
s2 = input()
d0 = dict()
d1 = dict()
d2 = dict()
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
for char in alphabet:
d0[char] = 0
d1[char] = 0
d2[char] = 0
for char in s0:
d0[char] += 1
for char in s1:
d1[char] += 1
for char in s2:
d2... | 3
Kuroo
Shiro
Katie
| Kuro
| Kuro
| true | 1,639 |
apps | verifiable_code | 73 | Solve the following coding problem using the programming language python:
Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages.
At first day Mister B read v_0 pages, but after that he started to speed up. Every day, starting from the second, he read a pag... | ```python
read = lambda: map(int, input().split())
c, v0, v1, a, l = read()
cur = 0
cnt = 0
while cur < c:
cur = max(0, cur - l)
cur += min(v1, v0 + a * cnt)
cnt += 1
print(cnt)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 5 10 5 4\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '12 4 12 4 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '15 1 100 0 0\n', 'output': '15\n'}, {'type': 'stdin_stdout', 'input': '1 1 1 0 0\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'inp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/820/A'} | vfc_10046 | ```python
read = lambda: map(int, input().split())
c, v0, v1, a, l = read()
cur = 0
cnt = 0
while cur < c:
cur = max(0, cur - l)
cur += min(v1, v0 + a * cnt)
cnt += 1
print(cnt)
``` | 5 5 10 5 4
| 1
| 1
| true | 1,640 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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..*..\n..*..\n', 'output': 'YES\n3 3\n'}, {'type': 'stdin_stdout', 'input... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/699/B'} | vfc_10054 | ```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... | 3 4
.*..
....
.*..
| YES
1 2
| YES
1 2
| true | 1,642 |
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))
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '500000000001 1000000000000 100 100\n', 'output': '49999999999900\n'},... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/990/A'} | vfc_10058 | ```python
n, m, a, b = list(map(int, input().split()))
k = n%m
print(min(k*b, (m - k)*a))
``` | 9 7 3 8
| 15
| 15
| true | 1,643 |
apps | verifiable_code | 77 | Solve the following coding problem using the programming language python:
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.... | ```python
n = int(input())
a = list(map(int, input().split()))
res = 0
new_a = []
for i in range(n):
if a[i] % 2 == 0:
if a[i] > 0:
res += a[i]
else:
new_a.append(a[i])
a = new_a
a.sort()
res += a[-1]
a.pop()
while len(a) > 1:
if a[-1] + a[-2] > 0:
res += a[-1] + a[-2]
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n-2 2 -3 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '3\n2 -5 -3\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '1\n1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1\n-1\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '15\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/797/B'} | vfc_10062 | ```python
n = int(input())
a = list(map(int, input().split()))
res = 0
new_a = []
for i in range(n):
if a[i] % 2 == 0:
if a[i] > 0:
res += a[i]
else:
new_a.append(a[i])
a = new_a
a.sort()
res += a[-1]
a.pop()
while len(a) > 1:
if a[-1] + a[-2] > 0:
res += a[-1] + a[-2]
... | 4
-2 2 -3 1
| 3
| 3
| true | 1,644 |
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:
... | {'test_cases': [{'type': 'stdin_stdout', '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': '10\n'}, {'type': 'stdin_stdout', 'input': '1 1\n1 1\n', 'output': '1\n'}, {'t... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1185/G1'} | vfc_10066 | ```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:
... | 3 3
1 1
1 2
1 3
| 6
| 6
| true | 1,645 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '3\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '5\n', 'output': '16666667... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1139/D'} | vfc_10070 | ```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... | 1
| 1
| 1
| true | 1,646 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '2 23\n21 23\n', 'output': '2'}, {'type': 'stdin_stdout', 'input': '5 1... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/810/A'} | vfc_10082 | ```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)
``` | 2 10
8 9
| 4 | 4
| true | 1,647 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '1\n777\n', 'output': '1'}, {'type': 'stdin_stdout', 'input... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1130/A'} | vfc_10086 | ```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)
``` | 5
10 0 -7 2 6
| 1 | 1
| true | 1,648 |
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:
... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '999999999\n', 'output': '499999999\n'}, {'type': 'stdin_stdout', 'input': '15\n', 'output'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/899/D'} | vfc_10090 | ```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:
... | 7
| 3
| 3
| true | 1,649 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': '36 5\n10 12\n', 'output': '1\n24 5\n10 12\n'}... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/490/D'} | vfc_10094 | ```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... | 2 6
2 3
| 1
1 6
2 3
| 1
1 6
2 3
| true | 1,650 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '80 100 83 97\n', 'output': 'Vasiliy\n'}, {'type': 's... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/532/C'} | vfc_10098 | ```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... | 2 1 2 2
| Polycarp
| Polycarp
| true | 1,651 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '2 7\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '2 1\n', 'output': '4\n'}... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/760/A'} | vfc_10102 | ```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)
``` | 1 7
| 6
| 6
| true | 1,652 |
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) <=... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '72057594000000000 72057595000000000\n', 'output': '26\n'}, {'type': 'stdin_... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/611/B'} | vfc_10106 | ```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) <=... | 5 10
| 2
| 2
| true | 1,653 |
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)))
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '21\n', 'output': '121\n'}, {'type': 'stdin_stdout', 'input': '100\n', 'output': '2550\n'}, {... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/909/B'} | vfc_10110 | ```python
n=int(input())
print(max((i+1)*(n-i)for i in range(n)))
``` | 2
| 2
| 2
| true | 1,654 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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_stdout', 'input': '25 25 25\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/525/E'} | vfc_10114 | ```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... | 2 2 30
4 3
| 1
| 1
| true | 1,655 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': '1\n1 10\n100... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1312/C'} | vfc_10118 | ```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... | 5
4 100
0 0 0 0
1 2
1
3 4
1 4 1
3 2
0 1 3
3 9
0 59049 810
| YES
YES
NO
NO
YES
| YES
YES
NO
NO
YES
| true | 1,656 |
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 ... | {'test_cases': [{'type': 'stdin_stdout', '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_stdout', 'input': '38 47 5\n', 'output': '160665\n'}, {'type': 'stdin_stdout', 'input'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/236/B'} | vfc_10122 | ```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 ... | 2 2 2
| 20
| 20
| true | 1,657 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': 'AB\nXC\nAX\nCB\n', 'output': 'YES\n'}, {'type': '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/645/A'} | vfc_10126 | ```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... | AB
XC
XB
AC
| YES
| YES
| true | 1,658 |
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,... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '17\n2016\n', 'output': '594'}, {'type': 'stdin_stdout', 'input': '1000\n1... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/758/D'} | vfc_10130 | ```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,... | 13
12
| 12 | 12
| true | 1,659 |
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")
``` | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': '7\n3 3 3 3 3 3 3\n', 'output': 'YES\n'}, {'type':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/831/A'} | vfc_10134 | ```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")
``` | 6
1 5 5 5 4 2
| YES
| YES
| true | 1,660 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '14 5\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '1000000 100\n', 'out... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1271/E'} | vfc_10138 | ```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... | 11 3
| 5
| 5
| true | 1,661 |
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
... | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '1000000000 1000000000 1 1000000000 0 1\n', 'output': '-1'},... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/982/E'} | vfc_10142 | ```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
... | 4 3 2 2 -1 1
| 0 0 | 0 0
| true | 1,662 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': '3 3\n1 1\n1 1\n', 'output': 'YES\n'}, {'type': 'std... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/560/B'} | vfc_10146 | ```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... | 3 2
1 3
2 1
| YES
| YES
| true | 1,663 |
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 ... | {'test_cases': [{'type': 'stdin_stdout', '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 124\n', 'output': 'inf'}, {'type': 'stdin_stdout', 'input': '3 2 25 2\n3... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/789/B'} | vfc_10150 | ```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 ... | 3 2 30 4
6 14 25 48
| 3 | 3
| true | 1,664 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '9960594\n2551\n2557\n', 'output': 'YES\n1951 1949\n'}... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/898/B'} | vfc_10158 | ```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... | 7
2
3
| YES
2 1
| YES
2 1
| true | 1,665 |
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:
... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '10\n', 'output': 'ten\n'}, {'type': 'stdin_stdout', 'input': '15\n', 'out... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/535/A'} | vfc_10162 | ```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:
... | 6
| six
| six
| true | 1,666 |
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))
``` | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '1\n1\n', 'output': '0'}, {'type': 'stdin_stdout', 'input': '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1062/A'} | vfc_10166 | ```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))
``` | 6
1 3 4 5 6 9
| 2 | 2
| true | 1,667 |
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()
``` | {'test_cases': [{'type': 'stdin_stdout', '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_stdout', 'input': '3\n2 1 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/962/A'} | vfc_10170 | ```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()
``` | 4
1 3 2 1
| 2
| 2
| true | 1,668 |
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):... | {'test_cases': [{'type': 'stdin_stdout', '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 12\n11 2 7 10\n', 'output': '23 0\n'}, {'type': 'stdin_stdout', 'input':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1065/D'} | vfc_10174 | ```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):... | 3
1 9 3
8 6 7
4 2 5
| 12 1
| 12 1
| true | 1,669 |
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) ... | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': '1000 1000 1000\n1 1000000000\n', 'output': '10... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/649/B'} | vfc_10178 | ```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) ... | 4 10 5
200 6
| 39
| 39
| true | 1,670 |
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')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '100010001\n', 'output': 'yes'}, {'type': 'stdin_stdout', 'input': '100\n', 'output': 'no'}, {'type': 'stdin_stdout', 'input': '0000001000000\n', 'output': 'yes'}, {'type': 'stdin_stdout', 'input': '11111111111111111111111111111111111111111111111111111111111111111111111... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/887/A'} | vfc_10182 | ```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')
``` | 100010001
| yes | yes
| true | 1,671 |
apps | verifiable_code | 108 | Solve the following coding problem using the programming language python:
You are given a string s consisting of |s| small english letters.
In one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with t, etc.). You cannot repl... | ```python
s = list(input())
target = 'abcdefghijklmnopqrstuvwxyz'
ind_t = 0
ind_s = 0
while ind_s < len(s) and ind_t < 26:
if ord(s[ind_s]) <= ord(target[ind_t]):
s[ind_s] = target[ind_t]
ind_t += 1
ind_s += 1
else:
ind_s += 1
if ind_t == 26:
print(''.join(s))
else:
print(-1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': 'aacceeggiikkmmooqqssuuwwyy\n', 'output': 'abcdefghijklmnopqrstuvwxyz\n'}, {'type': 'stdin_stdout', 'input': 'thereisnoanswer\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': 'jqcfvsaveaixhioaaeephbmsmfcgdyawscpyioybkgxlcrhaxs\n', 'output': '-1\n'}, {'type': 'st... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/946/C'} | vfc_10186 | ```python
s = list(input())
target = 'abcdefghijklmnopqrstuvwxyz'
ind_t = 0
ind_s = 0
while ind_s < len(s) and ind_t < 26:
if ord(s[ind_s]) <= ord(target[ind_t]):
s[ind_s] = target[ind_t]
ind_t += 1
ind_s += 1
else:
ind_s += 1
if ind_t == 26:
print(''.join(s))
else:
print(-1)
``` | aacceeggiikkmmooqqssuuwwyy
| abcdefghijklmnopqrstuvwxyz
| abcdefghijklmnopqrstuvwxyz
| true | 1,672 |
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 ... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '1 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '866421317361600 26880\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/762/A'} | vfc_10198 | ```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 ... | 4 2
| 2
| 2
| true | 1,674 |
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()
``` | {'test_cases': [{'type': 'stdin_stdout', '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_stdout', 'input': '123456789 8\n', 'output': '12345678900000000\n'}, {'type': 'stdi... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/858/A'} | vfc_10206 | ```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()
``` | 375 4
| 30000
| 30000
| true | 1,675 |
apps | verifiable_code | 114 | Solve the following coding problem using the programming language python:
You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$.
You may perform some operations with matrix $B$. During each operatio... | ```python
n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [[0] * m for _ in range(n)]
ans = []
for i in range(n - 1):
for j in range(m - 1):
if A[i][j] == 1 and A[i + 1][j] == 1 and A[i][j + 1] == 1 and A[i + 1][j + 1] == 1:
B[i][j] = 1
B[... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 3\n1 1 1\n1 1 1\n0 1 1\n', 'output': '3\n1 1\n1 2\n2 2\n'}, {'type': 'stdin_stdout', 'input': '3 3\n1 0 1\n1 0 1\n0 0 0\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '3 2\n0 0\n0 0\n0 0\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '2 50\n0 1 1 1... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1207/B'} | vfc_10210 | ```python
n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [[0] * m for _ in range(n)]
ans = []
for i in range(n - 1):
for j in range(m - 1):
if A[i][j] == 1 and A[i + 1][j] == 1 and A[i][j + 1] == 1 and A[i + 1][j + 1] == 1:
B[i][j] = 1
B[... | 3 3
1 1 1
1 1 1
0 1 1
| 3
1 1
1 2
2 2
| 3
1 1
1 2
2 2
| true | 1,676 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '1 1000000000 1 1000000000 1\n', 'output': '999999999\n'}, {... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/714/A'} | vfc_10218 | ```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)
``` | 1 10 9 20 1
| 2
| 2
| true | 1,678 |
apps | verifiable_code | 117 | Solve the following coding problem using the programming language python:
There is a grass field that stretches infinitely.
In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing ... | ```python
#写経
#https://atcoder.jp/contests/abc168/submissions/14421546
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
from bisect import bisect_left, bisect_right
INF = 10 **18
def resolve():
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [l... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n', 'output': '13\n'}, {'type': 'stdin_stdout', 'input': '6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n', 'output': 'INF\n'}, {'type': 'stdin_stdout', 'input': '586... | {'difficulty': 'interview', 'problem_url': 'https://atcoder.jp/contests/abc168/tasks/abc168_f'} | vfc_10222 | ```python
#写経
#https://atcoder.jp/contests/abc168/submissions/14421546
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
from bisect import bisect_left, bisect_right
INF = 10 **18
def resolve():
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [l... | 5 6
1 2 0
0 1 1
0 2 2
-3 4 -1
-2 6 3
1 0 1
0 1 2
2 0 2
-1 -4 5
3 -2 4
1 2 4
| 13
| 13
| true | 1,679 |
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')
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '3 8 52\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '456947... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/697/A'} | vfc_10226 | ```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')
``` | 3 10 4
| NO
| NO
| true | 1,680 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '4\nAA??\n', 'output': '===\n'}, {'type': 'stdin_stdout',... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/747/B'} | vfc_10234 | ```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... | 8
AG?C??CT
| AGACGTCT
| AGACGTCT
| true | 1,681 |
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(... | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '5\n72 32 17 46 82\n', 'output': 'NO\n'}, {'type': 'stdin_s... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/808/D'} | vfc_10242 | ```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(... | 3
1 3 2
| YES
| YES
| true | 1,682 |
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))... | {'test_cases': [{'type': 'stdin_stdout', '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': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/814/A'} | vfc_10246 | ```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))... | 4 2
11 0 0 14
5 4
| Yes
| Yes
| true | 1,683 |
apps | verifiable_code | 125 | Solve the following coding problem using the programming language python:
Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes getting out of the intersect... | ```python
lanes = []
for i in range(4):
lanes.append(list(map(int, input().split())))
lanes.extend(lanes)
for i in range(4):
ln = lanes[i]
if (ln[3] and (ln[0] or ln[1] or ln[2])) or \
(ln[0] and lanes[i + 3][3]) or \
(ln[1] and lanes[i + 2][3]) or \
(ln[2] and lanes[i... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 0 0 1\n0 1 0 0\n0 0 1 0\n0 0 0 1\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '0 1 1 0\n1 0 1 0\n1 1 0 0\n0 0 0 1\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '1 0 0 0\n0 0 0 1\n0 0 0 0\n1 0 1 0\n', 'output': 'NO\n'}, {'type': 'stdin_stdout',... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/812/A'} | vfc_10254 | ```python
lanes = []
for i in range(4):
lanes.append(list(map(int, input().split())))
lanes.extend(lanes)
for i in range(4):
ln = lanes[i]
if (ln[3] and (ln[0] or ln[1] or ln[2])) or \
(ln[0] and lanes[i + 3][3]) or \
(ln[1] and lanes[i + 2][3]) or \
(ln[2] and lanes[i... | 1 0 0 1
0 1 0 0
0 0 1 0
0 0 0 1
| YES
| YES
| true | 1,684 |
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")
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '3\n911\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '3\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/689/A'} | vfc_10258 | ```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")
``` | 3
586
| NO
| NO
| true | 1,685 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': '2 1\n8 12\n6 11\n', 'output': '19'}, {'type': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/810/B'} | vfc_10262 | ```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)
``` | 4 2
2 1
3 5
2 3
1 5
| 10 | 10
| true | 1,686 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '1 1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '8 3\n', 'outp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/645/B'} | vfc_10266 | ```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)
``` | 5 2
| 10
| 10
| true | 1,687 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '10 2 9 7\n', 'output': '-1'}, {'type': 'stdin_stdout', 'input': '5308978004... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1068/A'} | vfc_10270 | ```python
n, m, k, l = map(int, input().split())
cnt = (k + l + m - 1) // m
if cnt * m > n:
print(-1)
else:
print(cnt)
``` | 20 15 2 3
| 1 | 1
| true | 1,688 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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\n'}, {'type': 'stdin_stdout', 'input': '100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/828/B'} | vfc_10274 | ```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... | 5 4
WWWW
WWWB
WWWB
WWBB
WWWW
| 5
| 5
| true | 1,689 |
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')
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '40\n361 372 139 808 561 460 4... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1013/A'} | vfc_10278 | ```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')
``` | 5
1 2 3 4 5
2 1 4 3 5
| Yes
| Yes
| true | 1,690 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '4\n170 30 150 10\n', 'output': '0\n'}, {'type': 'stdin_std... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/895/A'} | vfc_10282 | ```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)
``` | 4
90 90 90 90
| 0
| 0
| true | 1,691 |
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((... | {'test_cases': [{'type': 'stdin_stdout', '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_stdout', 'input': '489132389 96\n', 'output': '496937'}, {'type': 'stdin_stdout', 'in... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1236/B'} | vfc_10286 | ```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((... | 1 3
| 7 | 7
| true | 1,692 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '17\n', 'output': '144 145'}, {'type': 'stdin_stdout', 'input': '67\n', 'output': '2244 2245'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/707/C'} | vfc_10290 | ```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)
``` | 3
| 4 5 | 4 5
| true | 1,693 |
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()
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '744 18\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '47879 10\n', 'ou... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/922/C'} | vfc_10294 | ```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()
``` | 4 4
| No
| No
| true | 1,694 |
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 '>')
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '0123\n9\n', 'output': '>\n'}, {'type': 'stdin_stdout', 'input': '0123... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/616/A'} | vfc_10298 | ```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 '>')
``` | 9
10
| <
| <
| true | 1,695 |
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]... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '1 0\n-1\n', 'output': '0'}, {'type': 'stdin_stdout', 'input': '1 1\n0\n', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/979/E'} | vfc_10302 | ```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]... | 3 1
-1 0 1
| 6 | 6
| true | 1,696 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '999999999 1000000000 1000000000 1000000000\n', 'output': '1000000000\n'}, ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/740/A'} | vfc_10306 | ```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)
``` | 1 1 3 4
| 3
| 3
| true | 1,697 |
apps | verifiable_code | 141 | Solve the following coding problem using the programming language python:
You have a set of items, each having some integer weight not greater than $8$. You denote that a subset of items is good if total weight of items in the subset does not exceed $W$.
You want to calculate the maximum possible weight of a good sub... | ```python
import time
import random
W = int(input())
M = [int(a) for a in input().split()]
A = [0] * 8
sTime = time.time()
s = 0
mi = 10**20
for i in range(8):
if s + M[i]*(i+1) <= W:
s += M[i]*(i+1)
A[i] = M[i]
else:
t = (W-s)//(i+1)
s += t*(i+1)
A[i] += t
if s... | {'test_cases': [{'type': 'stdin_stdout', 'input': '10\n1 2 3 4 5 6 7 8\n', 'output': '10\n'}, {'type': 'stdin_stdout', 'input': '0\n0 0 0 0 0 0 0 0\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '3\n0 4 1 0 0 9 8 3\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '27\n0 0 0 0 0 5 0 0\n', 'output': '24\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1132/E'} | vfc_10318 | ```python
import time
import random
W = int(input())
M = [int(a) for a in input().split()]
A = [0] * 8
sTime = time.time()
s = 0
mi = 10**20
for i in range(8):
if s + M[i]*(i+1) <= W:
s += M[i]*(i+1)
A[i] = M[i]
else:
t = (W-s)//(i+1)
s += t*(i+1)
A[i] += t
if s... | 10
1 2 3 4 5 6 7 8
| 10
| 10
| true | 1,698 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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': '30\n'}, {'type': 'stdin_stdout', 'input': '5 787787787\n123456789 2345678... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/913/C'} | vfc_10322 | ```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... | 4 12
20 30 70 90
| 150
| 150
| true | 1,699 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '1\n1000000000\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '1\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/682/B'} | vfc_10326 | ```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)
``` | 5
1 3 3 3 6
| 5
| 5
| true | 1,700 |
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
... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '3\n555\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '8\n0... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1030/C'} | vfc_10330 | ```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
... | 5
73452
| YES
| YES
| true | 1,701 |
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!")
``` | {'test_cases': [{'type': 'stdin_stdout', '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!\n'}, {'type': 'stdin_stdout', 'input': 'pezu\n', 'output': 'CHAT WITH HER!\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/236/A'} | vfc_10334 | ```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!")
``` | wjmzbmr
| CHAT WITH HER!
| CHAT WITH HER!
| true | 1,702 |
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)))
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '4 2\n-1 1 -1 -1\n', 'output... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1100/A'} | vfc_10338 | ```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)))
``` | 4 2
1 1 -1 1
| 2
| 2
| true | 1,703 |
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]
... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '5 5 5\n', 'output': '60\n'}, {'type': 'stdin_stdout', 'input': '4 0 0\n', 'outp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/717/B'} | vfc_10342 | ```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]
... | 4 1 2
| 12
| 12
| true | 1,704 |
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])
``` | {'test_cases': [{'type': 'stdin_stdout', '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_stdout', 'input': '100 2 97 84 89\n', 'output': 'YES\n'}, {'type': 'stdin_stdout'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1169/A'} | vfc_10346 | ```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])
``` | 5 1 4 3 2
| YES
| YES
| true | 1,705 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '2 2 1 10\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '2 2 1... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/813/B'} | vfc_10350 | ```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)
``` | 2 3 1 10
| 1
| 1
| true | 1,706 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '5\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '10\n', 'output': '2\n'}, {'type'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/735/D'} | vfc_10354 | ```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)
``` | 4
| 2
| 2
| true | 1,707 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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'}, {'type': 'stdin_stdout', 'input': 'ooo\n', 'output': 'ooo \n'}, {'type': 'stdin_stdou... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/858/C'} | vfc_10358 | ```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... | hellno
| hell no
| hell no
| true | 1,708 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '10 3 3\n10 33\n1 7 6\n17 25 68\n2 9 10\n78 89 125\n', 'outp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/734/C'} | vfc_10362 | ```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... | 20 3 2
10 99
2 4 3
20 10 40
4 15
10 80
| 20
| 20
| true | 1,709 |
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... | {'test_cases': [{'type': 'stdin_stdout', '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': 'stdin_stdout', 'input': '1 1 1\n1\n', 'output': '2\n'}, {'type': 'stdin_stdout'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/846/B'} | vfc_10366 | ```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... | 3 4 11
1 2 3 4
| 6
| 6
| true | 1,710 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '5\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '7\n', 'output': '0\n'}, {'type': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1237/E'} | vfc_10370 | ```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)
``` | 4
| 1
| 1
| true | 1,711 |
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)
``` | {'test_cases': [{'type': 'stdin_stdout', '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', 'input': '1000000000 2 1999999999\n', 'output': '1 2\n'}, {'type': 'stdin_stdout', ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/976/B'} | vfc_10374 | ```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)
``` | 4 3 0
| 1 1
| 1 1
| true | 1,712 |
apps | verifiable_code | 157 | Solve the following coding problem using the programming language python:
Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't cr... | ```python
n1 = int( input() )
n2 = int( input() )
n3 = int( input() )
print( min( n1 , n2 // 2 , n3 // 4 ) * 7 )
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n5\n7\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '4\n7\n13\n', 'output': '21\n'}, {'type': 'stdin_stdout', 'input': '2\n3\n2\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1\n1\n1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1\n2\n4... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/746/A'} | vfc_10382 | ```python
n1 = int( input() )
n2 = int( input() )
n3 = int( input() )
print( min( n1 , n2 // 2 , n3 // 4 ) * 7 )
``` | 2
5
7
| 7
| 7
| true | 1,714 |
apps | verifiable_code | 158 | Solve the following coding problem using the programming language python:
Berland annual chess tournament is coming!
Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organ... | ```python
n = int(input())
z = list(map(int, input().split()))
z.sort()
if z[n - 1] < z[n]:
print("YES")
else:
print("NO")
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n1 3 2 4\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '1\n3 3\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '5\n1 1 1 1 2 2 3 3 3 3\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '5\n1 1 1 1 1 2 2 2 2 2\n', 'output': 'YES\n'}, {'type... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/845/A'} | vfc_10386 | ```python
n = int(input())
z = list(map(int, input().split()))
z.sort()
if z[n - 1] < z[n]:
print("YES")
else:
print("NO")
``` | 2
1 3 2 4
| YES
| YES
| true | 1,715 |
apps | verifiable_code | 161 | Solve the following coding problem using the programming language python:
Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.
Assume that we have a cat with a numbe... | ```python
def main():
x = int(input())
n = x.bit_length()
t = 0
ans = []
while True:
if (x + 1) & (x) == 0:
break
if t & 1:
x += 1
else:
for i in range(n - 1, -1, -1):
if not (1 << i) & x:
ans.append(i + ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '39\n', 'output': '4\n5 3 '}, {'type': 'stdin_stdout', 'input': '1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '7\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1000000\n', 'output': '7\n14 6 9 15 '}, {'type': 'stdin_stdout', 'input': '524288\n', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1152/B'} | vfc_10398 | ```python
def main():
x = int(input())
n = x.bit_length()
t = 0
ans = []
while True:
if (x + 1) & (x) == 0:
break
if t & 1:
x += 1
else:
for i in range(n - 1, -1, -1):
if not (1 << i) & x:
ans.append(i + ... | 39
| 4
5 3 | 4
5 3
| true | 1,716 |
apps | verifiable_code | 162 | Solve the following coding problem using the programming language python:
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water a... | ```python
n, k = map(int, input().split())
a = list(map(int, input().split()))
maxd = -1
for x in a:
if k % x == 0:
maxd = max(maxd, x)
print(k // maxd)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 6\n2 3 5\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '6 7\n1 2 3 4 5 6\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '5 97\n1 10 50 97 2\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '5 97\n1 10 50 100 2\n', 'output': '97\n'}, {'type':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/915/A'} | vfc_10402 | ```python
n, k = map(int, input().split())
a = list(map(int, input().split()))
maxd = -1
for x in a:
if k % x == 0:
maxd = max(maxd, x)
print(k // maxd)
``` | 3 6
2 3 5
| 2
| 2
| true | 1,717 |
apps | verifiable_code | 163 | Solve the following coding problem using the programming language python:
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper t... | ```python
from math import *
from sys import *
from queue import *
from decimal import *
n,k=(int(z) for z in input().split())
s=input()
i=0
while i<len(s) and s[i] not in ["G","T"]:
i+=1
i+=k
while i<len(s) and s[i] not in ["G","T","#"]:
i+=k
if i>=len(s) or s[i]=="#":
print("NO")
else:
print("YES")
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 2\n#G#T#\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '6 1\nT....G\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '7 3\nT..#..G\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '6 2\n..GT..\n', 'output': 'NO\n'}, {'type': 'stdin_stdout... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/735/A'} | vfc_10406 | ```python
from math import *
from sys import *
from queue import *
from decimal import *
n,k=(int(z) for z in input().split())
s=input()
i=0
while i<len(s) and s[i] not in ["G","T"]:
i+=1
i+=k
while i<len(s) and s[i] not in ["G","T","#"]:
i+=k
if i>=len(s) or s[i]=="#":
print("NO")
else:
print("YES")
``` | 5 2
#G#T#
| YES
| YES
| true | 1,718 |
apps | verifiable_code | 164 | Solve the following coding problem using the programming language python:
It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guy... | ```python
y1, y2, w, x, y, r = map(int, input().strip().split())
w -= r
y1 = 2 * w - y1 - y - r
y2 = 2 * w - y2 - y
if x * x * (y2 - y1) * (y2 - y1) <= (y1 * y1 + x * x) * r * r:
print(-1)
else:
print(f"{x * (y1 + y - w) / y1:.10f}")
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 10 13 10 3 1\n', 'output': '4.3750000000\n'}, {'type': 'stdin_stdout', 'input': '1 4 6 2 2 1\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '3 10 15 17 9 2\n', 'output': '11.3333333333\n'}, {'type': 'stdin_stdout', 'input': '4 9 30 3 3 1\n', 'output': '-1\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/248/C'} | vfc_10410 | ```python
y1, y2, w, x, y, r = map(int, input().strip().split())
w -= r
y1 = 2 * w - y1 - y - r
y2 = 2 * w - y2 - y
if x * x * (y2 - y1) * (y2 - y1) <= (y1 * y1 + x * x) * r * r:
print(-1)
else:
print(f"{x * (y1 + y - w) / y1:.10f}")
``` | 4 10 13 10 3 1
| 4.3750000000
| 4.3750000000
| true | 1,719 |
apps | verifiable_code | 165 | Solve the following coding problem using the programming language python:
Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation!
Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only t... | ```python
a = list(map(int, input().split()))
m = max(a)
ans = 0
for i in range(3):
if a[i] < m - 1:
ans += (m - 1) - a[i]
a[i] = m - 1
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 2 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 0 0\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1 1 1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1000000000000000000 0 1000000000000000000\n', 'output': '999999999999999999\n'},... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/732/C'} | vfc_10414 | ```python
a = list(map(int, input().split()))
m = max(a)
ans = 0
for i in range(3):
if a[i] < m - 1:
ans += (m - 1) - a[i]
a[i] = m - 1
print(ans)
``` | 3 2 1
| 1
| 1
| true | 1,720 |
apps | verifiable_code | 166 | Solve the following coding problem using the programming language python:
There is a matrix A of size x × y filled with integers. For every $i \in [ 1 . . x ]$, $j \in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix.
You have traversed some path in this ... | ```python
MAXN = 1000000000
n = int(input())
a = list(map(int, input().split()))
def solve1():
for i in range(n-1):
if abs(a[i]-a[i+1]) != 1:
return False
print("YES\n%d %d" % (MAXN, 1))
return True
def solve2():
w = -1
for i in range(n-1):
d = abs(a[i]-a[i+1])
if d != 1:
if w == -1:
w = d
e... | {'test_cases': [{'type': 'stdin_stdout', 'input': '8\n1 2 3 6 9 8 5 2\n', 'output': 'YES\n1000000000 3\n'}, {'type': 'stdin_stdout', 'input': '6\n1 2 1 2 5 3\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '2\n1 10\n', 'output': 'YES\n1000000000 9\n'}, {'type': 'stdin_stdout', 'input': '3\n1 2 2\n', 'output': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/954/C'} | vfc_10418 | ```python
MAXN = 1000000000
n = int(input())
a = list(map(int, input().split()))
def solve1():
for i in range(n-1):
if abs(a[i]-a[i+1]) != 1:
return False
print("YES\n%d %d" % (MAXN, 1))
return True
def solve2():
w = -1
for i in range(n-1):
d = abs(a[i]-a[i+1])
if d != 1:
if w == -1:
w = d
e... | 8
1 2 3 6 9 8 5 2
| YES
1000000000 3
| YES
1000000000 3
| true | 1,721 |
apps | verifiable_code | 168 | Solve the following coding problem using the programming language python:
Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.
You are given $n$ operati... | ```python
n = int(input())
s = input()
b = 0
for i in s:
if i == '+':
b += 1
else:
b -= 1
b = max(b, 0)
print(b)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n---\n', 'output': '0'}, {'type': 'stdin_stdout', 'input': '4\n++++\n', 'output': '4'}, {'type': 'stdin_stdout', 'input': '2\n-+\n', 'output': '1'}, {'type': 'stdin_stdout', 'input': '5\n++-++\n', 'output': '3'}, {'type': 'stdin_stdout', 'input': '1\n+\n', 'output': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1159/A'} | vfc_10426 | ```python
n = int(input())
s = input()
b = 0
for i in s:
if i == '+':
b += 1
else:
b -= 1
b = max(b, 0)
print(b)
``` | 3
---
| 0 | 0
| true | 1,722 |
apps | verifiable_code | 169 | Solve the following coding problem using the programming language python:
Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.
Kolya is hungr... | ```python
n=int(input())
a=int(input())
b=int(input())
c=int(input())
r=n//a
if n > c:
r=max(r,(r-b+c)//a+1,(n-c)//(b-c)+((n-c)%(b-c)+c)//a)
print(r)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '10\n11\n9\n8\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '10\n5\n6\n1\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '2\n2\n2\n1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '10\n3\n3\n1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'in... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/625/A'} | vfc_10430 | ```python
n=int(input())
a=int(input())
b=int(input())
c=int(input())
r=n//a
if n > c:
r=max(r,(r-b+c)//a+1,(n-c)//(b-c)+((n-c)%(b-c)+c)//a)
print(r)
``` | 10
11
9
8
| 2
| 2
| true | 1,723 |
apps | verifiable_code | 170 | Solve the following coding problem using the programming language python:
Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then the... | ```python
n = int(input())
k1 = list(map(int, input().split()[1:]))
k2 = list(map(int, input().split()[1:]))
i = 0
while True:
if len(k1) == 0 or len(k2) == 0:
break
if i > 10000:
break
if k1[0] > k2[0]:
k1 = k1[1:] + k2[0:1] + k1[0:1]
k2 = k2[1:]
else:
k2 = k2[1... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n2 1 3\n2 4 2\n', 'output': '6 2'}, {'type': 'stdin_stdout', 'input': '3\n1 2\n2 1 3\n', 'output': '-1'}, {'type': 'stdin_stdout', 'input': '5\n4 5 3 2 4\n1 1\n', 'output': '1 1'}, {'type': 'stdin_stdout', 'input': '6\n2 6 5\n4 1 2 3 4\n', 'output': '6 1'}, {'type': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/546/C'} | vfc_10434 | ```python
n = int(input())
k1 = list(map(int, input().split()[1:]))
k2 = list(map(int, input().split()[1:]))
i = 0
while True:
if len(k1) == 0 or len(k2) == 0:
break
if i > 10000:
break
if k1[0] > k2[0]:
k1 = k1[1:] + k2[0:1] + k1[0:1]
k2 = k2[1:]
else:
k2 = k2[1... | 4
2 1 3
2 4 2
| 6 2 | 6 2
| true | 1,724 |
apps | verifiable_code | 171 | Solve the following coding problem using the programming language python:
You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a ... | ```python
s = input().strip()
flag1 = len(s) >= 5
d1 = 'qwertyuiopasdfghjklzxcvbnm'
d2 = 'QWERTYUIOPASDFGHJKLZXCVBNM'
d3 = '123456789'
flag2 = False
flag3 = False
flag4 = False
for i in d1:
if i in s:
flag2 = True
for i in d2:
if i in s:
flag3 = True
for i in d3:
if i in s:
flag4 = ... | {'test_cases': [{'type': 'stdin_stdout', 'input': 'abacaba\n', 'output': 'Too weak\n'}, {'type': 'stdin_stdout', 'input': 'X12345\n', 'output': 'Too weak\n'}, {'type': 'stdin_stdout', 'input': 'CONTEST_is_STARTED!!11\n', 'output': 'Correct\n'}, {'type': 'stdin_stdout', 'input': '1zA__\n', 'output': 'Correct\n'}, {'type... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/411/A'} | vfc_10438 | ```python
s = input().strip()
flag1 = len(s) >= 5
d1 = 'qwertyuiopasdfghjklzxcvbnm'
d2 = 'QWERTYUIOPASDFGHJKLZXCVBNM'
d3 = '123456789'
flag2 = False
flag3 = False
flag4 = False
for i in d1:
if i in s:
flag2 = True
for i in d2:
if i in s:
flag3 = True
for i in d3:
if i in s:
flag4 = ... | abacaba
| Too weak
| Too weak
| true | 1,725 |
apps | verifiable_code | 172 | Solve the following coding problem using the programming language python:
In Berland each high school student is characterized by academic performance — integer value between 1 and 5.
In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academi... | ```python
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0] * 5
b = [0] * 5
for j in range(n):
a[A[j]-1] += 1
b[B[j]-1] +=1
per = 0
for j in range(5):
if (a[j] + b[j]) % 2 == 1:
per = 1
break
if per == 1:
print(-1)
else:
ans = 0
for j ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n5 4 4 4\n5 5 4 5\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '6\n1 1 1 1 1 1\n5 5 5 5 5 5\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '1\n5\n3\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/779/A'} | vfc_10442 | ```python
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0] * 5
b = [0] * 5
for j in range(n):
a[A[j]-1] += 1
b[B[j]-1] +=1
per = 0
for j in range(5):
if (a[j] + b[j]) % 2 == 1:
per = 1
break
if per == 1:
print(-1)
else:
ans = 0
for j ... | 4
5 4 4 4
5 5 4 5
| 1
| 1
| true | 1,726 |
apps | verifiable_code | 173 | Solve the following coding problem using the programming language python:
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the ... | ```python
a, b = list(map(int, input().split(' ')))
hor = input()
ver = input()
if (hor[0], ver[0]) == ('>', 'v') or (hor[0], ver[-1]) == ('<', 'v'):
print("NO")
elif (hor[-1], ver[0]) == ('>', '^') or (hor[-1], ver[-1]) == ('<', '^'):
print("NO")
else:
print("YES")
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 3\n><>\nv^v\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '4 6\n<><>\nv^v^v^\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '2 2\n<>\nv^\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '2 2\n>>\n^v\n', 'output': 'NO\n'}, {'type': 'stdi... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/475/B'} | vfc_10446 | ```python
a, b = list(map(int, input().split(' ')))
hor = input()
ver = input()
if (hor[0], ver[0]) == ('>', 'v') or (hor[0], ver[-1]) == ('<', 'v'):
print("NO")
elif (hor[-1], ver[0]) == ('>', '^') or (hor[-1], ver[-1]) == ('<', '^'):
print("NO")
else:
print("YES")
``` | 3 3
><>
v^v
| NO
| NO
| true | 1,727 |
apps | verifiable_code | 174 | Solve the following coding problem using the programming language python:
Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false.
Implication is written by using character '$\rightarrow$', and the arg... | ```python
x = int(input())
seq = list(map(int, input().split(' ')))
if seq == [0]:
print("YES")
print(0)
elif seq == [0, 0]:
print("NO")
elif seq == [1, 0]:
print("YES")
print('1->0')
elif seq == [0, 0, 0]:
print("YES")
print("(0->0)->0")
elif seq == [1, 0, 0]:
print("NO")
elif se... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n0 1 1 0\n', 'output': 'YES\n0->1->1->0\n'}, {'type': 'stdin_stdout', 'input': '2\n1 1\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '1\n0\n', 'output': 'YES\n0\n'}, {'type': 'stdin_stdout', 'input': '4\n0 0 0 0\n', 'output': 'YES\n0->(0->0)->0\n'}, {'type... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/550/E'} | vfc_10450 | ```python
x = int(input())
seq = list(map(int, input().split(' ')))
if seq == [0]:
print("YES")
print(0)
elif seq == [0, 0]:
print("NO")
elif seq == [1, 0]:
print("YES")
print('1->0')
elif seq == [0, 0, 0]:
print("YES")
print("(0->0)->0")
elif seq == [1, 0, 0]:
print("NO")
elif se... | 4
0 1 1 0
| YES
0->1->1->0
| YES
0->1->1->0
| true | 1,728 |
apps | verifiable_code | 175 | Solve the following coding problem using the programming language python:
You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise,... | ```python
a, b = [int(v) for v in input().split()]
while a > 0 and b > 0:
if a >= 2 * b:
a %= 2 * b
elif b >= 2 * a:
b %= 2 * a
else:
break
print(a, b)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '12 5\n', 'output': '0 1\n'}, {'type': 'stdin_stdout', 'input': '31 12\n', 'output': '7 12\n'}, {'type': 'stdin_stdout', 'input': '1000000000000000000 7\n', 'output': '8 7\n'}, {'type': 'stdin_stdout', 'input': '31960284556200 8515664064180\n', 'output': '14928956427840... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/946/B'} | vfc_10454 | ```python
a, b = [int(v) for v in input().split()]
while a > 0 and b > 0:
if a >= 2 * b:
a %= 2 * b
elif b >= 2 * a:
b %= 2 * a
else:
break
print(a, b)
``` | 12 5
| 0 1
| 0 1
| true | 1,729 |
apps | verifiable_code | 176 | Solve the following coding problem using the programming language python:
Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.
-----Input-----
The only line contains three space-separated integers k,... | ```python
s=input()
ast=[int(i) for i in s.split(' ')]
k,a,b=ast[0],ast[1],ast[2]
s1=(a-1)//k
s2=b//k
print(s2-s1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 1 10\n', 'output': '10\n'}, {'type': 'stdin_stdout', 'input': '2 -4 4\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '1 1 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 0 0\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 0 1\n', 'out... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/597/A'} | vfc_10458 | ```python
s=input()
ast=[int(i) for i in s.split(' ')]
k,a,b=ast[0],ast[1],ast[2]
s1=(a-1)//k
s2=b//k
print(s2-s1)
``` | 1 1 10
| 10
| 10
| true | 1,730 |
apps | verifiable_code | 177 | Solve the following coding problem using the programming language python:
Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...
Your tas... | ```python
a = int(input())
s = ""
for i in range(1, a+1):
s += str(i)
print(s[a-1])
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '7\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '21\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '2\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '3\n', 'output': '3\n'}, {'type':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1177/A'} | vfc_10462 | ```python
a = int(input())
s = ""
for i in range(1, a+1):
s += str(i)
print(s[a-1])
``` | 7
| 7
| 7
| true | 1,731 |
apps | verifiable_code | 178 | Solve the following coding problem using the programming language python:
A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then playe... | ```python
n, s = int(input()), input()
cnt = (n - 11) // 2
cnt_8 = len(s[:n - 10].split('8')) - 1
if (cnt >= cnt_8):
print ("NO")
else:
print ("YES")
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '13\n8380011223344\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '15\n807345619350641\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '19\n8181818181111111111\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '29\n888111881181818181181111111... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1155/B'} | vfc_10466 | ```python
n, s = int(input()), input()
cnt = (n - 11) // 2
cnt_8 = len(s[:n - 10].split('8')) - 1
if (cnt >= cnt_8):
print ("NO")
else:
print ("YES")
``` | 13
8380011223344
| YES
| YES
| true | 1,732 |
apps | verifiable_code | 179 | Solve the following coding problem using the programming language python:
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in ... | ```python
MOD = 1000000007
def f(n, cnt):
"""
n! / (n - cnt)!
"""
ans = 1
for _ in range(cnt):
ans = (ans * n) % MOD
n -= 1
return ans
def main():
n, x, pos = list(map(int, input().split()))
chk1 = 0
chk_r = 0
left = 0
right = n
while left < right:
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 1 2\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '123 42 24\n', 'output': '824071958\n'}, {'type': 'stdin_stdout', 'input': '1 1 0\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1000 501 501\n', 'output': '646597996\n'}, {'type': 'stdin_stdout', ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1436/C'} | vfc_10470 | ```python
MOD = 1000000007
def f(n, cnt):
"""
n! / (n - cnt)!
"""
ans = 1
for _ in range(cnt):
ans = (ans * n) % MOD
n -= 1
return ans
def main():
n, x, pos = list(map(int, input().split()))
chk1 = 0
chk_r = 0
left = 0
right = n
while left < right:
... | 4 1 2
| 6
| 6
| true | 1,733 |
apps | verifiable_code | 180 | Solve the following coding problem using the programming language python:
Andrey received a postcard from Irina. It contained only the words "Hello, Andrey!", and a strange string consisting of lowercase Latin letters, snowflakes and candy canes. Andrey thought that this string is an encrypted message, and decided to ... | ```python
s = input()
k = int(input())
c = 0
p = 0
has_star = False
for i in range(len(s)):
if s[i] in ['*', '?']:
if s[i] == '*':
has_star = True
c -= 1
else:
p += 1
c += 1
if k < c:
print("Impossible")
elif (not has_star) and (k > p):
print("Impossible")
els... | {'test_cases': [{'type': 'stdin_stdout', 'input': 'hw?ap*yn?eww*ye*ar\n12\n', 'output': 'hwapppyewyar'}, {'type': 'stdin_stdout', 'input': 'ab?a\n2\n', 'output': 'aa'}, {'type': 'stdin_stdout', 'input': 'ab?a\n3\n', 'output': 'aba'}, {'type': 'stdin_stdout', 'input': 'ababb\n5\n', 'output': 'ababb'}, {'type': 'stdin_st... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1099/C'} | vfc_10474 | ```python
s = input()
k = int(input())
c = 0
p = 0
has_star = False
for i in range(len(s)):
if s[i] in ['*', '?']:
if s[i] == '*':
has_star = True
c -= 1
else:
p += 1
c += 1
if k < c:
print("Impossible")
elif (not has_star) and (k > p):
print("Impossible")
els... | hw?ap*yn?eww*ye*ar
12
| hwapppyewyar | hwapppyewyar
| true | 1,734 |
apps | verifiable_code | 181 | Solve the following coding problem using the programming language python:
Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.
One of the project's know-how is a camera rotating around its optical axis on shooting. People ... | ```python
n = (-int(input())) % 360
ret, opt = 4, 361
for i in range(4):
x = (n+90*i)%360
x = min(x, 360-x)
if (x, i) < (opt, ret):
opt, ret = x, i
print(ret)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '60\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '-60\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '0\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '44\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '45\n', 'output': '0\n'}, {'ty... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/630/M'} | vfc_10478 | ```python
n = (-int(input())) % 360
ret, opt = 4, 361
for i in range(4):
x = (n+90*i)%360
x = min(x, 360-x)
if (x, i) < (opt, ret):
opt, ret = x, i
print(ret)
``` | 60
| 1
| 1
| true | 1,735 |
apps | verifiable_code | 182 | Solve the following coding problem using the programming language python:
Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x ... | ```python
a, b, c = list(map(int, input().split()))
x, y, z = list(map(int, input().split()))
col = max(0, x - a) + max(0, y - b) + max(0, z - c)
sum = max(0, (a - x) // 2) + max(0, (b - y) // 2) + max(0, (c - z) // 2)
if sum >= col:
print('Yes')
else:
print('No')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 4 0\n2 1 2\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '5 6 1\n2 7 2\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '3 3 3\n2 2 2\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '0 0 0\n0 0 0\n', 'output': 'Yes\n'}, {'type': 'stdin_s... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/606/A'} | vfc_10482 | ```python
a, b, c = list(map(int, input().split()))
x, y, z = list(map(int, input().split()))
col = max(0, x - a) + max(0, y - b) + max(0, z - c)
sum = max(0, (a - x) // 2) + max(0, (b - y) // 2) + max(0, (c - z) // 2)
if sum >= col:
print('Yes')
else:
print('No')
``` | 4 4 0
2 1 2
| Yes
| Yes
| true | 1,736 |
apps | verifiable_code | 183 | Solve the following coding problem using the programming language python:
Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.
First he gave Amr two positive integers n and k... | ```python
n,k,m=list(map(int,input().split()))
d,r,p,P=0,0,1%k,(10**(n-1))*9
F=[0]*k
F[0]=1
while d<n:
d+=1
P//=10
E=[0]*k
if P==0:P=1
i=1
# print("E=",E)
# print("F=",F)
while i<10:
j=(-i*p)%k
f=0
while f<k:
E[f]+=F[j]
f+=1
j+=1
if j==k:j=0
i+=1
r+=E[0]*P
p=p*10%k
E[0]=0
i=1
while i<k:
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 2 1000\n', 'output': '4'}, {'type': 'stdin_stdout', 'input': '2 2 1000\n', 'output': '45'}, {'type': 'stdin_stdout', 'input': '5 3 1103\n', 'output': '590'}, {'type': 'stdin_stdout', 'input': '2 17 10000\n', 'output': '5'}, {'type': 'stdin_stdout', 'input': '3 9 1000... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/507/D'} | vfc_10486 | ```python
n,k,m=list(map(int,input().split()))
d,r,p,P=0,0,1%k,(10**(n-1))*9
F=[0]*k
F[0]=1
while d<n:
d+=1
P//=10
E=[0]*k
if P==0:P=1
i=1
# print("E=",E)
# print("F=",F)
while i<10:
j=(-i*p)%k
f=0
while f<k:
E[f]+=F[j]
f+=1
j+=1
if j==k:j=0
i+=1
r+=E[0]*P
p=p*10%k
E[0]=0
i=1
while i<k:
... | 1 2 1000
| 4 | 4
| true | 1,737 |
apps | verifiable_code | 184 | Solve the following coding problem using the programming language python:
You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.
The coach decided to form a team of even number of players... | ```python
import base64
import zlib
pro = base64.decodebytes("""eJxtUUFuwyAQvPOKVarKkDhOm2MlX/uC3qqqAhs7KBgswGr6+y4QrLqqL7DD7OzMWk2zdQFGGWbu
PVG59N/rdeLhUu6Om95OpVJBumCtXqlCedkFQgalpYcW3twiSS/FMmLxyrWXhKihzGrwXLx0lEHb
QjU4e5HmWgHOgKTwQgC/0p/EIoDeGh96ZRC0szR0F6QPjTI7lt4fCsMuoVCqREGgqqH6qjIxBSZo
cADdTZTXIFie6dCZM8BhDwJOp... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 4 2\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '5 5 5\n', 'output': '14\n'}, {'type': 'stdin_stdout', 'input': '0 2 0\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '30 70 34\n', 'output': '128\n'}, {'type': 'stdin_stdout', 'input': '89 32 24\n'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/950/A'} | vfc_10490 | ```python
import base64
import zlib
pro = base64.decodebytes("""eJxtUUFuwyAQvPOKVarKkDhOm2MlX/uC3qqqAhs7KBgswGr6+y4QrLqqL7DD7OzMWk2zdQFGGWbu
PVG59N/rdeLhUu6Om95OpVJBumCtXqlCedkFQgalpYcW3twiSS/FMmLxyrWXhKihzGrwXLx0lEHb
QjU4e5HmWgHOgKTwQgC/0p/EIoDeGh96ZRC0szR0F6QPjTI7lt4fCsMuoVCqREGgqqH6qjIxBSZo
cADdTZTXIFie6dCZM8BhDwJOp... | 1 4 2
| 6
| 6
| true | 1,738 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.