problem_id
int64
0
4.75k
question
stringlengths
146
5.9k
solutions
stringlengths
181
1.12M
input_output
stringlengths
236
35.4M
difficulty
stringclasses
3 values
url
stringlengths
47
54
starter_code
stringclasses
158 values
num_tests
int64
16
16
76
Berland Football Cup starts really soon! Commentators from all over the world come to the event. Organizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations wil...
["n, m, a, b = list(map(int, input().split()))\n\nk = n%m\nprint(min(k*b, (m - k)*a))\n", "n,m,a,b=list(map(int,input().split()))\nprint(min((n%m)*b,(m-(n%m))*a))\n", "(n, m, a, b) = list(map(int, input().split()))\n\nif n % m == 0:\n print(0)\nelse:\n k1 = n % m\n k2 = m - k1\n print(min(k1 * b, k2 * a))\n...
{"inputs": ["500000000001 1000000000000 100 100\n", "1000000000000 750000000001 100 10\n", "1 1000000000000 1 100\n", "999999999999 10000000007 100 100\n", "10000000001 2 1 1\n", "10000000000 1 1 1\n", "100 3 3 8\n", "100 3 5 2\n", "10 3 10 1\n", "1000000000000 6 1 3\n", "19 10 100 100\n", "1000000000000 2 1 1\n", "13 ...
interview
https://codeforces.com/problemset/problem/990/A
16
77
You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum. Subsequence is a sequence that can be derived from another sequence by de...
["n = int(input())\na = list(map(int, input().split()))\nres = 0\nnew_a = []\nfor i in range(n):\n if a[i] % 2 == 0:\n if a[i] > 0:\n res += a[i]\n else:\n new_a.append(a[i])\na = new_a\na.sort()\nres += a[-1]\na.pop()\nwhile len(a) > 1:\n if a[-1] + a[-2] > 0:\n res += a[-1] + ...
{"inputs": ["4\n-2 2 -3 1\n", "3\n2 -5 -3\n", "59\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895...
interview
https://codeforces.com/problemset/problem/797/B
16
78
The only difference between easy and hard versions is constraints. Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in exactly $T$ minutes. In the player, Polycarp stores $n$ songs, each of whic...
["from math import factorial\n\n\ndef lol(n):\n if n == 1:\n yield [0]\n yield [1]\n else:\n for p in lol(n - 1):\n p.append(0)\n yield p\n p[-1] = 1\n yield p\n p.pop()\n\n\ndef sp(g1, g2, g3, f):\n if g1 == 0:\n if g2 == g3:\n...
{"inputs": ["1 15\n15 1\n", "2 4\n1 3\n1 2\n", "15 15\n1 1\n1 1\n1 1\n1 1\n1 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 3\n1 3\n1 3\n1 3\n1 3\n", "4 3\n1 2\n1 1\n1 2\n1 2\n", "5 1\n1 3\n1 3\n1 1\n1 2\n1 3\n", "5 2\n1 2\n1 3\n1 1\n1 1\n1 3\n", "5 3\n3 1\n2 2\n2 2\n3 1\n2 1\n", "5 4\n1 2\n1 3\n1 1\n1 1\n1 3\n", "15 10\n1 1\n1 2\n1 1\...
interview
https://codeforces.com/problemset/problem/1185/G1
16
79
Vivek initially has an empty array $a$ and some integer constant $m$. He performs the following algorithm: Select a random integer $x$ uniformly in range from $1$ to $m$ and append it to the end of $a$. Compute the greatest common divisor of integers in $a$. In case it equals to $1$, break Otherwise, return to ste...
["big = 100010\ndef gen_mu():\n mu = [1]*big\n mu[0] = 0\n P = [True]*big\n P[0] = P[1] = False\n for i in range(2,big):\n if P[i]:\n j = i\n while j<big:\n P[j] = False\n mu[j] *= -1\n j += i\n j = i*i\n whil...
{"inputs": ["1\n", "6\n", "8\n", "64\n", "2048\n", "14\n", "15\n", "677\n", "29019\n", "88439\n", "74792\n", "22799\n", "41764\n", "99945\n", "55311\n", "77385\n"], "outputs": ["1\n", "500000006\n", "476190482\n", "572467262\n", "665668016\n", "966666676\n", "553571435\n", "948537108\n", "963174399\n", "567687036\n", "...
interview
https://codeforces.com/problemset/problem/1139/D
16
80
Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well. We define a pair of integers (a, b) good, if GCD(a, b) = x and LCM(a, b) = y, where GCD(a, b) denotes the greatest common...
["from math import sqrt\nfrom fractions import gcd\nl, r, x, y = list(map(int, input().split()))\nif y % x != 0:\n print(0)\n return\nlo = (l + x - 1) // x\nhi = r // x\np = y // x\ns = 0\n\nk1 = 1\nwhile k1 * k1 <= p:\n k2 = p // k1\n if lo <= k1 <= hi and lo <= k2 <= hi and gcd(k1, k2) == 1 and k1 * k2 ==...
{"inputs": ["50 100 3 30\n", "1 1000000000 1 1000000000\n", "1 1000000000 158260522 200224287\n", "1 1000000000 1 682290000\n", "1 1000000000 1 800280000\n", "2193 4224517 17 544962693\n", "100 1000000000 158260522 158260522\n", "1 1000000000 18470 112519240\n", "1 1000000000 33409 694005157\n", "2354 369467362 1177 73...
interview
https://codeforces.com/problemset/problem/992/B
16
81
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher. Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ is the smallest possible. If there are multiple optimal integers $k...
["from math import gcd\na, b = list(map(int, input().split()))\nif b < a:\n a, b = b, a\nif a == b:\n print(0)\n return\nc = b - a\ni = 1\nans = a * b // gcd(a, b)\n\ndef get(x):\n A = (a + x - 1) // x * x\n B = A - a + b\n return A * B // gcd(A, B), A\n\nr = 0\nwhile i * i <= c:\n if c % i == 0:\n...
{"inputs": ["1000000000 1000000000\n", "588854730 468415815\n", "21184942 66889\n", "34504222 65532\n", "480432805 79482\n", "5 18\n", "18 102\n", "21 1\n", "350089529 67401533\n", "173726711 47100867\n", "49160468 106133716\n", "882561035 53440816\n", "844002269 45400923\n", "823409948 63146277\n", "997908364 24058927...
interview
https://codeforces.com/problemset/problem/1152/C
16
82
Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one. In school, where Noora is studying, teachers are putting down marks to the online class register, wh...
["n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\ns = sum(a)\nans = 0\nc = k - 0.5\nwhile s / n < c:\n s += k\n n += 1\n ans += 1\nprint(ans)\n", "n, k = list(map(int, input().split(' ')))\nl = list(map(int, input().split(' ')))\n\ns = sum(l)\ntotal = len(l)\nres = 0\nwhile s < tot...
{"inputs": ["68 29\n29 29 29 29 29 28 29 29 29 27 29 29 29 29 29 29 29 23 29 29 26 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 26 29 29 29 29 29 29 29 29 29 29 29 29 22 29 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 29 29\n", "78 43\n2 7 6 5 5 6 4 5 3 4 6 8 4 5 5 4 3 1 2 4 4 6 5 6 4 4 6 4 8 4 6 5 6 1 4 5 6 3 2 5 2 5 ...
interview
https://codeforces.com/problemset/problem/810/A
16
83
You are given an array of $n$ integers: $a_1, a_2, \ldots, a_n$. Your task is to find some non-zero integer $d$ ($-10^3 \leq d \leq 10^3$) such that, after each number in the array is divided by $d$, the number of positive numbers that are presented in the array is greater than or equal to half of the array size (i.e.,...
["n=int(input())\nar=list(map(int,input().split()))\npos=0\nneg=0\nfor a in ar:\n if(a>0):pos+=1\n elif a<0:neg+=1\nif(pos*2>=n):\n print(1)\nelif neg*2>=n:\n print(-1)\nelse:\n print(0)\n", "n = int(input())\na = list(map(int, input().split()))\np = o = 0\nfor i in a:\n if i > 0:\n p += 1\n ...
{"inputs": ["7\n0 0 1 -1 0 0 2\n", "5\n0 0 0 1 1\n", "2\n1 0\n", "100\n-218 113 -746 -267 498 408 116 756 -793 0 -335 -213 593 -467 807 -342 -944 13 637 -82 -16 860 -333 -94 409 -149 -79 -431 -321 974 148 779 -860 -992 -598 0 -300 285 -187 404 -468 0 -586 875 0 0 -26 366 221 -759 -194 -353 -973 -968 -539 0 925 -223 -47...
interview
https://codeforces.com/problemset/problem/1130/A
16
84
There are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs. Visitors are more likely to buy a pair of shovels if their total cost ends with severa...
["from sys import stdin as cin\nfrom sys import stdout as cout\n\ndef main():\n n = int(cin.readline())\n o = 0\n for x in range(9, 0, -1):\n if 10 ** x // 2 <= n:\n ##print(x)\n for i in range(9):\n q = 10 ** x * (i + 1) // 2 - 1\n if q <= n:\n ...
{"inputs": ["13\n", "18\n", "24\n", "41\n", "48\n", "51\n", "4998\n", "10001\n", "9999\n", "764675465\n", "641009859\n", "219396918\n", "335521569\n", "808572289\n", "109054817\n", "248004555\n"], "outputs": ["8\n", "17\n", "28\n", "84\n", "116\n", "2\n", "12491\n", "5001\n", "4999\n", "264675466\n", "141009860\n", "23...
interview
https://codeforces.com/problemset/problem/899/D
16
85
Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a_1 × b_1 segments large and the second one is a_2 × b_2 segments large. Polycarpus wants to give Paraskevi one of the bars at the lunch break and eat the other one him...
["a,b=list(map(int,input().split()))\nc,d=list(map(int,input().split()))\ne=a*b\nf=c*d\nn=0\nwhile e%2==0:e=e//2\nwhile e%3==0:e=e//3\nwhile f%2==0:f=f//2\nwhile f%3==0:f=f//3\nif e!=f:print(\"-1\")\nelse:\n i=0\n j=0\n e=a*b\n f=c*d\n while e%3==0:\n e=e//3\n i+=1\n while f%3==0:\n f=f//3\n ...
{"inputs": ["3 5\n2 1\n", "432000 3000\n4800 10000\n", "12 39\n13 3\n", "644972544 886837248\n725594112 886837248\n", "10000 100000\n2 1000000000\n", "1920 50000000\n78125 25600\n", "3 540004266\n60000474 27\n", "859963392 816293376\n967458816 859963392\n", "199999978 2\n599999934 3\n", "144694977 881159765\n80372825 4...
interview
https://codeforces.com/problemset/problem/490/D
16
86
Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x, y) to one of cells: ...
["a, b, x, y = map(int, input().split())\nif a >= x:\n if b >= y:\n print('Vasiliy')\n else:\n z = y - b\n t = max(x - z, 0)\n if a - z <= t:\n print('Polycarp')\n else:\n print('Vasiliy')\nelse:\n if b <= y:\n print('Polycarp')\n else:\n ...
{"inputs": ["0 100000 100000 99999\n", "0 1 0 2\n", "0 2 2 0\n", "0 2 2 1\n", "2 0 0 1\n", "2 0 2 1\n", "2 1 0 1\n", "2 1 1 2\n", "32959 49970 75441 55257\n", "91573 91885 61527 58038\n", "67603 35151 67603 39519\n", "36711 38307 75018 72040\n", "7591 24141 31732 23276\n", "5 0 0 4\n", "4 5 5 5\n", "0 3 2 2\n"], "outpu...
interview
https://codeforces.com/problemset/problem/532/C
16
87
Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: $\left. \begin{...
["import sys\narr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\na, b = list(map(int, input().split()))\na -= 1\nb -= 1\nctr = 1\nfor i in range(arr[a] - 1):\n b += 1\n if (b == 7):\n b = 0\n ctr += 1\nprint(ctr)\n \n", "def main():\n\tm, d = map(int, input().split())\n\ta = [31, 28,...
{"inputs": ["1 7\n", "2 3\n", "2 6\n", "2 7\n", "4 4\n", "5 2\n", "5 4\n", "5 5\n", "7 3\n", "7 6\n", "7 7\n", "11 4\n", "12 3\n", "12 6\n", "3 6\n", "6 6\n"], "outputs": ["6\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "6\n", "6\n", "5\n", "5\n", "6\n", "6\n", "5\n"]}
interview
https://codeforces.com/problemset/problem/760/A
16
88
The year 2015 is almost over. Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 2015_10 = 11111011111_2. Note that he doesn't care about the number of zeros in the decimal representation. Lim...
["def zero(strx):\n k = []\n str2 = list(strx)\n for i in range(1, len(str2)):\n str3 = str2[:]\n str3[i] = '0'\n k.append(''.join(str3))\n return k\na = []\nfor i in range(1, 64):\n a += zero('1'*i)\n\nct = 0\nx, y = list(map(int, input().split(' ')))\nfor i in a:\n if x <= int(i...
{"inputs": ["5 10\n", "1 1\n", "2 6\n", "2 7\n", "4 5\n", "6 6\n", "1 1023\n", "511 1022\n", "509 1023\n", "511 1023\n", "512 1023\n", "1 1000000000\n", "1 287104476244869119\n", "1099444518910 1099444518911\n", "864691128455135232 1000000000000000000\n", "1 576460752303423486\n"], "outputs": ["2\n", "0\n", "3\n", "3\n...
interview
https://codeforces.com/problemset/problem/611/B
16
89
You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be $\frac{n(n + 1)}{2}$ of them. You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touc...
["n=int(input())\nprint(max((i+1)*(n-i)for i in range(n)))\n", "n = int(input())\n\na = (n + 1) // 2\nb = (n + 2) // 2\n\nprint(a * b)", "import sys\nn = int(input())\nans = 0\nwhile n > 0:\n ans += n\n n -= 2\nprint(ans)\n", "n = int(input())\nans = 0\nif(n % 2 == 0):\n\tans += (n//2) * (n//2+1)\nelse:\n\tans +=...
{"inputs": ["2\n", "5\n", "36\n", "45\n", "48\n", "49\n", "58\n", "59\n", "61\n", "67\n", "68\n", "75\n", "88\n", "93\n", "95\n", "98\n"], "outputs": ["2\n", "9\n", "342\n", "529\n", "600\n", "625\n", "870\n", "900\n", "961\n", "1156\n", "1190\n", "1444\n", "1980\n", "2209\n", "2304\n", "2450\n"]}
interview
https://codeforces.com/problemset/problem/909/B
16
90
Anya loves to fold and stick. Today she decided to do just that. Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that the number of stickers does not exceed the number of cubes. Anya can stick a...
["fact = [ 1 ]\nfor i in range( 1, 20, 1 ):\n fact.append( fact[ i - 1 ] * i )\n\nfrom collections import defaultdict\n\nN, K, S = list(map( int, input().split() ))\nA = list( map( int, input().split() ) )\n\nldp = [ [ defaultdict( int ) for i in range( K + 1 ) ] for j in range( 2 ) ]\nldp[ 0 ][ 0 ][ 0 ] = 1\nfor i in...
{"inputs": ["8 7 169\n4 3 4 3 5 5 2 5\n", "1 0 384338286\n384338286\n", "25 15 38\n2 1 2 1 1 2 1 2 1 2 1 1 2 2 2 2 2 1 1 1 2 1 2 1 2\n", "25 19 6402373705728432\n18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18\n", "25 19 2000000023\n1000000000 1000000000 1 1 2 1 1 1 2 1 1 1 2 1 2 1 2 1 2 1 2 ...
interview
https://codeforces.com/problemset/problem/525/E
16
91
Suppose you are performing the following algorithm. There is an array $v_1, v_2, \dots, v_n$ filled with zeroes at start. The following operation is applied to the array several times — at $i$-th step ($0$-indexed) you can: either choose position $pos$ ($1 \le pos \le n$) and increase $v_{pos}$ by $k^i$; or not choo...
["t = int(input())\nfor _ in range(t):\n n,k = list(map(int,input().split()))\n a = list(map(int,input().split()))\n for i in range(60, -1, -1):\n m = k ** i\n for j in range(n):\n if a[j] >= m:\n a[j] -= m\n break\n if all(i == 0 for i in a):\n ...
{"inputs": ["1\n1 10\n10000000000000000\n", "1\n23 100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23\n", "1\n1 16\n1000\n", "1\n1 3\n6\n", "1\n28 2\n281474976710656 0 281474976710656 70368752566272 2251799814733824 33554432 0 352118598795264 17600775979008 134217728 0 34359738368 0 1125900175278208 0 274...
interview
https://codeforces.com/problemset/problem/1312/C
16
92
Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum: $\sum_{i = 1}^{a} \sum_{j = 1}^{b} \sum_{k = 1}^{c} d(i \cdot j \cdot k)$ Find the sum modulo 1073741824 (2^30). -----Input----- The first line contains three s...
["a, b, c = map(int, input().split())\nd = 1073741824\np = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\nt = [{} for i in range(101)]\nans = {}\nfor i in p:\n j = i\n m = 1\n while j < 101:\n for k in range(j, 101, j):\n t[k][i] = m\n ...
{"inputs": ["5 6 7\n", "76 12 17\n", "72 16 41\n", "53 29 17\n", "21 22 100\n", "4 21 45\n", "53 31 5\n", "41 28 36\n", "98 34 100\n", "85 25 20\n", "27 99 28\n", "58 83 7\n", "16 18 99\n", "36 3 32\n", "68 14 28\n", "9 76 83\n"], "outputs": ["1520\n", "330197\n", "1309118\n", "621991\n", "1274891\n", "58045\n", "14483...
interview
https://codeforces.com/problemset/problem/236/B
16
93
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 × 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a move, Bessie or Elsie can slide a tile adjacent to the empty cell into the em...
["a, b, c, d = input(), input(), input(), input()\na = a + b[::-1]\nx = \"X\"\nfor i in range(4):\n if a[i] == x:\n a = a[:i] + a[i + 1:]\n break\nc = c + d[::-1]\n\nfor i in range(4):\n if c[i] == x:\n c = c[:i] + c[i + 1:]\n break\nflag = False\nfor i in range(4):\n if a == c:\n ...
{"inputs": ["AB\nXC\nAB\nCX\n", "XB\nAC\nBX\nAC\n", "CX\nBA\nAX\nBC\n", "XB\nCA\nXC\nBA\n", "AC\nXB\nCX\nBA\n", "AB\nCX\nXA\nBC\n", "XA\nBC\nCB\nAX\n", "AB\nCX\nXB\nAC\n", "AC\nBX\nCB\nAX\n", "AX\nCB\nCX\nAB\n", "XB\nCA\nBC\nXA\n", "CA\nXB\nXB\nCA\n", "BA\nCX\nBA\nXC\n", "XC\nBA\nBX\nCA\n", "XC\nAB\nBC\nXA\n", "AC\nXB\...
interview
https://codeforces.com/problemset/problem/645/A
16
94
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
["n=int(input())\ns=input()\npw=[1]\nlast=1\nfor i in range(70):\n if (last>1e19):\n break\n pw.append(last*n)\n last=last*n\ndp=[1e19]*100\nfor i in range(100):\n dp[i]=[1e19]*100\ndp[len(s)][0]=0\nfor i in range(len(s),-1,-1):\n for power in range(0,len(pw)):\n cur=''\n for j in ra...
{"inputs": ["17\n2016\n", "9\n1733607167155630041\n", "23\n12007622911918220\n", "23156\n27612518525717145\n", "7982154\n129530518193255487\n", "13568864\n2513398972677784\n", "1000000000\n7289468142097485\n", "442020\n13825031303078\n", "1740798\n321470190942028\n", "158\n25832612364\n", "2707\n11341512\n", "124849\n6...
interview
https://codeforces.com/problemset/problem/758/D
16
95
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent. For example, the following three arrays a...
["n = int(input())\nL = list(map(int, input().split()))\ni = 0\na = 0\nwhile i < n and L[i] > a:\n a = L[i]\n i += 1\nwhile i < n and L[i] == a:\n i += 1\nwhile i < n and L[i] < a:\n a = L[i]\n i += 1\nif i == n:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n = int(input())\na = list(map(int, input...
{"inputs": ["5\n10 20 30 20 10\n", "4\n1 2 1 2\n", "3\n516 516 515\n", "100\n524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524...
interview
https://codeforces.com/problemset/problem/831/A
16
96
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$ We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an...
["def gg(n,lol):\n\tans = 0\n\tcur = 1\n\tlol2 = lol\n\twhile(2*lol+1<=n):\n\t\tcur *= 2\n\t\tans += cur\n\t\tlol = 2*lol+1\n\t\tlol2 *= 2\n\tif lol2*2 <= n:\n\t\tans += n-lol2*2+1\t\n\treturn ans\n\nn,k = list(map(int,input().split()))\nlow = 1\nhigh = n//2\nres = 1\nwhile low <= high:\n\tmid = (low+high)//2\n\tif gg(...
{"inputs": ["14 5\n", "773014587697599 31\n", "946338791423 262143\n", "766540997167959122 81305011918141103\n", "1000000000000000000 100000000000\n", "771498451941492370 9554452753411241\n", "996517375802030514 562680741796166004\n", "743462629930971375 185994815084963322\n", "744288873109054799 87172378778063481\n", ...
interview
https://codeforces.com/problemset/problem/1271/E
16
97
Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image] There is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. The ball starts moving along a line tha...
["def INV(a, m) :\n m0 = m\n y = 0\n x = 1 \n if (m == 1) :\n return 0 \n while (a > 1) : \n q = a // m \n t = m \n m = a % m\n a = t\n t = y \n y = x - q * y\n x = t\n if (x < 0) :\n x = x + m0 \n return x\ndef GCD(a, b):\n if a == 0:...
{"inputs": ["5 3 4 3 1 -1\n", "15 9 3 2 1 1\n", "6 10 1 1 1 1\n", "682138812 116415655 516825996 73682791 -1 1\n", "313157692 571680270 238352863 235464142 1 -1\n", "120717601 973035857 103171773 511250918 -1 1\n", "827285013 307724101 775951207 175683367 -1 -1\n", "68076815 985943633 40657983 165191148 1 -1\n", "20940...
interview
https://codeforces.com/problemset/problem/982/E
16
98
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a_1 × b_1 rectangle, the paintings have shape of a a_2 × b_2 and a_3 × b_3 rectangles. Si...
["a, b = [int(i) for i in input().split()]\nc, d = [int(i) for i in input().split()]\ne, f = [int(i) for i in input().split()]\nif c+e <=a and max(d,f) <=b:\n print(\"YES\")\nelif c+e <=b and max(d,f) <=a:\n print(\"YES\")\nelif c+f <=a and max(d,e) <=b:\n print(\"YES\")\nelif c+f <=b and max(d,e) <=a:\n pr...
{"inputs": ["1000 1000\n999 999\n1 1000\n", "8 10\n3 8\n7 4\n", "8 9\n7 6\n2 3\n", "90 100\n52 76\n6 47\n", "100 100\n6 45\n97 54\n", "91 100\n61 40\n60 88\n", "965 1000\n606 895\n533 394\n", "824 503\n247 595\n151 570\n", "541 1000\n325 596\n403 56\n", "993 1000\n201 307\n692 758\n", "3 5\n3 6\n10 7\n", "3 3\n3 4\n3 6...
interview
https://codeforces.com/problemset/problem/560/B
16
99
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise. You are given geometric progression b defined by two integers b_1 and q. Remind that a geometric progression is a sequence of integers b_1, b_2, b_3, ..., where for each i > 1 the respective term satisfies the condition b...
["def main():\n (b1, q, l, m) = list(map(int, input().split()))\n a = set(map(int, input().split()))\n if abs(b1) > l:\n print(0)\n else:\n if b1 == 0:\n if 0 in a:\n print(0)\n else:\n print(\"inf\")\n elif q == 0:\n if 0 n...
{"inputs": ["3 2 30 4\n6 14 25 48\n", "3 3 104 17\n9 -73896485 -290898562 5254410 409659728 -916522518 -435516126 94354167 262981034 -375897180 -80186684 -173062070 -288705544 -699097793 -11447747 320434295 503414250\n", "2 2 4 1\n2\n", "0 5 100 2\n34 56\n", "4 0 4 1\n0\n", "3 2 3 4\n6 14 25 48\n", "0 4 1 1\n2\n", "-20...
interview
https://codeforces.com/problemset/problem/789/B
16
100
Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his younger brother Polycarpus. Innocentius is touch-typing a program that pain...
["3\n\ndef readln(): return list(map(int, input().split()))\nimport sys\ndef return:\n print(-1)\n return\n\nn, m = readln()\nmon = [list(input()) for _ in range(n)]\nhor = [i for i in range(n) if mon[i] != ['.'] * m]\nrmon = list(zip(*mon))\nver = [j for j in range(m) if rmon[j] != ('.',) * n]\nmini = hor[0]\nma...
{"inputs": ["9 4\n....\n....\n....\n....\n....\n..w.\n....\n....\n.w..\n", "1 1\nw\n", "2 2\n..\nww\n", "4 6\nw...w.\n......\n......\n.w....\n", "7 3\n...\n...\n...\n..w\n...\nw..\n...\n", "7 3\n...\n...\n...\n.w.\nw.w\nw..\n...\n", "1 7\nw.....w\n", "8 10\n..........\n..........\n.....w....\n.w........\n..........\n.....
interview
https://codeforces.com/problemset/problem/370/D
16
101
Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars. Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly n burles. I...
["def egcd(a, b):\n x,y, u,v = 0,1, 1,0\n while a != 0:\n q, r = b//a, b%a\n m, n = x-u*q, y-v*q\n b,a, x,y, u,v = a,r, u,v, m,n\n gcd = b\n return gcd, x, y\n\n\nimport math\nn=int(input())\na=int(input())\nb=int(input())\ngcd,x,y=(egcd(a,b))\n\n\nstatus=0\nif((n%gcd)!=0):\n print(\...
{"inputs": ["7\n2\n3\n", "100\n25\n10\n", "7817510\n2377\n743\n", "100\n10\n20\n", "10000000\n1234523\n1\n", "10000000\n10000000\n10000000\n", "81090\n527\n614\n", "9366189\n4326262\n8994187\n", "4\n7\n3\n", "1000000\n3\n7\n", "100\n1\n1000000\n", "10000000\n2\n9999999\n", "10000000\n3\n3\n", "3\n2\n17\n", "7005920\n57...
interview
https://codeforces.com/problemset/problem/898/B
16
102
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words. [Image] He ate coffee mi...
["n = int(input())\nif n == 0:\n\tprint('zero')\nelif n == 1:\n\tprint('one')\nelif n == 2:\n\tprint('two')\nelif n == 3:\n\tprint('three')\nelif n == 4:\n\tprint('four')\nelif n == 5:\n\tprint('five')\nelif n == 6:\n\tprint('six')\nelif n == 7:\n\tprint('seven')\nelif n == 8:\n\tprint('eight')\nelif n == 9:\n\tprint('...
{"inputs": ["27\n", "63\n", "19\n", "30\n", "47\n", "31\n", "41\n", "44\n", "58\n", "64\n", "67\n", "79\n", "81\n", "96\n", "97\n", "5\n"], "outputs": ["twenty-seven\n", "sixty-three\n", "nineteen\n", "thirty\n", "forty-seven\n", "thirty-one\n", "forty-one\n", "forty-four\n", "fifty-eight\n", "sixty-four\n", "sixty-sev...
interview
https://codeforces.com/problemset/problem/535/A
16
103
JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \le a_1 < a_2 < \ldots < a_n \le 10^3$, and then went to the bathroom. JATC decided to prank his friend by erasing some consecutive elements in th...
["n = int(input())\na = [0] + list(map(int, input().split())) + [1001]\nmx = 1\np = 1\nfor i in range(1, n + 2):\n if a[i] == a[i - 1] + 1:\n p += 1\n mx = max(p, mx)\n else:\n p = 1\nprint(max(0, mx - 2))", "n = int(input())\narr = [0] + list(map(int, input().split()))\narr.append(1001)\nmax...
{"inputs": ["100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "63\n1...
interview
https://codeforces.com/problemset/problem/1062/A
16
104
Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first. On the $i$-th day Polycarp will necessarily solve $a_i$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on...
["def main():\n n = int(input())\n a = list(int(x) for x in input().split())\n s = sum(a)\n t = 0\n for i in range(n):\n t += a[i]\n if 2 * t >= s:\n print(i + 1)\n return\n\nmain()\n", "#!/bin/python\n\nn = int(input())\nl = list(map(int, input().split()))\ns = sum(l)...
{"inputs": ["6\n2 2 2 2 2 2\n", "2\n1 3\n", "4\n1 1 2 5\n", "5\n9 5 3 4 8\n", "4\n1 2 2 2\n", "3\n3 1 3\n", "5\n1 2 4 4 4\n", "6\n4 2 1 2 3 1\n", "5\n1 1 1 1 3\n", "5\n1 2 1 2 1\n", "5\n2 2 2 2 1\n", "4\n2 2 1 4\n", "5\n1 1 1 2 2\n", "4\n1 4 2 4\n", "5\n1 1 1 1 5\n", "4\n7 1 3 4\n"], "outputs": ["3\n", "2\n", "4\n", "3...
interview
https://codeforces.com/problemset/problem/962/A
16
105
You stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily $8 \times 8$, but it still is $N \times N$. Each square has some number written on it, all the numbers are from $1$ to $N^2$ and all the numbers are pairwise distinct. The $j$-th square in the $i$-th row has a number $A_{ij}$...
["n=int(input())\ngraph=[{},{},{}]\nfor i in range(n):\n for j in range(n):\n graph[0][(i,j)]=[(k,j) for k in range(n)]+[(i,k) for k in range(n)]\n graph[0][(i,j)].remove((i,j))\n graph[0][(i,j)].remove((i,j))\n graph[1][(i,j)]=[]\n for k in range(n):\n for l in range(n)...
{"inputs": ["6\n8 3 15 14 29 17\n27 11 16 21 18 28\n34 23 36 12 10 5\n30 31 25 6 9 2\n7 24 13 1 35 4\n19 26 33 32 20 22\n", "10\n1 51 23 18 72 5 69 20 48 42\n25 88 50 70 16 79 12 61 99 8\n38 13 62 2 28 34 29 9 59 17\n33 44 67 77 78 84 52 11 39 27\n100 95 82 83 68 7 46 6 43 35\n53 93 21 97 76 26 80 36 22 10\n81 56 87 89...
interview
https://codeforces.com/problemset/problem/1065/D
16
106
Есть n-подъездный дом, в каждом подъезде по m этажей, и на каждом этаже каждого подъезда ровно k квартир. Таким образом, в доме всего n·m·k квартир. Они пронумерованы естественным образом от 1 до n·m·k, то есть первая квартира на первом этаже в первом подъезде имеет номер 1, первая квартира на втором этаже первого подъ...
["n, m, k = map(int, input().split())\na, b = map(int, input().split())\na -= 1\nb -= 1\ndef p(x):\n\treturn x // (m * k)\ndef e(x):\n\treturn (x - p(x) * m * k) // k\ndef lift(x):\n\treturn min(5 * x, 10 + x)\n\t\nif p(a) == p(b):\n\tdif = abs(e(a) - e(b))\n\tprint(lift(dif))\nelse:\n\tprint(lift(e(a)) + 15 * min((p(a...
{"inputs": ["3 1 5\n7 2\n", "35 296 7\n70033 65728\n", "186 312 492\n19512588 5916903\n", "149 186 417\n11126072 11157575\n", "841 727 726\n101540521 305197765\n", "828 68 391\n3563177 21665321\n", "165 198 834\n16752490 5105535\n", "24 644 653\n1326557 3894568\n", "100 1 1\n55 1\n", "1000 1000 1000\n1 10000000\n", "1 ...
interview
https://codeforces.com/problemset/problem/649/B
16
107
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills. Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisi...
["s = input()\ni = 0\nwhile i < len(s) and s[i] == '0':\n i += 1\ncnt = 0\nwhile i < len(s):\n if s[i] == '0':\n cnt += 1\n i += 1\n\nif cnt >= 6:\n print('yes')\nelse:\n print('no')\n", "s=input()\none=False\nzero=0\nfor x in s:\n if not one:\n if x=='1':\n one=True\n else...
{"inputs": ["100010001\n", "100\n", "0000001000000\n", "0110111111111111111111011111111110110111110111111111111111111111111111111111111110111111111111111111\n", "00000000\n", "00010000\n", "0001110000\n", "000000000000000000\n", "000000000001\n", "0000000000000000\n", "0000000000000000010\n", "0000000000001100\n", "000...
interview
https://codeforces.com/problemset/problem/887/A
16
108
You are given a string s consisting of |s| small english letters. In one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with t, etc.). You cannot replace letter z with any other letter. Your target is to make some number of ...
["s = list(input())\ntarget = 'abcdefghijklmnopqrstuvwxyz'\nind_t = 0\nind_s = 0\nwhile ind_s < len(s) and ind_t < 26:\n if ord(s[ind_s]) <= ord(target[ind_t]):\n s[ind_s] = target[ind_t]\n ind_t += 1\n ind_s += 1\n else:\n ind_s += 1\nif ind_t == 26:\n print(''.join(s))\nelse:\n print(-1)", "\na = list...
{"inputs": ["abcdefghijklmnopqrstuvwxya\n", "abcdefghijklmnopqrstuvwxyz\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "zaaaazaaaaaaaaaaaaaaaaaaaaaaaa\n", "aaaaaafghijklmnopqrstuvwxyz\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "aaaaaaaaaaaaaa...
interview
https://codeforces.com/problemset/problem/946/C
16
109
While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). The gift bundle also includes a square scoop of size r × r, designed for fishing....
["import heapq as hq\nfrom queue import PriorityQueue\n\nimport math\nn,m,r, k= input().split()\nN = int(n)\nM = int(m)\nR = int(r)\nK = int(k)\n\nq = PriorityQueue()\n\n\n\nfor i in range(1,math.floor((N+1)/2) + 1):\n maxi = min(min(i,N-i+1),min(R,N-R+1)) * min(min(R,M-R+1),math.ceil(M/2))\n num = M - (2 * min(m...
{"inputs": ["3 3 2 3\n", "12 17 9 40\n", "7 1 1 4\n", "44 22 13 515\n", "93240 88881 88881 94245\n", "68457 4046 983 38009\n", "67572 96232 61366 50178\n", "52 45 38 49\n", "74 63 30 92\n", "74 49 48 99\n", "2 89 2 80\n", "98155 95063 95062 98875\n", "96394 96141 96028 96100\n", "3689 2691 1885 47808\n", "1785 3525 178...
interview
https://codeforces.com/problemset/problem/912/D
16
110
Nick had received an awesome array of integers $a=[a_1, a_2, \dots, a_n]$ as a gift for his $5$ birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product $a_1 \cdot a_2 \cdot \dots a_n$ of its elements seemed to him not large enoug...
["n = int(input())\nA = list(map(int, input().split()))\nif n == 1:\n if A[0] >= 0:\n print(A[0])\n else:\n print(-A[0]-1)\n return\nfor i in range(n):\n if A[i] < 0:\n pass\n else:\n A[i] = -A[i]-1\nif n % 2 == 0:\n print(*A)\n return\nmim = 0\nindmim = 0\nfor i in rang...
{"inputs": ["3\n-3 -3 2\n", "2\n0 0\n", "1\n-1\n", "3\n2 1 -2\n", "6\n-1 -2 -3 0 0 0\n", "3\n10 -14 -20\n", "4\n0 1 2 3\n", "5\n-4 0 0 0 1\n", "6\n-5 0 0 0 0 0\n", "1\n-10\n", "5\n-2 -3 -7 -4 3\n", "3\n-3 3 2\n", "3\n0 -2 -3\n", "5\n5 5 -1 -1 -1\n", "6\n-3 -2 0 0 1 2\n", "5\n-6 -5 -3 2 3\n"], "outputs": ["-3 -3 2 ", "-...
interview
https://codeforces.com/problemset/problem/1180/B
16
111
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": ["1000000000000000 1000000000\n", "4 4\n", "9 3\n", "49 4\n", "36 10\n", "25 3\n", "100 6\n", "100 10\n", "1099511627776 22\n", "1000000007 100010\n", "3 1\n", "999999999999989 2\n", "1000 8\n", "16 2\n", "100000380000361 2\n", "24 4\n"], "outputs": ["-1\n", "-1\n", "9\n", "-1\n", "-1\n", "25\n", "20\n", "-1...
interview
https://codeforces.com/problemset/problem/762/A
16
112
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": ["1\n1 9 8 3 7 8\n", "2\n6 0 1 7 2 9\n1 3 4 6 7 0\n", "3\n5 0 7 6 2 1\n2 7 4 6 1 9\n0 2 6 1 7 5\n", "3\n0 1 9 1 0 8\n9 9 3 5 6 2\n9 3 9 9 7 3\n", "1\n7 9 2 5 0 4\n", "1\n8 6 0 9 4 2\n", "1\n8 2 7 4 1 0\n", "1\n0 8 7 1 3 2\n", "1\n8 1 9 2 9 7\n", "3\n7 7 2 5 3 2\n3 0 0 6 4 4\n1 2 1 1 9 1\n", "3\n4 6 0 3 9 2\n...
interview
https://codeforces.com/problemset/problem/887/B
16
113
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": ["100 0\n", "1 1\n", "4 1\n", "11 1\n", "36 2\n", "1 8\n", "96 8\n", "1953125 8\n", "268435456 8\n", "55555 8\n", "2 1\n", "1 1\n", "5 8\n", "8 3\n", "999999937 8\n", "2000000 7\n"], "outputs": ["100\n", "10\n", "20\n", "110\n", "900\n", "100000000\n", "300000000\n", "500000000\n", "104857600000000\n", "1111...
interview
https://codeforces.com/problemset/problem/858/A
16
114
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", "2 2\n0 1\n0 1\n", "2 2\n0 0\n1 1\n", "3 3\n0 0 0\n0 0 0\n0 0 1\n", "4 4\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 1\n", "4 5\n0 0 0 1 1\n0 0 0 1 1\n0 1 1 1 0\n0 1 1 0 0\n", "3 3\n1 1 0\n1 1 0\n1 0 0\n", "2 2\n0 1\n1 1\n", "4 4\n0 0 0 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n", "2 5\n1 1 0 0 1\n1...
interview
https://codeforces.com/problemset/problem/1207/B
16
115
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": ["1 1 3\n", "1 99 100\n", "90 5 100\n", "5 100 90\n", "100 5 90\n", "98 99 100\n", "100 99 98\n", "99 98 100\n", "100 99 99\n", "99 100 99\n", "80 80 80\n", "80 80 79\n", "78 80 80\n", "1 2 1\n", "2 3 1\n", "99 99 99\n"], "outputs": ["0.057142857143 0.657142857143 0.285714285714\n", "0.362287378787 0.6377126...
interview
https://codeforces.com/problemset/problem/540/D
16
116
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": ["6 6 5 8 9\n", "4722316546398 36672578279675 796716437180 33840047334985 13411035401708\n", "14300093617438 14381698008501 6957847034861 32510754974307 66056597033082\n", "700062402405871919 762322967106512617 297732773882447821 747309903322652819 805776739998108178\n", "59861796371397621 194872039092923459...
interview
https://codeforces.com/problemset/problem/714/A
16
117
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": ["538 260\n883045722 943846211 280584021\n649345935 811450707 -140223820\n-902389798 3853483 657006291\n-329714115 403347321 -120034877\n-688985179 59150247 407495152\n-119226509 -114041897 -409726159\n-680270073 -601528328 -740171953\n192522124 893095006 -154964336\n-915158092 -341685216 -203846624\n-693916...
interview
https://atcoder.jp/contests/abc168/tasks/abc168_f
16
118
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc. [Image] Barney woke up in the morning and wants to eat th...
["t, s, x = list(map(int, input().split()))\nf = False\nif x - 1 > t and (x - 1 - t) % s == 0:\n f = True\nif x >= t and (x - t) % s == 0:\n f = True\nif f:\n print('YES')\nelse:\n print('NO')\n", "# You lost the game.\nt,s,x = list(map(int, input().split()))\ne = x-t\nv = e % s\nif (x >= t+s and (v == 0 or...
{"inputs": ["33 232603 599417964\n", "6 52 30\n", "4796601 66897 4860613\n", "60686899 78474 60704617\n", "50 64536 153660266\n", "906385 342131991 685170368\n", "586389 79039 850729874\n", "0 2 0\n", "0 2 3\n", "0 215 403\n", "0 2 900000000\n", "5 1000 1000\n", "1 5 103\n", "1 2 3\n", "5 2 7\n", "0 10001 0\n"], "outpu...
interview
https://codeforces.com/problemset/problem/697/A
16
119
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": ["2\n1 1000000000\n500000000 500000000\n", "2\n1 10\n2 10\n", "2\n2 10\n1 10\n", "3\n1 3\n2 5\n3 4\n", "3\n1 10\n2 11\n3 11\n", "4\n1 3\n1 4\n5 10\n11 13\n", "3\n2 4\n2 4\n1 3\n", "6\n10 11\n12 13\n15 16\n15 17\n18 19\n59 60\n", "2\n1 3\n1 7\n", "2\n2 3\n1 3\n", "3\n1 10\n2 11\n2 11\n", "2\n1 5\n1 6\n", "3\n...
interview
https://codeforces.com/problemset/problem/976/C
16
120
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": ["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??????????A???????????????TCCCC?C?CA??AC??GC????????\n", "4\nT???\n", "56\n?GCCA?GC?GA??GA??T?CCGC????...
interview
https://codeforces.com/problemset/problem/747/B
16
121
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": ["o.x.\no...\n.x..\nooxx\n", ".xx.\n.xoo\n.oox\n....\n", "xxox\no.x.\nx.oo\nxo.o\n", "ox.o\nx..x\nx..o\noo.x\n", ".xox\n.x.o\nooxo\n..x.\n", "..ox\n.o..\nx..o\n.oxx\n", "xoxx\n..x.\no.oo\nx.o.\n", "x...\no.ox\nxo..\n....\n", "oxox\nx.oo\nooxx\nxxo.\n", "x..o\no..o\no..x\nxxox\n", ".x..\no.o.\n.x..\n....\n", ...
interview
https://codeforces.com/problemset/problem/754/B
16
122
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", "8\n9 5 5 10 4 9 5 8\n", "20\n71 83 54 6 10 64 91 98 94 49 65 68 14 39 91 60 74 100 17 13\n", "100\n35 31 83 11 7 94 57 58 30 26 2 99 33 58 98 6 3 52 13 66 21 53 26 94 100 5 1 3 91 13 97 49 86 25 63 90 88 98 57 57 34 81 32 16 65 94 59 83 44 14 46 18 28 89 75 95 87 57 52 18 46 80 31 43 38 54 69...
interview
https://codeforces.com/problemset/problem/808/D
16
123
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", "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\n", "5 1\n196 197 198 0 200\n199\n", "100 2\n0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 0 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 ...
interview
https://codeforces.com/problemset/problem/814/A
16
124
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": ["5 1 1\n4 3 2\n", "1 8 4\n3 1 9\n", "6 1 2\n4 9 6\n", "100000 100000 100000\n100000 100000 99999\n", "7 3 9\n7 8 4\n", "80000 80004 80000\n80000 80006 80009\n", "80001 80009 80008\n80006 80006 80003\n", "29 42 41\n94 70 42\n", "2 2 10\n100 1 1\n", "1 2 1\n1 1 50\n", "3 3 3\n3 2 4\n", "9 22 1\n10 20 30\n", "...
interview
https://codeforces.com/problemset/problem/1114/A
16
125
Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes getting out of the intersection, so we have 4 parts in total. Each part has 4 lights, one for each lane...
["lanes = []\n\nfor i in range(4):\n lanes.append(list(map(int, input().split())))\n\nlanes.extend(lanes)\n\nfor i in range(4):\n ln = lanes[i]\n if (ln[3] and (ln[0] or ln[1] or ln[2])) or \\\n (ln[0] and lanes[i + 3][3]) or \\\n (ln[1] and lanes[i + 2][3]) or \\\n (ln[2] and ...
{"inputs": ["0 0 0 0\n0 0 0 1\n0 0 0 1\n0 0 0 1\n", "1 0 0 0\n0 1 0 0\n1 1 0 0\n0 1 1 0\n", "0 0 1 0\n0 1 0 1\n1 0 1 0\n0 0 1 0\n", "1 0 1 0\n1 1 0 0\n1 1 0 0\n0 0 0 0\n", "0 0 0 0\n1 1 0 0\n0 0 0 1\n0 0 1 0\n", "1 0 0 1\n0 0 0 0\n0 0 0 0\n0 0 0 0\n", "0 1 0 1\n0 0 0 0\n0 0 0 0\n0 0 0 0\n", "0 0 0 1\n0 1 0 0\n0 0 0 0\n...
interview
https://codeforces.com/problemset/problem/812/A
16
126
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] Together with his old phone, he lost all his cont...
["# A\n\ninput()\nl = list(map(int, list(input())))\n\nif (1 in l or 4 in l or 7 in l or 0 in l) and (1 in l or 2 in l or 3 in l) and (3 in l or 6 in l or 9 in l or 0 in l) and (7 in l or 0 in l or 9 in l):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n = int(input())\nnumb = input()\nnum = [0]*10\nfor i in numb:...
{"inputs": ["3\n586\n", "4\n0068\n", "4\n0585\n", "9\n103481226\n", "7\n1588216\n", "2\n22\n", "6\n287245\n", "4\n3418\n", "4\n3553\n", "3\n609\n", "9\n722403540\n", "9\n769554547\n", "3\n780\n", "5\n78248\n", "2\n12\n", "4\n9394\n"], "outputs": ["NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", ...
interview
https://codeforces.com/problemset/problem/689/A
16
127
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", "2 1\n7 8\n3 6\n", "2 1\n9 10\n5 8\n", "3 2\n5 10\n5 10\n7 9\n", "2 1\n2 4\n12 12\n", "3 2\n10 10\n10 10\n1 2\n", "10 5\n9 1\n11 1\n12 1\n13 1\n14 1\n2 4\n2 4\n2 4\n2 4\n2 4\n", "2 1\n30 30\n10 20\n", "2 1\n14 28\n15 28\n", "2 1\n5 10\n6 10\n", "2 1\n7 8\n2 4\n", "4 2\n2 10\n3 1...
interview
https://codeforces.com/problemset/problem/810/B
16
128
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": ["9 2\n", "100000 49998\n", "99999 49997\n", "29614 7\n", "421 36817\n", "86946 63967\n", "71128 11076\n", "46111 64940\n", "3 4\n", "4 1\n", "4 4\n", "5 4\n", "6 2\n", "7 3\n", "7 4\n", "100000 1\n"], "outputs": ["26\n", "4999949994\n", "4999849991\n", "414491\n", "88410\n", "3779759985\n", "1330260828\n", ...
interview
https://codeforces.com/problemset/problem/645/B
16
129
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": ["2 1 1 1\n", "1000000000000000000 1 1 1000000000000000000\n", "1847865 4577 9483 478\n", "100000000000067841 932 9842 64\n", "695046328995629472 971547627530533122 523943811516500483 107182605463941115\n", "7 4 1 6\n", "99 5 98 1\n", "20 15 20 3\n", "19366 12326 871 14611\n", "1000000000000000000 1000000000...
interview
https://codeforces.com/problemset/problem/1068/A
16
130
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": ["1 1\nW\n", "5 4\nWWWW\nWWWW\nWWWB\nWWWW\nWWWW\n", "10 5\nWWWWB\nWWWWW\nWWWBB\nWWBWW\nWWWWW\nWWWWW\nWWWWW\nWWWWW\nWWWWW\nWWWWW\n", "2 2\nWB\nWW\n", "1 2\nWB\n", "2 1\nW\nW\n", "2 1\nB\nB\n", "1 100\nBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW\n", "100...
interview
https://codeforces.com/problemset/problem/828/B
16
131
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": ["50\n620 222 703 953 303 333 371 125 554 88 60 189 873 644 817 100 760 64 887 605 611 845 762 916 21 26 254 553 602 66 796 531 329 888 274 584 215 135 69 403 680 734 440 406 53 958 135 230 918 206\n464 128 878 999 197 358 447 191 530 218 63 443 630 587 836 232 659 117 787 254 667 646 498 845 252 179 452 390...
interview
https://codeforces.com/problemset/problem/1013/A
16
132
Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to a_{i}. Vasya and Petya want to divide all pi...
["n = int(input())\na = list(map(int, input().split()))\nmn = 360\nfor i in range(n):\n x = 0\n for j in range(i, n):\n x += a[j]\n mn = min(mn, abs(x - (360 - x)))\nprint(mn)", "n = int(input().strip())\n\nkosi = list(map(int, input().strip().split()))\n\nmini = 400\n\nfor a in range(len(kosi)):\n ...
{"inputs": ["2\n170 190\n", "3\n281 67 12\n", "50\n148 53 32 11 4 56 8 2 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "3\n1 1 358\n", "70\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
interview
https://codeforces.com/problemset/problem/895/A
16
133
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": ["185182737 683516583\n", "1956 1933\n", "958 1712\n", "204 697134196\n", "617282691 956569994\n", "534571158 222043261\n", "840387185 768322358\n", "188186551 379116090\n", "426452433 106792\n", "169231047 790996597\n", "290496089 820810891\n", "33727662 414901164\n", "428 71\n", "560 27\n", "1730 39\n", "2...
interview
https://codeforces.com/problemset/problem/1236/B
16
134
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples. For example, tripl...
["n = int(input())\nif n % 4 == 0:\n temp = n // 4\n m = temp * 3\n k = temp * 5\nelif n % 2 == 0:\n n //= 2\n m = n**2 // 2\n k = m + 1\n m *= 2\n k *= 2\nelse:\n m = n**2 // 2\n k = m + 1\nif 3 > n:\n print(\"-1\")\nelse:\n print(m,k)\n"]
{"inputs": ["67\n", "23\n", "246\n", "493804\n", "444\n", "44444\n", "444444\n", "2\n", "11\n", "117\n", "9999992\n", "9999973\n", "99999996\n", "99999978\n", "999999937\n", "999999998\n"], "outputs": ["2244 2245", "264 265", "15128 15130", "617255 370353", "555 333", "55555 33333", "555555 333333", "-1", "60 61", "684...
interview
https://codeforces.com/problemset/problem/707/C
16
135
Imp is watching a documentary about cave painting. [Image] Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1 to k. Unfortunately, there are too many integers to analyze for Imp. Imp ...
["def main():\n\tn, k = map(int, input().split())\n\tfor i in range(1, k + 1):\n\t\tif (n % i != (i - 1)):\n\t\t\tprint(\"No\")\n\t\t\treturn\n\tprint(\"Yes\")\n\nmain()", "#! /usr/bin/env python3\n\nimport math\nimport sys\n\n\ndef lcm(u, v):\n return u * v // math.gcd(u, v)\n\n\ndef main():\n n, k = list(map(in...
{"inputs": ["1000000000000000000 1000000000000000000\n", "442762254977842799 30\n", "319575605003866172 71\n", "72712630136142067 356370939\n", "631689521541558479 22\n", "224113913709159599 10\n", "205439024252247599 5\n", "167686318743248777 858743836723172421\n", "603915274316797622 822050585316952974\n", "647896534...
interview
https://codeforces.com/problemset/problem/922/C
16
136
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": ["00012345\n12345\n", "1000000000000000000000000000000000\n1000000000000000000000000000000001\n", "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...
interview
https://codeforces.com/problemset/problem/616/A
16
137
Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games. Kuro challenged Katie to create a game with only a white paper, a pencil, a pair of scissors and a lot o...
["n,p=list(map(int,input().split()))\nnums=[0]+list(map(int,input().split()))\nmod=10**9+7\n\nf=[[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(n+1)]\n\n_2=[0]*(n+1)\n_2[0]=1\nfor i in range(1,n+1):\n _2[i]=(_2[i-1]<<1)%mod\n \nf[0][0][0][0]=1\nif nums[1]!=0:\n f[1][1][0][1]+=1\nif nums[1]!=1:\n ...
{"inputs": ["50 1\n-1 -1 1 0 1 1 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 1 -1 1 0 -1 1 1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 -1 -1 0 1 -1 0 1 -1 1 0 -1 -1 1\n", "3 1\n0 -1 -1\n", "21 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "3 0\n0 0 0\n", "9 0\n0 -1 -1 -1 -1 -1 1 0 -1\n", "6 0\n0 -1 -1 0 0 -1\n", "22 1\n0 -1 1 0 0 1 1 1 -1 -1...
interview
https://codeforces.com/problemset/problem/979/E
16
138
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": ["4 4 4 4\n", "1016 3 2 1\n", "17 100 100 1\n", "18 1 3 3\n", "19 1 1 1\n", "999999998 1000000000 999999990 1000000000\n", "748955287 546879484 733686393 808572289\n", "458021753 810076598 324722563 992170945\n", "7 10 2 3\n", "3 1000 1000 3\n", "3 1000 1 1\n", "3 100000 1 1\n", "3 9 1 1\n", "3 4 3 1\n", "3 ...
interview
https://codeforces.com/problemset/problem/740/A
16
139
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": ["2 2\n1 2\n2 1\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 462\n126 285\n185 287\n223 221\n207 167\n203 127\n39 245\n394 444\n166 99\n399 328\n3 276\n142 325\n284 153\n65 3\n102 5\n459 168\n156 17\...
interview
https://codeforces.com/problemset/problem/915/D
16
140
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": ["1 1\n1 1\n", "7 300\n50 8\n49 6\n246 1\n123 3\n227 2\n183 5\n158 7\n", "25 100000\n3174 736\n88732 1969\n61424 1015\n77143 1483\n56805 2063\n25558 249\n48637 2511\n68912 63\n27671 733\n60995 2972\n6179 2108\n8416 702\n50179 1554\n37107 2862\n21129 2673\n45776 2144\n67145 1674\n94506 1588\n25711 345\n46646 ...
interview
https://codeforces.com/problemset/problem/1253/E
16
141
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": ["27\n0 0 0 0 0 5 0 0\n", "11171191554286070\n2626501702108587 0 0 0 0 5566294923912459 0 0\n", "37\n0 0 0 7 8 3 0 0\n", "5406\n0 0 0 0 445 0 317 449\n", "1875\n0 798 174 852 0 0 0 912\n", "38876292360852128\n1178251863709588 888548687085905 0 0 860241043595441 4299934410797162 6840168978135254 0\n", "19\n13...
interview
https://codeforces.com/problemset/problem/1132/E
16
142
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": ["5 787787787\n123456789 234567890 345678901 456789012 987654321\n", "30 1000000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...
interview
https://codeforces.com/problemset/problem/913/C
16
143
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": ["2\n2 2\n", "3\n3 1 1\n", "3\n3 3 1\n", "3\n4 3 3\n", "4\n1 3 2 1\n", "4\n1 3 4 1\n", "4\n3 3 1 2\n", "4\n3 4 3 1\n", "4\n2 2 2 2\n", "4\n2 4 3 3\n", "4\n3 3 3 3\n", "4\n4 3 3 4\n", "4\n4 4 4 4\n", "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "10\n1 1 1 1 1 1 1 1 2 3\n", "4\...
interview
https://codeforces.com/problemset/problem/682/B
16
144
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", "2\n00\n", "5\n11980\n", "5\n30213\n", "75\n701550968134602984948768446130093645674414572984517902437769409395298622678\n", "93\n422951129271016503700234397427203319704940397318938157846153922624198061914374358965386132849\n", "100\n1481434020093151013248488915859811727012058656675018437252629...
interview
https://codeforces.com/problemset/problem/1030/C
16
145
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": ["zcinitufxoldnokacdvtmdohsfdjepyfioyvclhmujiqwvmudbfjzxjfqqxjmoiyxrfsbvseawwoyynn\n", "qwbdfzfylckctudyjlyrtmvbidfatdoqfmrfshsqqmhzohhsczscvwzpwyoyswhktjlykumhvaounpzwpxcspxwlgt\n", "nuezoadauueermoeaabjrkxttkatspjsjegjcjcdmcxgodowzbwuqncfbeqlhkk\n", "lggvdmulrsvtuagoavstuyufhypdxfomjlzpnduulukszqnnwfvxbvxy...
interview
https://codeforces.com/problemset/problem/236/A
16
146
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": ["3 2\n1 1 -1\n", "36 27\n1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1\n", "52 22\n1 1 -1 1 1 1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 1 1 -1 1 1 -1 1 1 1\n", "68 2\n-1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 ...
interview
https://codeforces.com/problemset/problem/1100/A
16
147
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 0 0\n", "100000000 1 0\n", "2 0 0\n", "2 100000000 0\n", "2 50000000 0\n", "100000000 50000000 0\n", "100000000 50000000 100000000\n", "61988457 90532323 72913492\n", "1505663 3257962 1039115\n", "28258585 6194848 49146833\n", "9251 4756 2763\n", "5195 1354 2885\n", "151 7023 3093\n", "5992 2773 6869\n",...
interview
https://codeforces.com/problemset/problem/717/B
16
148
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": ["100 43 55 42 15\n", "33 15 6 1 3\n", "5 3 2 4 1\n", "4 3 2 1 4\n", "4 3 2 4 1\n", "4 4 2 1 3\n", "4 4 3 1 2\n", "4 4 3 2 1\n", "9 7 2 6 8\n", "5 4 2 1 5\n", "5 4 2 1 3\n", "5 1 3 2 5\n", "5 2 1 4 5\n", "10 2 5 8 4\n", "6 5 6 3 4\n", "10 9 10 1 8\n"], "outputs": ["NO\n", "NO\n", "YES\n", "YES\n", "NO\n", "N...
interview
https://codeforces.com/problemset/problem/1169/A
16
149
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": ["3 5 10 22\n", "2 2 1 10\n", "2 2 1 1000000000000000000\n", "2 3 1 1000000000000000000\n", "16 5 821690667 821691481\n", "1000000000000000000 2 1 1000000000000000000\n", "3 3 1 1\n", "650233444262690661 556292951587380938 715689923804218376 898772439356652923\n", "4294967297 4294967297 1 999999999999999999\...
interview
https://codeforces.com/problemset/problem/813/B
16
150
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": ["26\n", "1999999999\n", "10003\n", "25\n", "45\n", "9975\n", "39\n", "14\n", "24\n", "19828\n", "370359\n", "115\n", "536870912\n", "10759922\n", "200743933\n", "1908903481\n"], "outputs": ["2\n", "3\n", "3\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "3\n", "2\n", "2\n", "2\n", "3\n", "3\n"]}
interview
https://codeforces.com/problemset/problem/735/D
16
151
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": ["mvjajoyeg\n", "ibbtvelwjirxqermucqrgmoauonisgmarjxxybllktccdykvef\n", "jxevkmrwlomaaahaubvjzqtyfqhqbhpqhomxqpiuersltohinvfyeykmlooujymldjqhgqjkvqknlyj\n", "hzxkuwqxonsulnndlhygvmallghjerwp\n", "aab\n", "bbb\n", "llll\n", "lllllb\n", "bbbbbbbbbc\n", "bbbbbccc\n", "nnnnnnnnnnnnnnnnnn\n", "xxxxxxxx\n", "cclcc...
interview
https://codeforces.com/problemset/problem/858/C
16
152
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": ["10 3 3\n10 33\n1 7 6\n17 25 68\n2 9 10\n78 89 125\n", "100 1 1\n100 1\n1\n1000\n99\n1\n", "2000000000 1 1\n2000000000 1\n1\n2\n1\n2\n", "2000000000 3 2\n10 1\n2 4 3\n200 100 400\n4 15\n100 800\n", "20 1 1\n10 99\n1\n100\n4\n10\n", "100 1 1\n200 10\n10\n11\n100\n1\n", "100 1 1\n1000 5\n1\n6\n100\n4\n", "2 1...
interview
https://codeforces.com/problemset/problem/734/C
16
153
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": ["2 1 0\n2\n", "5 3 49\n1 3 6\n", "44 41 93891122\n447 314862 48587 198466 73450 166523 247421 50078 14115 229926 11070 53089 73041 156924 200782 53225 290967 219349 119034 88726 255048 59778 287298 152539 55104 170525 135722 111341 279873 168400 267489 157697 188015 94306 231121 304553 27684 46144 127122 16...
interview
https://codeforces.com/problemset/problem/846/B
16
154
Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key stored in the right subtree. The depth of a vertex is the number o...
["N = int(input())\nif N in [1, 2, 4, 5, 9, 10, 20, 21, 41, 42, 84, 85, 169, 170, 340, 341, 681, 682, 1364, 1365, 2729, 2730, 5460, 5461, 10921, 10922, 21844, 21845, 43689, 43690, 87380, 87381, 174761, 174762, 349524, 349525, 699049, 699050]:\n print(1)\nelse:\n print(0)\n\n", "N = 1000001\nans = [0 for x in rang...
{"inputs": ["699049\n", "6\n", "10922\n", "170\n", "22\n", "181407\n", "524288\n", "334846\n", "549836\n", "699046\n", "11\n", "10921\n", "796867\n", "527730\n", "740812\n", "2730\n"], "outputs": ["1\n", "0\n", "1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "0\n", "1\n"]}
interview
https://codeforces.com/problemset/problem/1237/E
16
155
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy. Lara is going to explore yet another dangerous dungeon. Game designers decided to use good old 2D e...
["n, m, k = map(int, input().split())\nans = 0, 0\nif k < n:\n ans = k + 1, 1\nelse:\n k -= n\n r = n - k // (m - 1)\n if r % 2:\n c = m - k % (m - 1)\n else:\n c = 2 + k % (m - 1)\n ans = r, c\nprint(*ans)", "n, m, k = map(int, input().split())\nif k < n:\n print(k + 1, 1)\nelse:\n ...
{"inputs": ["1000000000 2 1999999999\n", "28 3 1\n", "4 5 5\n", "2 3 4\n", "4 7 8\n", "500 100 800\n", "9213788 21936127 8761236\n", "999999998 999999998 999999995000000005\n", "999995712 999993076 999988788028978212\n", "999994900 999993699 999988599028973300\n", "1000000000 789 788999999000\n", "978642410 789244500 1...
interview
https://codeforces.com/problemset/problem/976/B
16
156
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", "1\n", "991921850317\n", "483524125987\n", "438282886646\n", "451941492387\n", "583102513046\n", "147869771841\n", "355170254369\n", "914665370955\n", "199399770518\n", "924639053494\n", "645583369174\n", "893056419894\n", "526667661132\n", "769845744556\n"], "outputs": ["1 2\n", "1 1\n", "1 99192185...
interview
https://codeforces.com/problemset/problem/1285/C
16
157
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": ["4\n7\n13\n", "1000\n1\n1000\n", "4\n8\n12\n", "199\n400\n800\n", "200\n400\n799\n", "139\n252\n871\n", "196\n280\n848\n", "190\n454\n699\n", "231\n464\n928\n", "20\n38\n80\n", "120\n239\n480\n", "208\n416\n831\n", "130\n260\n517\n", "10\n2\n100\n", "2\n100\n100\n", "100\n4\n1000\n"], "outputs": ["21\n", "0...
interview
https://codeforces.com/problemset/problem/746/A
16
158
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", "2\n10 4 4 4\n", "2\n3 8 10 2\n", "2\n1 1 3 3\n", "3\n3 3 3 2 3 2\n", "2\n1 3 2 2\n", "2\n1 3 3 4\n", "3\n1 2 7 19 19 7\n", "3\n100 99 1 1 1 1\n", "2\n1 2 1 2\n", "3\n7 7 4 5 319 19\n", "3\n3 2 3 4 5 2\n", "5\n1 2 3 3 4 5 6 7 8 4\n", "2\n1 4 5 4\n", "3\n1 3 4 4 2 5\n", "7\n6 7 6 7 3 1 9 4 6 ...
interview
https://codeforces.com/problemset/problem/845/A
16
159
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", "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 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 2 1 1 1 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 1 1 2 2 2 ...
interview
https://codeforces.com/problemset/problem/660/A
16
160
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": ["4 5\n10 1 2 22\n", "2 411810\n561589 20609\n", "2 426922\n243129 295272\n", "493 95\n1 1 1 1 1 1 1 1 1 1 254 1 1 1 1 1 1 1 1 1 1 444590 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 90 1 1 1 1 1 1 1 1 1 517215 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 394771 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
interview
https://atcoder.jp/contests/abc136/tasks/abc136_e
16
161
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": ["524288\n", "349525\n", "917503\n", "1365\n", "21\n", "9\n", "17\n", "20\n", "29\n", "35\n", "36\n", "62453\n", "524636\n", "575965\n", "776441\n", "915455\n"], "outputs": ["1\n19 ", "19\n0 1 3 5 7 9 11 13 15 17 ", "3\n0 17 ", "11\n0 1 3 5 7 9 ", "5\n0 1 3 ", "2\n3 ", "2\n4 ", "3\n2 3 ", "2\n2 ", "4\n2 5 ",...
interview
https://codeforces.com/problemset/problem/1152/B
16
162
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": ["5 97\n1 10 50 97 2\n", "100 91\n13 13 62 96 74 47 81 46 78 21 20 42 4 73 25 30 76 74 58 28 25 52 42 48 74 40 82 9 25 29 17 22 46 64 57 95 81 39 47 86 40 95 97 35 31 98 45 98 47 78 52 63 58 14 89 97 17 95 28 22 20 36 68 38 95 16 2 26 54 47 42 31 31 81 21 21 65 40 82 53 60 71 75 33 96 98 6 22 95 12 5 48 18 2...
interview
https://codeforces.com/problemset/problem/915/A
16
163
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": ["2 1\nGT\n", "100 2\n..#####.#.#.......#.#.#...##..####..###..#.#######GT####.#.#...##...##.#..###....##.#.#..#.###....#.\n", "100 3\nG..................................................................................................T\n", "100 33\nG..#.#..#..####......#......##...##...#.##........#...#...#....
interview
https://codeforces.com/problemset/problem/735/A
16
164
It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guys. For example, he can hit the ball directly to the specified point. And ye...
["y1, y2, w, x, y, r = map(int, input().strip().split())\nw -= r\ny1 = 2 * w - y1 - y - r\ny2 = 2 * w - y2 - y\nif x * x * (y2 - y1) * (y2 - y1) <= (y1 * y1 + x * x) * r * r:\n print(-1)\nelse:\n print(f\"{x * (y1 + y - w) / y1:.10f}\")", "from math import atan, asin\ny1, y2, yw, xb, yb, r = map(float, input().split(...
{"inputs": ["1 8 10 8 3 3\n", "2 9 10 4 6 3\n", "2 9 10 6 3 3\n", "2 9 10 6 5 3\n", "2 9 10 5 3 3\n", "1 9 10 4 5 3\n", "15 30 100 8 8 5\n", "15 30 100 7193 39 5\n", "15 30 100 243890 31 5\n", "712 950 1000 98 727 92\n", "10995 85967 100000 47813 44507 2442\n", "111724 287004 931554 512877 139642 23002\n", "65775 30070...
interview
https://codeforces.com/problemset/problem/248/C
16
165
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": ["1 1 1\n", "1000 0 0\n", "0 1 0\n", "1000000000000000000 999999999999999999 999999999999999999\n", "999999999999999999 999999999999999999 1000000000000000000\n", "12 8 8\n", "8912 10561 8205\n", "1000000100 1000000083 1000000047\n", "117864695669097197 53280311324979856 171825292362519668\n", "647397084215 ...
interview
https://codeforces.com/problemset/problem/732/C
16
166
There is a matrix A of size x × y filled with integers. For every $i \in [ 1 . . x ]$, $j \in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a_1, a_2,...
["MAXN = 1000000000\n\nn = int(input())\na = list(map(int, input().split()))\n\ndef solve1():\t\n\tfor i in range(n-1):\n\t\tif abs(a[i]-a[i+1]) != 1:\n\t\t\treturn False\n\tprint(\"YES\\n%d %d\" % (MAXN, 1))\n\treturn True\n\ndef solve2():\n\tw = -1\n\tfor i in range(n-1):\n\t\td = abs(a[i]-a[i+1])\n\t\tif d != 1:\n\t...
{"inputs": ["1\n6\n", "4\n1 2 1 3\n", "3\n1 4 3\n", "13\n1 3 4 6 5 3 1 2 4 6 5 3 1\n", "37\n94 7 32 29 57 22 11 70 57 61 12 75 93 24 4 47 98 43 99 22 50 32 37 64 80 9 40 87 38 70 17 41 77 76 20 66 48\n", "5\n3 4 5 6 2\n", "10\n999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 999...
interview
https://codeforces.com/problemset/problem/954/C
16
167
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": ["test\nt\n", "aa\nzzaa\n", "abbba\naba\n", "aaa\naa\n", "aaaaaaaaaaaa\naaa\n", "aaaaabbbbbbaaaaaa\naba\n", "b\nabb\n", "lctsczqr\nqvkp\n", "abab\nab\n", "accac\nbaacccbcccabaabbcacbbcccacbaabaaac\n", "abcde\nfabcde\n", "aaaaabbbaaaaa\naabbaa\n", "aaaaaaaaa\naaaa\n", "aaa\naaaaa\n", "abcabbcbcccbccbbcc\nacbc...
interview
https://codeforces.com/problemset/problem/762/C
16
168
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": ["100\n+-+-+-++--++-++-+-+---+--++++++-++++--++-++---+--++++--+++++++-++-+--+-+-+--+-+++++-+--+---+-++-++-+\n", "100\n-++------+---++++-+---++---+--+-++--+-+-++--+-+-++++-+++-+-----++-+--++-+++++---+-----+++---+-+-+-+-\n", "100\n-+--+++-++-+-+--++-++-------+-++--++----+--++-++------++--+++-+-+-+--+++---+----...
interview
https://codeforces.com/problemset/problem/1159/A
16
169
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\n1\n2\n1\n", "9\n10\n10\n1\n", "10\n5\n5\n1\n", "500\n250\n250\n1\n", "500\n1\n250\n1\n", "10000\n10\n5000\n4999\n", "1000000000000000000\n999999998000000000\n999999999000000000\n999999998000000000\n", "1000000000\n2\n2\n1\n", "999999999999999999\n2\n50000000000000000\n4999999999999999...
interview
https://codeforces.com/problemset/problem/625/A
16
170
Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then they play a "war"-like card game. The rules are following. On each turn a fi...
["n = int(input())\nk1 = list(map(int, input().split()[1:]))\nk2 = list(map(int, input().split()[1:]))\n\ni = 0\nwhile True:\n if len(k1) == 0 or len(k2) == 0:\n break\n if i > 10000:\n break\n if k1[0] > k2[0]:\n k1 = k1[1:] + k2[0:1] + k1[0:1]\n k2 = k2[1:]\n else:\n k2 ...
{"inputs": ["7\n6 6 5 2 7 4 1\n1 3\n", "3\n2 1 2\n1 3\n", "4\n3 1 3 2\n1 4\n", "5\n4 2 4 3 1\n1 5\n", "5\n4 3 2 5 1\n1 4\n", "5\n1 4\n4 3 2 5 1\n", "6\n3 2 4 1\n3 3 6 5\n", "7\n1 6\n6 1 2 5 4 7 3\n", "8\n1 4\n7 3 8 6 1 5 7 2\n", "8\n7 3 1 5 4 7 6 2\n1 8\n", "9\n7 6 5 9 2 1 3 8\n2 7 4\n", "9\n8 4 8 5 6 3 2 7 1\n1 9\n", ...
interview
https://codeforces.com/problemset/problem/546/C
16
171
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", "zA___\n", "1A___\n", "0\n", "?..!.,,?,__.,...????_???__!,?...?.,,,,___!,.!,_,,_,??!_?_,!!?_!_??.?,.!!?_?_.,!\n", "KSHMICWPK,LSBM_JVZ!IPDYDG_GOPCHXFJTKJBIFY,FPHMY,CB?PZEAG..,X,.GFHPIDBB,IQ?MZ\n", "qgw\n", "loaray\n", "MhnfZjsUyXYw?f?ubKA\n", "CpWxDVzwHfYFfoXNtXMFuAZr\n", "C672F429Y8...
interview
https://codeforces.com/problemset/problem/411/A
16
172
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": ["6\n1 1 1 1 1 1\n5 5 5 5 5 5\n", "8\n1 1 2 2 3 3 4 4\n4 4 5 5 1 1 1 1\n", "2\n2 2\n1 1\n", "2\n1 1\n2 2\n", "5\n2 3 2 3 3\n2 3 2 2 2\n", "5\n4 4 1 4 2\n1 2 4 2 2\n", "50\n1 3 1 3 3 3 1 3 3 3 3 1 1 1 3 3 3 1 3 1 1 1 3 1 3 1 3 3 3 1 3 1 1 3 3 3 1 1 1 1 3 3 1 1 1 3 3 1 1 1\n1 3 1 3 3 1 1 3 1 3 3 1 1 1 1 3 3 1 ...
interview
https://codeforces.com/problemset/problem/779/A
16
173
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traff...
["a, b = list(map(int, input().split(' ')))\nhor = input()\nver = input()\nif (hor[0], ver[0]) == ('>', 'v') or (hor[0], ver[-1]) == ('<', 'v'):\n print(\"NO\")\nelif (hor[-1], ver[0]) == ('>', '^') or (hor[-1], ver[-1]) == ('<', '^'):\n print(\"NO\")\nelse:\n print(\"YES\")\n", "h, w = map(int, input().split(...
{"inputs": ["3 3\n>><\n^^v\n", "8 18\n>>>><>>>\nv^vv^v^^^^^vvv^^vv\n", "18 18\n><><<><><>>><>>>><\n^^vvv^v^^^v^vv^^^v\n", "14 20\n<>><<<><<>>>>>\nvv^^v^^^^v^^vv^^vvv^\n", "20 20\n><<><<<<<<<>>><>>><<\n^^^^^^^^vvvv^vv^vvvv\n", "20 20\n><<<><<><>>><><<<<<<\nvv^^vvv^^v^^v^vv^vvv\n", "20 20\n<<>>><>>>><<<<>>><<>\nv^vv^^^^^...
interview
https://codeforces.com/problemset/problem/475/B
16
174
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 0 0 0\n", "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "1\n1\n", "2\n0 1\n", "4\n0 0 1 0\n", "4\n0 1 0 0\n", "4\n0 1 0 1\n", "4\n1 0 1 0\n", "4\n1 1 0 0\n", "4\n1 1 1 0\n", "5\n0 0 0 0 0\n", "5\n0 0 0 1 0\n", "5\n0 0 1 0 0\n", "5\n1 0 1 0 1\n", "5\n1 1 0 1 0\n", "40\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
interview
https://codeforces.com/problemset/problem/550/E
16
175
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": ["1 1000000\n", "1 99999999999999999\n", "1 4\n", "2 10\n", "51 100\n", "3 1000000000000000000\n", "1000000000000000000 3\n", "1 10000000000000000\n", "100000000000000001 10000000000000000\n", "1 123456789123456\n", "345869461223138161 835002744095575440\n", "1 1\n", "19 46\n", "3 6\n", "1000000000000000000 ...
interview
https://codeforces.com/problemset/problem/946/B
16