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 | 424 | Solve the following coding problem using the programming language python:
Alice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose... | ```python
from math import floor, sqrt
import bisect
import math
def rwh_primes2(n):
# https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
""" Input n>=6, Returns a list of primes, 2 <= p < n """
correction = (n%6>1)
n = {0:n,1:n-1,2:n+4,3:n+3,... | {'test_cases': [{'type': 'stdin_stdout', 'input': '14\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '20\n', 'output': '15\n'}, {'type': 'stdin_stdout', 'input': '8192\n', 'output': '8191\n'}, {'type': 'stdin_stdout', 'input': '1000000\n', 'output': '998677\n'}, {'type': 'stdin_stdout', 'input': '959806\n', 'o... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/923/A'} | vfc_11450 | ```python
from math import floor, sqrt
import bisect
import math
def rwh_primes2(n):
# https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
""" Input n>=6, Returns a list of primes, 2 <= p < n """
correction = (n%6>1)
n = {0:n,1:n-1,2:n+4,3:n+3,... | 14
| 6
| 6
| true | 1,949 |
apps | verifiable_code | 425 | Solve the following coding problem using the programming language python:
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binar... | ```python
n, p = list(map(int, input().split()))
for q in range(5757):
s = bin(n)
if n >= q >= s.count('1'):
print(q)
break
n -= p
else:
print(-1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '24 0\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '24 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '24 -1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '4 -7\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '1 1\n', 'output': '-... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1225/C'} | vfc_11454 | ```python
n, p = list(map(int, input().split()))
for q in range(5757):
s = bin(n)
if n >= q >= s.count('1'):
print(q)
break
n -= p
else:
print(-1)
``` | 24 0
| 2
| 2
| true | 1,950 |
apps | verifiable_code | 427 | Solve the following coding problem using the programming language python:
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also me... | ```python
n0, n1, x, y = list(map(int, input().split()))
def f(m, n, x, y):
return max(0, n - (m // y - m // (x * y)))
lo = -1
hi = x * y * (n0 + n1)
while lo + 1 < hi:
mid = lo + (hi - lo) // 2
if f(mid, n0, x, y) + f(mid, n1, y, x) <= mid - mid // x - mid // y + mid // (x * y):
hi = mid
else... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 1 2 3\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '1 3 2 3\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '916200 69682 2 3\n', 'output': '1832399\n'}, {'type': 'stdin_stdout', 'input': '808351 17767 433 509\n', 'output': '826121\n'}, {'type': 's... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/483/B'} | vfc_11462 | ```python
n0, n1, x, y = list(map(int, input().split()))
def f(m, n, x, y):
return max(0, n - (m // y - m // (x * y)))
lo = -1
hi = x * y * (n0 + n1)
while lo + 1 < hi:
mid = lo + (hi - lo) // 2
if f(mid, n0, x, y) + f(mid, n1, y, x) <= mid - mid // x - mid // y + mid // (x * y):
hi = mid
else... | 3 1 2 3
| 5
| 5
| true | 1,951 |
apps | verifiable_code | 428 | Solve the following coding problem using the programming language python:
Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the field on the intersection o... | ```python
#Simple non-optimized class of matrices. Used with small dense matrices.
import functools
import itertools
import math
class NotAMatrixError(Exception):
pass
class MatrixSizeError(Exception):
def __init__(self, s1, s2):
print('sizes do not match : ', s1, ', ', s2)
class NotSquareError(Excep... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 1 2 0 1 2\n', 'output': '3 1'}, {'type': 'stdin_stdout', 'input': '1 1 1 -1 -1 2\n', 'output': '1 1'}, {'type': 'stdin_stdout', 'input': '1 1 1 1 1 0\n', 'output': '1 1'}, {'type': 'stdin_stdout', 'input': '2 2 1 -2 -2 5\n', 'output': '1 2'}, {'type': 'stdin_stdout',... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/385/E'} | vfc_11466 | ```python
#Simple non-optimized class of matrices. Used with small dense matrices.
import functools
import itertools
import math
class NotAMatrixError(Exception):
pass
class MatrixSizeError(Exception):
def __init__(self, s1, s2):
print('sizes do not match : ', s1, ', ', s2)
class NotSquareError(Excep... | 5 1 2 0 1 2
| 3 1 | 3 1
| true | 1,952 |
apps | verifiable_code | 429 | Solve the following coding problem using the programming language python:
ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has ... | ```python
# You lost the game.
s = str(input())
n = len(s)
A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if n < 26:
print(-1)
else:
for i in range(n-25):
ok = 1
F = [0 for _ in range(26)]
for j in range(26):
if s[i:i+26].count(A[j]) > 1:
ok = 0
break
... | {'test_cases': [{'type': 'stdin_stdout', 'input': 'ABC??FGHIJK???OPQR?TUVWXY?\n', 'output': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {'type': 'stdin_stdout', 'input': 'WELCOMETOCODEFORCESROUNDTHREEHUNDREDANDSEVENTYTWO\n', 'output': '-1'}, {'type': 'stdin_stdout', 'input': '??????????????????????????\n', 'output': 'ABCDEFGHIJKLMN... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/716/B'} | vfc_11470 | ```python
# You lost the game.
s = str(input())
n = len(s)
A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if n < 26:
print(-1)
else:
for i in range(n-25):
ok = 1
F = [0 for _ in range(26)]
for j in range(26):
if s[i:i+26].count(A[j]) > 1:
ok = 0
break
... | ABC??FGHIJK???OPQR?TUVWXY?
| ABCDEFGHIJKLMNOPQRSTUVWXYZ | ABCDEFGHIJKLMNOPQRSTUVWXYZ | true | 1,953 |
apps | verifiable_code | 430 | Solve the following coding problem using the programming language python:
Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.
Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Th... | ```python
"""
Codeforces Round 248 Div 2 Problem A
Author : chaotic_iak
Language: Python 3.3.4
"""
class InputHandlerObject(object):
inputs = []
def getInput(self, n = 0):
res = ""
inputs = self.inputs
if not inputs: inputs.extend(input().split(" "))
if n == 0:
re... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n100 200 100\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '4\n100 100 100 200\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '1\n100\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '1\n200\n', 'output': 'NO\n'}, {'type': 'stdin_stdout'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/433/A'} | vfc_11474 | ```python
"""
Codeforces Round 248 Div 2 Problem A
Author : chaotic_iak
Language: Python 3.3.4
"""
class InputHandlerObject(object):
inputs = []
def getInput(self, n = 0):
res = ""
inputs = self.inputs
if not inputs: inputs.extend(input().split(" "))
if n == 0:
re... | 3
100 200 100
| YES
| YES
| true | 1,954 |
apps | verifiable_code | 432 | Solve the following coding problem using the programming language python:
Medicine faculty of Berland State University has just finished their admission campaign. As usual, about $80\%$ of applicants are girls and majority of them are going to live in the university dormitory for the next $4$ (hopefully) years.
The d... | ```python
import sys
rd = lambda : sys.stdin.readline().rstrip()
n = int(rd())
c = list(map(int, rd().split()))
a = list([int(x)-1 for x in rd().split()])
visited = [-1] * (n)
res = 0
for i in range(n):
trace = []
t = i
mn = 1e9
while visited[t] == -1:
visited[t] = i
trace.appen... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\n1 2 3 2 10\n1 3 4 3 3\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '4\n1 10 2 10\n2 4 2 2\n', 'output': '10\n'}, {'type': 'stdin_stdout', 'input': '7\n1 1 1 1 1 1 1\n2 2 2 3 6 7 6\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '10\n6 9 1 1 1 10 2... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1027/D'} | vfc_11482 | ```python
import sys
rd = lambda : sys.stdin.readline().rstrip()
n = int(rd())
c = list(map(int, rd().split()))
a = list([int(x)-1 for x in rd().split()])
visited = [-1] * (n)
res = 0
for i in range(n):
trace = []
t = i
mn = 1e9
while visited[t] == -1:
visited[t] = i
trace.appen... | 5
1 2 3 2 10
1 3 4 3 3
| 3
| 3
| true | 1,955 |
apps | verifiable_code | 433 | Solve the following coding problem using the programming language python:
Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided t... | ```python
n, a, b = list(map(int, input().split()))
ans = a + b
while ans < 0:
ans += n
ans %= n
if ans == 0:
print(n)
else:
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '6 2 -5\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '5 1 3\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '3 2 7\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '1 1 0\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 1 -1\n', 'outp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/659/A'} | vfc_11486 | ```python
n, a, b = list(map(int, input().split()))
ans = a + b
while ans < 0:
ans += n
ans %= n
if ans == 0:
print(n)
else:
print(ans)
``` | 6 2 -5
| 3
| 3
| true | 1,956 |
apps | verifiable_code | 435 | Solve the following coding problem using the programming language python:
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal let... | ```python
n, k = map(int,input().split())
s = input()
maxi = 0
a = 0
b = 0
st = 0
for i in range(0, n):
if s[i] == 'a': a += 1
else: b+=1
if min(a, b) > k:
if s[st] == 'a': a-=1
else: b-=1
st += 1
else: maxi += 1
print(maxi)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 2\nabba\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '8 1\naabaabaa\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '1 0\na\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 1\nb\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 0... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/676/C'} | vfc_11494 | ```python
n, k = map(int,input().split())
s = input()
maxi = 0
a = 0
b = 0
st = 0
for i in range(0, n):
if s[i] == 'a': a += 1
else: b+=1
if min(a, b) > k:
if s[st] == 'a': a-=1
else: b-=1
st += 1
else: maxi += 1
print(maxi)
``` | 4 2
abba
| 4
| 4
| true | 1,957 |
apps | verifiable_code | 436 | Solve the following coding problem using the programming language python:
Alice is the leader of the State Refactoring Party, and she is about to become the prime minister.
The elections have just taken place. There are $n$ parties, numbered from $1$ to $n$. The $i$-th party has received $a_i$ seats in the parliamen... | ```python
n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(1, n):
if a[i]*2 <= a[0]:
b += [i]
u=0
v=0
for i in range(n):
if i in b:
u += a[i]
else:
v += a[i]
if u > v:
print(len(b))
for x in b:
print(x+1, end=' ')
else:
print('0')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n100 50 50\n', 'output': '3\n1 2 3\n'}, {'type': 'stdin_stdout', 'input': '3\n80 60 60\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '2\n6 5\n', 'output': '1\n1\n'}, {'type': 'stdin_stdout', 'input': '4\n51 25 99 25\n', 'output': '3\n1 2 4\n'}, {'type': 'st... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1178/A'} | vfc_11498 | ```python
n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(1, n):
if a[i]*2 <= a[0]:
b += [i]
u=0
v=0
for i in range(n):
if i in b:
u += a[i]
else:
v += a[i]
if u > v:
print(len(b))
for x in b:
print(x+1, end=' ')
else:
print('0')
``` | 3
100 50 50
| 3
1 2 3
| 3
1 2 3 | true | 1,958 |
apps | verifiable_code | 438 | Solve the following coding problem using the programming language python:
Santa Claus has n candies, he dreams to give them as gifts to children.
What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants ... | ```python
n = int(input())
ans = []
nxt = 1
while n > 0:
x = nxt
n -= nxt
nxt += 1
if n < nxt:
x += n
n = 0
ans.append(str(x))
print(len(ans))
print(" ".join(ans))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\n', 'output': '2\n1 4 \n'}, {'type': 'stdin_stdout', 'input': '9\n', 'output': '3\n1 2 6 \n'}, {'type': 'stdin_stdout', 'input': '2\n', 'output': '1\n2 \n'}, {'type': 'stdin_stdout', 'input': '1\n', 'output': '1\n1 \n'}, {'type': 'stdin_stdout', 'input': '3\n', 'outp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/753/A'} | vfc_11506 | ```python
n = int(input())
ans = []
nxt = 1
while n > 0:
x = nxt
n -= nxt
nxt += 1
if n < nxt:
x += n
n = 0
ans.append(str(x))
print(len(ans))
print(" ".join(ans))
``` | 5
| 2
1 4
| 2
1 4
| true | 1,960 |
apps | verifiable_code | 439 | Solve the following coding problem using the programming language python:
The following problem is well-known: given integers n and m, calculate $2^{n} \operatorname{mod} m$,
where 2^{n} = 2·2·...·2 (n factors), and $x \operatorname{mod} y$ denotes the remainder of division of x by y.
You are asked to solve the "re... | ```python
n = int(input())
m = int(input())
print(m % (1 << n))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n42\n', 'output': '10\n'}, {'type': 'stdin_stdout', 'input': '1\n58\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '98765432\n23456789\n', 'output': '23456789\n'}, {'type': 'stdin_stdout', 'input': '8\n88127381\n', 'output': '149\n'}, {'type': 'stdin_stdout'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/913/A'} | vfc_11510 | ```python
n = int(input())
m = int(input())
print(m % (1 << n))
``` | 4
42
| 10
| 10
| true | 1,961 |
apps | verifiable_code | 440 | Solve the following coding problem using the programming language python:
Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced.... | ```python
n = int(input())
s = input()
t = []
vowels = 'aeiouy'
for c in s:
if t and t[-1] in vowels and c in vowels:
continue
else:
t.append(c)
print(''.join(t))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\nweird\n', 'output': 'werd\n'}, {'type': 'stdin_stdout', 'input': '4\nword\n', 'output': 'word\n'}, {'type': 'stdin_stdout', 'input': '5\naaeaa\n', 'output': 'a\n'}, {'type': 'stdin_stdout', 'input': '100\naaaaabbbbboyoyoyoyoyacadabbbbbiuiufgiuiuaahjabbbklboyoyoyoyoy... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/938/A'} | vfc_11514 | ```python
n = int(input())
s = input()
t = []
vowels = 'aeiouy'
for c in s:
if t and t[-1] in vowels and c in vowels:
continue
else:
t.append(c)
print(''.join(t))
``` | 5
weird
| werd
| werd
| true | 1,962 |
apps | verifiable_code | 441 | Solve the following coding problem using the programming language python:
There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.
The university team for the Olympiad consists of $a$ student-programmers and $b$ student-athletes. Determine the largest number ... | ```python
n, a, b = list(map(int, input().split()))
s = input()
s += '*'
n += 1
m = []
i = 0
i1 = -1
while i < len(s):
if s[i] == '*':
if i - i1 > 1:
m.append(i - i1 - 1)
i1 = i
i += 1
sm = a + b
for c in m:
if c % 2 == 0:
a = max(0, a - c // 2)
b = max(0, b - c /... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 1 1\n*...*\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '6 2 3\n*...*.\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '11 3 10\n.*....**.*.\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '3 2 3\n***\n', 'output': '0\n'}, {'type': 'stdin_s... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/962/B'} | vfc_11518 | ```python
n, a, b = list(map(int, input().split()))
s = input()
s += '*'
n += 1
m = []
i = 0
i1 = -1
while i < len(s):
if s[i] == '*':
if i - i1 > 1:
m.append(i - i1 - 1)
i1 = i
i += 1
sm = a + b
for c in m:
if c % 2 == 0:
a = max(0, a - c // 2)
b = max(0, b - c /... | 5 1 1
*...*
| 2
| 2
| true | 1,963 |
apps | verifiable_code | 442 | Solve the following coding problem using the programming language python:
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her ... | ```python
r=int(input())
if r<=4:
print("NO")
elif r%2==0:
print("NO")
else :
print(1, (r-3)//2)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '19\n', 'output': '1 8\n'}, {'type': 'stdin_stdout', 'input': '16\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '1\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '2\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '3\n', 'output': 'NO\n'}, {... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1184/A1'} | vfc_11522 | ```python
r=int(input())
if r<=4:
print("NO")
elif r%2==0:
print("NO")
else :
print(1, (r-3)//2)
``` | 19
| 1 8
| 1 8
| true | 1,964 |
apps | verifiable_code | 443 | Solve the following coding problem using the programming language python:
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens.
Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought $n$ packets wit... | ```python
n = int(input())
tab = [int(x) for x in input().split()]
if n < 2 or (n == 2 and tab[0] == tab[1]):
print(-1)
else:
print(1)
print(tab.index(min(tab)) + 1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n1 2 1\n', 'output': '1\n1\n'}, {'type': 'stdin_stdout', 'input': '2\n5 5\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '1\n10\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '1\n1\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '10\n1 1 ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/998/A'} | vfc_11526 | ```python
n = int(input())
tab = [int(x) for x in input().split()]
if n < 2 or (n == 2 and tab[0] == tab[1]):
print(-1)
else:
print(1)
print(tab.index(min(tab)) + 1)
``` | 3
1 2 1
| 1
1
| 1
1
| true | 1,965 |
apps | verifiable_code | 444 | Solve the following coding problem using the programming language python:
Vasya has his favourite number $n$. He wants to split it to some non-zero digits. It means, that he wants to choose some digits $d_1, d_2, \ldots, d_k$, such that $1 \leq d_i \leq 9$ for all $i$ and $d_1 + d_2 + \ldots + d_k = n$.
Vasya likes b... | ```python
import getpass
import sys
def ria():
return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
filename = 'half'
# sys.stdin = open('input.txt')
# sys.stdout = open('output.txt', 'w')
else:
sys.stdin = open('input.txt')
# sys.stdin.close()
n = ria()[0]
print(n)
p... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1\n', 'output': '1\n1 '}, {'type': 'stdin_stdout', 'input': '4\n', 'output': '4\n1 1 1 1 '}, {'type': 'stdin_stdout', 'input': '27\n', 'output': '27\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 1 1 '}, {'type': 'stdin_stdout', 'input': '239\n', 'output': '239\n1 ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1104/A'} | vfc_11530 | ```python
import getpass
import sys
def ria():
return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
filename = 'half'
# sys.stdin = open('input.txt')
# sys.stdout = open('output.txt', 'w')
else:
sys.stdin = open('input.txt')
# sys.stdin.close()
n = ria()[0]
print(n)
p... | 1
| 1
1 | 1
1
| true | 1,966 |
apps | verifiable_code | 445 | Solve the following coding problem using the programming language python:
A tuple of positive integers {x_1, x_2, ..., x_{k}} is called simple if for all pairs of positive integers (i, j) (1 ≤ i < j ≤ k), x_{i} + x_{j} is a prime.
You are given an array a with n positive integers a_1, a_2, ..., a_{n} (not ne... | ```python
def main():
n = int(input())
l = list(map(int, input().split()))
seive = [False, True] * max(l)
a = len(seive)
for i in range(3, int(a ** .5) + 1, 2):
if seive[i]:
for j in range(i * i, a, i):
seive[j] = False
i = l.count(1)
if i:
res = [... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n2 3\n', 'output': '2\n3 2\n'}, {'type': 'stdin_stdout', 'input': '2\n2 2\n', 'output': '1\n2\n'}, {'type': 'stdin_stdout', 'input': '3\n2 1 1\n', 'output': '3\n1 1 2\n'}, {'type': 'stdin_stdout', 'input': '2\n83 14\n', 'output': '2\n14 83\n'}, {'type': 'stdin_stdout... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/665/D'} | vfc_11534 | ```python
def main():
n = int(input())
l = list(map(int, input().split()))
seive = [False, True] * max(l)
a = len(seive)
for i in range(3, int(a ** .5) + 1, 2):
if seive[i]:
for j in range(i * i, a, i):
seive[j] = False
i = l.count(1)
if i:
res = [... | 2
2 3
| 2
3 2
| 2
3 2
| true | 1,967 |
apps | verifiable_code | 446 | Solve the following coding problem using the programming language python:
Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.
Some examples of beautiful n... | ```python
from collections import Counter, defaultdict
import itertools
import sys
def main():
n = int(input())
ans = 1
for k in range(1, 10):
v = ((1 << k) - 1) * (1 << (k - 1))
if n % v == 0:
ans = v
print(ans)
main()
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '992\n', 'output': '496\n'}, {'type': 'stdin_stdout', 'input': '81142\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '76920\n', 'output': '120\n'}, {'type': 'stdin_stdout', 'input': '2016\n', 'output': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/893/B'} | vfc_11538 | ```python
from collections import Counter, defaultdict
import itertools
import sys
def main():
n = int(input())
ans = 1
for k in range(1, 10):
v = ((1 << k) - 1) * (1 << (k - 1))
if n % v == 0:
ans = v
print(ans)
main()
``` | 3
| 1
| 1
| true | 1,968 |
apps | verifiable_code | 447 | Solve the following coding problem using the programming language python:
Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.
For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71... | ```python
#!/usr/bin/env python3
def addmod(left, right, modulo=1000000007):
res = left + right
if res >= modulo:
res -= modulo
return res
def counter(a, m, d):
res = [0, ] * (2*m)
res[0] = 1
shift = 1
for pos in range(len(a), 0, -1):
ptype = pos & 1
cur = int(a[p... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2 6\n10\n99\n', 'output': '8\n'}, {'type': 'stdin_stdout', 'input': '2 0\n1\n9\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '19 7\n1000\n9999\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '9 4\n33\n52\n', 'output': '0\n'}, {'type': 'stdin_stdout', ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/628/D'} | vfc_11542 | ```python
#!/usr/bin/env python3
def addmod(left, right, modulo=1000000007):
res = left + right
if res >= modulo:
res -= modulo
return res
def counter(a, m, d):
res = [0, ] * (2*m)
res[0] = 1
shift = 1
for pos in range(len(a), 0, -1):
ptype = pos & 1
cur = int(a[p... | 2 6
10
99
| 8
| 8
| true | 1,969 |
apps | verifiable_code | 448 | Solve the following coding problem using the programming language python:
There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least a_{i} candies.
Jzzhu asks children to line up. Initially, the i-th child stands... | ```python
def main():
from collections import deque
n, m = [int(i) for i in input().split()]
children = deque([0, int(v), i + 1] for i, v in enumerate(input().split()))
while len(children) > 1:
tmp = children.popleft()
tmp[0] += m
if tmp[1] > tmp[0]:
childre... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 2\n1 3 1 4 2\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '6 4\n1 1 2 2 3 3\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '7 3\n6 1 5 4 2 3 1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '10 5\n2 7 3 6 2 5 1 3 4 5\n', 'output': '4\n'},... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/450/A'} | vfc_11546 | ```python
def main():
from collections import deque
n, m = [int(i) for i in input().split()]
children = deque([0, int(v), i + 1] for i, v in enumerate(input().split()))
while len(children) > 1:
tmp = children.popleft()
tmp[0] += m
if tmp[1] > tmp[0]:
childre... | 5 2
1 3 1 4 2
| 4
| 4
| true | 1,970 |
apps | verifiable_code | 449 | Solve the following coding problem using the programming language python:
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum numb... | ```python
n=int(input())
ans=0
ans+=n//100
n%=100
ans+=n//20
n%=20
ans+=n//10
n%=10
ans+=n//5
n%=5
ans+=n
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '125\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '43\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '1000000000\n', 'output': '10000000\n'}, {'type': 'stdin_stdout', 'input': '4\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '5\n', 'output'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/996/A'} | vfc_11550 | ```python
n=int(input())
ans=0
ans+=n//100
n%=100
ans+=n//20
n%=20
ans+=n//10
n%=10
ans+=n//5
n%=5
ans+=n
print(ans)
``` | 125
| 3
| 3
| true | 1,971 |
apps | verifiable_code | 450 | Solve the following coding problem using the programming language python:
Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length o... | ```python
mod=10**9+7
n,k=list(map(int,input().split()))
A=[0]*(n+1)
B=[0]*(n+1)
C=[0]*(n+1)
F=[0]*(n+1)
G=[0]*(n+1)
F[0]=G[0]=1
for i in range(1,n+1):
G[i]=F[i]=F[i-1]*i%mod
G[i]=pow(F[i],(mod-2),mod)
for i in range(0,n):
if i*2>n:
break
B[i]=(F[n-i]*G[i]*G[n-i*2])%mod
for i in range(0,n//2+1):
for j in rang... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 0\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '2 1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '3 2\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '4 1\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '7 4\n', 'output': '328\n'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/285/E'} | vfc_11554 | ```python
mod=10**9+7
n,k=list(map(int,input().split()))
A=[0]*(n+1)
B=[0]*(n+1)
C=[0]*(n+1)
F=[0]*(n+1)
G=[0]*(n+1)
F[0]=G[0]=1
for i in range(1,n+1):
G[i]=F[i]=F[i-1]*i%mod
G[i]=pow(F[i],(mod-2),mod)
for i in range(0,n):
if i*2>n:
break
B[i]=(F[n-i]*G[i]*G[n-i*2])%mod
for i in range(0,n//2+1):
for j in rang... | 1 0
| 1
| 1
| true | 1,972 |
apps | verifiable_code | 452 | Solve the following coding problem using the programming language python:
A continued fraction of height n is a fraction of form $a_{1} + \frac{1}{a_{2} + \frac{1}{\ldots + \frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented as a finite fraction of hei... | ```python
#!/usr/bin/env python3
from fractions import Fraction
def __starting_point():
p, q = list(map(int, input().split()))
n = int(input())
l = list(map(int, input().split()))
f = Fraction(l[-1], 1)
for x in l[-2::-1]:
f = 1 / f
f += x
print(["NO", "YES"][f == Fraction(p... | {'test_cases': [{'type': 'stdin_stdout', 'input': '9 4\n2\n2 4\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '9 4\n3\n2 3 1\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '9 4\n3\n1 2 4\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '39088169 24157817\n36\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/305/B'} | vfc_11562 | ```python
#!/usr/bin/env python3
from fractions import Fraction
def __starting_point():
p, q = list(map(int, input().split()))
n = int(input())
l = list(map(int, input().split()))
f = Fraction(l[-1], 1)
for x in l[-2::-1]:
f = 1 / f
f += x
print(["NO", "YES"][f == Fraction(p... | 9 4
2
2 4
| YES
| YES
| true | 1,973 |
apps | verifiable_code | 453 | Solve the following coding problem using the programming language python:
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us... | ```python
t = input()
k = t.find('=')
n = 2 * k - len(t)
if n == 2:
if t[1] != '+': t = t[1: ] + '|'
else: t = t[: k - 1] + t[k: ] + '|'
elif n == -2: t = '|' + t[: -1]
elif n != 0: t = 'Impossible'
print(t)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '||+|=|||||\n', 'output': '|||+|=||||\n'}, {'type': 'stdin_stdout', 'input': '|||||+||=||\n', 'output': 'Impossible\n'}, {'type': 'stdin_stdout', 'input': '|+|=||||||\n', 'output': 'Impossible\n'}, {'type': 'stdin_stdout', 'input': '||||+||=||||||\n', 'output': '||||+||... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/394/A'} | vfc_11566 | ```python
t = input()
k = t.find('=')
n = 2 * k - len(t)
if n == 2:
if t[1] != '+': t = t[1: ] + '|'
else: t = t[: k - 1] + t[k: ] + '|'
elif n == -2: t = '|' + t[: -1]
elif n != 0: t = 'Impossible'
print(t)
``` | ||+|=|||||
| |||+|=||||
| |||+|=||||
| true | 1,974 |
apps | verifiable_code | 454 | Solve the following coding problem using the programming language python:
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
-----Constraints-----
- All values in in... | ```python
import numpy as np
def solve(n, k):
if k % 2 == 1:
return 0
k //= 2
MOD = 10 ** 9 + 7
dp = np.zeros((1, k + 1), dtype=np.int64)
dp[0, 0] = 1
for i in range(1, n + 1):
max_d = min(i + 1, n - i + 1, k + 1)
ndp = np.zeros((max_d, k + 1), dtype=np.int64)
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 2\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '39 14\n', 'output': '74764168\n'}, {'type': 'stdin_stdout', 'input': '44 350\n', 'output': '15060087\n'}, {'type': 'stdin_stdout', 'input': '22 444\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1 0... | {'difficulty': 'interview', 'problem_url': 'https://atcoder.jp/contests/abc134/tasks/abc134_f'} | vfc_11570 | ```python
import numpy as np
def solve(n, k):
if k % 2 == 1:
return 0
k //= 2
MOD = 10 ** 9 + 7
dp = np.zeros((1, k + 1), dtype=np.int64)
dp[0, 0] = 1
for i in range(1, n + 1):
max_d = min(i + 1, n - i + 1, k + 1)
ndp = np.zeros((max_d, k + 1), dtype=np.int64)
... | 3 2
| 2
| 2
| true | 1,975 |
apps | verifiable_code | 456 | Solve the following coding problem using the programming language python:
Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.
There is a filler word ogo in Oleg's speech. Al... | ```python
from sys import *
n = int(input())
a = input()
s = 0
i = 0
while i <= n-1:
if s == 0:
if a[i:i+3] == 'ogo':
s = 1
print('***', end = '')
i+=3
else:
print(a[i], end = '')
i += 1
else:
if a[i:i+2] == 'go':
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '7\naogogob\n', 'output': 'a***b\n'}, {'type': 'stdin_stdout', 'input': '13\nogogmgogogogo\n', 'output': '***gmg***\n'}, {'type': 'stdin_stdout', 'input': '9\nogoogoogo\n', 'output': '*********\n'}, {'type': 'stdin_stdout', 'input': '32\nabcdefogoghijklmnogoopqrstuvwxyz... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/729/A'} | vfc_11578 | ```python
from sys import *
n = int(input())
a = input()
s = 0
i = 0
while i <= n-1:
if s == 0:
if a[i:i+3] == 'ogo':
s = 1
print('***', end = '')
i+=3
else:
print(a[i], end = '')
i += 1
else:
if a[i:i+2] == 'go':
... | 7
aogogob
| a***b
| a***b | true | 1,976 |
apps | verifiable_code | 457 | Solve the following coding problem using the programming language python:
Let's introduce some definitions that will be needed later.
Let $prime(x)$ be the set of prime divisors of $x$. For example, $prime(140) = \{ 2, 5, 7 \}$, $prime(169) = \{ 13 \}$.
Let $g(x, p)$ be the maximum possible integer $p^k$ where $k$ i... | ```python
x, n = list(map(int, input().split()))
def primeFactor(N):
i, n, ret, d, sq = 2, N, {}, 2, 99
while i <= sq:
k = 0
while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
if i < 4: i = i * 2 - 1
else: i, d = i+d, d^6
if n... | {'test_cases': [{'type': 'stdin_stdout', 'input': '10 2\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '20190929 1605\n', 'output': '363165664\n'}, {'type': 'stdin_stdout', 'input': '947 987654321987654321\n', 'output': '593574252\n'}, {'type': 'stdin_stdout', 'input': '2 1\n', 'output': '1\n'}, {'type': 'stdi... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1228/C'} | vfc_11582 | ```python
x, n = list(map(int, input().split()))
def primeFactor(N):
i, n, ret, d, sq = 2, N, {}, 2, 99
while i <= sq:
k = 0
while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
if i < 4: i = i * 2 - 1
else: i, d = i+d, d^6
if n... | 10 2
| 2
| 2
| true | 1,977 |
apps | verifiable_code | 458 | Solve the following coding problem using the programming language python:
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment.
Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c,
where a, b, c are some prede... | ```python
a, b, c = list(map(int, input().split()))
ans = []
for sum in range(1, 200):
x = b * sum ** a + c
if x <= 0 or x >= 10 ** 9:
continue
summ = 0
for aa in str(x):
summ += int(aa)
if sum == summ:
ans.append(x)
print(len(ans))
print(*ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 2 8\n', 'output': '3\n10 2008 13726 '}, {'type': 'stdin_stdout', 'input': '1 2 -18\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '2 2 -1\n', 'output': '4\n1 31 337 967 '}, {'type': 'stdin_stdout', 'input': '1 1 0\n', 'output': '9\n1 2 3 4 5 6 7 8 9 '}, {'ty... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/460/B'} | vfc_11586 | ```python
a, b, c = list(map(int, input().split()))
ans = []
for sum in range(1, 200):
x = b * sum ** a + c
if x <= 0 or x >= 10 ** 9:
continue
summ = 0
for aa in str(x):
summ += int(aa)
if sum == summ:
ans.append(x)
print(len(ans))
print(*ans)
``` | 3 2 8
| 3
10 2008 13726 | 3
10 2008 13726
| true | 1,978 |
apps | verifiable_code | 459 | Solve the following coding problem using the programming language python:
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand... | ```python
l=list(map(int,input().split()))
l.insert(0,0)
c1=[1,6,3,8,5,10,7,12,9,23,11,21,13,14,15,16,17,18,19,20,4,22,2,24]
c2=[1,23,3,21,5,2,7,4,9,6,11,8,13,14,15,16,17,18,19,20,12,22,10,24]
c3=[1,2,3,4,5,6,15,16,9,10,11,12,13,14,23,24,17,18,7,8,21,22,19,20]
c4=[1,2,3,4,5,6,19,20,9,10,11,12,13,14,7,8,17,18,23,24,21,2... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\n', 'output': 'NO'}, {'type': 'stdin_stdout', 'input': '5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\n', 'output': 'YES'}, {'type': 'stdin_stdout', 'input': '2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1\n', 'output'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/887/C'} | vfc_11590 | ```python
l=list(map(int,input().split()))
l.insert(0,0)
c1=[1,6,3,8,5,10,7,12,9,23,11,21,13,14,15,16,17,18,19,20,4,22,2,24]
c2=[1,23,3,21,5,2,7,4,9,6,11,8,13,14,15,16,17,18,19,20,12,22,10,24]
c3=[1,2,3,4,5,6,15,16,9,10,11,12,13,14,23,24,17,18,7,8,21,22,19,20]
c4=[1,2,3,4,5,6,19,20,9,10,11,12,13,14,7,8,17,18,23,24,21,2... | 2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
| NO | NO
| true | 1,979 |
apps | verifiable_code | 460 | Solve the following coding problem using the programming language python:
Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.
Unfortunately, you didn't manage to get into... | ```python
from math import ceil
p,x,y = map(int, input().split())
h = x
while h >=y:
h-=50
h+=50
for i in range(h, 10000000000, 50):
u = (i//50)%475
d = []
for j in range(25):
u = (u * 96 + 42)%475
d.append(26 + u)
if p in d:
k = i
break
if k-x>0:
print(ceil((k-x... | {'test_cases': [{'type': 'stdin_stdout', 'input': '239 10880 9889\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '26 7258 6123\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '493 8000 8000\n', 'output': '24\n'}, {'type': 'stdin_stdout', 'input': '101 6800 6500\n', 'output': '0\n'}, {'type': 'stdin_std... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/807/B'} | vfc_11594 | ```python
from math import ceil
p,x,y = map(int, input().split())
h = x
while h >=y:
h-=50
h+=50
for i in range(h, 10000000000, 50):
u = (i//50)%475
d = []
for j in range(25):
u = (u * 96 + 42)%475
d.append(26 + u)
if p in d:
k = i
break
if k-x>0:
print(ceil((k-x... | 239 10880 9889
| 0
| 0
| true | 1,980 |
apps | verifiable_code | 461 | Solve the following coding problem using the programming language python:
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length o... | ```python
'''input
1
2
3
5
'''
n = int(input())
a = int(input())
b = int(input())
c = int(input())
cur = 0
pos = 0
for i in range(n-1):
if pos == 0:
if a < b:
pos = 1
cur += a
else:
pos = 2
cur += b
elif pos == 1:
if a < c:
po... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n2\n3\n1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '1\n2\n3\n5\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '10\n1\n8\n3\n', 'output': '9\n'}, {'type': 'stdin_stdout', 'input': '7\n10\n5\n6\n', 'output': '30\n'}, {'type': 'stdin_stdout', 'inp... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/876/A'} | vfc_11598 | ```python
'''input
1
2
3
5
'''
n = int(input())
a = int(input())
b = int(input())
c = int(input())
cur = 0
pos = 0
for i in range(n-1):
if pos == 0:
if a < b:
pos = 1
cur += a
else:
pos = 2
cur += b
elif pos == 1:
if a < c:
po... | 3
2
3
1
| 3
| 3
| true | 1,981 |
apps | verifiable_code | 462 | Solve the following coding problem using the programming language python:
There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x_1, the second friend lives at the point x_2, and the third friend lives at the point x_3. They plan to celebrate the New Year together, so t... | ```python
l = list(map(int, input().split()))
print(max(l) - min(l))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '7 1 4\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '30 20 10\n', 'output': '20\n'}, {'type': 'stdin_stdout', 'input': '1 4 100\n', 'output': '99\n'}, {'type': 'stdin_stdout', 'input': '100 1 91\n', 'output': '99\n'}, {'type': 'stdin_stdout', 'input': '1 45 1... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/723/A'} | vfc_11602 | ```python
l = list(map(int, input().split()))
print(max(l) - min(l))
``` | 7 1 4
| 6
| 6
| true | 1,982 |
apps | verifiable_code | 463 | Solve the following coding problem using the programming language python:
There is an array with n elements a_1, a_2, ..., a_{n} and the number x.
In one operation you can select some i (1 ≤ i ≤ n) and replace element a_{i} with a_{i} & x, where & denotes the bitwise and operation.
You want the array to have at leas... | ```python
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * 1000000
ans = 0
go = False
for i in a:
b[i] += 1
if b[i] > 1:
go = True
if go:
print(ans)
else:
for i in a:
b[i] -= 1
if b[i & x] + 1 > 1:
go = True
ans = 1
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 3\n1 2 3 7\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '2 228\n1 1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '3 7\n1 2 3\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '4 3\n1 2 7 15\n', 'output': '2\n'}, {'type': 'stdin_stdout', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1013/B'} | vfc_11606 | ```python
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * 1000000
ans = 0
go = False
for i in a:
b[i] += 1
if b[i] > 1:
go = True
if go:
print(ans)
else:
for i in a:
b[i] -= 1
if b[i & x] + 1 > 1:
go = True
ans = 1
... | 4 3
1 2 3 7
| 1
| 1
| true | 1,983 |
apps | verifiable_code | 466 | Solve the following coding problem using the programming language python:
The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.
The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c proble... | ```python
c,d=list(map(int,input().split()))
n,m=list(map(int,input().split()))
k=int(input())
z=0
best=10**10
while(1):
x=n*m-k
x-=z*n
best=min(best,z*c+(max(x,0)*d))
if(x<0):
break
z+=1
print(best)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 10\n7 2\n1\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '2 2\n2 1\n2\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '8 9\n2 2\n3\n', 'output': '8\n'}, {'type': 'stdin_stdout', 'input': '5 5\n8 8\n7\n', 'output': '40\n'}, {'type': 'stdin_stdout', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/417/A'} | vfc_11618 | ```python
c,d=list(map(int,input().split()))
n,m=list(map(int,input().split()))
k=int(input())
z=0
best=10**10
while(1):
x=n*m-k
x-=z*n
best=min(best,z*c+(max(x,0)*d))
if(x<0):
break
z+=1
print(best)
``` | 1 10
7 2
1
| 2
| 2
| true | 1,984 |
apps | verifiable_code | 467 | Solve the following coding problem using the programming language python:
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of... | ```python
3
s = input()
n = len(s)
a, b = 0, 0
d = dict()
for i in range(len(s)):
if s[i] in d:
a = d[s[i]]
b = i
d[s[i]] = i
if a == b - 1:
print("Impossible")
else:
ans = [[' '] * 13 for i in range(2)]
if (b - a) % 2 == 1:
for i in range((b - a) // 2):
ans[0]... | {'test_cases': [{'type': 'stdin_stdout', 'input': 'ABCDEFGHIJKLMNOPQRSGTUVWXYZ\n', 'output': 'YXWVUTGHIJKLM\nZABCDEFSRQPON\n'}, {'type': 'stdin_stdout', 'input': 'BUVTYZFQSNRIWOXXGJLKACPEMDH\n', 'output': 'Impossible\n'}, {'type': 'stdin_stdout', 'input': 'DYCEUXXKMGZOINVPHWQSRTABLJF\n', 'output': 'Impossible\n'}, {'ty... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/725/C'} | vfc_11622 | ```python
3
s = input()
n = len(s)
a, b = 0, 0
d = dict()
for i in range(len(s)):
if s[i] in d:
a = d[s[i]]
b = i
d[s[i]] = i
if a == b - 1:
print("Impossible")
else:
ans = [[' '] * 13 for i in range(2)]
if (b - a) % 2 == 1:
for i in range((b - a) // 2):
ans[0]... | ABCDEFGHIJKLMNOPQRSGTUVWXYZ
| YXWVUTGHIJKLM
ZABCDEFSRQPON
| YXWVUTGHIJKLM
ZABCDEFSRQPON
| true | 1,985 |
apps | verifiable_code | 468 | Solve the following coding problem using the programming language python:
Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before.
It turns out that high school struggles are not gone... | ```python
import math
x, y = [int(v) for v in input().split()]
xly = x * math.log(y)
ylx = y * math.log(x)
if abs(xly - ylx) < 1e-8:
print('=')
elif ylx < xly:
print('<')
else:
print('>')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 8\n', 'output': '>\n'}, {'type': 'stdin_stdout', 'input': '10 3\n', 'output': '<\n'}, {'type': 'stdin_stdout', 'input': '6 6\n', 'output': '=\n'}, {'type': 'stdin_stdout', 'input': '14 1\n', 'output': '>\n'}, {'type': 'stdin_stdout', 'input': '2 4\n', 'output': '=\n'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/987/B'} | vfc_11626 | ```python
import math
x, y = [int(v) for v in input().split()]
xly = x * math.log(y)
ylx = y * math.log(x)
if abs(xly - ylx) < 1e-8:
print('=')
elif ylx < xly:
print('<')
else:
print('>')
``` | 5 8
| >
| >
| true | 1,986 |
apps | verifiable_code | 469 | Solve the following coding problem using the programming language python:
A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectang... | ```python
from math import *
r, h = list(map(int, input().split()))
d = h % r
if d * 2 < r:
print(h // r * 2 + 1)
elif sqrt(3) * (r / 2) + r - 1e-6 <= d + r:
print(h // r * 2 + 3)
else:
print(h // r * 2 + 2)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '1 2\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '2 1\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '2 2\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '2 3\n', 'output': '4\n'},... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/342/C'} | vfc_11630 | ```python
from math import *
r, h = list(map(int, input().split()))
d = h % r
if d * 2 < r:
print(h // r * 2 + 1)
elif sqrt(3) * (r / 2) + r - 1e-6 <= d + r:
print(h // r * 2 + 3)
else:
print(h // r * 2 + 2)
``` | 1 1
| 3
| 3
| true | 1,987 |
apps | verifiable_code | 470 | Solve the following coding problem using the programming language python:
A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.
Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not dis... | ```python
cards = list(map(int, input().split()))
result = sum(cards)
for i in range(5):
cnt = cards.count(cards[i])
cnt = min(cnt, 3)
if cnt not in [2, 3]:
continue
result = min(result, sum(cards) - cnt * cards[i])
print(result)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '7 3 7 3 20\n', 'output': '26\n'}, {'type': 'stdin_stdout', 'input': '7 9 3 1 8\n', 'output': '28\n'}, {'type': 'stdin_stdout', 'input': '10 10 10 10 10\n', 'output': '20\n'}, {'type': 'stdin_stdout', 'input': '8 7 1 8 7\n', 'output': '15\n'}, {'type': 'stdin_stdout', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/680/A'} | vfc_11634 | ```python
cards = list(map(int, input().split()))
result = sum(cards)
for i in range(5):
cnt = cards.count(cards[i])
cnt = min(cnt, 3)
if cnt not in [2, 3]:
continue
result = min(result, sum(cards) - cnt * cards[i])
print(result)
``` | 7 3 7 3 20
| 26
| 26
| true | 1,988 |
apps | verifiable_code | 471 | Solve the following coding problem using the programming language python:
Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish ... | ```python
from math import *
n, a = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
if n == 1:
print(0)
else:
if a > A[-1]:
print(abs(a - A[1]))
elif a < A[0]:
print(abs(a - A[-2]))
else:
per1 = abs(A[0] - A[-2])
per2 = abs(A[1] - A[-1])
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 10\n1 7 12\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '2 0\n11 -10\n', 'output': '10\n'}, {'type': 'stdin_stdout', 'input': '5 0\n0 0 1000 0 0\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1 0\n0\n', 'output': '0\n'}, {'type': 'stdin_stdout', ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/709/B'} | vfc_11638 | ```python
from math import *
n, a = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
if n == 1:
print(0)
else:
if a > A[-1]:
print(abs(a - A[1]))
elif a < A[0]:
print(abs(a - A[-2]))
else:
per1 = abs(A[0] - A[-2])
per2 = abs(A[1] - A[-1])
... | 3 10
1 7 12
| 7
| 7
| true | 1,989 |
apps | verifiable_code | 472 | Solve the following coding problem using the programming language python:
Let's consider equation:x^2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of... | ```python
import re
import itertools
from collections import Counter, deque
class Task:
maxDigitSum = 18 * 9
n = 0
answer = ""
def getData(self):
self.n = int(input())
#inFile = open('input.txt', 'r')
#inFile.readline().rstrip()
#self.childs = inFile.readline().rstrip... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '110\n', 'output': '10\n'}, {'type': 'stdin_stdout', 'input': '4\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '8\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '10000000100000000\n', 'output... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/233/B'} | vfc_11642 | ```python
import re
import itertools
from collections import Counter, deque
class Task:
maxDigitSum = 18 * 9
n = 0
answer = ""
def getData(self):
self.n = int(input())
#inFile = open('input.txt', 'r')
#inFile.readline().rstrip()
#self.childs = inFile.readline().rstrip... | 2
| 1
| 1
| true | 1,990 |
apps | verifiable_code | 473 | Solve the following coding problem using the programming language python:
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t.
Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George coul... | ```python
s = input()
t = input()
a, b = int(s[:2]), int(s[3:])
c, d = int(t[:2]), int(t[3:])
a -= c
b -= d
if b < 0:
a -= 1
b = 60 + b
if a < 0:
a = 24 + a
if a < 10:
print(0, end = '')
print(a, ':', end = '', sep = '')
if b < 10:
print(0, end = '')
print(b)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '05:50\n05:44\n', 'output': '00:06\n'}, {'type': 'stdin_stdout', 'input': '00:00\n01:00\n', 'output': '23:00\n'}, {'type': 'stdin_stdout', 'input': '00:01\n00:00\n', 'output': '00:01\n'}, {'type': 'stdin_stdout', 'input': '23:59\n23:59\n', 'output': '00:00\n'}, {'type':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/387/A'} | vfc_11646 | ```python
s = input()
t = input()
a, b = int(s[:2]), int(s[3:])
c, d = int(t[:2]), int(t[3:])
a -= c
b -= d
if b < 0:
a -= 1
b = 60 + b
if a < 0:
a = 24 + a
if a < 10:
print(0, end = '')
print(a, ':', end = '', sep = '')
if b < 10:
print(0, end = '')
print(b)
``` | 05:50
05:44
| 00:06
| 00:06
| true | 1,991 |
apps | verifiable_code | 474 | Solve the following coding problem using the programming language python:
You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding... | ```python
n = int(input())
a = list(map(int,input().split()))
m = max(a)
current = 0
longest = 0
for x in a:
if x == m:
current +=1
else:
longest = max(current,longest)
current = 0
longest = max(current,longest)
print (longest)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\n6 1 6 6 0\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '1\n1000000000\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '6\n1 1 0 1 1 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '5\n2 2 2 2 3\n', 'output': '1\n'}, {'type': 'stdin_stdou... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1117/A'} | vfc_11650 | ```python
n = int(input())
a = list(map(int,input().split()))
m = max(a)
current = 0
longest = 0
for x in a:
if x == m:
current +=1
else:
longest = max(current,longest)
current = 0
longest = max(current,longest)
print (longest)
``` | 5
6 1 6 6 0
| 2
| 2
| true | 1,992 |
apps | verifiable_code | 475 | Solve the following coding problem using the programming language python:
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.
There are $n$ bricks lined in a row on the ground. Chouti has got $m$ paint buckets of different colors at hand, so he painted each bri... | ```python
import math
n,m,k=map(int,input().split())
out=1
for i in range(k):
out*=(m-1)
out%=998244353
out*=m
out%=998244353
out*=(math.factorial(n-1)//math.factorial(k)//math.factorial(n-1-k))
out%=998244353
print(out)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 3 0\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '3 2 1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '3 3 2\n', 'output': '12\n'}, {'type': 'stdin_stdout', 'input': '123 45 67\n', 'output': '212505593\n'}, {'type': 'stdin_stdout', 'input': '1234... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1081/C'} | vfc_11654 | ```python
import math
n,m,k=map(int,input().split())
out=1
for i in range(k):
out*=(m-1)
out%=998244353
out*=m
out%=998244353
out*=(math.factorial(n-1)//math.factorial(k)//math.factorial(n-1-k))
out%=998244353
print(out)
``` | 3 3 0
| 3
| 3
| true | 1,993 |
apps | verifiable_code | 476 | Solve the following coding problem using the programming language python:
A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.
You're given a number. Determin... | ```python
n = input()
good = True
while n != '' and good:
if n.endswith('144'):
n = n[:-3]
elif n.endswith('14'):
n = n[:-2]
elif n.endswith('1'):
n = n[:-1]
else:
good = False
print('YES' if good else 'NO')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '114114\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '1111\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '441231\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '1\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '14\n', 'outpu... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/320/A'} | vfc_11658 | ```python
n = input()
good = True
while n != '' and good:
if n.endswith('144'):
n = n[:-3]
elif n.endswith('14'):
n = n[:-2]
elif n.endswith('1'):
n = n[:-1]
else:
good = False
print('YES' if good else 'NO')
``` | 114114
| YES
| YES
| true | 1,994 |
apps | verifiable_code | 477 | Solve the following coding problem using the programming language python:
Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b.
Dima put the chessboard in front o... | ```python
n,m,i,j,a,b=list(map(int,input().split()))
ans=100000000000
if((i,j)==(n,1) or (i,j)==(1,1) or (i,j)==(1,m) or (i,j)==(n,m)):
print(0)
else:
#Corner (1,1)
hor=i-1
ver=j-1
if(hor%a==0 and ver%b==0):
x=hor//a
y=ver//b
if(x%2==y%2 and a<=n-1 and b<=m-1):
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 7 1 3 2 2\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '5 5 2 3 1 1\n', 'output': 'Poor Inna and pony!\n'}, {'type': 'stdin_stdout', 'input': '1 1 1 1 1 1\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '23000 15500 100 333 9 1\n', 'output': '15167... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/374/A'} | vfc_11662 | ```python
n,m,i,j,a,b=list(map(int,input().split()))
ans=100000000000
if((i,j)==(n,1) or (i,j)==(1,1) or (i,j)==(1,m) or (i,j)==(n,m)):
print(0)
else:
#Corner (1,1)
hor=i-1
ver=j-1
if(hor%a==0 and ver%b==0):
x=hor//a
y=ver//b
if(x%2==y%2 and a<=n-1 and b<=m-1):
... | 5 7 1 3 2 2
| 2
| 2
| true | 1,995 |
apps | verifiable_code | 478 | Solve the following coding problem using the programming language python:
You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.
In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) ... | ```python
from sys import stdin
input = stdin.readline
n = int(input())
s = list(input().strip())
for i in range(26):
char = chr(ord('z') - i)
prev = chr(ord('z') - i - 1)
updated = True
while updated:
updated = False
for idx in range(len(s)-1, -1, -1):
if s[idx] == char:
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '8\nbacabcab\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '4\nbcda\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '6\nabbbbb\n', 'output': '5\n'}, {'type': 'stdin_stdout', 'input': '1\na\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1\nt\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1321/C'} | vfc_11666 | ```python
from sys import stdin
input = stdin.readline
n = int(input())
s = list(input().strip())
for i in range(26):
char = chr(ord('z') - i)
prev = chr(ord('z') - i - 1)
updated = True
while updated:
updated = False
for idx in range(len(s)-1, -1, -1):
if s[idx] == char:
... | 8
bacabcab
| 4
| 4
| true | 1,996 |
apps | verifiable_code | 479 | Solve the following coding problem using the programming language python:
ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiar... | ```python
n, k = map(int, input().split())
a = set(map(int, input().split()))
q = int(input())
# def isIn(x, fm, to):
# if fm >= to:
# return a[fm] == x
# t = a[(fm+to) // 2]
# if t > x:
# return isIn(x, fm, (fm+to) // 2 - 1)
# elif t < x:
# return isIn(x, (fm+to) // 2 + 1, to)
# else:
# return True
for ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '6 20\n10 50 100 500 1000 5000\n8\n4200\n100000\n95000\n96000\n99000\n10100\n2015\n9950\n', 'output': '6\n20\n19\n20\n-1\n3\n-1\n-1\n'}, {'type': 'stdin_stdout', 'input': '5 2\n1 2 3 5 8\n8\n1\n3\n5\n7\n9\n11\n13\n15\n', 'output': '1\n1\n1\n2\n2\n2\n2\n-1\n'}, {'type': ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/524/C'} | vfc_11670 | ```python
n, k = map(int, input().split())
a = set(map(int, input().split()))
q = int(input())
# def isIn(x, fm, to):
# if fm >= to:
# return a[fm] == x
# t = a[(fm+to) // 2]
# if t > x:
# return isIn(x, fm, (fm+to) // 2 - 1)
# elif t < x:
# return isIn(x, (fm+to) // 2 + 1, to)
# else:
# return True
for ... | 6 20
10 50 100 500 1000 5000
8
4200
100000
95000
96000
99000
10100
2015
9950
| 6
20
19
20
-1
3
-1
-1
| 6
20
19
20
-1
3
-1
-1
| true | 1,997 |
apps | verifiable_code | 480 | Solve the following coding problem using the programming language python:
The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at... | ```python
#!/usr/bin/env python3
def main():
try:
while True:
s, x1, x2 = list(map(int, input().split()))
t1, t2 = list(map(int, input().split()))
p, d = list(map(int, input().split()))
def travel(src, trg):
nonlocal d
if src ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 2 4\n3 4\n1 1\n', 'output': '8\n'}, {'type': 'stdin_stdout', 'input': '5 4 0\n1 2\n3 1\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '5 4 0\n5 14\n1 -1\n', 'output': '55\n'}, {'type': 'stdin_stdout', 'input': '10 7 2\n7 9\n9 -1\n', 'output': '45\n'}, {'type... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/746/C'} | vfc_11674 | ```python
#!/usr/bin/env python3
def main():
try:
while True:
s, x1, x2 = list(map(int, input().split()))
t1, t2 = list(map(int, input().split()))
p, d = list(map(int, input().split()))
def travel(src, trg):
nonlocal d
if src ... | 4 2 4
3 4
1 1
| 8
| 8
| true | 1,998 |
apps | verifiable_code | 481 | Solve the following coding problem using the programming language python:
Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1.
You are given a positive integer x. Your task ... | ```python
n, x = map(int, input().split())
ans = 0
for i in range(n, 0, -1):
if x % i == 0 and x//i <= n:
ans += 1
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '10 5\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '6 12\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '5 13\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '2 1\n', 'output': '1\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/577/A'} | vfc_11678 | ```python
n, x = map(int, input().split())
ans = 0
for i in range(n, 0, -1):
if x % i == 0 and x//i <= n:
ans += 1
print(ans)
``` | 10 5
| 2
| 2
| true | 1,999 |
apps | verifiable_code | 482 | Solve the following coding problem using the programming language python:
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions: the ... | ```python
n, k = map(int, input().split())
print(('abcdefghijklmnopqrstuvwxyz'[:k] * n)[:n])
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 3\n', 'output': 'abca\n'}, {'type': 'stdin_stdout', 'input': '6 6\n', 'output': 'abcdef\n'}, {'type': 'stdin_stdout', 'input': '5 2\n', 'output': 'ababa\n'}, {'type': 'stdin_stdout', 'input': '3 2\n', 'output': 'aba\n'}, {'type': 'stdin_stdout', 'input': '10 2\n', 'o... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/770/A'} | vfc_11682 | ```python
n, k = map(int, input().split())
print(('abcdefghijklmnopqrstuvwxyz'[:k] * n)[:n])
``` | 4 3
| abca
| abca
| true | 2,000 |
apps | verifiable_code | 483 | Solve the following coding problem using the programming language python:
There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located ... | ```python
import sys, math
n=int(input())
s=input()
z=list(map(int,input().split()))
best = 10**9
for i in range(len(s)-1):
if s[i]=='R' and s[i+1]=='L':
best=min(best, z[i+1]-(z[i]+z[i+1])//2)
if best != 10**9:
print(best)
else:
print(-1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\nRLRL\n2 4 6 10\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '3\nLLR\n40 50 60\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '4\nRLLR\n46 230 264 470\n', 'output': '92\n'}, {'type': 'stdin_stdout', 'input': '6\nLLRLLL\n446 492 650 844 930 970\n'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/699/A'} | vfc_11686 | ```python
import sys, math
n=int(input())
s=input()
z=list(map(int,input().split()))
best = 10**9
for i in range(len(s)-1):
if s[i]=='R' and s[i+1]=='L':
best=min(best, z[i+1]-(z[i]+z[i+1])//2)
if best != 10**9:
print(best)
else:
print(-1)
``` | 4
RLRL
2 4 6 10
| 1
| 1
| true | 2,001 |
apps | verifiable_code | 484 | Solve the following coding problem using the programming language python:
One very important person has a piece of paper in the form of a rectangle a × b.
Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size x_{i} × y_{i}. Each impression must be parallel to the sid... | ```python
R=lambda:list(map(int,input().split()))
n,a,b=R()
xy = [R() for _ in range(n)]
ans = 0
def f(xy1, xy2):
tans = 0
for _ in range(2):
for __ in range(2):
if (xy1[0]+xy2[0]<=a and max(xy1[1], xy2[1])<=b) or\
(max(xy1[0], xy2[0])<=a and xy1[1]+xy2[1]<=b):
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2 2 2\n1 2\n2 1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '4 10 9\n2 3\n1 1\n5 10\n9 11\n', 'output': '56\n'}, {'type': 'stdin_stdout', 'input': '3 10 10\n6 6\n7 7\n20 5\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '2 1 1\n1 1\n1 1\n', 'output'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/837/C'} | vfc_11690 | ```python
R=lambda:list(map(int,input().split()))
n,a,b=R()
xy = [R() for _ in range(n)]
ans = 0
def f(xy1, xy2):
tans = 0
for _ in range(2):
for __ in range(2):
if (xy1[0]+xy2[0]<=a and max(xy1[1], xy2[1])<=b) or\
(max(xy1[0], xy2[0])<=a and xy1[1]+xy2[1]<=b):
... | 2 2 2
1 2
2 1
| 4
| 4
| true | 2,002 |
apps | verifiable_code | 486 | Solve the following coding problem using the programming language python:
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.
Help Kurt find the maximum possible product of digits among all integers from $1$ to $n$.
-----I... | ```python
n = int(input())
def p(x):
ans = 1
while x > 0:
ans *= x % 10
x //= 10
return ans
ans = p(n)
for i in range(len(str(n))):
cans = 9 ** i * p((n // 10 ** i) - 1)
ans = max(ans, cans)
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '390\n', 'output': '216\n'}, {'type': 'stdin_stdout', 'input': '7\n', 'output': '7\n'}, {'type': 'stdin_stdout', 'input': '1000000000\n', 'output': '387420489\n'}, {'type': 'stdin_stdout', 'input': '1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '9\n', 'outpu... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1143/B'} | vfc_11698 | ```python
n = int(input())
def p(x):
ans = 1
while x > 0:
ans *= x % 10
x //= 10
return ans
ans = p(n)
for i in range(len(str(n))):
cans = 9 ** i * p((n // 10 ** i) - 1)
ans = max(ans, cans)
print(ans)
``` | 390
| 216
| 216
| true | 2,003 |
apps | verifiable_code | 487 | Solve the following coding problem using the programming language python:
Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are $n$ students in the school. Each student has exactly $k$ votes and is obligated to use all of them. So Awruk knows that if a per... | ```python
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
for k in range(max(a), 999999):
vote = sum(k-x for x in a)
if vote > s: print(k); break
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\n1 1 1 5 1\n', 'output': '5'}, {'type': 'stdin_stdout', 'input': '5\n2 2 3 2 2\n', 'output': '5'}, {'type': 'stdin_stdout', 'input': '1\n100\n', 'output': '201'}, {'type': 'stdin_stdout', 'input': '2\n15 5\n', 'output': '21'}, {'type': 'stdin_stdout', 'input': '50\n1... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1043/A'} | vfc_11702 | ```python
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
for k in range(max(a), 999999):
vote = sum(k-x for x in a)
if vote > s: print(k); break
``` | 5
1 1 1 5 1
| 5 | 5
| true | 2,004 |
apps | verifiable_code | 488 | Solve the following coding problem using the programming language python:
You are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors - one from the left and... | ```python
s = input()
cur_len = 1
a = []
char = []
for i in range(1, len(s)):
if s[i] == s[i-1]: cur_len += 1
else:
a.append(cur_len)
char.append(s[i-1])
cur_len = 1
a.append(cur_len)
char.append(s[len(s)-1])
ans = 0
while len(a) > 1:
n = len(a)
inner_min = 100000000
for i... | {'test_cases': [{'type': 'stdin_stdout', 'input': 'aabb\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': 'aabcaa\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': 'abbcccbba\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': 'aaaaaaaaaaa\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': 'aaaaaaa... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/909/D'} | vfc_11706 | ```python
s = input()
cur_len = 1
a = []
char = []
for i in range(1, len(s)):
if s[i] == s[i-1]: cur_len += 1
else:
a.append(cur_len)
char.append(s[i-1])
cur_len = 1
a.append(cur_len)
char.append(s[len(s)-1])
ans = 0
while len(a) > 1:
n = len(a)
inner_min = 100000000
for i... | aabb
| 2
| 2
| true | 2,005 |
apps | verifiable_code | 489 | Solve the following coding problem using the programming language python:
After returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn't been solving problems for a long time, so he became interested to answer a particular question: how many triples of indices (i, ... | ```python
n=int(input())
inp=input().split()
l=[]
for val in inp:
l.append(int(val))
l.sort()
count=3
while(count<n and l[count]==l[count-1]):
count+=1
if(l[2]!=l[1]):
print(count-2)
elif(l[2]!=l[0]):
print(((count-1)*(count-2))//2)
else:
print((count*(count-1)*(count-2))//6)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4\n1 1 1 1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '5\n1 3 2 3 4\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '6\n1 3 3 1 3 2\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '3\n1000000000 1000000000 1000000000\n', 'output': '1\n'}, {... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/817/B'} | vfc_11710 | ```python
n=int(input())
inp=input().split()
l=[]
for val in inp:
l.append(int(val))
l.sort()
count=3
while(count<n and l[count]==l[count-1]):
count+=1
if(l[2]!=l[1]):
print(count-2)
elif(l[2]!=l[0]):
print(((count-1)*(count-2))//2)
else:
print((count*(count-1)*(count-2))//6)
``` | 4
1 1 1 1
| 4
| 4
| true | 2,006 |
apps | verifiable_code | 490 | Solve the following coding problem using the programming language python:
Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.
Today is Shiro's birthday. She really loves pizza so she... | ```python
n=int(input())+1
if n==1: print(0)
else: print(n if n%2==1 else n//2)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n', 'output': '2'}, {'type': 'stdin_stdout', 'input': '4\n', 'output': '5'}, {'type': 'stdin_stdout', 'input': '10\n', 'output': '11'}, {'type': 'stdin_stdout', 'input': '10000000000\n', 'output': '10000000001'}, {'type': 'stdin_stdout', 'input': '1234567891\n', 'out... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/979/A'} | vfc_11714 | ```python
n=int(input())+1
if n==1: print(0)
else: print(n if n%2==1 else n//2)
``` | 3
| 2 | 2
| true | 2,007 |
apps | verifiable_code | 491 | Solve the following coding problem using the programming language python:
Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank ac... | ```python
n = int(input())
if n >= 0:
print(n)
else:
n = str(n)
print(max(int(n[:-1]), int(n[:-2] + n[-1])))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2230\n', 'output': '2230\n'}, {'type': 'stdin_stdout', 'input': '-10\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '-100003\n', 'output': '-10000\n'}, {'type': 'stdin_stdout', 'input': '544883178\n', 'output': '544883178\n'}, {'type': 'stdin_stdout', 'input':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/313/A'} | vfc_11718 | ```python
n = int(input())
if n >= 0:
print(n)
else:
n = str(n)
print(max(int(n[:-1]), int(n[:-2] + n[-1])))
``` | 2230
| 2230
| 2230
| true | 2,008 |
apps | verifiable_code | 492 | Solve the following coding problem using the programming language python:
[Image]
Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immediately bought the strange co... | ```python
a, b = input().split(' ')
n = int(input())
d = {'v': 0, '>': 1, '^': 2, '<': 3}
a, b = d[a], d[b]
ccw = bool((a + n) % 4 == b)
cw = bool((a - n) % 4 == b)
if cw and not ccw:
print('cw')
elif ccw and not cw:
print('ccw')
else:
print('undefined')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '^ >\n1\n', 'output': 'cw\n'}, {'type': 'stdin_stdout', 'input': '< ^\n3\n', 'output': 'ccw\n'}, {'type': 'stdin_stdout', 'input': '^ v\n6\n', 'output': 'undefined\n'}, {'type': 'stdin_stdout', 'input': '^ >\n999999999\n', 'output': 'ccw\n'}, {'type': 'stdin_stdout', 'i... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/834/A'} | vfc_11722 | ```python
a, b = input().split(' ')
n = int(input())
d = {'v': 0, '>': 1, '^': 2, '<': 3}
a, b = d[a], d[b]
ccw = bool((a + n) % 4 == b)
cw = bool((a - n) % 4 == b)
if cw and not ccw:
print('cw')
elif ccw and not cw:
print('ccw')
else:
print('undefined')
``` | ^ >
1
| cw
| cw
| true | 2,009 |
apps | verifiable_code | 493 | Solve the following coding problem using the programming language python:
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges n dominoes in a line, placing each piece vertical... | ```python
n = int(input())
a = input().strip()
nextl = [-1] * n
lastr = [-1] * n
ll = -1
for i in range(n):
if a[i] == "R":
ll = i
if a[i] == "L":
ll = -1
lastr[i] = ll
nl = -1
for i in range(n - 1, -1, -1):
if a[i] == "L":
nl = i
if a[i] == "R":
nl = -1
nextl[i] ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '14\n.L.R...LR..L..\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '5\nR....\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1\n.\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1\nL\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '1\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/405/B'} | vfc_11726 | ```python
n = int(input())
a = input().strip()
nextl = [-1] * n
lastr = [-1] * n
ll = -1
for i in range(n):
if a[i] == "R":
ll = i
if a[i] == "L":
ll = -1
lastr[i] = ll
nl = -1
for i in range(n - 1, -1, -1):
if a[i] == "L":
nl = i
if a[i] == "R":
nl = -1
nextl[i] ... | 14
.L.R...LR..L..
| 4
| 4
| true | 2,010 |
apps | verifiable_code | 494 | Solve the following coding problem using the programming language python:
n children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation a_1, a_2, ..., a_{n} of length n. It is an integer sequence such that each integer from 1 to n appears exactly once in it.
The game... | ```python
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
n,m=map(int,input().split())
l=list(map(int,input().split()))
for i in range(len(l)):
l[i]-=1
use=[0]*n
a=[0]*n
bad=0
for i in range(len(l)-1):
# transfer l[i] to l[i+1]
if a[l[i]] and a[l[i]]%n!=(l[i+1]-l[i])%n:
bad=1
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 5\n2 3 1 4 4\n', 'output': '3 1 2 4 \n'}, {'type': 'stdin_stdout', 'input': '3 3\n3 1 2\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input': '1 100\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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/818/B'} | vfc_11730 | ```python
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
n,m=map(int,input().split())
l=list(map(int,input().split()))
for i in range(len(l)):
l[i]-=1
use=[0]*n
a=[0]*n
bad=0
for i in range(len(l)-1):
# transfer l[i] to l[i+1]
if a[l[i]] and a[l[i]]%n!=(l[i+1]-l[i])%n:
bad=1
... | 4 5
2 3 1 4 4
| 3 1 2 4
| 3 1 2 4
| true | 2,011 |
apps | verifiable_code | 495 | Solve the following coding problem using the programming language python:
Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer.
Help Pasha ... | ```python
a, k = input().split()
k = int(k)
a = [i for i in a]
i = 0
while k > 0 and i < len(a):
m = a[i : i + k + 1].index(max(a[i : i + k + 1]))
if a[i + m] > a[i]:
k -= m
for j in range(i + m, i, -1):
a[j], a[j - 1] = a[j - 1], a[j]
i += 1
print("".join(a))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '1990 1\n', 'output': '9190\n'}, {'type': 'stdin_stdout', 'input': '300 0\n', 'output': '300\n'}, {'type': 'stdin_stdout', 'input': '1034 2\n', 'output': '3104\n'}, {'type': 'stdin_stdout', 'input': '9090000078001234 6\n', 'output': '9907000008001234\n'}, {'type': 'stdi... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/435/B'} | vfc_11734 | ```python
a, k = input().split()
k = int(k)
a = [i for i in a]
i = 0
while k > 0 and i < len(a):
m = a[i : i + k + 1].index(max(a[i : i + k + 1]))
if a[i + m] > a[i]:
k -= m
for j in range(i + m, i, -1):
a[j], a[j - 1] = a[j - 1], a[j]
i += 1
print("".join(a))
``` | 1990 1
| 9190
| 9190
| true | 2,012 |
apps | verifiable_code | 496 | Solve the following coding problem using the programming language python:
Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.
Arithmetic progression is a sequence a... | ```python
def isZ(a):
return a == int(a)
def geom(a,b,c,d):
if 0 in (a,b,c,d) and not (a==b==c==d==0):
return False
if(b/a==c/b==d/c):
nxt = d * (d/c)
if not isZ(nxt): return False
print(int(nxt))
return True
return False
def ar(a,b,c,d):
if(b-a==c-b==d-c):
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '836 624 412 200\n', 'output': '-12\n'}, {'type': 'stdin_stdout', 'input': '1 334 667 1000\n', 'output': '1333\n'}, {'type': 'stdin_stdout', 'input': '501 451 400 350\n', 'output': '42\n'}, {'type': 'stdin_stdout', 'input': '836 624 412 200\n', 'output': '-12\n'}, {'typ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/328/A'} | vfc_11738 | ```python
def isZ(a):
return a == int(a)
def geom(a,b,c,d):
if 0 in (a,b,c,d) and not (a==b==c==d==0):
return False
if(b/a==c/b==d/c):
nxt = d * (d/c)
if not isZ(nxt): return False
print(int(nxt))
return True
return False
def ar(a,b,c,d):
if(b-a==c-b==d-c):
... | 836 624 412 200
| -12
| -12
| true | 2,013 |
apps | verifiable_code | 497 | Solve the following coding problem using the programming language python:
Ilya lives in a beautiful city of Chordalsk.
There are $n$ houses on the street Ilya lives, they are numerated from $1$ to $n$ from left to right; the distance between every two neighboring houses is equal to $1$ unit. The neighboring houses ar... | ```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return tuple(map(int, sys.stdin.read... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\n1 2 3 2 3\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '3\n1 2 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '7\n1 1 3 1 1 1 1\n', 'output': '4\n'}, {'type': 'stdin_stdout', 'input': '10\n1 5 2 10 9 3 3 2 9 5\n', 'output': '9\n'}, {'type': 'st... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1119/A'} | vfc_11742 | ```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return tuple(map(int, sys.stdin.read... | 5
1 2 3 2 3
| 4
| 4
| true | 2,014 |
apps | verifiable_code | 498 | Solve the following coding problem using the programming language python:
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are nu... | ```python
n, m, k = list(map(int, input().split()))
print((k - 1) // (2 * m) + 1, end=" ")
print((k - 1) % (2 * m) // 2 + 1, end=" ")
if ((k - 1) % (2 * m) % 2 == 0):
print("L")
else:
print("R")
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 3 9\n', 'output': '2 2 L\n'}, {'type': 'stdin_stdout', 'input': '4 3 24\n', 'output': '4 3 R\n'}, {'type': 'stdin_stdout', 'input': '2 4 4\n', 'output': '1 2 R\n'}, {'type': 'stdin_stdout', 'input': '3 10 24\n', 'output': '2 2 R\n'}, {'type': 'stdin_stdout', 'input':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/748/A'} | vfc_11746 | ```python
n, m, k = list(map(int, input().split()))
print((k - 1) // (2 * m) + 1, end=" ")
print((k - 1) % (2 * m) // 2 + 1, end=" ")
if ((k - 1) % (2 * m) % 2 == 0):
print("L")
else:
print("R")
``` | 4 3 9
| 2 2 L
| 2 2 L
| true | 2,015 |
apps | verifiable_code | 499 | Solve the following coding problem using the programming language python:
Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them fo... | ```python
def main():
n = int(input())
s = input()
b, g, r = [s.count(i) for i in "BGR"]
if min(b, g, r) > 0:
print("BGR")
return
if max(b, g, r) == n:
if b == n: print("B")
if g == n: print("G")
if r == n: print("R")
return
if max(b, g, ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\nRB\n', 'output': 'G\n'}, {'type': 'stdin_stdout', 'input': '3\nGRG\n', 'output': 'BR\n'}, {'type': 'stdin_stdout', 'input': '5\nBBBBB\n', 'output': 'B\n'}, {'type': 'stdin_stdout', 'input': '1\nR\n', 'output': 'R\n'}, {'type': 'stdin_stdout', 'input': '200\nBBRGRRBB... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/626/B'} | vfc_11750 | ```python
def main():
n = int(input())
s = input()
b, g, r = [s.count(i) for i in "BGR"]
if min(b, g, r) > 0:
print("BGR")
return
if max(b, g, r) == n:
if b == n: print("B")
if g == n: print("G")
if r == n: print("R")
return
if max(b, g, ... | 2
RB
| G
| G
| true | 2,016 |
apps | verifiable_code | 501 | Solve the following coding problem using the programming language python:
Nazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a math teacher gave him a very difficult task.
Consider two infinite sets of numbers. The first set consists of odd... | ```python
def f(n, mod):
res = 0
n1 = 1
n2 = 2
k = 1
now = 0
while n >= k:
if now == 0:
now = 1
res = (res + n1 * k + (k * (k - 1))) % mod
n -= k
k *= 2
n1 = n1 + k
else:
now = 0
res = (res + n2 *... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 3\n', 'output': '7'}, {'type': 'stdin_stdout', 'input': '5 14\n', 'output': '105'}, {'type': 'stdin_stdout', 'input': '88005553535 99999999999\n', 'output': '761141116'}, {'type': 'stdin_stdout', 'input': '1 1000000000000000000\n', 'output': '724824772'}, {'type': 's... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1151/C'} | vfc_11758 | ```python
def f(n, mod):
res = 0
n1 = 1
n2 = 2
k = 1
now = 0
while n >= k:
if now == 0:
now = 1
res = (res + n1 * k + (k * (k - 1))) % mod
n -= k
k *= 2
n1 = n1 + k
else:
now = 0
res = (res + n2 *... | 1 3
| 7 | 7
| true | 2,018 |
apps | verifiable_code | 502 | Solve the following coding problem using the programming language python:
Arpa is taking a geometry exam. Here is the last problem of the exam.
You are given three points a, b, c.
Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old pos... | ```python
def read_ints():
return [int(i) for i in input().split()]
coords = read_ints()
a, b, c = [(coords[i], coords[i + 1]) for i in range(0, len(coords), 2)]
def length_sqr(a, b):
return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2
if length_sqr(a, b) != length_sqr(b, c):
print('No')
elif (c[0] - b[0]) * (b[1] - a[... | {'test_cases': [{'type': 'stdin_stdout', 'input': '0 1 1 1 1 0\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '1 1 0 0 1000 1000\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '1 0 2 0 3 0\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '3 4 0 0 4 3\n', 'output': 'Yes\n'}, {'type': 'stdin_... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/851/B'} | vfc_11762 | ```python
def read_ints():
return [int(i) for i in input().split()]
coords = read_ints()
a, b, c = [(coords[i], coords[i + 1]) for i in range(0, len(coords), 2)]
def length_sqr(a, b):
return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2
if length_sqr(a, b) != length_sqr(b, c):
print('No')
elif (c[0] - b[0]) * (b[1] - a[... | 0 1 1 1 1 0
| Yes
| Yes
| true | 2,019 |
apps | verifiable_code | 503 | Solve the following coding problem using the programming language python:
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subsequen... | ```python
def main():
import sys
from collections import defaultdict
tokens = [int(i) for i in sys.stdin.read().split()]
tokens.reverse()
n, k = tokens.pop(), tokens.pop()
d1 = defaultdict(int)
d2 = defaultdict(int)
result = 0
for i in tokens:
result += d2[i * ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 2\n1 1 2 2 4\n', 'output': '4'}, {'type': 'stdin_stdout', 'input': '3 1\n1 1 1\n', 'output': '1'}, {'type': 'stdin_stdout', 'input': '10 3\n1 2 6 2 3 6 9 18 3 9\n', 'output': '6'}, {'type': 'stdin_stdout', 'input': '20 2\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/567/C'} | vfc_11766 | ```python
def main():
import sys
from collections import defaultdict
tokens = [int(i) for i in sys.stdin.read().split()]
tokens.reverse()
n, k = tokens.pop(), tokens.pop()
d1 = defaultdict(int)
d2 = defaultdict(int)
result = 0
for i in tokens:
result += d2[i * ... | 5 2
1 1 2 2 4
| 4 | 4
| true | 2,020 |
apps | verifiable_code | 504 | Solve the following coding problem using the programming language python:
Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:
Max owns n creatures, i-th of them can be described wit... | ```python
# python3
from sys import stdin
from collections import namedtuple
def readline(): return tuple(map(int, input().split()))
n, a, b = readline()
hand = [tuple(map(int, line.split())) for line in stdin.readlines()]
if not b:
print(sum(creature[1] for creature in hand))
else:
hand.sort(key=lambda se... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2 1 1\n10 15\n6 1\n', 'output': '27\n'}, {'type': 'stdin_stdout', 'input': '3 0 3\n10 8\n7 11\n5 2\n', 'output': '26\n'}, {'type': 'stdin_stdout', 'input': '1 0 0\n2 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1 0 200000\n1 2\n', 'output': '2\n'}, {'type... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/976/E'} | vfc_11770 | ```python
# python3
from sys import stdin
from collections import namedtuple
def readline(): return tuple(map(int, input().split()))
n, a, b = readline()
hand = [tuple(map(int, line.split())) for line in stdin.readlines()]
if not b:
print(sum(creature[1] for creature in hand))
else:
hand.sort(key=lambda se... | 2 1 1
10 15
6 1
| 27
| 27
| true | 2,021 |
apps | verifiable_code | 505 | Solve the following coding problem using the programming language python:
The Robot is in a rectangular maze of size n × m. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right (the symbol "R"), up (the symbol "U") or do... | ```python
import math
from collections import deque
def main():
n, m, k = list(map(int, input().split()))
grid = ["" for _ in range(n)]
x, y = 0, 0
for i in range(n):
grid[i] = input()
if 'X' in grid[i]:
x, y = i, grid[i].index('X')
if k % 2 == 1:
print("IMPOSSIBLE")
return
dx = [1, 0, 0, -1]
dy ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '2 3 2\n.**\nX..\n', 'output': 'RL\n'}, {'type': 'stdin_stdout', 'input': '5 6 14\n..***.\n*...X.\n..*...\n..*.**\n....*.\n', 'output': 'DLDDLLLRRRUURU\n'}, {'type': 'stdin_stdout', 'input': '3 3 4\n***\n*X*\n***\n', 'output': 'IMPOSSIBLE\n'}, {'type': 'stdin_stdout', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/769/C'} | vfc_11774 | ```python
import math
from collections import deque
def main():
n, m, k = list(map(int, input().split()))
grid = ["" for _ in range(n)]
x, y = 0, 0
for i in range(n):
grid[i] = input()
if 'X' in grid[i]:
x, y = i, grid[i].index('X')
if k % 2 == 1:
print("IMPOSSIBLE")
return
dx = [1, 0, 0, -1]
dy ... | 2 3 2
.**
X..
| RL
| RL
| true | 2,022 |
apps | verifiable_code | 506 | Solve the following coding problem using the programming language python:
One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular shee... | ```python
a, b = list(map(int, input().split()))
ans = 0
while a and b:
if a > b:
ans += a // b
a = a % b
else:
ans += b // a
b = b % a
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2 1\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '10 7\n', 'output': '6\n'}, {'type': 'stdin_stdout', 'input': '1000000000000 1\n', 'output': '1000000000000\n'}, {'type': 'stdin_stdout', 'input': '3 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/527/A'} | vfc_11778 | ```python
a, b = list(map(int, input().split()))
ans = 0
while a and b:
if a > b:
ans += a // b
a = a % b
else:
ans += b // a
b = b % a
print(ans)
``` | 2 1
| 2
| 2
| true | 2,023 |
apps | verifiable_code | 508 | Solve the following coding problem using the programming language python:
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides)... | ```python
3
def read_ints():
return [int(i) for i in input().split()]
n, a = read_ints()
res = 1
for i in range(2, n - 1):
if abs(a - res * 180 / n) > abs(a - i * 180 / n):
res = i
print(2, 1, res + 2)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 15\n', 'output': '2 1 3\n'}, {'type': 'stdin_stdout', 'input': '4 67\n', 'output': '2 1 3\n'}, {'type': 'stdin_stdout', 'input': '4 68\n', 'output': '2 1 4\n'}, {'type': 'stdin_stdout', 'input': '3 1\n', 'output': '2 1 3\n'}, {'type': 'stdin_stdout', 'input': '3 180\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/820/B'} | vfc_11786 | ```python
3
def read_ints():
return [int(i) for i in input().split()]
n, a = read_ints()
res = 1
for i in range(2, n - 1):
if abs(a - res * 180 / n) > abs(a - i * 180 / n):
res = i
print(2, 1, res + 2)
``` | 3 15
| 2 1 3
| 2 1 3
| true | 2,025 |
apps | verifiable_code | 510 | Solve the following coding problem using the programming language python:
Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad.
The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad a... | ```python
ii = lambda: int(input())
mi = lambda: list(map(int, input().split()))
li = lambda: list(mi())
a, b, c, d = mi()
a, b, c = sorted([a, b, c])
ans = max(0, d - (b - a)) + max(0, d - (c - b))
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 2 6 3\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '3 1 5 6\n', 'output': '8\n'}, {'type': 'stdin_stdout', 'input': '8 3 3 2\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '2 3 10 4\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '10000000... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1185/A'} | vfc_11794 | ```python
ii = lambda: int(input())
mi = lambda: list(map(int, input().split()))
li = lambda: list(mi())
a, b, c, d = mi()
a, b, c = sorted([a, b, c])
ans = max(0, d - (b - a)) + max(0, d - (c - b))
print(ans)
``` | 5 2 6 3
| 2
| 2
| true | 2,026 |
apps | verifiable_code | 512 | Solve the following coding problem using the programming language python:
There is a building with 2N floors, numbered 1, 2, \ldots, 2N from bottom to top.
The elevator in this building moved from Floor 1 to Floor 2N just once.
On the way, N persons got on and off the elevator. Each person i (1 \leq i \leq N) got on a... | ```python
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
N = int(readline())
L = 2 * N
floor = [[0, 0] for _ in range(L)]
com = dict()
for i in range(1, N + 1):
A, B = map(int, readline().split())
com[i] = ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n1 -1\n-1 4\n-1 6\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '2\n1 4\n2 3\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '2\n4 1\n2 4\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input': '2\n3 -1\n-1 2\n', 'output': 'Yes\n'}, {'type': 'st... | {'difficulty': 'interview', 'problem_url': 'https://atcoder.jp/contests/arc104/tasks/arc104_c'} | vfc_11802 | ```python
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
N = int(readline())
L = 2 * N
floor = [[0, 0] for _ in range(L)]
com = dict()
for i in range(1, N + 1):
A, B = map(int, readline().split())
com[i] = ... | 3
1 -1
-1 4
-1 6
| Yes
| Yes
| true | 2,027 |
apps | verifiable_code | 513 | Solve the following coding problem using the programming language python:
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except fo... | ```python
X=[]
Y=[]
Points=[]
k=False
for i in range(8):
x,y=list(map(int,input().split()))
X.append(x)
Y.append(y)
if([x,y] in Points):
k=True
Points.append([x,y])
X.sort()
Y.sort()
if(len(set(X))!=3 or len(set(Y))!=3 or k):
print("ugly")
elif(X.count(X[0])!=3 or X.count(X[3])!=2 or X... | {'test_cases': [{'type': 'stdin_stdout', 'input': '0 0\n0 1\n0 2\n1 0\n1 2\n2 0\n2 1\n2 2\n', 'output': 'respectable\n'}, {'type': 'stdin_stdout', 'input': '0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n', 'output': 'ugly\n'}, {'type': 'stdin_stdout', 'input': '1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n', 'output': 'ugly\n'}, ... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/334/B'} | vfc_11806 | ```python
X=[]
Y=[]
Points=[]
k=False
for i in range(8):
x,y=list(map(int,input().split()))
X.append(x)
Y.append(y)
if([x,y] in Points):
k=True
Points.append([x,y])
X.sort()
Y.sort()
if(len(set(X))!=3 or len(set(Y))!=3 or k):
print("ugly")
elif(X.count(X[0])!=3 or X.count(X[3])!=2 or X... | 0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
| respectable
| respectable
| true | 2,028 |
apps | verifiable_code | 514 | Solve the following coding problem using the programming language python:
Adilbek was assigned to a special project. For Adilbek it means that he has $n$ days to run a special program and provide its results. But there is a problem: the program needs to run for $d$ days to calculate the results.
Fortunately, Adilbek ... | ```python
t = int(input())
for _ in range(t):
n, d = list(map(int, input().split()))
if (1 - n) ** 2 - 4 * (d - n) >= 0:
print('YES')
else:
print('NO')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n1 1\n4 5\n5 11\n', 'output': 'YES\nYES\nNO\n'}, {'type': 'stdin_stdout', 'input': '50\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 1\n3 2\n3 3\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n3 10\n4 1\n4 2\n4 3\n4 4\n4 5\n4... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1288/A'} | vfc_11810 | ```python
t = int(input())
for _ in range(t):
n, d = list(map(int, input().split()))
if (1 - n) ** 2 - 4 * (d - n) >= 0:
print('YES')
else:
print('NO')
``` | 3
1 1
4 5
5 11
| YES
YES
NO
| YES
YES
NO
| true | 2,029 |
apps | verifiable_code | 515 | Solve the following coding problem using the programming language python:
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be dr... | ```python
k = int(input())
if k // 2 + k % 2 > 18:
print(-1)
else:
print('8' * (k // 2) + ('6' if k % 2 else ''))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n', 'output': '8\n'}, {'type': 'stdin_stdout', 'input': '6\n', 'output': '888\n'}, {'type': 'stdin_stdout', 'input': '3\n', 'output': '86\n'}, {'type': 'stdin_stdout', 'input': '4\n', 'output': '88\n'}, {'type': 'stdin_stdout', 'input': '5\n', 'output': '886\n'}, {'t... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/934/B'} | vfc_11814 | ```python
k = int(input())
if k // 2 + k % 2 > 18:
print(-1)
else:
print('8' * (k // 2) + ('6' if k % 2 else ''))
``` | 2
| 8
| 8
| true | 2,030 |
apps | verifiable_code | 516 | Solve the following coding problem using the programming language python:
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In... | ```python
n, m = map(int, input().split())
mi = 100000000000000
ts = ""
def num_d(a, b):
t = 0
for x in range(len(a)):
if a[x] != b[x]:
t += 1
return t
s, t = input(), input()
for x in range(m-n+1):
d = num_d(s, t[x:x+n])
if d < mi:
mi = d
ts = t[x:x+n]
print(mi)
for x in range(n):
if s[x]... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 5\nabc\nxaybz\n', 'output': '2\n2 3 \n'}, {'type': 'stdin_stdout', 'input': '4 10\nabcd\nebceabazcd\n', 'output': '1\n2 \n'}, {'type': 'stdin_stdout', 'input': '1 1\na\na\n', 'output': '0\n\n'}, {'type': 'stdin_stdout', 'input': '1 1\na\nz\n', 'output': '1\n1 \n'}, {... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/822/B'} | vfc_11818 | ```python
n, m = map(int, input().split())
mi = 100000000000000
ts = ""
def num_d(a, b):
t = 0
for x in range(len(a)):
if a[x] != b[x]:
t += 1
return t
s, t = input(), input()
for x in range(m-n+1):
d = num_d(s, t[x:x+n])
if d < mi:
mi = d
ts = t[x:x+n]
print(mi)
for x in range(n):
if s[x]... | 3 5
abc
xaybz
| 2
2 3
| 2
2 3 | true | 2,031 |
apps | verifiable_code | 520 | Solve the following coding problem using the programming language python:
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the universi... | ```python
n = int(input())
arr = list(map(int, input().split()))
print(sum(arr) // n)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n2014 2016 2015\n', 'output': '2015\n'}, {'type': 'stdin_stdout', 'input': '1\n2050\n', 'output': '2050\n'}, {'type': 'stdin_stdout', 'input': '1\n2010\n', 'output': '2010\n'}, {'type': 'stdin_stdout', 'input': '1\n2011\n', 'output': '2011\n'}, {'type': 'stdin_stdout... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/769/A'} | vfc_11834 | ```python
n = int(input())
arr = list(map(int, input().split()))
print(sum(arr) // n)
``` | 3
2014 2016 2015
| 2015
| 2015
| true | 2,035 |
apps | verifiable_code | 521 | Solve the following coding problem using the programming language python:
Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.
Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into ... | ```python
input()
s = input()
if 'MM' in s or 'YY' in s or 'CC' in s:
print ('No')
elif s.startswith('?') or s.endswith('?'):
print ('Yes')
elif '??' in s:
print ('Yes')
elif 'C?C' in s or 'M?M' in s or 'Y?Y' in s:
print ('Yes')
else:
print ('No')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '5\nCY??Y\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '5\nC?C?Y\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '5\n?CYC?\n', 'output': 'Yes\n'}, {'type': 'stdin_stdout', 'input': '5\nC??MM\n', 'output': 'No\n'}, {'type': 'stdin_stdout', 'input':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/957/A'} | vfc_11838 | ```python
input()
s = input()
if 'MM' in s or 'YY' in s or 'CC' in s:
print ('No')
elif s.startswith('?') or s.endswith('?'):
print ('Yes')
elif '??' in s:
print ('Yes')
elif 'C?C' in s or 'M?M' in s or 'Y?Y' in s:
print ('Yes')
else:
print ('No')
``` | 5
CY??Y
| Yes
| Yes
| true | 2,036 |
apps | verifiable_code | 522 | Solve the following coding problem using the programming language python:
Let $f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3}$ for $x \ge 4$.
You have given integers $n$, $f_{1}$, $f_{2}$, $f_{3}$, and $c$. Find $f_{n} \bmod (10^{9}+7)$.
-----Input-----
The only line contains five integers $n$, $f_{1}$... | ```python
n, f1, f2, f3, c = list(map(int,input().split()))
mat = [[1,1,1],[1,0,0],[0,1,0]]
final = [[1,0,0],[0,1,0],[0,0,1]]
nn = n - 3
N = 10**9 + 6
def prod(a, b):
m = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
for j in range(3):
m[i][j] = (a[i][0]*b[0][j] + a[i][1]*b[1][j]+a[i][2]*b[2][j]) % N
return m
wh... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 1 2 5 3\n', 'output': '72900\n'}, {'type': 'stdin_stdout', 'input': '17 97 41 37 11\n', 'output': '317451037\n'}, {'type': 'stdin_stdout', 'input': '4 1 1 1 1\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '1000000000000000000 1000000000 1000000000 100000000... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1182/E'} | vfc_11842 | ```python
n, f1, f2, f3, c = list(map(int,input().split()))
mat = [[1,1,1],[1,0,0],[0,1,0]]
final = [[1,0,0],[0,1,0],[0,0,1]]
nn = n - 3
N = 10**9 + 6
def prod(a, b):
m = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
for j in range(3):
m[i][j] = (a[i][0]*b[0][j] + a[i][1]*b[1][j]+a[i][2]*b[2][j]) % N
return m
wh... | 5 1 2 5 3
| 72900
| 72900
| true | 2,037 |
apps | verifiable_code | 523 | Solve the following coding problem using the programming language python:
Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings "pop", "noon", "x", and "kkkkkk" are palindromes, while strings "moon", ... | ```python
n, m = map(int, input().split())
p = ''
q = []
arr = [input() for __ in range(n)]
s = set(arr)
for z in arr:
if z == z[::-1]:
p = z
else:
if z not in s: continue
if z[::-1] in s:
s.remove(z)
s.remove(z[::-1])
q += z,
res = ''.join(q)
res =... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 3\ntab\none\nbat\n', 'output': '6\ntabbat\n'}, {'type': 'stdin_stdout', 'input': '4 2\noo\nox\nxo\nxx\n', 'output': '6\noxxxxo\n'}, {'type': 'stdin_stdout', 'input': '3 5\nhello\ncodef\norces\n', 'output': '0\n\n'}, {'type': 'stdin_stdout', 'input': '9 4\nabab\nbaba\... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1304/B'} | vfc_11846 | ```python
n, m = map(int, input().split())
p = ''
q = []
arr = [input() for __ in range(n)]
s = set(arr)
for z in arr:
if z == z[::-1]:
p = z
else:
if z not in s: continue
if z[::-1] in s:
s.remove(z)
s.remove(z[::-1])
q += z,
res = ''.join(q)
res =... | 3 3
tab
one
bat
| 6
tabbat
| 6
tabbat
| true | 2,038 |
apps | verifiable_code | 524 | Solve the following coding problem using the programming language python:
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$.
Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are a... | ```python
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
if(n>65):
print(sum(a)-n)
elif(n==1 or n==2):
print(a[0]-1)
else:
ans=10**20
for i in range(1,50000):
now=1
ta=0
for j in a:
ta+=abs(now-j)
now*=i
ans=min(ans,ta)
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '3\n1 3 2\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '3\n1000000000 1000000000 1000000000\n', 'output': '1999982505\n'}, {'type': 'stdin_stdout', 'input': '20\n51261 11877 300 30936722 84 75814681 352366 23 424 16392314 27267 832 4 562873474 33 516967731 15... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1397/B'} | vfc_11850 | ```python
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
if(n>65):
print(sum(a)-n)
elif(n==1 or n==2):
print(a[0]-1)
else:
ans=10**20
for i in range(1,50000):
now=1
ta=0
for j in a:
ta+=abs(now-j)
now*=i
ans=min(ans,ta)
print(ans)
``` | 3
1 3 2
| 1
| 1
| true | 2,039 |
apps | verifiable_code | 525 | Solve the following coding problem using the programming language python:
Lord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!
A password is an array $a$ of $n$ positive integers. You apply the following operation to the array: p... | ```python
# for _ in range(1):
for _ in range(int(input())):
# a, b = map(int, input().split())
n = int(input())
arr = list(map(int, input().split()))
# s = input()
if [arr[0]] * n == arr:
print(n)
else:
print(1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n4\n2 1 3 1\n2\n420 420\n', 'output': '1\n2\n'}, {'type': 'stdin_stdout', 'input': '8\n6\n1 7 7 1 7 1\n2\n3 3\n8\n1 1000000000 1000000000 2 2 1 2 2\n2\n420 69\n10\n1 3 5 7 9 2 4 6 8 10\n5\n6 16 7 6 1\n3\n16 16 16\n5\n1 2 9 8 4\n', 'output': '1\n2\n1\n1\n1\n1\n3\n1\n'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1392/A'} | vfc_11854 | ```python
# for _ in range(1):
for _ in range(int(input())):
# a, b = map(int, input().split())
n = int(input())
arr = list(map(int, input().split()))
# s = input()
if [arr[0]] * n == arr:
print(n)
else:
print(1)
``` | 2
4
2 1 3 1
2
420 420
| 1
2
| 1
2
| true | 2,040 |
apps | verifiable_code | 526 | Solve the following coding problem using the programming language python:
Student Dima from Kremland has a matrix $a$ of size $n \times m$ filled with non-negative integers.
He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater... | ```python
n, m = [int(i) for i in input().split()]
A = []
C = []
for i in range(n):
B = [int(j) for j in input().split()]
A.append(B)
C.append(sorted(list(set(B))))
xor = 0
ans = []
for i in range(n):
xor ^= A[i][0]
ans.append(1)
if xor==0:
found = 0
for trial in range(n-1, -1, -1):
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '3 2\n0 0\n0 0\n0 0\n', 'output': 'NIE\n'}, {'type': 'stdin_stdout', 'input': '2 3\n7 7 7\n7 7 10\n', 'output': 'TAK\n1 3 \n'}, {'type': 'stdin_stdout', 'input': '1 1\n706\n', 'output': 'TAK\n1 \n'}, {'type': 'stdin_stdout', 'input': '1 1\n0\n', 'output': 'NIE\n'}, {'ty... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1151/B'} | vfc_11858 | ```python
n, m = [int(i) for i in input().split()]
A = []
C = []
for i in range(n):
B = [int(j) for j in input().split()]
A.append(B)
C.append(sorted(list(set(B))))
xor = 0
ans = []
for i in range(n):
xor ^= A[i][0]
ans.append(1)
if xor==0:
found = 0
for trial in range(n-1, -1, -1):
... | 3 2
0 0
0 0
0 0
| NIE
| NIE
| true | 2,041 |
apps | verifiable_code | 528 | Solve the following coding problem using the programming language python:
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).
There are n members, numbered 1 through n. m pairs of members are friends. Of cou... | ```python
from collections import deque
def bfs(start):
res = []
queue = deque([start])
while queue:
vertex = queue.pop()
if not vis[vertex]:
vis[vertex] = 1
res.append(vertex)
for i in s[vertex]:
if not vis[i]:
queue.... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 3\n1 3\n3 4\n1 4\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '4 4\n3 1\n2 3\n3 4\n1 2\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '10 4\n4 3\n5 10\n8 9\n1 2\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '3 2\n1 2\n2 3\n', 'outpu... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/771/A'} | vfc_11866 | ```python
from collections import deque
def bfs(start):
res = []
queue = deque([start])
while queue:
vertex = queue.pop()
if not vis[vertex]:
vis[vertex] = 1
res.append(vertex)
for i in s[vertex]:
if not vis[i]:
queue.... | 4 3
1 3
3 4
1 4
| YES
| YES
| true | 2,042 |
apps | verifiable_code | 529 | Solve the following coding problem using the programming language python:
[Image]
-----Input-----
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.
The second line of the input is an integer between 0... | ```python
t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]
print(''.join(i.upper() if i < p else i for i in t))
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': 'AprilFool\n14\n', 'output': 'AprILFooL\n'}, {'type': 'stdin_stdout', 'input': 'abcdefabc\n3\n', 'output': 'ABCdefABC\n'}, {'type': 'stdin_stdout', 'input': 'fgWjSAlPOvcAbCdDEFjz\n7\n', 'output': 'FGwjsAlpovCABCDDEFjz\n'}, {'type': 'stdin_stdout', 'input': 'sm\n26\n', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/290/D'} | vfc_11870 | ```python
t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]
print(''.join(i.upper() if i < p else i for i in t))
``` | AprilFool
14
| AprILFooL
| AprILFooL
| true | 2,043 |
apps | verifiable_code | 530 | Solve the following coding problem using the programming language python:
Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game.
Roman leaves a word for each of them. Each word consists of 2·n binary characters "... | ```python
n = int(input())
a, b = input(), input()
t = {i + j: 0 for i in '01' for j in '01'}
for i in range(2 * n): t[a[i] + b[i]] += 1
d = t['11'] & 1
d += (t['10'] - t['01'] + 1 - d) // 2
if d > 0: d = 1
elif d < 0: d = 2
print(['Draw', 'First', 'Second'][d])
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n0111\n0001\n', 'output': 'First\n'}, {'type': 'stdin_stdout', 'input': '3\n110110\n001001\n', 'output': 'First\n'}, {'type': 'stdin_stdout', 'input': '3\n111000\n000111\n', 'output': 'Draw\n'}, {'type': 'stdin_stdout', 'input': '4\n01010110\n00101101\n', 'output': '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/293/A'} | vfc_11874 | ```python
n = int(input())
a, b = input(), input()
t = {i + j: 0 for i in '01' for j in '01'}
for i in range(2 * n): t[a[i] + b[i]] += 1
d = t['11'] & 1
d += (t['10'] - t['01'] + 1 - d) // 2
if d > 0: d = 1
elif d < 0: d = 2
print(['Draw', 'First', 'Second'][d])
``` | 2
0111
0001
| First
| First
| true | 2,044 |
apps | verifiable_code | 531 | Solve the following coding problem using the programming language python:
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.
Kirill has already made his measurements, and has got the following integer... | ```python
n=int(input())
a=list(map(int,input().split()))
mm=max(a)
mmm=min(a)
if mmm!=mm-2:
print(n)
print(*a)
else:
q,w,e=0,0,0
for i in a:
if i==mm:
e+=1
elif i==mmm:
q+=1
else:
w+=1
y=w%2+q+e
p=max(q,e)-min(q,e)
u=p+w
if y<u... | {'test_cases': [{'type': 'stdin_stdout', 'input': '6\n-1 1 1 0 0 -1\n', 'output': '2\n0 0 0 0 0 0 \n'}, {'type': 'stdin_stdout', 'input': '3\n100 100 101\n', 'output': '3\n101 100 100 \n'}, {'type': 'stdin_stdout', 'input': '7\n-10 -9 -10 -8 -10 -9 -9\n', 'output': '5\n-10 -10 -9 -9 -9 -9 -9 \n'}, {'type': 'stdin_stdou... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/931/C'} | vfc_11878 | ```python
n=int(input())
a=list(map(int,input().split()))
mm=max(a)
mmm=min(a)
if mmm!=mm-2:
print(n)
print(*a)
else:
q,w,e=0,0,0
for i in a:
if i==mm:
e+=1
elif i==mmm:
q+=1
else:
w+=1
y=w%2+q+e
p=max(q,e)-min(q,e)
u=p+w
if y<u... | 6
-1 1 1 0 0 -1
| 2
0 0 0 0 0 0
| 2
0 0 0 0 0 0
| true | 2,045 |
apps | verifiable_code | 532 | Solve the following coding problem using the programming language python:
Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the t... | ```python
now = "a"
ans = 0
S = input()
for s in S:
x = abs(ord(s) - ord(now))
ans += min(x, 26 - x)
now = s
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': 'zeus\n', 'output': '18\n'}, {'type': 'stdin_stdout', 'input': 'map\n', 'output': '35\n'}, {'type': 'stdin_stdout', 'input': 'ares\n', 'output': '34\n'}, {'type': 'stdin_stdout', 'input': 'l\n', 'output': '11\n'}, {'type': 'stdin_stdout', 'input': 'abcdefghijklmnopqrstu... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/731/A'} | vfc_11882 | ```python
now = "a"
ans = 0
S = input()
for s in S:
x = abs(ord(s) - ord(now))
ans += min(x, 26 - x)
now = s
print(ans)
``` | zeus
| 18
| 18
| true | 2,046 |
apps | verifiable_code | 533 | Solve the following coding problem using the programming language python:
The final match of the Berland Football Cup has been held recently. The referee has shown $n$ yellow cards throughout the match. At the beginning of the match there were $a_1$ players in the first team and $a_2$ players in the second team.
The ... | ```python
a1=int(input())
a2=int(input())
k1=int(input())
k2=int(input())
n=int(input())
ans1=0
ans2=0
if k1<k2:
ans1+=min(n//k1,a1)
ans1+=(n-ans1*k1)//k2
else :
ans1+=min(n//k2,a2)
ans1+=(n-ans1*k2)//k1
ans2=max(0,n-(k1-1)*a1-(k2-1)*a2)
print(ans2,ans1)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '2\n3\n5\n1\n8\n', 'output': '0 4\n'}, {'type': 'stdin_stdout', 'input': '3\n1\n6\n7\n25\n', 'output': '4 4\n'}, {'type': 'stdin_stdout', 'input': '6\n4\n9\n10\n89\n', 'output': '5 9\n'}, {'type': 'stdin_stdout', 'input': '10\n6\n5\n3\n56\n', 'output': '4 13\n'}, {'type... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1215/A'} | vfc_11886 | ```python
a1=int(input())
a2=int(input())
k1=int(input())
k2=int(input())
n=int(input())
ans1=0
ans2=0
if k1<k2:
ans1+=min(n//k1,a1)
ans1+=(n-ans1*k1)//k2
else :
ans1+=min(n//k2,a2)
ans1+=(n-ans1*k2)//k1
ans2=max(0,n-(k1-1)*a1-(k2-1)*a2)
print(ans2,ans1)
``` | 2
3
5
1
8
| 0 4
| 0 4
| true | 2,047 |
apps | verifiable_code | 534 | Solve the following coding problem using the programming language python:
During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of ... | ```python
import copy
def process( s ):
res = s[:]
for i in range( 1, len(s) ):
if s[i] == 'G' and s[i - 1] == 'B':
res[i], res[i - 1] = res[i - 1], res[i]
return res
fl = input().split()
n = int( fl[0] )
t = int( fl[1] )
s = input().split()[0]
S = []
for i in range(n):
S.append( s[i] )
for i in range(t):
S... | {'test_cases': [{'type': 'stdin_stdout', 'input': '5 1\nBGGBG\n', 'output': 'GBGGB\n'}, {'type': 'stdin_stdout', 'input': '5 2\nBGGBG\n', 'output': 'GGBGB\n'}, {'type': 'stdin_stdout', 'input': '4 1\nGGGB\n', 'output': 'GGGB\n'}, {'type': 'stdin_stdout', 'input': '2 1\nBB\n', 'output': 'BB\n'}, {'type': 'stdin_stdout',... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/266/B'} | vfc_11890 | ```python
import copy
def process( s ):
res = s[:]
for i in range( 1, len(s) ):
if s[i] == 'G' and s[i - 1] == 'B':
res[i], res[i - 1] = res[i - 1], res[i]
return res
fl = input().split()
n = int( fl[0] )
t = int( fl[1] )
s = input().split()[0]
S = []
for i in range(n):
S.append( s[i] )
for i in range(t):
S... | 5 1
BGGBG
| GBGGB
| GBGGB
| true | 2,048 |
apps | verifiable_code | 535 | Solve the following coding problem using the programming language python:
Makoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times:
Suppose the number currently written on the blackboard is $v$. He will randomly pick one of the divisors of $v$ (poss... | ```python
def primeFactor(N):
i = 2
ret = {}
n = N
mrFlg = 0
if n < 0:
ret[-1] = 1
n = -n
if n == 0:
ret[0] = 1
while i**2 <= n:
k = 0
while n % i == 0:
n //= i
k += 1
ret[i] = k
if i == 2:
i = 3
... | {'test_cases': [{'type': 'stdin_stdout', 'input': '6 1\n', 'output': '3\n'}, {'type': 'stdin_stdout', 'input': '6 2\n', 'output': '875000008\n'}, {'type': 'stdin_stdout', 'input': '60 5\n', 'output': '237178099\n'}, {'type': 'stdin_stdout', 'input': '2 4\n', 'output': '562500005\n'}, {'type': 'stdin_stdout', 'input': '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/1097/D'} | vfc_11894 | ```python
def primeFactor(N):
i = 2
ret = {}
n = N
mrFlg = 0
if n < 0:
ret[-1] = 1
n = -n
if n == 0:
ret[0] = 1
while i**2 <= n:
k = 0
while n % i == 0:
n //= i
k += 1
ret[i] = k
if i == 2:
i = 3
... | 6 1
| 3
| 3
| true | 2,049 |
apps | verifiable_code | 536 | Solve the following coding problem using the programming language python:
Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.
For each team Olympiad, V... | ```python
from sys import stdin, stdout
n, m = map(int, stdin.readline().split())
if m < n - 1: stdout.write('-1')
elif m == n - 1: stdout.write('0' + '10' * m)
elif m == n: stdout.write('10' * m)
elif m == n + 1: stdout.write('10' * n + '1')
else:
k = m - (n + 1)
if k > n + 1: stdout.write('-1')
elif k == ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '1 2\n', 'output': '101\n'}, {'type': 'stdin_stdout', 'input': '4 8\n', 'output': '110110110101\n'}, {'type': 'stdin_stdout', 'input': '4 10\n', 'output': '11011011011011\n'}, {'type': 'stdin_stdout', 'input': '1 5\n', 'output': '-1\n'}, {'type': 'stdin_stdout', 'input'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/401/C'} | vfc_11898 | ```python
from sys import stdin, stdout
n, m = map(int, stdin.readline().split())
if m < n - 1: stdout.write('-1')
elif m == n - 1: stdout.write('0' + '10' * m)
elif m == n: stdout.write('10' * m)
elif m == n + 1: stdout.write('10' * n + '1')
else:
k = m - (n + 1)
if k > n + 1: stdout.write('-1')
elif k == ... | 1 2
| 101
| 101 | true | 2,050 |
apps | verifiable_code | 537 | Solve the following coding problem using the programming language python:
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called ... | ```python
n, k = list(map(int, input().split()))
p = (n // 2) // (k + 1)
g = p * k
o = n - p - g
print(p, g, o)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '18 2\n', 'output': '3 6 9\n'}, {'type': 'stdin_stdout', 'input': '9 10\n', 'output': '0 0 9\n'}, {'type': 'stdin_stdout', 'input': '1000000000000 5\n', 'output': '83333333333 416666666665 500000000002\n'}, {'type': 'stdin_stdout', 'input': '1000000000000 499999999999\n... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/818/A'} | vfc_11902 | ```python
n, k = list(map(int, input().split()))
p = (n // 2) // (k + 1)
g = p * k
o = n - p - g
print(p, g, o)
``` | 18 2
| 3 6 9
| 3 6 9
| true | 2,051 |
apps | verifiable_code | 538 | Solve the following coding problem using the programming language python:
Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string.
String t is called a palindrome, if it reads the same from left to right and from right to left.
For example, numb... | ```python
n = input()
n = n.strip('0')
print('YES' if n == n[::-1] else 'NO')
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '131\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '320\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '2010200\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '1\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '1000000000\n', '... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/863/A'} | vfc_11906 | ```python
n = input()
n = n.strip('0')
print('YES' if n == n[::-1] else 'NO')
``` | 131
| YES
| YES
| true | 2,052 |
apps | verifiable_code | 539 | Solve the following coding problem using the programming language python:
Imp is in a magic forest, where xorangles grow (wut?)
[Image]
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count ... | ```python
n = int(input())
ans = 0
for i in range(1, n + 1):
for j in range(i, n + 1):
if 0 < i ^ j < n + 1 and i ^ j < i + j and i ^ j >= j:
ans += 1
print(ans)
``` | {'test_cases': [{'type': 'stdin_stdout', 'input': '6\n', 'output': '1\n'}, {'type': 'stdin_stdout', 'input': '10\n', 'output': '2\n'}, {'type': 'stdin_stdout', 'input': '3\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '4\n', 'output': '0\n'}, {'type': 'stdin_stdout', 'input': '5\n', 'output': '0\n'}, {'type':... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/922/B'} | vfc_11910 | ```python
n = int(input())
ans = 0
for i in range(1, n + 1):
for j in range(i, n + 1):
if 0 < i ^ j < n + 1 and i ^ j < i + j and i ^ j >= j:
ans += 1
print(ans)
``` | 6
| 1
| 1
| true | 2,053 |
apps | verifiable_code | 540 | Solve the following coding problem using the programming language python:
You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.
The level of the cave where you are... | ```python
def read_data():
n, m = map(int, input().split())
maze = [[False] * (m + 2)]
for i in range(n):
maze.append([False] + [c == '.' for c in input().rstrip()] + [False])
maze.append([False] * (m + 2))
r1, c1 = map(int, input().split())
r2, c2 = map(int, input().split())
return ... | {'test_cases': [{'type': 'stdin_stdout', 'input': '4 6\nX...XX\n...XX.\n.X..X.\n......\n1 6\n2 2\n', 'output': 'YES\n'}, {'type': 'stdin_stdout', 'input': '5 4\n.X..\n...X\nX.X.\n....\n.XX.\n5 3\n1 1\n', 'output': 'NO\n'}, {'type': 'stdin_stdout', 'input': '4 7\n..X.XX.\n.XX..X.\nX...X..\nX......\n2 2\n1 6\n', 'output'... | {'difficulty': 'interview', 'problem_url': 'https://codeforces.com/problemset/problem/540/C'} | vfc_11914 | ```python
def read_data():
n, m = map(int, input().split())
maze = [[False] * (m + 2)]
for i in range(n):
maze.append([False] + [c == '.' for c in input().rstrip()] + [False])
maze.append([False] * (m + 2))
r1, c1 = map(int, input().split())
r2, c2 = map(int, input().split())
return ... | 4 6
X...XX
...XX.
.X..X.
......
1 6
2 2
| YES
| YES
| true | 2,054 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.