problem_id
stringlengths
32
32
name
stringclasses
1 value
problem
stringlengths
200
14k
solutions
stringlengths
12
1.12M
test_cases
stringlengths
37
74M
difficulty
stringclasses
3 values
language
stringclasses
1 value
source
stringclasses
7 values
num_solutions
int64
12
1.12M
starter_code
stringlengths
0
956
b61f9bb719e59069f0aa3e4de68a0637
UNKNOWN
You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist. Divisor of n is any such natural number, that n can be divided by it without remainder. -----Input----- The first line contains two integers n and k (1 ≤ n ≤ 10^15, 1 ≤ k ≤ 10^9). -----Output----- If n has less ...
["import sys\nimport math\n\ndef factorization(n):\n res = []\n limit = math.ceil(math.sqrt(n))\n p = 2\n cnt = 0\n\n while n % p == 0:\n cnt += 1\n n //= p\n\n if cnt > 0:\n res.append((p, cnt))\n\n cnt = 0\n for p in range(3, limit + 1, 2):\n if n % p == 0:\n ...
{ "inputs": [ "4 2\n", "5 3\n", "12 5\n", "1 1\n", "866421317361600 26880\n", "866421317361600 26881\n", "1000000000000000 1000000000\n", "1000000000000000 100\n", "1 2\n", "4 3\n", "4 4\n", "9 3\n", "21 3\n", "67280421310721 1\n", "6 3\n", "3 3\n", ...
INTERVIEW
PYTHON3
CODEFORCES
1,957
7b100bece82464a803f3b263f2589f03
UNKNOWN
Absent-minded Masha got set of n cubes for her birthday. At each of 6 faces of each cube, there is exactly one digit from 0 to 9. Masha became interested what is the largest natural x such she can make using her new cubes all integers from 1 to x. To make a number Masha can rotate her cubes and put them in a row. Aft...
["n = int(input())\na = sorted([list(map(int, input().split())) for i in range(n)])\n\nimport itertools\nfor x in range(1,10**n):\n good = False\n s = str(x)\n for p in itertools.permutations(a, len(s)):\n good |= all([int(s[i]) in v for i, v in enumerate(p)])\n if not good:\n print(x-1)\n return\n \npr...
{ "inputs": [ "3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n", "3\n0 1 3 5 6 8\n1 2 4 5 7 8\n2 3 4 6 7 9\n", "3\n0 1 2 3 4 5\n0 1 2 3 4 5\n0 1 2 3 4 5\n", "3\n1 2 3 7 8 9\n9 8 7 1 2 3\n7 9 2 3 1 8\n", "1\n5 2 2 5 6 7\n", "1\n7 6 5 8 9 0\n", "1\n2 5 9 6 7 9\n", "1\n6 3 1 9 4 9\n", "1\n...
INTERVIEW
PYTHON3
CODEFORCES
21,641
4390dbd27d9978fc5315b54909af2347
UNKNOWN
For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n. For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it ends with 4 or more zeros and is divisible by 375. Write a program...
["def main():\n\tn, k = map(int, input().split())\n\tnum_2 = 0\n\tnum_5 = 0\n\tx = n\n\twhile (x % 2 == 0):\n\t\tnum_2 += 1\n\t\tx //= 2\n\t\t\n\twhile (x % 5 == 0):\n\t\tnum_5 += 1\n\t\tx //= 5\n\tnum_2 = k - min(num_2, k)\n\tnum_5 = k - min(num_5, k)\n\tprint(n * 5 ** num_5 * 2 ** num_2)\n\n\nmain()", "a, b = map(int...
{ "inputs": [ "375 4\n", "10000 1\n", "38101 0\n", "123456789 8\n", "1 0\n", "2 0\n", "100 0\n", "1000000000 0\n", "160 2\n", "3 0\n", "10 0\n", "1 1\n", "2 1\n", "3 1\n", "4 1\n", "5 1\n", "6 1\n", "7 1\n", "8 1\n", "9 1\n", "10 1\n"...
INTERVIEW
PYTHON3
CODEFORCES
5,397
1cd0586ba8e709ea72ff04b991ee840e
UNKNOWN
You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$. You may perform some operations with matrix $B$. During each operation, you choose any submatrix of $B$ having size $2 \times 2$, and replace ev...
["n, m = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(n)]\nB = [[0] * m for _ in range(n)]\nans = []\nfor i in range(n - 1):\n for j in range(m - 1):\n if A[i][j] == 1 and A[i + 1][j] == 1 and A[i][j + 1] == 1 and A[i + 1][j + 1] == 1:\n B[i][j] = 1\n B[...
{ "inputs": [ "3 3\n1 1 1\n1 1 1\n0 1 1\n", "3 3\n1 0 1\n1 0 1\n0 0 0\n", "3 2\n0 0\n0 0\n0 0\n", "2 50\n0 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1\n0 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 ...
INTERVIEW
PYTHON3
CODEFORCES
15,665
b602cc073eea14ec672ab0b44fc5e5e7
UNKNOWN
The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, then one individual kills the other one: a rock kills scissors, scissors kill paper...
["r, s, p = list(map(int, input().split()))\ndp = [[[0] * (p+1) for _ in range(s+1)] for _ in range(r+1)]\ndp[r][s][p] = 1\ndef nCk(n, k):\n if n <= k:\n return 1\n res = 1\n for i in range(k):\n res *= n-i\n for i in range(k):\n res //= (i+1)\n return res\n\nC = [nCk(i, 2) for i in ...
{ "inputs": [ "2 2 2\n", "2 1 2\n", "1 1 3\n", "3 2 1\n", "100 100 100\n", "1 100 100\n", "100 1 100\n", "100 100 1\n", "1 100 99\n", "99 1 100\n", "100 99 1\n", "100 1 99\n", "1 99 100\n", "99 100 1\n", "1 1 1\n", "100 100 2\n", "100 2 100\n", "...
INTERVIEW
PYTHON3
CODEFORCES
4,090
00e67300c715d714e0e66d67152ac367
UNKNOWN
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sleeps during the day and stay awake from minute l_1 to minute r_1 inclusive. Also, during the minute k she prinks and is unavailable for Filya. Filya works a lot and he plans to visi...
["read = lambda: list(map(int, input().split()))\nl1, r1, l2, r2, k = read()\nR = min(r1, r2)\nL = max(l1, l2)\nans = max(R - L + 1, 0)\nif L <= k <= R: ans = max(ans - 1, 0)\nprint(ans)\n", "l1,r1,l2,r2,k = (int(i) for i in input().split())\nl = max(l1,l2)\nr = min(r1,r2)\nif r < l:\n print(0)\nelse:\n ans = r-l...
{ "inputs": [ "1 10 9 20 1\n", "1 100 50 200 75\n", "6 6 5 8 9\n", "1 1000000000 1 1000000000 1\n", "5 100 8 8 8\n", "1 1000000000000000000 2 99999999999999999 1000000000\n", "1 1 1 1 1\n", "1 2 3 4 5\n", "1 1000000000 2 999999999 3141592\n", "24648817341102 41165114064236 8804...
INTERVIEW
PYTHON3
CODEFORCES
7,093
2908d162bf3b19f29eb9ead6de2c08f2
UNKNOWN
There is a grass field that stretches infinitely. In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0). There are also N north-south lines and M east-west lines drawn o...
["#\u5199\u7d4c\n#https://atcoder.jp/contests/abc168/submissions/14421546\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nfrom bisect import bisect_left, bisect_right\nINF = 10 **18\n\ndef resolve():\n n, m = map(int, input().split())\n a = [list(map(int, input().split())) for i in range(n)...
{"inputs": ["5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n", "6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n", "586 535\n469954409 885825535 -760706611\n-285407458 697006880 -664406918\n-406367558 -276502062 -449723222\n-533951988 -427873157 -98748055\n3057700...
INTERVIEW
PYTHON3
ATCODER.JP
31,828
a7b6ed51ea67280e44f6c0247e1c2b5e
UNKNOWN
You are given a sequence a_1, a_2, ..., a_{n} of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment a_{i} lies within segment a_{j}. Segment [l_1, r_1] lies within segment [l_2, r_2] iff l_1 ≥ l_2 and r_1 ≤ r_2. Print indices i and j. If there are multip...
["n = int(input())\na = []\nfor i in range(1, n + 1):\n l, r = list(map(int, input().split()))\n a.append([l, -r, i])\na.sort()\nhh = a[0][1]\nwahh = max(-1, a[0][2])\nfor i in range(1, n):\n if a[i][1] >= hh:\n print(a[i][2], wahh)\n return\n else:\n hh = a[i][1]\n wahh = a[i][2...
{ "inputs": [ "5\n1 10\n2 9\n3 9\n2 3\n2 9\n", "3\n1 5\n2 6\n6 20\n", "1\n1 1000000000\n", "2\n1 1000000000\n1 1000000000\n", "2\n1 1000000000\n500000000 500000000\n", "2\n1 10\n2 10\n", "2\n10 20\n10 11\n", "3\n1 10\n10 20\n9 11\n", "3\n1 1\n2 3\n2 2\n", "4\n1 10\n2 11\n3 1000...
INTERVIEW
PYTHON3
CODEFORCES
5,766
0d30251ac6a233a20cfba8779a3c0423
UNKNOWN
The process of mammoth's genome decoding in Berland comes to its end! One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is...
["\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn=int(input())\nif n%4: print(\"===\")\nelse:\n t=input().strip()\n a=[n//4]*4\n for i in t:\n if i=='A': a[0]-=1\n elif i=='C': a[1]-=1\n elif i=='G': a[2]-=1\n elif i=='T': a[3]-=1\n if min(a)<0: print(\...
{ "inputs": [ "8\nAG?C??CT\n", "4\nAGCT\n", "6\n????G?\n", "4\nAA??\n", "4\n????\n", "252\n???????GCG??T??TT?????T?C???C?CCG???GA???????AC??A???AAC?C?CC??CCC??A??TA?CCC??T???C??CA???CA??G????C?C?C????C??C??A???C?T????C??ACGC??CC?A?????A??CC?C??C?CCG?C??C??A??CG?A?????A?CT???CC????CCC?CATC?G???...
INTERVIEW
PYTHON3
CODEFORCES
9,999
2781956f25c16befdf5c8269d47e3b12
UNKNOWN
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have won the game by making...
["def chk(l):\n\tfor i in range(4):\n\t\tfor j in range(2):\n\t\t\tif l[i][j]==l[i][j+1]==l[i][j+2]=='x':\n\t\t\t\treturn True\n\tfor i in range(2):\n\t\tfor j in range(4):\n\t\t\tif l[i][j]==l[i+1][j]==l[i+2][j]=='x':\n\t\t\t\treturn True\n\tfor i in range(2):\n\t\tfor j in range(2):\n\t\t\tif l[i][j]==l[i+1][j+1]==l[...
{ "inputs": [ "xx..\n.oo.\nx...\noox.\n", "x.ox\nox..\nx.o.\noo.x\n", "x..x\n..oo\no...\nx.xo\n", "o.x.\no...\n.x..\nooxx\n", ".xox\no.x.\nx.o.\n..o.\n", "o.oo\n.x.o\nx.x.\n.x..\n", ".xx.\n.xoo\n.oox\n....\n", "xxox\no.x.\nx.oo\nxo.o\n", ".xox\n.x..\nxoo.\noox.\n", ".oxx\nx...\...
INTERVIEW
PYTHON3
CODEFORCES
27,593
79d464fd5b64b3e51b30c8d5a1fb2f90
UNKNOWN
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part. It is not always possible, so Vasya will move some element be...
["def solve(n,a):\n tot=0\n for i in range(n):\n tot+=a[i]\n diffs = [] #alla suffix - prefix diffs[i]=prefix-suffix om delas innan element i\n diffs.append(-tot)\n for i in range(n):\n tot-=2*a[i]\n diffs.append(-tot)\n if tot==0:\n return (\"YES\")\n for i in r...
{ "inputs": [ "3\n1 3 2\n", "5\n1 2 3 4 5\n", "5\n2 2 3 4 5\n", "5\n72 32 17 46 82\n", "6\n26 10 70 11 69 57\n", "7\n4 7 10 7 5 5 1\n", "8\n9 5 5 10 4 9 5 8\n", "10\n9 6 8 5 5 2 8 9 2 2\n", "15\n4 8 10 3 1 4 5 9 3 2 1 7 7 3 8\n", "20\n71 83 54 6 10 64 91 98 94 49 65 68 14 39 91...
INTERVIEW
PYTHON3
CODEFORCES
16,276
6e694b276842ec81f3fe325c55f28cd2
UNKNOWN
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed. To get rid of the oddity and recover her weight, a special integer sequence is needed. Hitagi's sequence has been broken for a long t...
["import sys\n\nn, k = list(map(int, input().split()))\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nb.sort(reverse=True)\n\nres = []\ncur_b = 0\nfor a_i in a:\n if a_i != 0:\n res.append(a_i)\n else:\n res.append(b[cur_b])\n cur_b += 1\n\nif res != list(sor...
{ "inputs": [ "4 2\n11 0 0 14\n5 4\n", "6 1\n2 3 0 8 9 10\n5\n", "4 1\n8 94 0 4\n89\n", "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\n", "40 1\n23 26 27 28 31 35 38 40 43 50 52 53 56 57 59 61 65 73 75 76 79 0 82 84 85 86 88 93 99 101 103 104 105 106 110 111 112 117 119 120\n80\n", "100 1\n99 95 22 110 4...
INTERVIEW
PYTHON3
CODEFORCES
8,078
b1142f1a3d2351decbcca67ab2fd597f
UNKNOWN
The Duck song For simplicity, we'll assume that there are only three types of grapes: green grapes, purple grapes and black grapes. Andrew, Dmitry and Michal are all grapes' lovers, however their preferences of grapes are different. To make all of them happy, the following should happen: Andrew, Dmitry and Michal sho...
["x,y,z = list(map(int,input().split()))\na,b,c = list(map(int,input().split()))\nif a < x:\n print(\"NO\")\n return\nx -= a\ny += x\nif b < y:\n print(\"NO\")\n return\ny -= b\nz += y\nif c < z:\n print(\"NO\")\n return\nprint(\"YES\") \n", "x, y, z= map(int, input().split())\na, b, c = map(int,in...
{ "inputs": [ "1 6 2\n4 3 3\n", "5 1 1\n4 3 2\n", "1 1 100000\n4 2 99995\n", "1 2 3\n3 2 1\n", "1 8 4\n3 1 9\n", "6 1 2\n4 9 6\n", "100000 100000 100000\n100000 100000 100000\n", "3 2 1\n1 2 3\n", "99999 99998 99997\n99997 99998 99999\n", "1 7 9\n4 5 7\n", "99999 100000 100...
INTERVIEW
PYTHON3
CODEFORCES
7,399
ee71648bd27c13f90b539c2dfa9caa55
UNKNOWN
Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant. Shop, where Noora is working, has a plan on the following n days. For each day sales manager...
["n, f = list(map(int, input().split(' ')))\nres = 0\nwow = []\nfor a0 in range(n):\n k, l = list(map(int, input().split(' ')))\n res += min(k, l)\n wow.append(min(2*k, l) - min(k, l))\nwow = sorted(wow)\ni = len(wow)-1\nfor a0 in range(f):\n res += wow[i]\n i -= 1\nprint(res)\n", "from sys import stdin,...
{ "inputs": [ "4 2\n2 1\n3 5\n2 3\n1 5\n", "4 1\n0 2\n0 3\n3 5\n0 6\n", "1 1\n5 8\n", "2 1\n8 12\n6 11\n", "2 1\n6 7\n5 7\n", "2 1\n5 7\n6 7\n", "2 1\n7 8\n3 6\n", "2 1\n9 10\n5 8\n", "2 1\n3 6\n7 8\n", "1 0\n10 20\n", "2 1\n99 100\n3 6\n", "4 2\n2 10\n3 10\n9 9\n5 10\n...
INTERVIEW
PYTHON3
CODEFORCES
11,576
9bf27735af95c358a4aa530ebd223467
UNKNOWN
It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bessie's limelight, has f...
["# You lost the game.\nn,k = map(int, input().split())\nr = 0\nfor i in range(min(k,n//2)):\n r += (n-2*i-1) + (n-2*i-2)\nprint(r)", "def main():\n n, k = map(int, input().split())\n if k > (n // 2):\n k = n // 2\n ans = 0\n for i in range(k):\n ans += 2 * (n - 2 * i - 2) + 1\n print(an...
{ "inputs": [ "5 2\n", "1 10\n", "100000 2\n", "1 1\n", "8 3\n", "7 1\n", "100000 40000\n", "1 1000\n", "100 45\n", "9 2\n", "456 78\n", "100000 50000\n", "100000 50001\n", "100000 50002\n", "100000 50003\n", "100000 49998\n", "100000 49997\n", "...
INTERVIEW
PYTHON3
CODEFORCES
4,396
addd438636ba731e5388b4c3466421ba
UNKNOWN
Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as many coins as others. All coins given to Ivan must be different. Not less tha...
["n, m, k, l = map(int, input().split())\ncnt = (k + l + m - 1) // m\nif cnt * m > n:\n print(-1)\nelse:\n print(cnt)", "n, m, k, l = map(int, input().split())\nneed = k + l\nif need % m == 0 and need <= n:\n print(need // m)\nelse:\n x = need // m + 1\n if x * m > n:\n print(-1)\n else:\n ...
{ "inputs": [ "20 15 2 3\n", "10 11 2 4\n", "2 1 1 1\n", "10 2 9 7\n", "530897800469409942 582203276934671957 137373076313041391 377446491430894140\n", "1000000000000000000 1 1 1000000000000000000\n", "48295947839584738 12 49503958 47108947578469711\n", "100 20 98 2\n", "1000000000...
INTERVIEW
PYTHON3
CODEFORCES
5,015
d089f0fa16a5f9ea913980b99aa975f3
UNKNOWN
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square. You are to determine the minimum possible ...
["h, w = map(int, input().split())\nx0, y0, x1, y1, c = 1000, 1000, -1, -1, 0\nfor i in range(h):\n row = str(input())\n for j in range(w):\n if row[j] == 'B':\n x0, y0, x1, y1, c = min(x0, i), min(y0, j), max(x1, i), max(y1, j), c + 1\nln = max(x1 - x0 + 1, y1 - y0 + 1)\nif ln > min(h, w):\n print(-1)\nelif...
{ "inputs": [ "5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW\n", "1 2\nBB\n", "3 3\nWWW\nWWW\nWWW\n", "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\n...
INTERVIEW
PYTHON3
CODEFORCES
17,981
9f0fe7315ac058ebe54581bf1832e328
UNKNOWN
There is a beautiful garden of stones in Innopolis. Its most beautiful place is the $n$ piles with stones numbered from $1$ to $n$. EJOI participants have visited this place twice. When they first visited it, the number of stones in piles was $x_1, x_2, \ldots, x_n$, correspondingly. One of the participants wrote d...
["n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nc = sum(a)\nd = sum(b)\n\nif c >= d:\n print('Yes')\nelse:\n print('No')", "import sys, math, random\nfrom fractions import gcd\nfrom itertools import permutations\n\ndebug = 0\nif debug:\n f = open(\"input.txt\", \...
{ "inputs": [ "5\n1 2 3 4 5\n2 1 4 3 5\n", "5\n1 1 1 1 1\n1 0 1 0 1\n", "3\n2 3 9\n1 7 9\n", "40\n361 372 139 808 561 460 421 961 727 719 130 235 320 470 432 759 317 886 624 666 917 133 736 710 462 424 541 118 228 216 612 339 800 557 291 128 801 9 0 318\n364 689 60 773 340 571 627 932 581 856 131 153 ...
INTERVIEW
PYTHON3
CODEFORCES
3,756
66dbf8fc72d35e1fb0bc56adc4830eca
UNKNOWN
Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are $n$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different ...
["# Contest: Codeforces Round #593 (Div. 2) (https://codeforces.com/contest/1236)\n# Problem: B: Alice and the List of Presents (https://codeforces.com/contest/1236/problem/B)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\nM = 10**9 + 7\nn, m = rints()\nprint(...
{ "inputs": [ "1 3\n", "2 2\n", "1000000000 1000000000\n", "489132389 96\n", "462817723 208\n", "10 415749054\n", "185182737 683516583\n", "1 1\n", "67 445057511\n", "53 710974288\n", "766313215 146\n", "483378560 249\n", "294440070 297\n", "22 346212760\n", ...
INTERVIEW
PYTHON3
CODEFORCES
5,032
112f2894770408301643edde9c9306d0
UNKNOWN
You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal. The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token. As input/output can reach huge...
["a = input()\nb = input()\nn, m = len(a), len(b)\nif n > m: b = '0' * (n - m) + b\nelse: a = '0' * (m - n) + a\ni = 0\nwhile i < max(n, m) and a[i] == b[i]:\n i += 1\nprint('=' if i == max(n, m) else '<' if int(a[i]) < int(b[i]) else '>')\n", "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# ...
{ "inputs": [ "9\n10\n", "11\n10\n", "00012345\n12345\n", "0123\n9\n", "0123\n111\n", "9\n9\n", "0\n0000\n", "1213121\n1213121\n", "8631749422082281871941140403034638286979613893271246118706788645620907151504874585597378422393911017\n146017563370120161528504797580620647099370814387...
INTERVIEW
PYTHON3
CODEFORCES
11,755
795e065323db02e7935568684ae2e51b
UNKNOWN
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for a rubles, a pack of two copybooks for b rubles, and a pack of t...
["n, a, b, c = map(int, input().split())\nres = 10 ** 100\nfor i in range(50):\n for j in range(50):\n for k in range(50):\n if (n + i + 2 * j + 3 * k) % 4 == 0:\n res = min(res, a * i + b * j + c * k)\nprint(res)", "n, a, b, c = list(map(int, input().split()))\na = [0, a, b, c]\nfor...
{ "inputs": [ "1 1 3 4\n", "6 2 1 1\n", "4 4 4 4\n", "999999999 1000000000 1000000000 1000000000\n", "1016 3 2 1\n", "17 100 100 1\n", "17 2 3 100\n", "18 1 3 3\n", "19 1 1 1\n", "999999997 999999990 1000000000 1000000000\n", "999999998 1000000000 999999990 1000000000\n", ...
INTERVIEW
PYTHON3
CODEFORCES
8,425
625fedd35ed6d245cc5fc14fc6a76325
UNKNOWN
You are given a directed graph consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. Can you make this graph acyclic by removing at most one edge from it? A directed graph is called acyclic iff it doesn't contain ...
["n,m = map(int, input().split())\ng = [[] for i in range(n)]\nfor _ in range(m):\n u,v = map(int, input().split())\n g[u-1].append(v-1)\n\nst = []\nvis = [0 for _ in range(n)]\nnxt = [0 for _ in range(n)]\nes = set()\ncycle=False\nfor i in range(n):\n if cycle:\n break\n if vis[i] != 0:\n con...
{ "inputs": [ "3 4\n1 2\n2 3\n3 2\n3 1\n", "5 6\n1 2\n2 3\n3 2\n3 1\n2 1\n4 5\n", "2 2\n1 2\n2 1\n", "7 7\n1 3\n3 6\n3 7\n5 3\n6 2\n6 7\n7 2\n", "500 50\n396 340\n47 341\n422 140\n492 209\n263 248\n461 300\n124 495\n33 6\n93 384\n389 182\n130 297\n217 329\n131 136\n355 94\n388 275\n115 368\n279 46...
INTERVIEW
PYTHON3
CODEFORCES
13,091
07d91356c34bd2f27eef75123e55542e
UNKNOWN
The mayor of the Central Town wants to modernize Central Street, represented in this problem by the $(Ox)$ axis. On this street, there are $n$ antennas, numbered from $1$ to $n$. The $i$-th antenna lies on the position $x_i$ and has an initial scope of $s_i$: it covers all integer positions inside the interval $[x_i -...
["import sys\ninput = sys.stdin.readline\n\nn,m=list(map(int,input().split()))\n\nA=[]\nCOVERED=[0]*(m+1)\n\nfor i in range(n):\n x,y=list(map(int,input().split()))\n A.append((x-y,x+y))\n\n for j in range(max(0,x-y),min(m+1,x+y+1)):\n COVERED[j]=1\n\nif min(COVERED[1:])==1:\n print(0)\n return\n\...
{ "inputs": [ "3 595\n43 2\n300 4\n554 10\n", "1 1\n1 1\n", "2 50\n20 0\n3 1\n", "5 240\n13 0\n50 25\n60 5\n155 70\n165 70\n", "1 100000\n99998 0\n", "1 100000\n100000 0\n", "1 100000\n1 0\n", "2 100000\n1 0\n100000 0\n", "7 300\n50 8\n49 6\n246 1\n123 3\n227 2\n183 5\n158 7\n", ...
INTERVIEW
PYTHON3
CODEFORCES
15,479
012b890cd0d58cf6c1a75f8beb5a0fca
UNKNOWN
You have a set of items, each having some integer weight not greater than $8$. You denote that a subset of items is good if total weight of items in the subset does not exceed $W$. You want to calculate the maximum possible weight of a good subset of items. Note that you have to consider the empty set and the original...
["import time\nimport random\nW = int(input())\nM = [int(a) for a in input().split()]\nA = [0] * 8\nsTime = time.time()\n\ns = 0\nmi = 10**20\nfor i in range(8):\n if s + M[i]*(i+1) <= W:\n s += M[i]*(i+1)\n A[i] = M[i]\n else:\n t = (W-s)//(i+1)\n s += t*(i+1)\n A[i] += t\n ...
{ "inputs": [ "10\n1 2 3 4 5 6 7 8\n", "0\n0 0 0 0 0 0 0 0\n", "3\n0 4 1 0 0 9 8 3\n", "27\n0 0 0 0 0 5 0 0\n", "178\n731 0 0 0 0 0 0 0\n", "9890292762705840\n0 0 0 0 7807819738278974 0 0 0\n", "11994176272990019\n0 6395394930893349 0 0 0 0 0 0\n", "7517891175237043\n0 0 0 0 0 0 0 1985...
INTERVIEW
PYTHON3
CODEFORCES
1,432
b4a2e464111d8ad95975db4167a69ab3
UNKNOWN
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
["3\n# Copyright (C) 2017 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY...
{ "inputs": [ "4 12\n20 30 70 90\n", "4 3\n10000 1000 100 10\n", "4 3\n10 100 1000 10000\n", "5 787787787\n123456789 234567890 345678901 456789012 987654321\n", "30 792520535\n528145579 682850171 79476920 178914057 180053263 538638086 433143781 299775597 723428544 177615223 959893339 639448861 506...
INTERVIEW
PYTHON3
CODEFORCES
15,679
bd268c302ed0b489924113ac78a2461c
UNKNOWN
Someone gave Alyona an array containing n positive integers a_1, a_2, ..., a_{n}. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may...
["x=int(input())\nl=list(map(int, input().split(' ')))\nl.sort()\na=1\nfor i in l:\n if i>=a:\n a+=1\nprint(a)\n", "n = int(input())\nA = [int(x) for x in input().split()]\nA.sort()\nmex = 1\nfor i in range(n):\n if A[i] >= mex:\n A[i] = mex\n mex += 1\nprint(mex)\n\n\n", "n = int(input())\nc...
{ "inputs": [ "5\n1 3 3 3 6\n", "2\n2 1\n", "1\n1\n", "1\n1000000000\n", "1\n2\n", "2\n1 1\n", "2\n1 3\n", "2\n2 2\n", "2\n2 3\n", "2\n3 3\n", "3\n1 1 1\n", "3\n2 1 1\n", "3\n3 1 1\n", "3\n1 1 4\n", "3\n2 1 2\n", "3\n3 2 1\n", "3\n2 4 1\n", "3\n3...
INTERVIEW
PYTHON3
CODEFORCES
5,114
557cf73f97851f3e589374f3748d38f0
UNKNOWN
Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ is lucky since it can be divided into three segments $350$, $17$ and $8$: $...
["n = int(input())\na = list(map(int, list(input())))\nfor i in range(n - 1):\n sm = sum(a[:i + 1])\n tn = 0\n res = True\n has = False\n for j in range(i + 1, n):\n tn += a[j]\n if (tn == sm):\n tn = 0\n has = True\n elif tn > sm:\n res = False\n ...
{ "inputs": [ "5\n73452\n", "4\n1248\n", "2\n00\n", "3\n555\n", "8\n00020200\n", "4\n7435\n", "99\n999999999999999999999999999999999999999999999918888888888888888888888888888888888888888888888888887\n", "5\n11980\n", "4\n2680\n", "15\n333703919182090\n", "8\n54174760\n", ...
INTERVIEW
PYTHON3
CODEFORCES
11,619
3095eea13de1e2905c8dcb270e3ced9f
UNKNOWN
Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network. Bu...
["s = input()\nq = set()\nfor i in range(0, len(s)):\n q.add(s[i])\nprint(\"IGNORE HIM!\" if len(q) % 2 == 1 else \"CHAT WITH HER!\")", "print(\"IGNORE HIM!\" if len(set(input())) % 2 == 1 else \"CHAT WITH HER!\")", "print(\"CHAT WITH HER!\" if len(set(input())) % 2 == 0 else \"IGNORE HIM!\")", "print('CHAT WITH HER...
{ "inputs": [ "wjmzbmr\n", "xiaodao\n", "sevenkplus\n", "pezu\n", "wnemlgppy\n", "zcinitufxoldnokacdvtmdohsfdjepyfioyvclhmujiqwvmudbfjzxjfqqxjmoiyxrfsbvseawwoyynn\n", "qsxxuoynwtebujwpxwpajitiwxaxwgbcylxneqiebzfphugwkftpaikixmumkhfbjiswmvzbtiyifbx\n", "qwbdfzfylckctudyjlyrtmvbidfatdoqf...
INTERVIEW
PYTHON3
CODEFORCES
3,841
dcc2c29bcd5177b2851c69dc86b201af
UNKNOWN
This morning, Roman woke up and opened the browser with $n$ opened tabs numbered from $1$ to $n$. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many tabs open so he wants to close some of them. He decided to accomplis...
["n, k = list(map(int, input().split()))\n\nt = list(map(int, input().split()))\n\nd = [0 for _ in range(n)]\n\nfor _ in range(n):\n for i in range(n):\n if i % k != _ % k:\n d[_] += t[i]\n\nprint(max(abs(d[_]) for _ in range(n)))\n", "n,k = list(map(int,input().split()))\na = list(map(int,input().split()))\na...
{ "inputs": [ "4 2\n1 1 -1 1\n", "14 3\n-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1\n", "4 2\n1 1 1 -1\n", "4 2\n-1 1 -1 -1\n", "3 2\n1 1 -1\n", "20 2\n-1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1\n", "20 19\n-1 -1 1 1 -1 1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 -1 1\n", "20 7\n-1 1 1 1 1 -1 1 1...
INTERVIEW
PYTHON3
CODEFORCES
9,917
e966e0afc248ab398d4ca8343cbb4593
UNKNOWN
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met anoth...
["import sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,a,b=map(int,input().split())\n\nif a<b: a,b=b,a\n\nif b==0:\n # 1 01 001 0001 ... is optimal, plus a long series of 0's\n print((n-1)*a)\nelse:\n # pascal's triangle thing\n pascal=[[1]*20005]\n for i in range(20004):\n new...
{ "inputs": [ "4 1 2\n", "2 1 5\n", "3 1 1\n", "5 5 5\n", "4 0 0\n", "6 0 6\n", "6 6 0\n", "2 1 2\n", "100000000 1 0\n", "2 0 0\n", "2 100000000 100000000\n", "2 100000000 0\n", "2 0 100000000\n", "100000000 0 0\n", "100000000 100000000 100000000\n", "10...
INTERVIEW
PYTHON3
CODEFORCES
6,120
d4b13281c4dc17bc63763516b099b8bb
UNKNOWN
The circle line of the Roflanpolis subway has $n$ stations. There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(x+1)$ if $x < n$ and $1$ otherwise). The second route visits stations in or...
["n, a, x, b, y = map(int, input().split())\n\nwhile a != x and b != y and a != b:\n\tif a == b:\n\t\tbreak\n\n\ta = a % n + 1\n\tb = b - 1 if b - 1 else n\n\nprint(\"YNEOS\"[a != b::2])", "n, a, x, b, y = list(map(int, input().split()))\na -= 1\nx -= 1\nb -= 1\ny -= 1\n\ndaniel = []\nvlad = []\ni = a\nwhile i != x:\n ...
{ "inputs": [ "5 1 4 3 2\n", "10 2 1 9 10\n", "4 3 4 2 1\n", "100 2 97 84 89\n", "100 43 55 42 15\n", "47 15 45 28 38\n", "17 14 2 12 10\n", "82 9 11 15 79\n", "53 10 34 1 48\n", "55 55 27 45 50\n", "33 15 6 1 3\n", "45 26 22 39 10\n", "5 3 2 4 1\n", "20 19 10 1...
INTERVIEW
PYTHON3
CODEFORCES
10,921
43d375c3ea27bd78b865ec5b6f279a58
UNKNOWN
Unlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers. For example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 2^0 + 3^1, 17 = 2^3 + 3^2 = 2^4 + 3^0) and year 18 isn't unlucky as there is no such representation...
["x,y,l,r=list(map(int,input().split()))\nb=set()\na=0\nb.add(l-1)\nb.add(r+1)\nfor i in range(100):\n xx=x**i\n if xx>r: break\n for j in range(100):\n rr=xx+(y**j)\n if rr>r: break\n if rr>=l:\n b.add(rr)\nb=sorted(list(b))\nfor i in range(1,len(b)):\n a=max(a,b[i]-b[i-1]-1)\nprint(a)\n", "x, y, l, ...
{ "inputs": [ "2 3 1 10\n", "3 5 10 22\n", "2 3 3 5\n", "2 2 1 10\n", "2 2 1 1000000\n", "2 2 1 1000000000000000000\n", "2 3 1 1000000\n", "2 3 1 1000000000000000000\n", "12345 54321 1 1000000\n", "54321 12345 1 1000000000000000000\n", "2 3 100000000 1000000000000\n", "...
INTERVIEW
PYTHON3
CODEFORCES
11,953
337f97df1f309eb5e74e3fcd0cbcb75f
UNKNOWN
Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). For example, if n = 6 then Funt has to pay 3 burles, while for n = 25 he ne...
["def is_izi(k):\n i = 2\n while (i * i <= k):\n if (k % i == 0):\n return 0\n i += 1\n return 1\nn = int(input())\nif (is_izi(n)):\n print(1)\nelif n % 2 == 0:\n print(2)\nelif n % 2 == 1:\n if (is_izi(n - 2)):\n print(2)\n else:\n print(3)", "def rwh_primes(...
{ "inputs": [ "4\n", "27\n", "3\n", "5\n", "10\n", "2000000000\n", "26\n", "7\n", "2\n", "11\n", "1000000007\n", "1000000009\n", "1999999999\n", "1000000011\n", "101\n", "103\n", "1001\n", "1003\n", "10001\n", "10003\n", "129401294\n"...
INTERVIEW
PYTHON3
CODEFORCES
11,872
2698e8de3246692dbda250043301e8ba
UNKNOWN
Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are thr...
["s = input()\nst = {'a', 'e', 'i', 'o', 'u', ' '}\nres = \"\"\n\ndef check(s):\n\tif (len(s) < 3):\n\t\treturn True\n\tif (s[-1] not in st and s[-2] not in st and s[-3] not in st) and (s[-1] != s[-2] or s[-2] != s[-3] or s[-1] != s[-3]):\n\t\treturn False\n\treturn True\n\nfor item in s:\n\tif not check(res + item):\n...
{ "inputs": [ "hellno\n", "abacaba\n", "asdfasdf\n", "ooo\n", "moyaoborona\n", "jxegxxx\n", "orfyaenanabckumulsboloyhljhacdgcmnooxvxrtuhcslxgslfpnfnyejbxqisxjyoyvcvuddboxkqgbogkfz\n", "zxdgmhsjotvajkwshjpvzcuwehpeyfhakhtlvuoftkgdmvpafmxcliqvrztloocziqdkexhzcbdgxaoyvte\n", "niblehmw...
INTERVIEW
PYTHON3
CODEFORCES
11,946
59dece458ab6c94eccf72317a5bd827a
UNKNOWN
Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of two types that can faster the process of preparing potions. Spells of this...
["n, m, k = list(map(int, input().split()))\nx, s = list(map(int, input().split()))\nt = list(map(int, input().split()))\npr = list(map(int, input().split()))\nt2 = list(map(int, input().split()))\npr2 = list(map(int, input().split()))\nmass1 = []\nminans = 10**20\nfor i in range(m):\n mass1.append((pr[i], t[i]))\nm...
{ "inputs": [ "20 3 2\n10 99\n2 4 3\n20 10 40\n4 15\n10 80\n", "20 3 2\n10 99\n2 4 3\n200 100 400\n4 15\n100 800\n", "10 3 3\n10 33\n1 7 6\n17 25 68\n2 9 10\n78 89 125\n", "94 1 1\n26 324\n7\n236\n77\n5\n", "3 4 5\n5 9\n1 2 1 1\n3 5 4 1\n1 1 1 1 3\n1 2 3 4 5\n", "1 4 2\n3 10\n2 1 1 1\n1 5 3 5\...
INTERVIEW
PYTHON3
CODEFORCES
18,448
56ab5a9109e45ffcf07a0a53ff24afc7
UNKNOWN
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order. By solvin...
["n, k, m = list(map(int, input().split()))\nl = list(map(int, input().split()))\nl.sort()\ns = sum(l)\n\nans = 0\nfor i in range(n + 1):\n mi = m - s * i\n if mi < 0:\n break\n cnt = (k + 1) * i\n for j in range(k):\n x = min(mi // l[j], n - i)\n cnt += x\n mi -= l[j] * x\n a...
{ "inputs": [ "3 4 11\n1 2 3 4\n", "5 5 10\n1 2 4 8 16\n", "1 1 0\n2\n", "1 1 1\n1\n", "2 1 0\n2\n", "2 2 2\n2 3\n", "4 2 15\n1 4\n", "24 42 126319796\n318996 157487 174813 189765 259136 406743 138997 377982 244813 16862 95438 346702 454882 274633 67361 387756 61951 448901 427272 28884...
INTERVIEW
PYTHON3
CODEFORCES
13,183
79c41b5f0632f9ed8e434789a4945a5e
UNKNOWN
Today, Osama gave Fadi an integer $X$, and Fadi was wondering about the minimum possible value of $max(a, b)$ such that $LCM(a, b)$ equals $X$. Both $a$ and $b$ should be positive integers. $LCM(a, b)$ is the smallest positive integer that is divisible by both $a$ and $b$. For example, $LCM(6, 8) = 24$, $LCM(4, 12) = ...
["import math\nx = int(input())\n\nans = 10**13\nab = [1, 1]\nfor i in range(1, int(x**(1/2))+1):\n if x % i == 0:\n a = x//i\n b = i\n\n g = math.gcd(a, b)\n a *= g\n b *= g\n if ans > max(a, b):\n ans = max(a, b)\n ab = [a, b]\n\nprint(ab[0], ab[1])\n...
{ "inputs": [ "2\n", "6\n", "4\n", "1\n", "24\n", "200560490130\n", "999999999989\n", "1000000000000\n", "999966000289\n", "991921850317\n", "997167959139\n", "244641009859\n", "483524125987\n", "726702209411\n", "965585325539\n", "213058376259\n", "...
INTERVIEW
PYTHON3
CODEFORCES
2,596
2f1b8eb7c5bcd8855902423bbdee1ad3
UNKNOWN
Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. These fruits — lemons, ...
["n1 = int( input() )\nn2 = int( input() )\nn3 = int( input() )\nprint( min( n1 , n2 // 2 , n3 // 4 ) * 7 )\n", "#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n a = int(input())\n b = int(input())\n c = int(input())\n x = min(a, b >> 1, c >> 2)\n ...
{ "inputs": [ "2\n5\n7\n", "4\n7\n13\n", "2\n3\n2\n", "1\n1\n1\n", "1\n2\n4\n", "1000\n1000\n1000\n", "1\n1\n4\n", "1\n2\n3\n", "1\n1000\n1000\n", "1000\n1\n1000\n", "1000\n2\n1000\n", "1000\n500\n1000\n", "1000\n1000\n4\n", "1000\n1000\n3\n", "4\n8\n12\n", ...
INTERVIEW
PYTHON3
CODEFORCES
3,554
82c04f2d1125d1da3a92482fafa81535
UNKNOWN
Berland annual chess tournament is coming! Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerOil. Thus, organizers sh...
["n = int(input())\nz = list(map(int, input().split()))\nz.sort()\nif z[n - 1] < z[n]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n", "n=int(input())\na=sorted(list(map(int,input().split())))\nprint('YES'if a[n-1]<a[n] else 'NO')\n", "n = int(input())\n\nnums = list(map(int, input().split()))\nnums = sorted(...
{ "inputs": [ "2\n1 3 2 4\n", "1\n3 3\n", "5\n1 1 1 1 2 2 3 3 3 3\n", "5\n1 1 1 1 1 2 2 2 2 2\n", "10\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "1\n2 3\n", "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...
INTERVIEW
PYTHON3
CODEFORCES
3,854
fb770dd0c0cd4a344ac7505c60202c85
UNKNOWN
You are given an array of n elements, you must make it a co-prime array in as few moves as possible. In each move you can insert any positive integral number you want not greater than 10^9 in any place in the array. An array is co-prime if any two adjacent numbers of it are co-prime. In the number theory, two intege...
["import fractions\n\nn = int(input())\nA = [int(x) for x in input().split()]\nB = []\nfor i in range(n-1):\n B.append(A[i])\n if fractions.gcd(A[i], A[i+1]) != 1:\n B.append(1)\nB.append(A[-1])\nprint(len(B) - n)\nprint(' '.join(map(str, B)))\n\n\n", "from fractions import gcd\n\nn = int(input())\na = lis...
{ "inputs": [ "3\n2 7 28\n", "1\n1\n", "1\n548\n", "1\n963837006\n", "10\n1 1 1 1 1 1 1 1 1 1\n", "10\n26 723 970 13 422 968 875 329 234 983\n", "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "100\n1 1 1 1 2 1 1 1 1 1 2 2 1 ...
INTERVIEW
PYTHON3
CODEFORCES
9,948
9dc27f2e4ecf390aa57dd3d2851aa8ca
UNKNOWN
We have a sequence of N integers: A_1, A_2, \cdots, A_N. You can perform the following operation between 0 and K times (inclusive): - Choose two integers i and j such that i \neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element. Compute the maximum possible positiv...
["# \u5272\u308a\u5207\u308b\u6570\u306f\u3001A\u306e\u7dcf\u548c\u306e\u7d04\u6570\u3067\u3042\u308b\n# \u81ea\u5206\u81ea\u8eab\u3092\u9664\u304f\u7d04\u6570\u306b\u3064\u3044\u3066\u5927\u304d\u3044\u9806\u306b\u3059\u3079\u3066\u8a66\u3057\u3066\u3001\u5f53\u3066\u306f\u307e\u308b\u3082\u306e\u304c\u3042\u308c\u307...
{"inputs": ["2 3\n8 20\n", "2 10\n3 5\n", "4 5\n10 1 2 22\n", "8 7\n1 7 5 6 8 2 6 5\n", "2 1\n1 1\n", "500 1000000000\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1...
INTERVIEW
PYTHON3
ATCODER.JP
81,102
b1a39f6229b23675c680514913bfc798
UNKNOWN
Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat. Assume that we have a cat with a number $x$. A perfect longcat is a cat with a number equal $2^m - 1$ for some no...
["def main():\n x = int(input())\n n = x.bit_length()\n t = 0\n ans = []\n while True:\n if (x + 1) & (x) == 0:\n break\n if t & 1:\n x += 1\n else:\n for i in range(n - 1, -1, -1):\n if not (1 << i) & x:\n ans.append...
{ "inputs": [ "39\n", "1\n", "7\n", "1000000\n", "524288\n", "524289\n", "524287\n", "699050\n", "349525\n", "2\n", "5\n", "6\n", "11\n", "13\n", "545860\n", "917503\n", "174762\n", "43690\n", "10922\n", "2730\n", "682\n", "170\n"...
INTERVIEW
PYTHON3
CODEFORCES
12,741
5657beb44ca1217a7bb93990ac1a5c2f
UNKNOWN
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ...
["n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nmaxd = -1\nfor x in a:\n if k % x == 0:\n maxd = max(maxd, x)\nprint(k // maxd)", "import itertools as it, math, functools as ft\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nres = 100000\nfor i in a:\n\tif k ...
{ "inputs": [ "3 6\n2 3 5\n", "6 7\n1 2 3 4 5 6\n", "5 97\n1 10 50 97 2\n", "5 97\n1 10 50 100 2\n", "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 4...
INTERVIEW
PYTHON3
CODEFORCES
4,467
8210dc777f52fd07454c06b285bba711
UNKNOWN
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The gras...
["from math import *\nfrom sys import *\nfrom queue import *\nfrom decimal import *\n\nn,k=(int(z) for z in input().split())\ns=input()\ni=0\nwhile i<len(s) and s[i] not in [\"G\",\"T\"]:\n i+=1\ni+=k\nwhile i<len(s) and s[i] not in [\"G\",\"T\",\"#\"]:\n i+=k\nif i>=len(s) or s[i]==\"#\":\n print(\"NO\")\nelse:\n ...
{ "inputs": [ "5 2\n#G#T#\n", "6 1\nT....G\n", "7 3\nT..#..G\n", "6 2\n..GT..\n", "2 1\nGT\n", "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####T####\n", "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.########...
INTERVIEW
PYTHON3
CODEFORCES
31,153
9cc629422f340e063f4cd9f069e59664
UNKNOWN
Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes ho...
["a = list(map(int, input().split()))\nm = max(a)\n\nans = 0\nfor i in range(3):\n if a[i] < m - 1:\n ans += (m - 1) - a[i]\n a[i] = m - 1\n\nprint(ans)\n", "def c(ans, b ,d, s):\n\treturn(min(ans, 3 * max(b, d, s) - b - d - s))\nb, d, s = list(map(int, input().split()))\nans = 10**19\nm = min(b, d, s)...
{ "inputs": [ "3 2 1\n", "1 0 0\n", "1 1 1\n", "1000000000000000000 0 1000000000000000000\n", "1000 0 0\n", "0 1 0\n", "0 0 1\n", "1 1 0\n", "0 1 1\n", "1000000000000000000 999999999999999999 999999999999999999\n", "1000000000000000000 1000000000000000000 999999999999999999...
INTERVIEW
PYTHON3
CODEFORCES
9,790
9526177785d832980394f93e9f22054b
UNKNOWN
You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of th...
["def get_substr_ends(haystack, needle):\n\tans = [-1]\n\tindex = 0\n\tfor char in needle:\n\t\twhile index < len(haystack) and char != haystack[index]:\n\t\t\tindex += 1\n\t\tans.append(index)\n\t\tif index < len(haystack):\n\t\t\tindex += 1\n\treturn ans\n\nhaystack = input()\nneedle = input()\n\npref = get_substr_en...
{ "inputs": [ "hi\nbob\n", "abca\naccepted\n", "abacaba\nabcdcba\n", "lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm\n", "aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk\n", "npnkmawey\nareakefvowledfriyjejqnnaeqheoh\n", "fdtffutxkujflswyddvhusfcook\nkavkh...
INTERVIEW
PYTHON3
CODEFORCES
8,360
115550da3664f4fe0b5b7c456adb1928
UNKNOWN
Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile. You are given $n$ operations which Vasya has made. Find the minimal possible number of stones that c...
["n = int(input())\ns = input()\nb = 0\nfor i in s:\n if i == '+':\n b += 1\n else:\n b -= 1\n b = max(b, 0)\nprint(b)", "def go():\n n = int(input())\n a = [i for i in input()]\n x = 0\n for i in a:\n if i == '-':\n x = max(0, x - 1)\n else:\n ...
{ "inputs": [ "3\n---\n", "4\n++++\n", "2\n-+\n", "5\n++-++\n", "1\n+\n", "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "100\n---------------------------------------------------------------------------------------------------...
INTERVIEW
PYTHON3
CODEFORCES
5,537
97de21663009bdeb2720d7e2f95d8b42
UNKNOWN
Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated. Kolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plas...
["n=int(input())\na=int(input())\nb=int(input())\nc=int(input())\nr=n//a\nif n > c:\n r=max(r,(r-b+c)//a+1,(n-c)//(b-c)+((n-c)%(b-c)+c)//a)\nprint(r)", "n = int(input())\na = int(input())\nb = int(input())\nc = int(input())\nif(a < (b - c) or n < b):\n print(n // a)\nelse:\n print((n-b)//(b-c) + 1 + (c + (n-b)...
{ "inputs": [ "10\n11\n9\n8\n", "10\n5\n6\n1\n", "2\n2\n2\n1\n", "10\n3\n3\n1\n", "10\n1\n2\n1\n", "10\n2\n3\n1\n", "9\n2\n4\n1\n", "9\n2\n2\n1\n", "9\n10\n10\n1\n", "10\n2\n2\n1\n", "1000000000000000000\n2\n10\n9\n", "501000000000000000\n300000000000000000\n30100000000...
INTERVIEW
PYTHON3
CODEFORCES
9,123
6ab7f12203bae47341b56459308e71bd
UNKNOWN
You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your task is to implement such an automatic che...
["s = input().strip()\nflag1 = len(s) >= 5\nd1 = 'qwertyuiopasdfghjklzxcvbnm'\nd2 = 'QWERTYUIOPASDFGHJKLZXCVBNM'\nd3 = '123456789'\nflag2 = False\nflag3 = False\nflag4 = False\n\nfor i in d1:\n if i in s:\n flag2 = True\nfor i in d2:\n if i in s:\n flag3 = True\nfor i in d3:\n if i in s:\n ...
{ "inputs": [ "abacaba\n", "X12345\n", "CONTEST_is_STARTED!!11\n", "1zA__\n", "1zA_\n", "zA___\n", "1A___\n", "z1___\n", "0\n", "_\n", "a\n", "D\n", "_\n", "?\n", "?\n", "._,.!.,...?_,!.\n", "!_?_,?,?.,.,_!!!.!,.__,?!!,_!,?_,!??,?!..._!?_,?_!,?_.,._,...
INTERVIEW
PYTHON3
CODEFORCES
9,275
5cf0d57006edc87254b8ee785746e8a8
UNKNOWN
In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known — integer value between 1 and 5. Th...
["n = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0] * 5\nb = [0] * 5\nfor j in range(n):\n a[A[j]-1] += 1\n b[B[j]-1] +=1\nper = 0\nfor j in range(5):\n if (a[j] + b[j]) % 2 == 1:\n per = 1\n break\nif per == 1:\n print(-1)\nelse:\n ans = 0\n ...
{ "inputs": [ "4\n5 4 4 4\n5 5 4 5\n", "6\n1 1 1 1 1 1\n5 5 5 5 5 5\n", "1\n5\n3\n", "9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n", "1\n1\n2\n", "1\n1\n1\n", "8\n1 1 2 2 3 3 4 4\n4 4 5 5 1 1 1 1\n", "10\n1 1 1 1 1 1 1 1 1 1\n2 2 2 2 2 2 2 2 2 2\n", "100\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5...
INTERVIEW
PYTHON3
CODEFORCES
11,623
e850cc77998be5aa5198db9e6706cee2
UNKNOWN
Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false. Implication is written by using character '$\rightarrow$', and the arguments and the result of the implication are written as '0' (false) and '1'...
["x = int(input())\n\nseq = list(map(int, input().split(' ')))\n\nif seq == [0]:\n print(\"YES\")\n print(0)\n\nelif seq == [0, 0]:\n print(\"NO\")\n\nelif seq == [1, 0]:\n print(\"YES\")\n print('1->0')\n\nelif seq == [0, 0, 0]:\n print(\"YES\")\n print(\"(0->0)->0\")\n\nelif seq == [1, 0, 0]:\n ...
{ "inputs": [ "4\n0 1 1 0\n", "2\n1 1\n", "1\n0\n", "4\n0 0 0 0\n", "6\n0 0 0 0 0 1\n", "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "20\n1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0\n", "1\n1\n", "2\n0 0\n", "2\n0 1\n", "2\n1 0\n", "3\n0 0 0\n", "3\n0 0 1\n", "3...
INTERVIEW
PYTHON3
CODEFORCES
2,655
19b941a3e51c041f6ee4a8de27f75ff0
UNKNOWN
You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to step 3; If b ≥ 2·a, then set the value of b to b - 2·a, and repeat s...
["a, b = [int(v) for v in input().split()]\n\nwhile a > 0 and b > 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else:\n break\n\nprint(a, b)\n", "a,b=list(map(int,input().split()))\nwhile a>0 and b>0:\n if a>=b+b:a%=b+b\n elif b>=a+a:b%=a+a\n else: break\nprint(a,b)...
{ "inputs": [ "12 5\n", "31 12\n", "1000000000000000000 7\n", "31960284556200 8515664064180\n", "1000000000000000000 1000000000000000000\n", "1 1000\n", "1 1000000\n", "1 1000000000000000\n", "1 99999999999999999\n", "1 4\n", "1000000000000001 500000000000000\n", "1 100...
INTERVIEW
PYTHON3
CODEFORCES
6,156
95b85642753dfef717f61819f6a46c77
UNKNOWN
Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k. -----Input----- The only line contains three space-separated integers k, a and b (1 ≤ k ≤ 10^18; - 10^18 ≤ a ≤ b ≤ 10^18). -----Output----- Prin...
["s=input()\nast=[int(i) for i in s.split(' ')]\nk,a,b=ast[0],ast[1],ast[2]\ns1=(a-1)//k\ns2=b//k\nprint(s2-s1)\n", "k, a, b = list(map(int, input().split()))\nf = (a + k - 1) // k\nl = b // k\nprint(l - f + 1)\n", "k, a, b = [int(i) for i in input().split()]\nif a % k != 0:\n a += k - a % k\nif (b - a + 1) % k == 0...
{ "inputs": [ "1 1 10\n", "2 -4 4\n", "1 1 1\n", "1 0 0\n", "1 0 1\n", "1 10181 10182\n", "1 10182 10183\n", "1 -191 1011\n", "2 0 0\n", "2 0 1\n", "2 1 2\n", "2 2 3\n", "2 -1 0\n", "2 -1 1\n", "2 -7 -6\n", "2 -7 -5\n", "2 -6 -6\n", "2 -6 -4\n", ...
INTERVIEW
PYTHON3
CODEFORCES
4,911
0637c25e0fc982532a2be87963dd150f
UNKNOWN
Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536... Your task is to print the $k$-th digit of this sequence. -----Input----- The fir...
["a = int(input())\ns = \"\"\nfor i in range(1, a+1):\n s += str(i)\nprint(s[a-1])", "k = int(input())\ns = \"\"\ni = 1\nwhile len(s) < k + 10:\n\ts += str(i)\n\ti += 1\nk -= 1\nprint(s[k])", "s='0'\nfor i in range(1,10000):\n s+=str(i)\nprint(s[int(input())])\n\n", "from sys import stdin\nimport math\nfrom colle...
{ "inputs": [ "7\n", "21\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "8\n", "9\n", "10\n", "12\n", "188\n", "189\n", "190\n", "191\n", "192\n", "193\n", "194\n", "195\n", "196\n", "197\n", "198\n", "199\n", "200\n", ...
INTERVIEW
PYTHON3
CODEFORCES
42,184
a640c703e19c0591d17c08b19ee4fea4
UNKNOWN
A telephone number is a sequence of exactly $11$ digits such that its first digit is 8. Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and eras...
["n, s = int(input()), input()\ncnt = (n - 11) // 2\ncnt_8 = len(s[:n - 10].split('8')) - 1\nif (cnt >= cnt_8):\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\")", "def main():\n n = int(input())\n arr = list(map(int, input()))\n a = arr.count(8)\n if a <= (n - 11) // 2:\n print(\"NO\")\n return 0\n...
{ "inputs": [ "13\n8380011223344\n", "15\n807345619350641\n", "19\n8181818181111111111\n", "29\n88811188118181818118111111111\n", "15\n980848088815548\n", "13\n9999999998888\n", "13\n0000008888888\n", "13\n2480011223348\n", "17\n87879887989788999\n", "21\n123456788888812378910\...
INTERVIEW
PYTHON3
CODEFORCES
12,747
4413df95a295ec32961d93a8e724b6e3
UNKNOWN
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo...
["MOD = 1000000007\n\n\ndef f(n, cnt):\n \"\"\"\n n! / (n - cnt)!\n \"\"\"\n ans = 1\n for _ in range(cnt):\n ans = (ans * n) % MOD\n n -= 1\n return ans\n\n\ndef main():\n n, x, pos = list(map(int, input().split()))\n chk1 = 0\n chk_r = 0\n left = 0\n right = n\n while...
{ "inputs": [ "4 1 2\n", "123 42 24\n", "1 1 0\n", "1000 501 501\n", "1000 999 799\n", "2 1 1\n", "2 2 0\n", "3 1 2\n", "3 2 2\n", "3 3 1\n", "4 2 0\n", "4 3 2\n", "4 4 3\n", "7 1 1\n", "7 7 6\n", "7 2 4\n", "7 4 4\n", "8 4 1\n", "8 1 5\n", ...
INTERVIEW
PYTHON3
CODEFORCES
4,433
82f3bb27083418d90acdc0bcd1f56466
UNKNOWN
Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple...
["a, b, c = list(map(int, input().split()))\nx, y, z = list(map(int, input().split()))\ncol = max(0, x - a) + max(0, y - b) + max(0, z - c)\nsum = max(0, (a - x) // 2) + max(0, (b - y) // 2) + max(0, (c - z) // 2)\nif sum >= col:\n print('Yes')\nelse:\n print('No')\n", "a, b, c = list(map(int, input().split(' '))...
{ "inputs": [ "4 4 0\n2 1 2\n", "5 6 1\n2 7 2\n", "3 3 3\n2 2 2\n", "0 0 0\n0 0 0\n", "0 0 0\n0 0 1\n", "0 1 0\n0 0 0\n", "1 0 0\n1 0 0\n", "2 2 1\n1 1 2\n", "1 3 1\n2 1 1\n", "1000000 1000000 1000000\n1000000 1000000 1000000\n", "1000000 500000 500000\n0 750000 750000\n", ...
INTERVIEW
PYTHON3
CODEFORCES
7,907
d189bb5e0aca9d74775453b3cd6b2126
UNKNOWN
Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't. First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x > 0 exist such that: Decim...
["n,k,m=list(map(int,input().split()))\nd,r,p,P=0,0,1%k,(10**(n-1))*9\nF=[0]*k\nF[0]=1\nwhile d<n:\n\td+=1\n\tP//=10\n\tE=[0]*k\n\tif P==0:P=1\n\ti=1\n#\tprint(\"E=\",E)\n#\tprint(\"F=\",F)\n\twhile i<10:\n\t\tj=(-i*p)%k\n\t\tf=0\n\t\twhile f<k:\n\t\t\tE[f]+=F[j]\n\t\t\tf+=1\n\t\t\tj+=1\n\t\t\tif j==k:j=0\n\t\ti+=1\n\t...
{ "inputs": [ "1 2 1000\n", "2 2 1000\n", "5 3 1103\n", "2 17 10000\n", "3 9 10000\n", "6 64 941761822\n", "183 3 46847167\n", "472 44 364550669\n", "510 76 811693420\n", "783 30 602209107\n", "863 47 840397713\n", "422 22 411212542\n", "370 9 385481464\n", "312...
INTERVIEW
PYTHON3
CODEFORCES
6,401
e1dbec4e8f2c784a8d9759a395b3281b
UNKNOWN
You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand. The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactl...
["import base64\nimport zlib\npro = base64.decodebytes(\"\"\"eJxtUUFuwyAQvPOKVarKkDhOm2MlX/uC3qqqAhs7KBgswGr6+y4QrLqqL7DD7OzMWk2zdQFGGWbu\nPVG59N/rdeLhUu6Om95OpVJBumCtXqlCedkFQgalpYcW3twiSS/FMmLxyrWXhKihzGrwXLx0lEHb\nQjU4e5HmWgHOgKTwQgC/0p/EIoDeGh96ZRC0szR0F6QPjTI7lt4fCsMuoVCqREGgqqH6qjIxBSZo\ncADdTZTXIFie6dCZM8BhDwJOp...
{ "inputs": [ "1 4 2\n", "5 5 5\n", "0 2 0\n", "30 70 34\n", "89 32 24\n", "89 44 77\n", "0 0 0\n", "100 100 100\n", "1 1 1\n", "30 70 35\n", "89 44 76\n", "0 100 100\n", "100 0 100\n", "100 1 100\n", "1 100 100\n", "100 100 0\n", "100 100 1\n", ...
INTERVIEW
PYTHON3
CODEFORCES
4,792
5cfb754ec592172086e4b08377759bb0
UNKNOWN
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. The students don’t want to use too many blocks, but they also want to be uniq...
["n, m = list(map(int, input().split()))\n\nstart = 0\nend = 10**10\nwhile (end - start > 1):\n mid = (end + start) // 2\n two = mid // 2 - mid // 6\n three = mid // 3 - mid // 6\n six = mid // 6\n\n nn = n\n mm = m\n\n nn -= two\n mm -= three\n nn = max(nn, 0)\n mm = max(mm, 0)\n if (s...
{ "inputs": [ "1 3\n", "3 2\n", "5 0\n", "4 2\n", "0 1000000\n", "1000000 1\n", "1083 724\n", "1184 868\n", "1285 877\n", "820189 548173\n", "968867 651952\n", "817544 553980\n", "813242 543613\n", "961920 647392\n", "825496 807050\n", "974174 827926\n",...
INTERVIEW
PYTHON3
CODEFORCES
10,987
e4f883d4478f1f32dc8ed44708fcdced
UNKNOWN
Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with num...
["def list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \nn = int(input()) \na = []\nfor _ in range(n):\n\ta.append(int(input()))\nb = list(set(a[::]))\nif(len(b) == 2 and a.count(a[0]) == n//2):\n\tprin...
{ "inputs": [ "4\n11\n27\n27\n11\n", "2\n6\n6\n", "6\n10\n20\n30\n20\n10\n20\n", "6\n1\n1\n2\n2\n3\n3\n", "2\n1\n100\n", "2\n1\n1\n", "2\n100\n100\n", "14\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n", "100\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n1...
INTERVIEW
PYTHON3
CODEFORCES
7,703
05d13124fd684cea637829c4dcb44d44
UNKNOWN
Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \ldots, a_n$. For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$. A ...
["n = int(input())\na = list(map(int,input().split()))\nt = 0\nmn = 1000000000\nfor i in range(1,100):\n cur = 0\n for j in range(n):\n cur += max(0,abs(i-a[j])-1)\n if cur < mn:\n mn = cur\n t = i\nprint(t,mn)\n", "n=int(input())\na=[*map(int,input().split())]\n\nmcost = 10**8\nans = 0\n\...
{ "inputs": [ "3\n10 1 4\n", "5\n1 1 2 2 3\n", "1\n5\n", "2\n1 2\n", "3\n1 1 1\n", "5\n100 100 100 100 100\n", "113\n86 67 31 33 72 100 88 63 16 12 79 80 76 45 31 96 44 10 24 33 53 11 56 100 23 57 9 48 28 73 18 48 12 89 73 9 51 11 82 94 90 92 34 99 54 58 33 67 35 87 58 90 94 64 57 80 87 99...
INTERVIEW
PYTHON3
CODEFORCES
7,415
0bf4315b5a68f2604b28cbc3cb359e88
UNKNOWN
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and the number $k$. Exactly $k$ times the following happens: Two numbe...
["N, T = list(map(int, input().split()))\nA = [int(a) for a in input().split()]\nif sum(A) > N//2:\n A = [1-a for a in A][::-1]\nK = sum(A)\nS = sum(A[-K:])\nM = K + 1\nP = 10**9+7\ninv = pow(N*(N-1)//2, P-2, P)\nX = [[0]*M for _ in range(M)]\nfor i in range(M):\n if i > 0: X[i-1][i] = ((K-i+1)**2*inv)%P\n if ...
{ "inputs": [ "3 2\n0 1 0\n", "5 1\n1 1 1 0 0\n", "6 4\n1 0 0 1 1 0\n", "3 2\n1 1 1\n", "5 2\n1 1 1 0 0\n", "6 4\n0 0 1 1 1 1\n", "100 1000000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
INTERVIEW
PYTHON3
CODEFORCES
5,167
0ee7de9be9de57c0f9fd50295a7784c9
UNKNOWN
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second, he can modify the length of a single side of the current triangle such th...
["x, y = list(map(int, input().split()))\nx, y = y, x\nA = x\nB = x\ncurr = x\ncount = 0\nwhile curr < y:\n\tcurr = B + A - 1\n\tA, B = B, curr\n\tcount += 1\ncount += 2\nprint(count)\n", "t, f = list(map(int, input().split()))\ns = [f] * 3\ncount = 0\nwhile sum(s) < 3*t:\n\ts.sort()\n\ts[0] = min(t, s[1]+s[2] - 1)\n\t...
{ "inputs": [ "6 3\n", "8 5\n", "22 4\n", "4 3\n", "57 27\n", "61 3\n", "5 4\n", "10 6\n", "20 10\n", "30 5\n", "25 24\n", "25 3\n", "12 7\n", "18 6\n", "100000 3\n", "100000 9999\n", "9999 3\n", "5323 32\n", "6666 66\n", "38578 32201\n",...
INTERVIEW
PYTHON3
CODEFORCES
7,778
99061054e6bd5fcac6d74693e02369d3
UNKNOWN
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You ar...
["def seg(x, y, h):\n A = [x - h, x + h]\n B = [y - h, y + h]\n Z = []\n for a in A:\n for b in B:\n Z.append(a * b)\n Z.sort()\n return (Z[0], Z[-1])\n\ndef check(a, b, c, d, h):\n x1, y1 = seg(a, d, h)\n x2, y2 = seg(b, c, h)\n return max(x1, x2) <= min(y1, y2)\n\na, b = l...
{ "inputs": [ "1 2\n3 4\n", "1 0\n0 1\n", "1000000000 0\n0 1000000000\n", "8205 9482\n11 -63\n", "0 0\n0 0\n", "1000000000 -1000000000\n1000000000 1000000000\n", "1000000000 1000000000\n1000000000 -1000000000\n", "-1 -1\n1 0\n", "5 2\n-15 -6\n", "2 -5\n-3 2\n", "-5 -2\n-1 -...
INTERVIEW
PYTHON3
CODEFORCES
19,477
2b318226df785e660e81037f4b2830a3
UNKNOWN
In a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater tabl...
["n, a, b = list(map(int,input().split()))\nl = input().split()\no = 0\nc = 0\nfor i in l:\n if i == '2':\n if b > 0:\n b -= 1\n else:\n o += 2\n if i == '1':\n if a > 0:\n a -= 1\n elif b > 0:\n b -= 1\n c += 1\n elif c > 0...
{ "inputs": [ "4 1 2\n1 2 1 1\n", "4 1 1\n1 1 2 1\n", "1 1 1\n1\n", "2 1 2\n2 2\n", "5 1 3\n1 2 2 2 1\n", "7 6 1\n1 1 1 1 1 1 1\n", "10 2 1\n2 1 2 2 2 2 1 2 1 2\n", "20 4 3\n2 2 2 2 2 2 2 2 1 2 1 1 2 2 1 2 2 2 1 2\n", "1 1 1\n1\n", "1 1 1\n2\n", "1 200000 200000\n2\n", ...
INTERVIEW
PYTHON3
CODEFORCES
11,178
30cf5af4219a870f2c479c3d09ddb90a
UNKNOWN
Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after the exam. Some of them celebrated in the BugDonalds restaurant, some of them...
["a,b,c,n=list(map(int,input().split()))\nx=a+b-c\nprint(n-x if c<=a and c<=b and x<n else -1)\n", "a,b,c,n = list(map(int, input().split()))\nif c > a or c > b or n- (a+b-c) < 1:\n print(-1)\nelse:\n print(n- (a+b-c))\n", "a, b, c, n = list(map(int, input().split()))\nrem = n - (a + b - c)\nif (rem < 1 or c > a ...
{ "inputs": [ "10 10 5 20\n", "2 2 0 4\n", "2 2 2 1\n", "98 98 97 100\n", "1 5 2 10\n", "5 1 2 10\n", "6 7 5 8\n", "6 7 5 9\n", "6 7 5 7\n", "50 50 1 100\n", "8 3 2 12\n", "10 19 6 25\n", "1 0 0 99\n", "0 1 0 98\n", "1 1 0 97\n", "1 1 1 96\n", "0 0 0...
INTERVIEW
PYTHON3
CODEFORCES
6,231
0b382ce3e5688d5ef61595fd2e31a068
UNKNOWN
Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month). Unfortunately, right after the doubling the wardrobe eats one of the dresses (if any) with ...
["x, k = map(int, input().split())\nif x == 0:\n print(0)\nelse:\n mod = 10 ** 9 + 7\n p = pow(2, k, mod)\n ans = (x * (p * 2) - (p - 1)) % mod\n print(ans)", "mod = 10**9+7\nx, k = list(map(int, input().split(' ')))\nif (x == 0):\n print(0)\nelse:\n val1 = pow(2,k+1,mod) * x\n val2 = pow(2, k, ...
{ "inputs": [ "2 0\n", "2 1\n", "3 2\n", "1 411\n", "1 692\n", "16 8\n", "18 12\n", "1 1000000000000000000\n", "0 24\n", "24 0\n", "1000000000000000000 1\n", "348612312017571993 87570063840727716\n", "314647997243943415 107188213956410843\n", "375000003 2\n", ...
INTERVIEW
PYTHON3
CODEFORCES
7,538
d4d7e150edae145d5c269cc297d298d9
UNKNOWN
An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared $n$ problems; and since the platform is very popular, $998244351$ coder from all over the world is going to solve them. For each problem, the authors estimated the number of people who would solve it...
["from bisect import bisect_left\n\nM = 998244353\n\ndef pw(x, y):\n if y == 0:\n return 1\n res = pw(x, y//2)\n res = res * res % M\n if y % 2 == 1:\n res = res * x % M\n return res\n\ndef cal(x, y):\n y += x - 1\n res = 1\n for i in range(1, x + 1):\n res = res * (y - i + ...
{ "inputs": [ "3\n1 2\n1 2\n1 2\n", "2\n42 1337\n13 420\n", "2\n1 1\n0 0\n", "2\n1 1\n1 1\n", "2\n1 1\n0 1\n", "2\n0 1\n0 1\n", "2\n0 0\n0 1\n", "2\n0 0\n0 1\n", "2\n0 0\n0 1\n", "2\n0 1\n1 1\n", "2\n10 34\n17 26\n", "2\n12 19\n39 69\n", "2\n25 29\n29 78\n", "2\...
INTERVIEW
PYTHON3
CODEFORCES
10,541
87093f957fa727e6c71f6881db8ac08c
UNKNOWN
Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n. Pasha likes rectangles but hates squares, so he wonders, how many ways are there to spli...
["x = int(input())\nif x%2==1:\n print(0)\n quit()\nif x%2 ==0:\n x//=2\n if x%2==0:\n print(x//2-1)\n else:\n print(x//2)\n", "n = int(input())\nif n%2==1:\n print(0)\nelif n%4==2:\n print(n//4)\nelse:\n print(n//4-1)\n", "n = int(input())\np = n // 2\nif (n % 2 == 1):\n print(...
{ "inputs": [ "6\n", "20\n", "1\n", "2\n", "3\n", "4\n", "2000000000\n", "1924704072\n", "73740586\n", "1925088820\n", "593070992\n", "1925473570\n", "629490186\n", "1980649112\n", "36661322\n", "1943590793\n", "71207034\n", "1757577394\n", "...
INTERVIEW
PYTHON3
CODEFORCES
3,216
ea19d6c91a51a1102fac033ad3d87530
UNKNOWN
The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of k...
["def doit():\n xx = input().split()\n n = int(xx[0])\n s = int(xx[1])\n v = [int(k) for k in input().split()]\n\n S = sum(v)\n newS = S - s\n if newS < 0:\n return -1\n return min(newS//n, min(v))\n \nprint(doit())\n", "n, s = list(map(int, input().split()))\n\nv = list(map(int, i...
{ "inputs": [ "3 3\n4 3 5\n", "3 4\n5 3 4\n", "3 7\n1 2 3\n", "1 1\n1\n", "1 2\n1\n", "5 10\n10 10 10 10 10\n", "1 1000000000\n1000000000\n", "1 1000000000000\n42\n", "3 2\n1 1 5\n", "2 1\n1 100\n", "3 1\n5 10 15\n", "2 1\n1 1000\n", "3 3\n2 4 4\n", "10 1\n1 2 3...
INTERVIEW
PYTHON3
CODEFORCES
7,981
1d1950e05f0f64cb5299d9d9da708a36
UNKNOWN
The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h_1 cm from the ground. On the height h_2 cm (h_2 > h_1) on the same tree hung an apple and the caterpillar was crawling to the apple. Gabriel is interested when the cater...
["from math import *\n\nh1, h2 = [int(i) for i in input().split()]\na, b = [int(i) for i in input().split()]\na *= 12\nb *= 12\nif a <= b and h2 - h1 > (a // 12 * 8):\n print(-1)\n return\nh1 += (a // 12 * 8)\nif h1 >= h2:\n print(0)\n return\nday = int(ceil((h2 - h1) / (a - b)))\nprint(day)", "def solve():...
{ "inputs": [ "10 30\n2 1\n", "10 13\n1 1\n", "10 19\n1 2\n", "1 50\n5 4\n", "1 1000\n2 1\n", "999 1000\n1 1\n", "999 1000\n1 1000\n", "1 1000\n999 1\n", "1 1000\n100 99\n", "500 509\n1 1\n", "500 555\n6 1\n", "1 100000\n2 1\n", "99990 100000\n1 1\n", "90000 100...
INTERVIEW
PYTHON3
CODEFORCES
11,201
2650fa7e3ae255647c070860184bccca
UNKNOWN
Professor GukiZ makes a new robot. The robot are in the point with coordinates (x_1, y_1) and should go to the point (x_2, y_2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal number of s...
["a, b = map(int, input().split())\nd, c = map(int, input().split())\nprint(max(abs(a - d), abs(b - c)))", "x1, y1 = list(map(int, input().split()))\nx2, y2 = list(map(int, input().split()))\n\ndx = abs(x1 - x2)\ndy = abs(y1 - y2)\n\nprint(max(dx, dy))\n", "x1, x2 = map(int, input().split())\nx3, x4 = map(int, input()....
{ "inputs": [ "0 0\n4 5\n", "3 4\n6 1\n", "0 0\n4 6\n", "1 1\n-3 -5\n", "-1 -1\n-10 100\n", "1 -1\n100 -100\n", "-1000000000 -1000000000\n1000000000 1000000000\n", "-1000000000 -1000000000\n0 999999999\n", "0 0\n2 1\n", "10 0\n100 0\n", "1 5\n6 4\n", "0 0\n5 4\n", "...
INTERVIEW
PYTHON3
CODEFORCES
4,102
d338726dffb388a08d7c0f7c8da18700
UNKNOWN
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
["n = int(input())\ns = input()\ncountr = s.count('R')\ncountd = n - countr\ncr = 0\ncd = 0\ni = 0\nnews = []\nwhile countr != 0 and countd != 0:\n if s[i] == 'D':\n if cd == 0:\n cr += 1\n countr -= 1\n news.append('D')\n else:\n cd -= 1\n else:\n ...
{ "inputs": [ "5\nDDRRR\n", "6\nDDRRRR\n", "1\nD\n", "1\nR\n", "2\nDR\n", "3\nRDD\n", "3\nDRD\n", "4\nDRRD\n", "4\nDRRR\n", "4\nRDRD\n", "5\nDRDRR\n", "4\nRRRR\n", "5\nRDDRD\n", "5\nDDRRD\n", "5\nDRRRD\n", "5\nDDDDD\n", "6\nDRRDDR\n", "7\nRDRDRDD...
INTERVIEW
PYTHON3
CODEFORCES
12,762
d2233742161818639dc47e4be09d869a
UNKNOWN
Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $a$ and screen height not greater than $b$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $...
["def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\na, b, x, y = list(map(int, input().split()))\n\ng = gcd(x, y)\nx //= g\ny //= g\n\n\nprint(min(a // x, b // y))\n", "from sys import stdin, stdout\n\n\ndef gcd(a, b):\n if not b:\n return a\n else:\n return gcd(b, a % b)\n\n\na...
{ "inputs": [ "17 15 5 3\n", "14 16 7 22\n", "4 2 6 4\n", "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\n", "1 1 1 1\n", "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "3 3 2 4\n", "3 3 2 6\n", "1000000000000000...
INTERVIEW
PYTHON3
CODEFORCES
6,417
d77aed790b442116c240504fe43004d4
UNKNOWN
The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the number $9200$ has two trailing zeros. Aki thinks the more trailing zero digits a...
["n, k = map(int, input().split())\na = []\ni = 2\nwhile (i * i <= k):\n if (k % i == 0):\n a.append([i, 0])\n while (k % i == 0):\n a[len(a) - 1][1] += 1\n k //= i\n i += 1\nif (k > 1):\n a.append([k, 1])\nans = 10 ** 20\nfor i in a:\n cnt = 0\n x = i[0]\n while (x...
{ "inputs": [ "6 9\n", "38 11\n", "5 2\n", "5 10\n", "1000000000000000000 1000000000000\n", "1000000000000000000 999999999989\n", "1000000000000000000 97\n", "62 45\n", "25 48\n", "594703138034372316 960179812013\n", "1 2\n", "2 2\n", "7 10080\n", "8 10080\n", ...
INTERVIEW
PYTHON3
CODEFORCES
17,032
bfb9b7b993680fe2c6a54c8b9cd2066f
UNKNOWN
A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$. Let $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, x]$. The frog doesn't ne...
["import math\nm,a,b=map(int,input().split())\ng=math.gcd(a,b)\na1=a//g\nb1=b//g\nalls=g*(a1+b1-1)\ndists=[0]+[-1]*(a1+b1-1)\ndist=0\nfar=0\nwhile dist!=b1:\n if dist<b1:\n dist+=a1\n far=max(dist,far)\n else:\n dist-=b1\n if dists[dist]==-1:\n dists[dist]=far\ntot=0\nfor i in range...
{ "inputs": [ "7 5 3\n", "1000000000 1 2019\n", "100 100000 1\n", "6 4 5\n", "172165 93846 84\n", "9978 99 98615\n", "9909 95875 20\n", "42651129 26190 16875\n", "5 8253 91700\n", "14712 8142 9912\n", "98898 1040 98615\n", "79674 62280 77850\n", "78139 77688 1161\n"...
INTERVIEW
PYTHON3
CODEFORCES
6,582
e979ab4c16a25fb16771909e63b998fb
UNKNOWN
Where do odds begin, and where do they end? Where does hope emerge, and will they ever break? Given an integer sequence a_1, a_2, ..., a_{n} of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with odd numbers. A ...
["def read_ints():\n\treturn [int(i) for i in input().split()]\n\nn = read_ints()\na = read_ints()\nif len(a) % 2 and a[0] % 2 and a[-1] % 2:\n\tprint('Yes')\nelse:\n\tprint('No')", "n = int(input())\narr = list(map(int,input().split()))\nif(n%2 == 0):\n\tprint('No')\nelse:\n\tif(arr[0] % 2 == 1 and arr[-1] % 2 == 1):\...
{ "inputs": [ "3\n1 3 5\n", "5\n1 0 1 5 1\n", "3\n4 3 1\n", "4\n3 9 9 3\n", "1\n1\n", "5\n100 99 100 99 99\n", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1...
INTERVIEW
PYTHON3
CODEFORCES
4,780
73b88ff97d5fa0d5cef6e40318ae1786
UNKNOWN
Pashmak has fallen in love with an attractive girl called Parmida since one year ago... Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to the coordinate axes. He al...
["x1, y1, x2, y2 = map(int, input().split())\n#diagonal\nif x1 != x2 and y1 != y2:\n if abs(x1 - x2) == abs(y1 - y2):\n print(x1, y2, x2, y1)\n else:\n print(-1)\n#same side\nelif x1 == x2:\n aux = abs(y2 - y1)\n print(x1 + aux, y1, x1 + aux, y2)\nelif y1 == y2:\n aux = abs(x2 - x1)\n pr...
{ "inputs": [ "0 0 0 1\n", "0 0 1 1\n", "0 0 1 2\n", "-100 -100 100 100\n", "-100 -100 99 100\n", "0 -100 0 100\n", "27 -74 27 74\n", "0 1 2 3\n", "-100 100 100 -100\n", "-100 -100 -100 100\n", "100 100 100 -100\n", "100 -100 -100 -100\n", "-100 100 100 100\n", ...
INTERVIEW
PYTHON3
CODEFORCES
6,256
eb98dcfdd3acf9212da20124d2743e83
UNKNOWN
Jzzhu has invented a kind of sequences, they meet the following property:$f_{1} = x ; f_{2} = y ; \forall i(i \geq 2), f_{i} = f_{i - 1} + f_{i + 1}$ You are given x and y, please calculate f_{n} modulo 1000000007 (10^9 + 7). -----Input----- The first line contains two integers x and y (|x|, |y| ≤ 10^9). The second...
["def main():\n x, y = [int(i) for i in input().split()]\n n = int(input())\n \n result = [x, y, y - x, -x, -y, x - y][(n - 1) % 6]\n \n print(result % 1000000007)\n\n\nmain()\n", "x, y = list(map(int, input().split()))\nn = int(input())\nr = [x, y, y - x, -x, -y, x - y]\nprint(r[(n-1) % len(r)] % 100...
{ "inputs": [ "2 3\n3\n", "0 -1\n2\n", "-9 -11\n12345\n", "0 0\n1000000000\n", "-1000000000 1000000000\n2000000000\n", "-12345678 12345678\n1912345678\n", "728374857 678374857\n1928374839\n", "278374837 992837483\n1000000000\n", "-693849384 502938493\n982838498\n", "-783928374 ...
INTERVIEW
PYTHON3
CODEFORCES
5,768
2d02455319d5c1f22302decf6bdfc24c
UNKNOWN
One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays one...
["from sys import stdin\n\nn = int(input())\na = [int(x) for x in input().split()]\n\nf = False\nfor i in range(len(a)):\n if a[i] != 0:\n ln = i\n f = True\n break\nif not f:\n print('NO')\nelse:\n print('YES')\n l = 0\n i = ln + 1\n ans = []\n while i < len(a):\n if a[...
{"inputs": ["3\n1 2 -3\n", "8\n9 -12 3 4 -4 -10 7 3\n", "1\n0\n", "4\n1 2 3 -5\n", "6\n0 0 0 0 0 0\n", "7\n0 0 0 0 3 -3 0\n", "5\n0 0 -4 0 0\n", "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -38 0 0...
INTERVIEW
PYTHON3
CODEFORCES
1,173
50e4dc8ed4eeabb29c8560df3b5515aa
UNKNOWN
Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a question incorrectly,...
["MOD = 1000000009\n\nn,m,k = [int(x) for x in input().split()]\n\nnum0 = n-m\nnum1fin = num0*(k-1)\nif num1fin >= m:\n print(m)\nelse:\n num1open = m-num1fin\n sets = num1open//k\n rem = num1open%k\n print(((pow(2,sets,MOD)-1)*2*k+rem+num1fin)%MOD)\n", "n, m, k = map(int, input().split())\nmod = 1000000...
{ "inputs": [ "5 3 2\n", "5 4 2\n", "300 300 3\n", "300 282 7\n", "1000000000 1000000000 1000000000\n", "1000000000 800000000 2\n", "2 0 2\n", "2 1 2\n", "2 2 2\n", "3 2 2\n", "3 3 2\n", "10 7 3\n", "10 8 3\n", "10 8 5\n", "10 9 5\n", "972 100 2\n", ...
INTERVIEW
PYTHON3
CODEFORCES
7,729
4f5174d85a278ea77a5bbdcfec7eea4e
UNKNOWN
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes. Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-...
["n1 = input()\nn = []\nfor i in n1:\n n.append(int(i))\nk = len(n)\n\nfor i in range(k):\n if (n[i] % 8) == 0:\n print(\"YES\")\n print(n[i])\n return\n\nif k > 1:\n for i in range(k):\n t = n[i] * 10\n for j in range(i+1, k):\n if (t+n[j]) % 8 == 0:\n ...
{ "inputs": [ "3454\n", "10\n", "111111\n", "8996988892\n", "5555555555\n", "1\n", "8147522776919916277306861346922924221557534659480258977017038624458370459299847590937757625791239188\n", "8\n", "14\n", "2363\n", "3554\n", "312\n", "7674\n", "126\n", "344\n...
INTERVIEW
PYTHON3
CODEFORCES
1,706
c3f9260f803b65f7981bc66735f8874c
UNKNOWN
In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the next several flats are o...
["def floo(num, k):\n\treturn (num - 1) // k + 1\n\ndef main():\n\tn, m = map(int, input().split())\n\tlow = 1\n\thigh = 10**9\n\n\tif (m == 0):\n\t\tif (n == 1):\n\t\t\tprint(1)\n\t\telse:\n\t\t\tprint(-1)\n\t\treturn\n\n\tfor i in range(m):\n\t\tk, f = map(int, input().split())\n\t\tlow = max(low, (k + f - 1) // f)\n...
{ "inputs": [ "10 3\n6 2\n2 1\n7 3\n", "8 4\n3 1\n6 2\n5 2\n2 1\n", "8 3\n7 2\n6 2\n1 1\n", "4 2\n8 3\n3 1\n", "11 4\n16 4\n11 3\n10 3\n15 4\n", "16 6\n3 1\n16 4\n10 3\n9 3\n19 5\n8 2\n", "1 0\n", "1 1\n1 1\n", "1 1\n1 1\n", "1 2\n1 1\n2 2\n", "2 2\n2 1\n1 1\n", "2 0\n"...
INTERVIEW
PYTHON3
CODEFORCES
15,107
049f181396261ee0ed19d801400b98db
UNKNOWN
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc...
["f = []\nfor i in range(2):\n f.append(list(input()))\n\n\nanswer = 0\n\nn = len(f[0])\nfor i in range(n):\n if f[0][i] == f[1][i] == '0' and i + 1 < n:\n if f[0][i + 1] == '0':\n answer += 1\n f[0][i + 1] = 'X'\n elif f[1][i + 1] == '0':\n answer += 1\n ...
{ "inputs": [ "00\n00\n", "00X00X0XXX0\n0XXX0X00X00\n", "0X0X0\n0X0X0\n", "0XXX0\n00000\n", "0\n0\n", "0\nX\n", "X\n0\n", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
INTERVIEW
PYTHON3
CODEFORCES
18,110
d911c6c075a6ae25fbce9eccc5af4ecc
UNKNOWN
Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters. Let A be a set of positions in the string. Let's call it pretty if following conditions are met: letters on positions from A in the string are all distinct and lowercase; the...
["def list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \nn = int(input()) \na = list(input())\nans = 0\nfor i in range(n):\n\tfor j in range(i,n):\n\t\tb = a[i:j+1]\n\t\tfor k in b:\n\t\t\tif k.lower() ...
{ "inputs": [ "11\naaaaBaabAbA\n", "12\nzACaAbbaazzC\n", "3\nABC\n", "1\na\n", "2\naz\n", "200\nXbTJZqcbpYuZQEoUrbxlPXAPCtVLrRExpQzxzqzcqsqzsiisswqitswzCtJQxOavicSdBIodideVRKHPojCNHmbnrLgwJlwOpyrJJIhrUePszxSjJGeUgTtOfewPQnPVWhZAtogRPrJLwyShNQaeNsvrJwjuuBOMPCeSckBMISQzGngfOmeyfDObncyeNsihYVtQbS...
INTERVIEW
PYTHON3
CODEFORCES
8,053
8b8dd62d6dd629feea99022cea4a6ffa
UNKNOWN
You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. Let B be the sum of elements belonging to b, and C be the sum of elements belonging to c (if some of these sequences is empty, the...
["\nn=int(input())\narr= list(map(int,input().strip().split(' ')))\ns = 0\nfor i in range(n):\n s+=abs(arr[i])\nprint(s)", "n = int(input())\na = [int(v) for v in input().split()]\n\nprint(sum(abs(v) for v in a))\n", "n = int(input())\narr = list(map(int, input().split()))\nb = c = 0\nfor val in arr:\n if val >= 0...
{ "inputs": [ "3\n1 -2 0\n", "6\n16 23 16 15 42 8\n", "1\n-1\n", "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -...
INTERVIEW
PYTHON3
CODEFORCES
3,911
f998b63cd25704c4a53126815a45f5db
UNKNOWN
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
["def list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \na,b,f,k = map_input()\ntot = a*k\ns = 2*a-f\ncur = 0\ncnt = b\ngo = 0\nans = 0\nwhile cur < tot:\n\tgo = 1-go\n\tif(go == 1):\n\t\tif cnt < s and cn...
{ "inputs": [ "6 9 2 4\n", "6 10 2 4\n", "6 5 4 3\n", "2 2 1 1\n", "10 4 6 10\n", "3 1 1 1\n", "2 1 1 1\n", "1000000 51923215 2302 10000\n", "10 11 3 2\n", "20 50 10 25\n", "10 10 5 20\n", "15 65 5 50\n", "10 19 1 5\n", "10 19 9 5\n", "23 46 12 2\n", "23...
INTERVIEW
PYTHON3
CODEFORCES
25,370
5c592db4322c6ea889f48149abc44b9f
UNKNOWN
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q. For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo". Note it is allowed to split the string s to the strings only of length p or...
["a, b, c = map(int, input().split(' '))\nx = input()\nfor i in range(105):\n for j in range(105):\n if i*b+j*c == a:\n print(i+j)\n for k in range(i):\n print(x[:b])\n x = x[b:]\n for l in range(j):\n print(x[:c])\n ...
{ "inputs": [ "5 2 3\nHello\n", "10 9 5\nCodeforces\n", "6 4 5\nPrivet\n", "8 1 1\nabacabac\n", "1 1 1\n1\n", "10 8 1\nuTl9w4lcdo\n", "20 6 4\nfmFRpk2NrzSvnQC9gB61\n", "30 23 6\nWXDjl9kitaDTY673R5xyTlbL9gqeQ6\n", "40 14 3\nSOHBIkWEv7ScrkHgMtFFxP9G7JQLYXFoH1sJDAde\n", "50 16 3\n...
INTERVIEW
PYTHON3
CODEFORCES
7,127
64196a2b2431c1ed35ebc8e3f6a23467
UNKNOWN
A sportsman starts from point x_{start} = 0 and runs to point with coordinate x_{finish} = m (on a straight line). Also, the sportsman can jump — to jump, he should first take a run of length of not less than s meters (in this case for these s meters his path should have no obstacles), and after that he can jump over a...
["n, m, s, d = list(map(int, input().split()))\n\nbeg = [float('-inf')]\nend = [float('-inf')]\n\na = [int(i) for i in input().split()]\n\nfor x in sorted(a):\n\tif (x - end[-1] > s + 1):\n\t\tbeg.append(x)\n\t\tend.append(x)\n\telse:\n\t\tend[-1] = x\n\nlast = 0\nR = []\nJ = []\n\nfor i in range(1, len(beg)):\n\tR.app...
{"inputs": ["3 10 1 3\n3 4 7\n", "2 9 2 3\n6 4\n", "10 100 2 8\n93 35 24 87 39 46 86 37 73 33\n", "10 1000000000 8905990 20319560\n233244997 997992814 242452779 497363176 572234096 126615858 886769539 662035052 989086824 716655858\n", "100 1000 1 4\n228 420 360 642 442 551 940 343 24 83 928 110 663 548 704 461 942 799 ...
INTERVIEW
PYTHON3
CODEFORCES
14,481
6169041378baaaca74fcd6cab414037f
UNKNOWN
Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)? -----Input----- The first line of the input contains two integers s and x (2 ≤ s ≤ 10^12, 0 ≤ x ≤ 10^12), the sum and bitwise xor of the pair of positive integers, respectively. ---...
["s, x = list(map(int, input().split()))\nrem = int(s == x) * 2\np, t, cur = [], 0, 1\nfor i in range(64):\n if x % 2:\n t += 1\n s -= cur\n else:\n p.append(cur * 2)\n cur *= 2\n x //= 2\nfor i in p[::-1]:\n if s >= i: s -= i\nans = 0 if s else 2 ** t - rem\nprint(ans)\n", "def o(s,...
{ "inputs": [ "9 5\n", "3 3\n", "5 2\n", "6 0\n", "549755813887 549755813887\n", "2 0\n", "2 2\n", "433864631347 597596794426\n", "80 12\n", "549755813888 549755813886\n", "643057379466 24429729346\n", "735465350041 356516240229\n", "608032203317 318063018433\n", ...
INTERVIEW
PYTHON3
CODEFORCES
10,657
c03fe71917580f874de7bc5edc0a956e
UNKNOWN
Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over. This time Miroslav laid out $n$ skewers parallel to each other, and enumerated them with consecutive integers from $1$ to $n$ in order from left...
["n, k = map(int, input().split())\nif n <= k + k + 1:\n print(1)\n print((n + 1) // 2)\nelse:\n answer = -1\n answer_n = 10**100\n for i in range(min(k + 1, n)):\n t = n - (k + i + 1)\n if t % (k + k + 1) >= k + 1:\n if 2 + t // (k + k + 1) < answer_n:\n answer = ...
{"inputs": ["7 2\n", "5 1\n", "10 0\n", "10 1\n", "10 10\n", "11 10\n", "100 2\n", "100 200\n", "1000 1000\n", "1000 31\n", "1 0\n", "2 0\n", "3 0\n", "4 0\n", "5 0\n", "15 0\n", "153 0\n", "1 1\n", "2 1\n", "3 1\n", "4 1\n", "5 1\n", "15 1\n", "153 1\n", "1 2\n", "2 2\n", "3 2\n", "4 2\n", "5 2\n", "15 2\n", "153 2\n"...
INTERVIEW
PYTHON3
CODEFORCES
9,645
c2030299eb2415d2d61bcd13fd545be8
UNKNOWN
You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect). In one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros. Determine the minimum number of operations that you need to consistently ...
["ar=[]\nfor i in range(1,10**5):\n if(i*i>2*10**9):break\n ar.append(i*i)\ns=input()\nans=len(s)\nfor x in ar:\n s2=str(x)\n i=0\n for x in range(len(s)):\n if i<len(s2) and s[x]==s2[i]:\n i+=1\n if(i==len(s2)):\n ans=min(ans,len(s)-i)\nif(ans==len(s)):\n print(-1)\nelse:\...
{ "inputs": [ "8314\n", "625\n", "333\n", "1881388645\n", "1059472069\n", "1354124829\n", "149723943\n", "101\n", "1999967841\n", "2000000000\n", "1999431225\n", "30\n", "1000\n", "3081\n", "10\n", "2003064\n", "701\n", "1234567891\n", "10625...
INTERVIEW
PYTHON3
CODEFORCES
11,604
57fa9fca9d5ed0c1579541d913354061
UNKNOWN
Let's define a function $f(p)$ on a permutation $p$ as follows. Let $g_i$ be the greatest common divisor (GCD) of elements $p_1$, $p_2$, ..., $p_i$ (in other words, it is the GCD of the prefix of length $i$). Then $f(p)$ is the number of distinct elements among $g_1$, $g_2$, ..., $g_n$. Let $f_{max}(n)$ be the maximum...
["p=10**9+7\nimport math\ndef inv(k,p):\n prod=1\n while k>1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)...
{ "inputs": [ "2\n", "3\n", "6\n", "10\n", "64\n", "1227\n", "49152\n", "1000000\n", "524288\n", "786431\n", "999999\n", "217292\n", "16339\n", "4\n", "5\n", "7\n", "8\n", "9\n", "50\n", "87\n", "71\n", "73\n", "89\n", "40...
INTERVIEW
PYTHON3
CODEFORCES
5,444
db5ac3288269a02192f0c507612be1e5
UNKNOWN
Dawid has four bags of candies. The $i$-th of them contains $a_i$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total? Note, that you can't keep bags for yourself or ...
["l=list(map(int,input().split()))\nfor i in range(16):\n cur1,cur2=0,0\n for j in range(4):\n if (i&(1<<j))==0:\n cur1+=l[j]\n else:\n cur2+=l[j]\n if cur1==cur2:\n print(\"YES\")\n quit()\nprint(\"NO\")", "arr=list(map(int,input().split()))\narr.sort()\nif(ar...
{ "inputs": [ "1 7 11 5\n", "7 3 2 5\n", "3 14 36 53\n", "30 74 41 63\n", "92 69 83 97\n", "26 52 7 19\n", "72 52 62 62\n", "1 1 1 1\n", "70 100 10 86\n", "14 10 18 24\n", "20 14 37 71\n", "1 1 2 1\n", "2 4 1 1\n", "34 11 84 39\n", "76 97 99 74\n", "44 5...
INTERVIEW
PYTHON3
CODEFORCES
7,720
cdc3fce91ef35b412457256b14611494
UNKNOWN
You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be ...
["n = int(input())\na = list(map(int, input().split()))\na = a[::-1]\nd = 0\nfor i in range(len(a)):\n d = max(0 + d, a[i] + (sum(a[:i]) - d))\nprint(sum(a)-d, d)\n", "n = int(input())\nX = list(map(int, input().split()))\n\nali = [None]*(n+1)\nbob = [None]*(n+1)\n\nali[n] = 0\nbob[n] = 0\n\nfor i in range(n-1, -1, ...
{ "inputs": [ "3\n141 592 653\n", "5\n10 21 10 21 10\n", "1\n100000\n", "50\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 1...
INTERVIEW
PYTHON3
CODEFORCES
10,405
195d23fed877c85c552bf3acf37fcd41
UNKNOWN
You've got a positive integer sequence a_1, a_2, ..., a_{n}. All numbers in the sequence are distinct. Let's fix the set of variables b_1, b_2, ..., b_{m}. Initially each variable b_{i} (1 ≤ i ≤ m) contains the value of zero. Consider the following sequence, consisting of n operations. The first operation is assigning...
["def Solve(x,B):\n if((X,x,B) in Mem):\n return Mem[(X,x,B)]\n if(len(B)>X):\n return False\n if(x==len(L)):\n return True\n if(Form(L[x],B)):\n A=list(B)\n for e in range(len(B)):\n r=A[e]\n A[e]=L[x]\n if(Solve(x+1,tuple(sorted(A)))):\n ...
{ "inputs": [ "5\n1 2 3 6 8\n", "3\n3 6 5\n", "6\n2 4 8 6 10 18\n", "7\n1 2 4 5 3 6 7\n", "10\n11 22 44 88 132 264 66 33 165 55\n", "10\n201 402 804 603 1608 2010 1206 2412 4824 2211\n", "16\n92 184 368 276 552 1104 1196 736 1472 1288 1012 2576 5152 1840 3680 1656\n", "18\n8478 16956 3...
INTERVIEW
PYTHON3
CODEFORCES
937
387fa09a40d96d076afebadb86aa5fbb
UNKNOWN
Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly $\frac{n}{2}$ nonempty piles and independently remove a positi...
["n=int(input())\ns=list(map(int,input().split()))\nprint(\"Bob\"if s.count(min(s))>n/2 else\"Alice\")\n", "def judge(i):\n return \"Bob\" if cnt[i]>n//2 else \"Alice\"\nn=int(input())\na=list(map(int,input().split()))\ncnt=[0 for i in range(51)]\nfor i in a:\n cnt[i]+=1\nprint(judge(min(a)))", "n = int(input())\...
{ "inputs": [ "2\n8 8\n", "4\n3 1 4 1\n", "4\n42 49 42 42\n", "8\n11 21 31 41 41 31 21 11\n", "10\n21 4 7 21 18 38 12 17 21 13\n", "12\n33 26 11 11 32 25 18 24 27 47 28 7\n", "14\n4 10 7 13 27 28 13 34 16 18 39 26 29 22\n", "16\n47 27 33 49 2 47 48 9 37 39 5 24 38 38 4 32\n", "18\n...
INTERVIEW
PYTHON3
CODEFORCES
2,596
672a8b52e8f54d07a9b4b6ca47a733a2
UNKNOWN
Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x and then he adds x to some elements of the array (no more than once), subtra...
["read = lambda: list(map(int, input().split()))\nn = int(input())\na = list(read())\ns = set()\nfor i in a:\n s.add(i)\nf1 = len(s) < 3\nf2 = len(s) == 3 and max(s) + min(s) == 2 * sorted(s)[1]\nprint('YES' if f1 or f2 else 'NO')\n", "n = int(input())\na = map(int, input().split())\nb = set(a)\nif len(b) <= 2:\n\tp...
{ "inputs": [ "5\n1 3 3 2 1\n", "5\n1 2 3 4 5\n", "2\n1 2\n", "3\n1 2 3\n", "3\n1 1 1\n", "2\n1 1000000000\n", "4\n1 2 3 4\n", "10\n1 1 1 1 1 2 2 2 2 2\n", "2\n4 2\n", "4\n1 1 4 7\n", "3\n99999999 1 50000000\n", "1\n0\n", "5\n0 0 0 0 0\n", "4\n4 2 2 1\n", "3...
INTERVIEW
PYTHON3
CODEFORCES
8,814
1044fb647933dba4a780fb58e8612d03
UNKNOWN
Given is a string S of length N. Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping. More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following: - ...
["n = int(input())\ns = input()\nj = 1\nresult = []\nfor i in range(n):\n while (j < n-1) and (s[i:j] in s[j:]):\n j += 1\n result.append(j-i-1)\nprint(max(result))", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n...
{"inputs": ["5\nababa\n", "2\nxy\n", "13\nstrangeorange\n", "5000\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
INTERVIEW
PYTHON3
ATCODER.JP
97,992