problem_id int64 0 4.72k | problem_content stringlengths 152 5.64k | code_prompt stringclasses 1
value | difficulty stringclasses 3
values | solutions stringlengths 98 1.12M | test_cases stringlengths 70 1.03M |
|---|---|---|---|---|---|
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... | interview | [{"code": "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]... | [{"input": "xx..\n.oo.\nx...\noox.\n", "output": "YES\n"}, {"input": "x.ox\nox..\nx.o.\noo.x\n", "output": "NO\n"}, {"input": "x..x\n..oo\no...\nx.xo\n", "output": "YES\n"}, {"input": "o.x.\no...\n.x..\nooxx\n", "output": "NO\n"}, {"input": ".xox\no.x.\nx.o.\n..o.\n", "output": "YES\n"}, {"input": "o.oo\n.x.o\nx.x.\n.x... | |
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... | interview | [{"code": "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 f... | [{"input": "3\n1 3 2\n", "output": "YES\n"}, {"input": "5\n1 2 3 4 5\n", "output": "NO\n"}, {"input": "5\n2 2 3 4 5\n", "output": "YES\n"}, {"input": "5\n72 32 17 46 82\n", "output": "NO\n"}, {"input": "6\n26 10 70 11 69 57\n", "output": "NO\n"}, {"input": "7\n4 7 10 7 5 5 1\n", "output": "NO\n"}, {"input": "8\n9 5 5 1... | |
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... | interview | [{"code": "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 !=... | [{"input": "4 2\n11 0 0 14\n5 4\n", "output": "Yes\n"}, {"input": "6 1\n2 3 0 8 9 10\n5\n", "output": "No\n"}, {"input": "4 1\n8 94 0 4\n89\n", "output": "Yes\n"}, {"input": "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\n", "output": "Yes\n"}, {"input": "40 1\n23 26 27 28 31 35 38 40 43 50 52 53 56 57 59 61 65 73 75 76 79 0 82 84... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.3, "memory": 14440.0, ... | [{"input": "1 6 2\n4 3 3\n", "output": "YES\n"}, {"input": "5 1 1\n4 3 2\n", "output": "NO\n"}, {"input": "1 1 100000\n4 2 99995\n", "output": "NO\n"}, {"input": "1 2 3\n3 2 1\n", "output": "YES\n"}, {"input": "1 8 4\n3 1 9\n", "output": "NO\n"}, {"input": "6 1 2\n4 9 6\n", "output": "NO\n"}, {"input": "100000 100000 1... | |
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... | interview | [{"code": "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 (l... | [{"input": "1 0 0 1\n0 1 0 0\n0 0 1 0\n0 0 0 1\n", "output": "YES\n"}, {"input": "0 1 1 0\n1 0 1 0\n1 1 0 0\n0 0 0 1\n", "output": "NO\n"}, {"input": "1 0 0 0\n0 0 0 1\n0 0 0 0\n1 0 1 0\n", "output": "NO\n"}, {"input": "0 0 0 0\n0 0 0 1\n0 0 0 1\n0 0 0 1\n", "output": "NO\n"}, {"input": "1 1 1 0\n0 1 0 1\n1 1 1 0\n1 1 ... | |
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... | interview | [{"code": "# 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", "passed": true, "time": 0.15, "memory": 14620.0, "stat... | [{"input": "3\n586\n", "output": "NO\n"}, {"input": "2\n09\n", "output": "NO\n"}, {"input": "9\n123456789\n", "output": "YES\n"}, {"input": "3\n911\n", "output": "YES\n"}, {"input": "3\n089\n", "output": "NO\n"}, {"input": "3\n159\n", "output": "YES\n"}, {"input": "9\n000000000\n", "output": "NO\n"}, {"input": "4\n0874... | |
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... | interview | [{"code": "from sys import stdin, stdout\nimport math\n\nn, k = map(int, stdin.readline().split())\nvalues = []\nans = 0\n\nfor i in range(n):\n a, b = map(int, stdin.readline().split())\n ans += min(a, b)\n \n if a < b:\n b -= a\n values.append(min(a, b))\n\n\n\nvalues.sort()\nfor v in values... | [{"input": "4 2\n2 1\n3 5\n2 3\n1 5\n", "output": "10"}, {"input": "4 1\n0 2\n0 3\n3 5\n0 6\n", "output": "5"}, {"input": "1 1\n5 8\n", "output": "8"}, {"input": "2 1\n8 12\n6 11\n", "output": "19"}, {"input": "2 1\n6 7\n5 7\n", "output": "13"}, {"input": "2 1\n5 7\n6 7\n", "output": "13"}, {"input": "2 1\n7 8\n3 6\n",... | |
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... | interview | [{"code": "# 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)", "passed": true, "time": 0.43, "memory": 14532.0, "status": "done"}, {"code": "def main():\n n, k = map(int, input().split())\n if k > (n // 2):\n k = n // 2\n ... | [{"input": "5 2\n", "output": "10\n"}, {"input": "1 10\n", "output": "0\n"}, {"input": "100000 2\n", "output": "399990\n"}, {"input": "1 1\n", "output": "0\n"}, {"input": "8 3\n", "output": "27\n"}, {"input": "7 1\n", "output": "11\n"}, {"input": "100000 40000\n", "output": "4799960000\n"}, {"input": "1 1000\n", "outpu... | |
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... | interview | [{"code": "from sys import stdin, stdout\nfrom math import sin, tan, cos\n\nn, m, k, l = map(int, stdin.readline().split())\n\nlb, rb = 0, n // m + 1\nwhile rb - lb > 1:\n mid = (lb + rb) >> 1\n \n if mid * m - k >= l:\n rb = mid\n else:\n lb = mid\n\nif lb != n // m:\n stdout.write(str(rb)... | [{"input": "20 15 2 3\n", "output": "1"}, {"input": "10 11 2 4\n", "output": "-1"}, {"input": "2 1 1 1\n", "output": "2"}, {"input": "10 2 9 7\n", "output": "-1"}, {"input": "530897800469409942 582203276934671957 137373076313041391 377446491430894140\n", "output": "-1"}, {"input": "1000000000000000000 1 1 1000000000000... | |
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 ... | interview | [{"code": "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(... | [{"input": "5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW\n", "output": "5\n"}, {"input": "1 2\nBB\n", "output": "-1\n"}, {"input": "3 3\nWWW\nWWW\nWWW\n", "output": "1\n"}, {"input": "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\... | |
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... | interview | [{"code": "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')", "passed": true, "time": 0.15, "memory": 14528.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nb... | [{"input": "5\n1 2 3 4 5\n2 1 4 3 5\n", "output": "Yes\n"}, {"input": "5\n1 1 1 1 1\n1 0 1 0 1\n", "output": "Yes\n"}, {"input": "3\n2 3 9\n1 7 9\n", "output": "No\n"}, {"input": "40\n361 372 139 808 561 460 421 961 727 719 130 235 320 470 432 759 317 886 624 666 917 133 736 710 462 424 541 118 228 216 612 339 800 557 ... | |
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... | interview | [{"code": "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)", "passed": true, "time": 0.4, "memory": 14636.0, "status": "done"}, {"code": "n = int(input().strip())\n\nkosi = l... | [{"input": "4\n90 90 90 90\n", "output": "0\n"}, {"input": "3\n100 100 160\n", "output": "40\n"}, {"input": "1\n360\n", "output": "360\n"}, {"input": "4\n170 30 150 10\n", "output": "0\n"}, {"input": "5\n10 10 10 10 320\n", "output": "280\n"}, {"input": "8\n45 45 45 45 45 45 45 45\n", "output": "0\n"}, {"input": "3\n12... | |
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 ... | interview | [{"code": "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()", "passed": true, "time": 0.16, "memory": 14604.0, "status": "done"}, {"code": "#! /usr/bin/env python3\n\nimport math\nimport sys\n\n\ndef l... | [{"input": "4 4\n", "output": "No\n"}, {"input": "5 3\n", "output": "Yes\n"}, {"input": "1 1\n", "output": "Yes\n"}, {"input": "744 18\n", "output": "No\n"}, {"input": "47879 10\n", "output": "Yes\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "No\n"}, {"input": "657180569218773599 42\n", "output... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.15, "memory": 14644.0, "status": "done... | [{"input": "9\n10\n", "output": "<\n"}, {"input": "11\n10\n", "output": ">\n"}, {"input": "00012345\n12345\n", "output": "=\n"}, {"input": "0123\n9\n", "output": ">\n"}, {"input": "0123\n111\n", "output": ">\n"}, {"input": "9\n9\n", "output": "=\n"}, {"input": "0\n0000\n", "output": "=\n"}, {"input": "1213121\n1213121\... | |
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... | interview | [{"code": "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)", "passed": true, "time": 4.19, "memory": 14388.0, "status": ... | [{"input": "1 1 3 4\n", "output": "3\n"}, {"input": "6 2 1 1\n", "output": "1\n"}, {"input": "4 4 4 4\n", "output": "0\n"}, {"input": "999999999 1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1016 3 2 1\n", "output": "0\n"}, {"input": "17 100 100 1\n", "output": "1\n"}, {"input": "17 2 3 100... | |
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 ... | interview | [{"code": "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 ... | [{"input": "3 4\n1 2\n2 3\n3 2\n3 1\n", "output": "YES\n"}, {"input": "5 6\n1 2\n2 3\n3 2\n3 1\n2 1\n4 5\n", "output": "NO\n"}, {"input": "2 2\n1 2\n2 1\n", "output": "YES\n"}, {"input": "7 7\n1 3\n3 6\n3 7\n5 3\n6 2\n6 7\n7 2\n", "output": "YES\n"}, {"input": "500 50\n396 340\n47 341\n422 140\n492 209\n263 248\n461 30... | |
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 -... | interview | [{"code": "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 ... | [{"input": "3 595\n43 2\n300 4\n554 10\n", "output": "281\n"}, {"input": "1 1\n1 1\n", "output": "0\n"}, {"input": "2 50\n20 0\n3 1\n", "output": "30\n"}, {"input": "5 240\n13 0\n50 25\n60 5\n155 70\n165 70\n", "output": "26\n"}, {"input": "1 100000\n99998 0\n", "output": "99997\n"}, {"input": "1 100000\n100000 0\n", "... | |
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... | interview | [{"code": "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 WI... | [{"input": "4 12\n20 30 70 90\n", "output": "150\n"}, {"input": "4 3\n10000 1000 100 10\n", "output": "10\n"}, {"input": "4 3\n10 100 1000 10000\n", "output": "30\n"}, {"input": "5 787787787\n123456789 234567890 345678901 456789012 987654321\n", "output": "44981600785557577\n"}, {"input": "30 792520535\n528145579 68285... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.21, "memory": 14568.0, "status": "done"}, {"code": "n = int(input())\nA = [int(x) for x in input().split()]\nA.sort()\nmex = 1\nfor i in range(n):\n if A[i] ... | [{"input": "5\n1 3 3 3 6\n", "output": "5\n"}, {"input": "2\n2 1\n", "output": "3\n"}, {"input": "1\n1\n", "output": "2\n"}, {"input": "1\n1000000000\n", "output": "2\n"}, {"input": "1\n2\n", "output": "2\n"}, {"input": "2\n1 1\n", "output": "2\n"}, {"input": "2\n1 3\n", "output": "3\n"}, {"input": "2\n2 2\n", "output"... | |
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$: $... | interview | [{"code": "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 = Fa... | [{"input": "5\n73452\n", "output": "YES\n"}, {"input": "4\n1248\n", "output": "NO\n"}, {"input": "2\n00\n", "output": "YES\n"}, {"input": "3\n555\n", "output": "YES\n"}, {"input": "8\n00020200\n", "output": "YES\n"}, {"input": "4\n7435\n", "output": "NO\n"}, {"input": "99\n9999999999999999999999999999999999999999999999... | |
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... | interview | [{"code": "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!\")", "passed": true, "time": 0.24, "memory": 14592.0, "status": "done"}, {"code": "print(\"IGNORE HIM!\" if len(set(input())) % 2 == 1 else \"CHAT WITH HER!\")", "passed": true,... | [{"input": "wjmzbmr\n", "output": "CHAT WITH HER!\n"}, {"input": "xiaodao\n", "output": "IGNORE HIM!\n"}, {"input": "sevenkplus\n", "output": "CHAT WITH HER!\n"}, {"input": "pezu\n", "output": "CHAT WITH HER!\n"}, {"input": "wnemlgppy\n", "output": "CHAT WITH HER!\n"}, {"input": "zcinitufxoldnokacdvtmdohsfdjepyfioyvclh... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.29, "memory": 14256.0, "status": "done"},... | [{"input": "4 2\n1 1 -1 1\n", "output": "2\n"}, {"input": "14 3\n-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1\n", "output": "9\n"}, {"input": "4 2\n1 1 1 -1\n", "output": "2\n"}, {"input": "4 2\n-1 1 -1 -1\n", "output": "2\n"}, {"input": "3 2\n1 1 -1\n", "output": "1\n"}, {"input": "20 2\n-1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 ... | |
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... | interview | [{"code": "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 ... | [{"input": "4 1 2\n", "output": "12\n"}, {"input": "2 1 5\n", "output": "6\n"}, {"input": "3 1 1\n", "output": "5\n"}, {"input": "5 5 5\n", "output": "60\n"}, {"input": "4 0 0\n", "output": "0\n"}, {"input": "6 0 6\n", "output": "30\n"}, {"input": "6 6 0\n", "output": "30\n"}, {"input": "2 1 2\n", "output": "3\n"}, {"i... | |
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... | interview | [{"code": "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])", "passed": true, "time": 2.02, "memory": 14620.0, "status": "done"}, {"code": "n, a, x, b, y = list(map(int, input().split(... | [{"input": "5 1 4 3 2\n", "output": "YES\n"}, {"input": "10 2 1 9 10\n", "output": "NO\n"}, {"input": "4 3 4 2 1\n", "output": "NO\n"}, {"input": "100 2 97 84 89\n", "output": "YES\n"}, {"input": "100 43 55 42 15\n", "output": "NO\n"}, {"input": "47 15 45 28 38\n", "output": "YES\n"}, {"input": "17 14 2 12 10\n", "outp... | |
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... | interview | [{"code": "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", "... | [{"input": "2 3 1 10\n", "output": "1\n"}, {"input": "3 5 10 22\n", "output": "8\n"}, {"input": "2 3 3 5\n", "output": "0\n"}, {"input": "2 2 1 10\n", "output": "1\n"}, {"input": "2 2 1 1000000\n", "output": "213568\n"}, {"input": "2 2 1 1000000000000000000\n", "output": "144115188075855871\n"}, {"input": "2 3 1 100000... | |
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... | interview | [{"code": "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)", "passed... | [{"input": "4\n", "output": "2\n"}, {"input": "27\n", "output": "3\n"}, {"input": "3\n", "output": "1\n"}, {"input": "5\n", "output": "1\n"}, {"input": "10\n", "output": "2\n"}, {"input": "2000000000\n", "output": "2\n"}, {"input": "26\n", "output": "2\n"}, {"input": "7\n", "output": "1\n"}, {"input": "2\n", "output": ... | |
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... | interview | [{"code": "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], ... | [{"input": "20 3 2\n10 99\n2 4 3\n20 10 40\n4 15\n10 80\n", "output": "20\n"}, {"input": "20 3 2\n10 99\n2 4 3\n200 100 400\n4 15\n100 800\n", "output": "200\n"}, {"input": "10 3 3\n10 33\n1 7 6\n17 25 68\n2 9 10\n78 89 125\n", "output": "10\n"}, {"input": "94 1 1\n26 324\n7\n236\n77\n5\n", "output": "119\n"}, {"input"... | |
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... | interview | [{"code": "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] *... | [{"input": "3 4 11\n1 2 3 4\n", "output": "6\n"}, {"input": "5 5 10\n1 2 4 8 16\n", "output": "7\n"}, {"input": "1 1 0\n2\n", "output": "0\n"}, {"input": "1 1 1\n1\n", "output": "2\n"}, {"input": "2 1 0\n2\n", "output": "0\n"}, {"input": "2 2 2\n2 3\n", "output": "1\n"}, {"input": "4 2 15\n1 4\n", "output": "9\n"}, {"i... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.1... | [{"input": "4\n", "output": "1\n"}, {"input": "3\n", "output": "0\n"}, {"input": "2\n", "output": "1\n"}, {"input": "5\n", "output": "1\n"}, {"input": "7\n", "output": "0\n"}, {"input": "8\n", "output": "0\n"}, {"input": "9\n", "output": "1\n"}, {"input": "1\n", "output": "1\n"}, {"input": "21\n", "output": "1\n"}, {"i... | |
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... | interview | [{"code": "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)", "passed": true, "time": 0.14, "memory": 14668.0, "status": "done"}, {"... | [{"input": "4 3 0\n", "output": "1 1\n"}, {"input": "4 3 11\n", "output": "1 2\n"}, {"input": "4 3 7\n", "output": "3 2\n"}, {"input": "1000000000 2 1999999999\n", "output": "1 2\n"}, {"input": "1000000000 1000000000 999999999999999999\n", "output": "1 2\n"}, {"input": "1000000000 1000000000 999999999\n", "output": "10... | |
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) = ... | interview | [{"code": "import sys\ninput = sys.stdin.readline\n\nx=int(input())\ny=x\nANS=x+1\nAX=[0,0]\n\nimport math\nL=int(math.sqrt(x))\n\nFACT=dict()\n\nfor i in range(2,L+2):\n while x%i==0:\n FACT[i]=FACT.get(i,0)+1\n x=x//i\n\nif x!=1:\n FACT[x]=FACT.get(x,0)+1\nx=y\nLEN=len(FACT)\nLIST=list(FACT.keys()... | [{"input": "2\n", "output": "1 2\n"}, {"input": "6\n", "output": "2 3\n"}, {"input": "4\n", "output": "1 4\n"}, {"input": "1\n", "output": "1 1\n"}, {"input": "24\n", "output": "8 3\n"}, {"input": "200560490130\n", "output": "448630 447051\n"}, {"input": "999999999989\n", "output": "1 999999999989\n"}, {"input": "10000... | |
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, ... | interview | [{"code": "n1 = int( input() )\nn2 = int( input() )\nn3 = int( input() )\nprint( min( n1 , n2 // 2 , n3 // 4 ) * 7 )\n", "passed": true, "time": 0.2, "memory": 14496.0, "status": "done"}, {"code": "#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n a = int(input())\n b = int(in... | [{"input": "2\n5\n7\n", "output": "7\n"}, {"input": "4\n7\n13\n", "output": "21\n"}, {"input": "2\n3\n2\n", "output": "0\n"}, {"input": "1\n1\n1\n", "output": "0\n"}, {"input": "1\n2\n4\n", "output": "7\n"}, {"input": "1000\n1000\n1000\n", "output": "1750\n"}, {"input": "1\n1\n4\n", "output": "0\n"}, {"input": "1\n2\n3... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.15, "memory": 14616.0, "status": "done"}, {"code": "n=int(input())\na=sorted(list(map(int,input().split())))\nprint('YES'if a[n-1]<a[n] else... | [{"input": "2\n1 3 2 4\n", "output": "YES\n"}, {"input": "1\n3 3\n", "output": "NO\n"}, {"input": "5\n1 1 1 1 2 2 3 3 3 3\n", "output": "NO\n"}, {"input": "5\n1 1 1 1 1 2 2 2 2 2\n", "output": "YES\n"}, {"input": "10\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n"... | |
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... | interview | [{"code": "n = int(input())\na = [int(i) for i in input().split()]\nc = 0\ni = 0\nwhile i < n - 1:\n x = a[i]\n y = a[i + 1]\n while y > 0:\n x, y = y, x % y\n if x > 1:\n a = a[:i + 1] + [1] + a[i + 1:]\n i += 2\n c += 1\n n += 1\n else:\n i += 1\nprint(c)\nprin... | [{"input": "3\n2 7 28\n", "output": "1\n2 7 1 28\n"}, {"input": "1\n1\n", "output": "0\n1\n"}, {"input": "1\n548\n", "output": "0\n548\n"}, {"input": "1\n963837006\n", "output": "0\n963837006\n"}, {"input": "10\n1 1 1 1 1 1 1 1 1 1\n", "output": "0\n1 1 1 1 1 1 1 1 1 1\n"}, {"input": "10\n26 723 970 13 422 968 875 329 ... | |
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... | interview | [{"code": "# \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\u... | [{"input": "2 3\n8 20\n", "output": "7\n"}, {"input": "2 10\n3 5\n", "output": "8\n"}, {"input": "4 5\n10 1 2 22\n", "output": "7\n"}, {"input": "8 7\n1 7 5 6 8 2 6 5\n", "output": "5\n"}, {"input": "2 1\n1 1\n", "output": "2\n"}, {"input": "500 1000000000\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 100000... | |
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 ... | interview | [{"code": "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)", "passed": true, "time": 0.15, "memory": 14624.0, "status": "done"}, {"code": "import itertools as it, math, functools as ft\nn, k = map(int, inp... | [{"input": "3 6\n2 3 5\n", "output": "2\n"}, {"input": "6 7\n1 2 3 4 5 6\n", "output": "7\n"}, {"input": "5 97\n1 10 50 97 2\n", "output": "1\n"}, {"input": "5 97\n1 10 50 100 2\n", "output": "97\n"}, {"input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 4... | |
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... | interview | [{"code": "n,k=[int(i) for i in input().split()]\ns=input()\nf=s.find('G')\nt=s.find('T')\nif f<t:\n f,t=t,f\nif (f-t)%k:\n print('NO')\nelse:\n for i in range(t+k,f,k):\n if s[i]=='#':\n print('NO')\n break\n else:\n print('YES')\n", "passed": true, "time": 1.85, "memory... | [{"input": "5 2\n#G#T#\n", "output": "YES\n"}, {"input": "6 1\nT....G\n", "output": "YES\n"}, {"input": "7 3\nT..#..G\n", "output": "NO\n"}, {"input": "6 2\n..GT..\n", "output": "NO\n"}, {"input": "2 1\nGT\n", "output": "YES\n"}, {"input": "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.####.#... | |
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... | interview | [{"code": "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}\")", "passed": true, "time": 0.14, "memory": 14408.0, "status": "done"}, {"... | [{"input": "4 10 13 10 3 1\n", "output": "4.3750000000\n"}, {"input": "1 4 6 2 2 1\n", "output": "-1\n"}, {"input": "3 10 15 17 9 2\n", "output": "11.3333333333\n"}, {"input": "4 9 30 3 3 1\n", "output": "-1\n"}, {"input": "4 9 13 2 3 1\n", "output": "-1\n"}, {"input": "4 9 13 1 1 1\n", "output": "-1\n"}, {"input": "1 ... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.24, "memory": 14356.0, "status": "done"}, {"code": "def c(ans, b ,d, s):\n\treturn(min(ans, 3 * max(b, d, s) - ... | [{"input": "3 2 1\n", "output": "1\n"}, {"input": "1 0 0\n", "output": "0\n"}, {"input": "1 1 1\n", "output": "0\n"}, {"input": "1000000000000000000 0 1000000000000000000\n", "output": "999999999999999999\n"}, {"input": "1000 0 0\n", "output": "1998\n"}, {"input": "0 1 0\n", "output": "0\n"}, {"input": "0 0 1\n", "outp... | |
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,... | interview | [{"code": "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 ... | [{"input": "8\n1 2 3 6 9 8 5 2\n", "output": "YES\n1000000000 3\n"}, {"input": "6\n1 2 1 2 5 3\n", "output": "NO\n"}, {"input": "2\n1 10\n", "output": "YES\n1000000000 9\n"}, {"input": "3\n1 2 2\n", "output": "NO\n"}, {"input": "1\n1\n", "output": "YES\n1000000000 1\n"}, {"input": "1\n6\n", "output": "YES\n1000000000 1... | |
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... | interview | [{"code": "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_... | [{"input": "hi\nbob\n", "output": "-\n"}, {"input": "abca\naccepted\n", "output": "ac\n"}, {"input": "abacaba\nabcdcba\n", "output": "abcba\n"}, {"input": "lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm\n", "output": "-\n"}, {"input": "aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk\n"... | |
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... | interview | [{"code": "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)", "passed": true, "time": 0.15, "memory": 14480.0, "status": "done"}, {"code": "n = int(input())\na = int(input())\nb = int(input())\nc = int(input())\nif(a <... | [{"input": "10\n11\n9\n8\n", "output": "2\n"}, {"input": "10\n5\n6\n1\n", "output": "2\n"}, {"input": "2\n2\n2\n1\n", "output": "1\n"}, {"input": "10\n3\n3\n1\n", "output": "4\n"}, {"input": "10\n1\n2\n1\n", "output": "10\n"}, {"input": "10\n2\n3\n1\n", "output": "5\n"}, {"input": "9\n2\n4\n1\n", "output": "4\n"}, {"in... | |
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... | interview | [{"code": "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:... | [{"input": "abacaba\n", "output": "Too weak\n"}, {"input": "X12345\n", "output": "Too weak\n"}, {"input": "CONTEST_is_STARTED!!11\n", "output": "Correct\n"}, {"input": "1zA__\n", "output": "Correct\n"}, {"input": "1zA_\n", "output": "Too weak\n"}, {"input": "zA___\n", "output": "Too weak\n"}, {"input": "1A___\n", "outp... | |
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... | interview | [{"code": "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 a... | [{"input": "4\n5 4 4 4\n5 5 4 5\n", "output": "1\n"}, {"input": "6\n1 1 1 1 1 1\n5 5 5 5 5 5\n", "output": "3\n"}, {"input": "1\n5\n3\n", "output": "-1\n"}, {"input": "9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n", "output": "4\n"}, {"input": "1\n1\n2\n", "output": "-1\n"}, {"input": "1\n1\n1\n", "output": "0\n"}, {"input... | |
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... | interview | [{"code": "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", "passed": true, "time"... | [{"input": "3 3\n><>\nv^v\n", "output": "NO\n"}, {"input": "4 6\n<><>\nv^v^v^\n", "output": "YES\n"}, {"input": "2 2\n<>\nv^\n", "output": "YES\n"}, {"input": "2 2\n>>\n^v\n", "output": "NO\n"}, {"input": "3 3\n>><\n^^v\n", "output": "YES\n"}, {"input": "3 4\n>><\n^v^v\n", "output": "YES\n"}, {"input": "3 8\n>><\nv^^^^... | |
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'... | interview | [{"code": "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... | [{"input": "4\n0 1 1 0\n", "output": "YES\n0->1->1->0\n"}, {"input": "2\n1 1\n", "output": "NO\n"}, {"input": "1\n0\n", "output": "YES\n0\n"}, {"input": "4\n0 0 0 0\n", "output": "YES\n0->(0->0)->0\n"}, {"input": "6\n0 0 0 0 0 1\n", "output": "NO\n"}, {"input": "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output":... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.24, "memory": 14588.0, "status": "done"}, {"code": "a,b=list(map(int,input().split()))\nw... | [{"input": "12 5\n", "output": "0 1\n"}, {"input": "31 12\n", "output": "7 12\n"}, {"input": "1000000000000000000 7\n", "output": "8 7\n"}, {"input": "31960284556200 8515664064180\n", "output": "14928956427840 8515664064180\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000 10000... | |
176 | Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.
-----Input-----
The only line contains three space-separated integers k, a and b (1 ≤ k ≤ 10^18; - 10^18 ≤ a ≤ b ≤ 10^18).
-----Output-----
Prin... | interview | [{"code": "s=input()\nast=[int(i) for i in s.split(' ')]\nk,a,b=ast[0],ast[1],ast[2]\ns1=(a-1)//k\ns2=b//k\nprint(s2-s1)\n", "passed": true, "time": 0.24, "memory": 14372.0, "status": "done"}, {"code": "k, a, b = list(map(int, input().split()))\nf = (a + k - 1) // k\nl = b // k\nprint(l - f + 1)\n", "passed": true, "ti... | [{"input": "1 1 10\n", "output": "10\n"}, {"input": "2 -4 4\n", "output": "5\n"}, {"input": "1 1 1\n", "output": "1\n"}, {"input": "1 0 0\n", "output": "1\n"}, {"input": "1 0 1\n", "output": "2\n"}, {"input": "1 10181 10182\n", "output": "2\n"}, {"input": "1 10182 10183\n", "output": "2\n"}, {"input": "1 -191 1011\n", ... | |
177 | Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...
Your task is to print the $k$-th digit of this sequence.
-----Input-----
The fir... | interview | [{"code": "a = int(input())\ns = \"\"\nfor i in range(1, a+1):\n s += str(i)\nprint(s[a-1])", "passed": true, "time": 0.37, "memory": 14292.0, "status": "done"}, {"code": "k = int(input())\ns = \"\"\ni = 1\nwhile len(s) < k + 10:\n\ts += str(i)\n\ti += 1\nk -= 1\nprint(s[k])", "passed": true, "time": 0.17, "memory":... | [{"input": "7\n", "output": "7\n"}, {"input": "21\n", "output": "5\n"}, {"input": "1\n", "output": "1\n"}, {"input": "2\n", "output": "2\n"}, {"input": "3\n", "output": "3\n"}, {"input": "4\n", "output": "4\n"}, {"input": "5\n", "output": "5\n"}, {"input": "6\n", "output": "6\n"}, {"input": "8\n", "output": "8\n"}, {"i... | |
178 | A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and eras... | interview | [{"code": "n, s = int(input()), input()\ncnt = (n - 11) // 2\ncnt_8 = len(s[:n - 10].split('8')) - 1\nif (cnt >= cnt_8):\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\")", "passed": true, "time": 0.15, "memory": 14580.0, "status": "done"}, {"code": "def main():\n n = int(input())\n arr = list(map(int, input()))\n a... | [{"input": "13\n8380011223344\n", "output": "YES\n"}, {"input": "15\n807345619350641\n", "output": "NO\n"}, {"input": "19\n8181818181111111111\n", "output": "YES\n"}, {"input": "29\n88811188118181818118111111111\n", "output": "NO\n"}, {"input": "15\n980848088815548\n", "output": "NO\n"}, {"input": "13\n9999999998888\n"... | |
179 | Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | interview | [{"code": "MOD = 1000000007\n\n\ndef f(n, cnt):\n \"\"\"\n n! / (n - cnt)!\n \"\"\"\n ans = 1\n for _ in range(cnt):\n ans = (ans * n) % MOD\n n -= 1\n return ans\n\n\ndef main():\n n, x, pos = list(map(int, input().split()))\n chk1 = 0\n chk_r = 0\n left = 0\n right = n\n... | [{"input": "4 1 2\n", "output": "6\n"}, {"input": "123 42 24\n", "output": "824071958\n"}, {"input": "1 1 0\n", "output": "1\n"}, {"input": "1000 501 501\n", "output": "646597996\n"}, {"input": "1000 999 799\n", "output": "0\n"}, {"input": "2 1 1\n", "output": "1\n"}, {"input": "2 2 0\n", "output": "0\n"}, {"input": "3... | |
181 | Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.
One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it be... | interview | [{"code": "n = (-int(input())) % 360\n\nret, opt = 4, 361\nfor i in range(4):\n x = (n+90*i)%360\n x = min(x, 360-x)\n if (x, i) < (opt, ret):\n opt, ret = x, i\n\nprint(ret)", "passed": true, "time": 0.24, "memory": 14568.0, "status": "done"}, {"code": "from functools import reduce\nfrom math import fa... | [{"input": "60\n", "output": "1\n"}, {"input": "-60\n", "output": "3\n"}, {"input": "0\n", "output": "0\n"}, {"input": "44\n", "output": "0\n"}, {"input": "45\n", "output": "0\n"}, {"input": "46\n", "output": "1\n"}, {"input": "134\n", "output": "1\n"}, {"input": "135\n", "output": "1\n"}, {"input": "136\n", "output": ... | |
182 | Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple... | interview | [{"code": "a, b, c = list(map(int, input().split()))\nx, y, z = list(map(int, input().split()))\ncol = max(0, x - a) + max(0, y - b) + max(0, z - c)\nsum = max(0, (a - x) // 2) + max(0, (b - y) // 2) + max(0, (c - z) // 2)\nif sum >= col:\n print('Yes')\nelse:\n print('No')\n", "passed": true, "time": 0.16, "memo... | [{"input": "4 4 0\n2 1 2\n", "output": "Yes\n"}, {"input": "5 6 1\n2 7 2\n", "output": "No\n"}, {"input": "3 3 3\n2 2 2\n", "output": "Yes\n"}, {"input": "0 0 0\n0 0 0\n", "output": "Yes\n"}, {"input": "0 0 0\n0 0 1\n", "output": "No\n"}, {"input": "0 1 0\n0 0 0\n", "output": "Yes\n"}, {"input": "1 0 0\n1 0 0\n", "outp... | |
184 | You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.
The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactl... | interview | [{"code": "import base64\nimport zlib\npro = base64.decodebytes(\"\"\"eJxtUUFuwyAQvPOKVarKkDhOm2MlX/uC3qqqAhs7KBgswGr6+y4QrLqqL7DD7OzMWk2zdQFGGWbu\nPVG59N/rdeLhUu6Om95OpVJBumCtXqlCedkFQgalpYcW3twiSS/FMmLxyrWXhKihzGrwXLx0lEHb\nQjU4e5HmWgHOgKTwQgC/0p/EIoDeGh96ZRC0szR0F6QPjTI7lt4fCsMuoVCqREGgqqH6qjIxBSZo\ncADdTZTXIFie6dCZ... | [{"input": "1 4 2\n", "output": "6\n"}, {"input": "5 5 5\n", "output": "14\n"}, {"input": "0 2 0\n", "output": "0\n"}, {"input": "30 70 34\n", "output": "128\n"}, {"input": "89 32 24\n", "output": "112\n"}, {"input": "89 44 77\n", "output": "210\n"}, {"input": "0 0 0\n", "output": "0\n"}, {"input": "100 100 100\n", "ou... | |
185 | Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible.
There are $n$ manholes in the room which are situated on one line, but, unfortunately, all the manholes are c... | interview | [{"code": "n, k = list(map(int,input().split()))\nif k == 1 or k == n:\n print(3 * n)\nelse:\n print(3 * n + min(k - 1, n - k))\n", "passed": true, "time": 0.17, "memory": 14352.0, "status": "done"}, {"code": "l = list(map(int, input().split()))\nprint(3*l[0]+min(l[1]-1,l[0]-l[1]))\n", "passed": true, "time": 0.1... | [{"input": "2 2\n", "output": "6\n"}, {"input": "4 2\n", "output": "13\n"}, {"input": "5 1\n", "output": "15\n"}, {"input": "64 49\n", "output": "207\n"}, {"input": "24 6\n", "output": "77\n"}, {"input": "91 39\n", "output": "311\n"}, {"input": "87 87\n", "output": "261\n"}, {"input": "72 36\n", "output": "251\n"}, {"i... | |
186 | Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.
The students don’t want to use too many blocks, but they also want to be uniq... | interview | [{"code": "n, m = list(map(int, input().split()))\n\nstart = 0\nend = 10**10\nwhile (end - start > 1):\n mid = (end + start) // 2\n two = mid // 2 - mid // 6\n three = mid // 3 - mid // 6\n six = mid // 6\n\n nn = n\n mm = m\n\n nn -= two\n mm -= three\n nn = max(nn, 0)\n mm = max(mm, 0)\n... | [{"input": "1 3\n", "output": "9\n"}, {"input": "3 2\n", "output": "8\n"}, {"input": "5 0\n", "output": "10\n"}, {"input": "4 2\n", "output": "9\n"}, {"input": "0 1000000\n", "output": "3000000\n"}, {"input": "1000000 1\n", "output": "2000000\n"}, {"input": "1083 724\n", "output": "2710\n"}, {"input": "1184 868\n", "ou... | |
187 | Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card.
Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with num... | interview | [{"code": "n = int(input())\na = [int(input()) for i in range(n)]\na.sort()\nb = [ai for ai in a if ai==a[0]]\nc = [ai for ai in a if ai!=a[0]]\nif len(b)==len(c) and c[0]==c[-1]:\n print('YES')\n print(b[0], c[0])\nelse:\n print('NO')", "passed": true, "time": 0.15, "memory": 14364.0, "status": "done"}, {"cod... | [{"input": "4\n11\n27\n27\n11\n", "output": "YES\n11 27\n"}, {"input": "2\n6\n6\n", "output": "NO\n"}, {"input": "6\n10\n20\n30\n20\n10\n20\n", "output": "NO\n"}, {"input": "6\n1\n1\n2\n2\n3\n3\n", "output": "NO\n"}, {"input": "2\n1\n100\n", "output": "YES\n1 100\n"}, {"input": "2\n1\n1\n", "output": "NO\n"}, {"input":... | |
188 | Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains a_{i} soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call tw... | interview | [{"code": "import sys\n\ndef r():\n return list(map(int, input().split()))\n\nn, k = list(map(int, input().split()))\na = r()\n\ncnt4 = n\ncnt2 = 2*n\ncnt1 = 0\nfor i in range(k):\n x = min((a[i]+1)//4, cnt4)\n cnt4 -= x\n a[i] = max(0, a[i]-4*x)\n\ncnt2 += cnt4\ncnt1 += cnt4\nfor i in range(k):\n x = mi... | [{"input": "2 2\n5 8\n", "output": "YES\n"}, {"input": "1 2\n7 1\n", "output": "NO\n"}, {"input": "1 2\n4 4\n", "output": "YES\n"}, {"input": "1 4\n2 2 1 2\n", "output": "YES\n"}, {"input": "10000 100\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 ... | |
189 | Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \ldots, a_n$.
For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.
A ... | interview | [{"code": "n = int(input())\na = list(map(int,input().split()))\nt = 0\nmn = 1000000000\nfor i in range(1,100):\n cur = 0\n for j in range(n):\n cur += max(0,abs(i-a[j])-1)\n if cur < mn:\n mn = cur\n t = i\nprint(t,mn)\n", "passed": true, "time": 0.2, "memory": 14536.0, "status": "done"},... | [{"input": "3\n10 1 4\n", "output": "3 7\n"}, {"input": "5\n1 1 2 2 3\n", "output": "2 0\n"}, {"input": "1\n5\n", "output": "4 0\n"}, {"input": "2\n1 2\n", "output": "1 0\n"}, {"input": "3\n1 1 1\n", "output": "1 0\n"}, {"input": "5\n100 100 100 100 100\n", "output": "99 0\n"}, {"input": "113\n86 67 31 33 72 100 88 63 ... | |
190 | Карта звёздного неба представляет собой прямоугольное поле, состоящее из n строк по m символов в каждой строке. Каждый символ — это либо «.» (означает пустой участок неба), либо «*» (означает то, что в этом месте на небе есть звезда).
Новое издание карты звёздного неба будет напечатано на квадратных листах, поэтому т... | interview | [{"code": "n, m = input().split()\nn = int(n)\nm = int(m)\na = []\nN = n\nfor i in range(n) :\n a.append(input().split())\n \nfor i in range(n) :\n if a[i][0].find('*') == -1 :\n n-=1\n else :\n break\nif n != 1 :\n for i in range(len(a)-1,-1,-1) :\n if a[i][0].find('*') == -1 :\n ... | [{"input": "4 4\n....\n..*.\n...*\n..**\n", "output": "3\n"}, {"input": "1 3\n*.*\n", "output": "3\n"}, {"input": "2 1\n.\n*\n", "output": "1\n"}, {"input": "1 1\n*\n", "output": "1\n"}, {"input": "1 2\n.*\n", "output": "1\n"}, {"input": "1 2\n*.\n", "output": "1\n"}, {"input": "1 2\n**\n", "output": "2\n"}, {"input": ... | |
192 | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | interview | [{"code": "x, y = list(map(int, input().split()))\nx, y = y, x\nA = x\nB = x\ncurr = x\ncount = 0\nwhile curr < y:\n\tcurr = B + A - 1\n\tA, B = B, curr\n\tcount += 1\ncount += 2\nprint(count)\n", "passed": true, "time": 0.15, "memory": 14568.0, "status": "done"}, {"code": "t, f = list(map(int, input().split()))\ns = [... | [{"input": "6 3\n", "output": "4\n"}, {"input": "8 5\n", "output": "3\n"}, {"input": "22 4\n", "output": "6\n"}, {"input": "4 3\n", "output": "3\n"}, {"input": "57 27\n", "output": "4\n"}, {"input": "61 3\n", "output": "9\n"}, {"input": "5 4\n", "output": "3\n"}, {"input": "10 6\n", "output": "3\n"}, {"input": "20 10\n... | |
194 | In a small restaurant there are a tables for one person and b tables for two persons.
It it known that n groups of people come today, each consisting of one or two people.
If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater tabl... | interview | [{"code": "n, a, b = list(map(int,input().split()))\nl = input().split()\no = 0\nc = 0\nfor i in l:\n if i == '2':\n if b > 0:\n b -= 1\n else:\n o += 2\n if i == '1':\n if a > 0:\n a -= 1\n elif b > 0:\n b -= 1\n c += 1\n e... | [{"input": "4 1 2\n1 2 1 1\n", "output": "0\n"}, {"input": "4 1 1\n1 1 2 1\n", "output": "2\n"}, {"input": "1 1 1\n1\n", "output": "0\n"}, {"input": "2 1 2\n2 2\n", "output": "0\n"}, {"input": "5 1 3\n1 2 2 2 1\n", "output": "1\n"}, {"input": "7 6 1\n1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "10 2 1\n2 1 2 2 2 2 1 ... | |
195 | Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after the exam.
Some of them celebrated in the BugDonalds restaurant, some of them... | interview | [{"code": "from sys import stdin, stdout\n\na, b, c, d = map(int, stdin.readline().split())\nq = d - a - b + c\n\nif c > min(a, b) or q <= 0:\n stdout.write('-1')\nelse:\n stdout.write(str(q))", "passed": true, "time": 0.14, "memory": 14348.0, "status": "done"}] | [{"input": "10 10 5 20\n", "output": "5"}, {"input": "2 2 0 4\n", "output": "-1"}, {"input": "2 2 2 1\n", "output": "-1"}, {"input": "98 98 97 100\n", "output": "1"}, {"input": "1 5 2 10\n", "output": "-1"}, {"input": "5 1 2 10\n", "output": "-1"}, {"input": "6 7 5 8\n", "output": "-1"}, {"input": "6 7 5 9\n", "output"... | |
196 | Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month).
Unfortunately, right after the doubling the wardrobe eats one of the dresses (if any) with ... | interview | [{"code": "x, k = map(int, input().split())\nif x == 0:\n print(0)\nelse:\n mod = 10 ** 9 + 7\n p = pow(2, k, mod)\n ans = (x * (p * 2) - (p - 1)) % mod\n print(ans)", "passed": true, "time": 0.24, "memory": 14576.0, "status": "done"}, {"code": "mod = 10**9+7\nx, k = list(map(int, input().split(' ')))\ni... | [{"input": "2 0\n", "output": "4\n"}, {"input": "2 1\n", "output": "7\n"}, {"input": "3 2\n", "output": "21\n"}, {"input": "1 411\n", "output": "485514976\n"}, {"input": "1 692\n", "output": "860080936\n"}, {"input": "16 8\n", "output": "7937\n"}, {"input": "18 12\n", "output": "143361\n"}, {"input": "1 100000000000000... | |
197 | An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared $n$ problems; and since the platform is very popular, $998244351$ coder from all over the world is going to solve them.
For each problem, the authors estimated the number of people who would solve it... | interview | [{"code": "from bisect import bisect_left\n\nM = 998244353\n\ndef pw(x, y):\n if y == 0:\n return 1\n res = pw(x, y//2)\n res = res * res % M\n if y % 2 == 1:\n res = res * x % M\n return res\n\ndef cal(x, y):\n y += x - 1\n res = 1\n for i in range(1, x + 1):\n res = res * ... | [{"input": "3\n1 2\n1 2\n1 2\n", "output": "499122177\n"}, {"input": "2\n42 1337\n13 420\n", "output": "578894053\n"}, {"input": "2\n1 1\n0 0\n", "output": "1\n"}, {"input": "2\n1 1\n1 1\n", "output": "1\n"}, {"input": "2\n1 1\n0 1\n", "output": "1\n"}, {"input": "2\n0 1\n0 1\n", "output": "249561089\n"}, {"input": "2\... | |
198 | Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n.
Pasha likes rectangles but hates squares, so he wonders, how many ways are there to spli... | interview | [{"code": "n = int(input())\nif n%2==1:\n print(0)\nelif n%4==2:\n print(n//4)\nelse:\n print(n//4-1)\n", "passed": true, "time": 0.22, "memory": 14400.0, "status": "done"}, {"code": "n = int(input())\np = n // 2\nif (n % 2 == 1):\n print(0)\nelse:\n if (n % 4 == 0):\n print((p-1)//2)\n else:\n... | [{"input": "6\n", "output": "1\n"}, {"input": "20\n", "output": "4\n"}, {"input": "1\n", "output": "0\n"}, {"input": "2\n", "output": "0\n"}, {"input": "3\n", "output": "0\n"}, {"input": "4\n", "output": "0\n"}, {"input": "2000000000\n", "output": "499999999\n"}, {"input": "1924704072\n", "output": "481176017\n"}, {"in... | |
199 | The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of k... | interview | [{"code": "def doit():\n xx = input().split()\n n = int(xx[0])\n s = int(xx[1])\n v = [int(k) for k in input().split()]\n\n S = sum(v)\n newS = S - s\n if newS < 0:\n return -1\n return min(newS//n, min(v))\n \nprint(doit())\n", "passed": true, "time": 0.36, "memory": 14452.0, "sta... | [{"input": "3 3\n4 3 5\n", "output": "3\n"}, {"input": "3 4\n5 3 4\n", "output": "2\n"}, {"input": "3 7\n1 2 3\n", "output": "-1\n"}, {"input": "1 1\n1\n", "output": "0\n"}, {"input": "1 2\n1\n", "output": "-1\n"}, {"input": "5 10\n10 10 10 10 10\n", "output": "8\n"}, {"input": "1 1000000000\n1000000000\n", "output": "... | |
200 | The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h_1 cm from the ground. On the height h_2 cm (h_2 > h_1) on the same tree hung an apple and the caterpillar was crawling to the apple.
Gabriel is interested when the cater... | interview | [{"code": "def solve():\n h1, h2 = list(map(int, input().split()))\n a, b = list(map(int, input().split()))\n\n h3 = h1 + a * 8\n\n if h3 >= h2:\n print(0)\n return\n\n if b >= a:\n print(-1)\n return\n\n h4 = h2 - h3\n\n c = (a - b) * 12\n\n ans = int((h4 + (c - 1)) ... | [{"input": "10 30\n2 1\n", "output": "1\n"}, {"input": "10 13\n1 1\n", "output": "0\n"}, {"input": "10 19\n1 2\n", "output": "-1\n"}, {"input": "1 50\n5 4\n", "output": "1\n"}, {"input": "1 1000\n2 1\n", "output": "82\n"}, {"input": "999 1000\n1 1\n", "output": "0\n"}, {"input": "999 1000\n1 1000\n", "output": "0\n"}, ... | |
201 | A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | interview | [{"code": "import sys\nf = sys.stdin\n\nC, Hr, Hb, Wr, Wb = map(int, f.readline().strip().split())\n\nif Hr/Wr < Hb/Wb:\n Hr, Hb, Wr, Wb = Hb, Hr, Wb, Wr\n\nif (C % Wr) == 0 and (C // Wr) > 0:\n print((C // Wr)*Hr)\n \nelif (C // Wr) == 0:\n print((C // Wb)*Hb)\n\nelse:\n nmax = (C // Wr)\n pmax = nm... | [{"input": "10 3 5 2 3\n", "output": "16\n"}, {"input": "5 3 1 6 7\n", "output": "0\n"}, {"input": "982068341 55 57 106 109\n", "output": "513558662\n"}, {"input": "930064129 32726326 25428197 83013449 64501049\n", "output": "363523396\n"}, {"input": "927155987 21197 15994 54746 41309\n", "output": "358983713\n"}, {"in... | |
202 | Professor GukiZ makes a new robot. The robot are in the point with coordinates (x_1, y_1) and should go to the point (x_2, y_2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal number of s... | interview | [{"code": "a, b = map(int, input().split())\nd, c = map(int, input().split())\nprint(max(abs(a - d), abs(b - c)))", "passed": true, "time": 0.17, "memory": 14380.0, "status": "done"}, {"code": "x1, y1 = list(map(int, input().split()))\nx2, y2 = list(map(int, input().split()))\n\ndx = abs(x1 - x2)\ndy = abs(y1 - y2)\n\n... | [{"input": "0 0\n4 5\n", "output": "5\n"}, {"input": "3 4\n6 1\n", "output": "3\n"}, {"input": "0 0\n4 6\n", "output": "6\n"}, {"input": "1 1\n-3 -5\n", "output": "6\n"}, {"input": "-1 -1\n-10 100\n", "output": "101\n"}, {"input": "1 -1\n100 -100\n", "output": "99\n"}, {"input": "-1000000000 -1000000000\n1000000000 100... | |
203 | There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | interview | [{"code": "n = int(input())\ns = input()\ncountr = s.count('R')\ncountd = n - countr\ncr = 0\ncd = 0\ni = 0\nnews = []\nwhile countr != 0 and countd != 0:\n if s[i] == 'D':\n if cd == 0:\n cr += 1\n countr -= 1\n news.append('D')\n else:\n cd -= 1\n else:\... | [{"input": "5\nDDRRR\n", "output": "D\n"}, {"input": "6\nDDRRRR\n", "output": "R\n"}, {"input": "1\nD\n", "output": "D\n"}, {"input": "1\nR\n", "output": "R\n"}, {"input": "2\nDR\n", "output": "D\n"}, {"input": "3\nRDD\n", "output": "D\n"}, {"input": "3\nDRD\n", "output": "D\n"}, {"input": "4\nDRRD\n", "output": "D\n"}... | |
204 | Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $a$ and screen height not greater than $b$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $... | interview | [{"code": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\na, b, x, y = list(map(int, input().split()))\n\ng = gcd(x, y)\nx //= g\ny //= g\n\n\nprint(min(a // x, b // y))\n", "passed": true, "time": 0.15, "memory": 14396.0, "status": "done"}, {"code": "from math import gcd\n\na, b, x, y = map(int... | [{"input": "17 15 5 3\n", "output": "3\n"}, {"input": "14 16 7 22\n", "output": "0\n"}, {"input": "4 2 6 4\n", "output": "1\n"}, {"input": "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\n", "output": "1000000063\n"}, {"input": "1 1 1 1\n", "output": "1\n"}, {"input": "1000000000000000000... | |
205 | The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis.
Aki is fond of numbers, especially those with trailing zeros. For example, the number $9200$ has two trailing zeros. Aki thinks the more trailing zero digits a... | interview | [{"code": "n, k = map(int, input().split())\na = []\ni = 2\nwhile (i * i <= k):\n if (k % i == 0):\n a.append([i, 0])\n while (k % i == 0):\n a[len(a) - 1][1] += 1\n k //= i\n i += 1\nif (k > 1):\n a.append([k, 1])\nans = 10 ** 20\nfor i in a:\n cnt = 0\n x = i[0]\n ... | [{"input": "6 9\n", "output": "1\n"}, {"input": "38 11\n", "output": "3\n"}, {"input": "5 2\n", "output": "3\n"}, {"input": "5 10\n", "output": "1\n"}, {"input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"input": "1000000000000000000 999999999989\n", "output": "1000000\n"}, {"input": "10... | |
206 | A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.
Let $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, x]$. The frog doesn't ne... | interview | [{"code": "import math\nm,a,b=map(int,input().split())\ng=math.gcd(a,b)\na1=a//g\nb1=b//g\nalls=g*(a1+b1-1)\ndists=[0]+[-1]*(a1+b1-1)\ndist=0\nfar=0\nwhile dist!=b1:\n if dist<b1:\n dist+=a1\n far=max(dist,far)\n else:\n dist-=b1\n if dists[dist]==-1:\n dists[dist]=far\ntot=0\nfor i... | [{"input": "7 5 3\n", "output": "19\n"}, {"input": "1000000000 1 2019\n", "output": "500000001500000001\n"}, {"input": "100 100000 1\n", "output": "101\n"}, {"input": "6 4 5\n", "output": "10\n"}, {"input": "172165 93846 84\n", "output": "1735345812\n"}, {"input": "9978 99 98615\n", "output": "507929\n"}, {"input": "99... | |
207 | Where do odds begin, and where do they end? Where does hope emerge, and will they ever break?
Given an integer sequence a_1, a_2, ..., a_{n} of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with odd numbers.
A ... | interview | [{"code": "def read_ints():\n\treturn [int(i) for i in input().split()]\n\nn = read_ints()\na = read_ints()\nif len(a) % 2 and a[0] % 2 and a[-1] % 2:\n\tprint('Yes')\nelse:\n\tprint('No')", "passed": true, "time": 0.14, "memory": 14448.0, "status": "done"}, {"code": "n = int(input())\narr = list(map(int,input().split(... | [{"input": "3\n1 3 5\n", "output": "Yes\n"}, {"input": "5\n1 0 1 5 1\n", "output": "Yes\n"}, {"input": "3\n4 3 1\n", "output": "No\n"}, {"input": "4\n3 9 9 3\n", "output": "No\n"}, {"input": "1\n1\n", "output": "Yes\n"}, {"input": "5\n100 99 100 99 99\n", "output": "No\n"}, {"input": "100\n100 100 100 100 100 100 100 1... | |
208 | Pashmak has fallen in love with an attractive girl called Parmida since one year ago...
Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to the coordinate axes. He al... | interview | [{"code": "x1, y1, x2, y2 = map(int, input().split())\n#diagonal\nif x1 != x2 and y1 != y2:\n if abs(x1 - x2) == abs(y1 - y2):\n print(x1, y2, x2, y1)\n else:\n print(-1)\n#same side\nelif x1 == x2:\n aux = abs(y2 - y1)\n print(x1 + aux, y1, x1 + aux, y2)\nelif y1 == y2:\n aux = abs(x2 - x1... | [{"input": "0 0 0 1\n", "output": "1 0 1 1\n"}, {"input": "0 0 1 1\n", "output": "0 1 1 0\n"}, {"input": "0 0 1 2\n", "output": "-1\n"}, {"input": "-100 -100 100 100\n", "output": "-100 100 100 -100\n"}, {"input": "-100 -100 99 100\n", "output": "-1\n"}, {"input": "0 -100 0 100\n", "output": "200 -100 200 100\n"}, {"in... | |
209 | Jzzhu has invented a kind of sequences, they meet the following property:$f_{1} = x ; f_{2} = y ; \forall i(i \geq 2), f_{i} = f_{i - 1} + f_{i + 1}$
You are given x and y, please calculate f_{n} modulo 1000000007 (10^9 + 7).
-----Input-----
The first line contains two integers x and y (|x|, |y| ≤ 10^9). The second... | interview | [{"code": "def main():\n x, y = [int(i) for i in input().split()]\n n = int(input())\n \n result = [x, y, y - x, -x, -y, x - y][(n - 1) % 6]\n \n print(result % 1000000007)\n\n\nmain()\n", "passed": true, "time": 0.15, "memory": 14356.0, "status": "done"}, {"code": "x, y = list(map(int, input().split(... | [{"input": "2 3\n3\n", "output": "1\n"}, {"input": "0 -1\n2\n", "output": "1000000006\n"}, {"input": "-9 -11\n12345\n", "output": "1000000005\n"}, {"input": "0 0\n1000000000\n", "output": "0\n"}, {"input": "-1000000000 1000000000\n2000000000\n", "output": "1000000000\n"}, {"input": "-12345678 12345678\n1912345678\n", "... | |
210 | One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays one... | interview | [{"code": "from sys import stdin\n\nn = int(input())\na = [int(x) for x in input().split()]\n\nf = False\nfor i in range(len(a)):\n if a[i] != 0:\n ln = i\n f = True\n break\nif not f:\n print('NO')\nelse:\n print('YES')\n l = 0\n i = ln + 1\n ans = []\n while i < len(a):\n ... | [{"input": "3\n1 2 -3\n", "output": "YES\n3\n1 1\n2 2\n3 3\n"}, {"input": "8\n9 -12 3 4 -4 -10 7 3\n", "output": "YES\n8\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n"}, {"input": "1\n0\n", "output": "NO\n"}, {"input": "4\n1 2 3 -5\n", "output": "YES\n4\n1 1\n2 2\n3 3\n4 4\n"}, {"input": "6\n0 0 0 0 0 0\n", "output": "NO\n... | |
211 | Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a question incorrectly,... | interview | [{"code": "MOD = 1000000009\n\nn,m,k = [int(x) for x in input().split()]\n\nnum0 = n-m\nnum1fin = num0*(k-1)\nif num1fin >= m:\n print(m)\nelse:\n num1open = m-num1fin\n sets = num1open//k\n rem = num1open%k\n print(((pow(2,sets,MOD)-1)*2*k+rem+num1fin)%MOD)\n", "passed": true, "time": 0.15, "memory": 14... | [{"input": "5 3 2\n", "output": "3\n"}, {"input": "5 4 2\n", "output": "6\n"}, {"input": "300 300 3\n", "output": "17717644\n"}, {"input": "300 282 7\n", "output": "234881124\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "999999991\n"}, {"input": "1000000000 800000000 2\n", "output": "785468433\n"}, {"... | |
212 | You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-... | interview | [{"code": "n1 = input()\nn = []\nfor i in n1:\n n.append(int(i))\nk = len(n)\n\nfor i in range(k):\n if (n[i] % 8) == 0:\n print(\"YES\")\n print(n[i])\n return\n\nif k > 1:\n for i in range(k):\n t = n[i] * 10\n for j in range(i+1, k):\n if (t+n[j]) % 8 == 0:\n ... | [{"input": "3454\n", "output": "YES\n344\n"}, {"input": "10\n", "output": "YES\n0\n"}, {"input": "111111\n", "output": "NO\n"}, {"input": "8996988892\n", "output": "YES\n8\n"}, {"input": "5555555555\n", "output": "NO\n"}, {"input": "1\n", "output": "NO\n"}, {"input": "814752277691991627730686134692292422155753465948025... | |
213 | In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the next several flats are o... | interview | [{"code": "def floo(num, k):\n\treturn (num - 1) // k + 1\n\ndef main():\n\tn, m = map(int, input().split())\n\tlow = 1\n\thigh = 10**9\n\n\tif (m == 0):\n\t\tif (n == 1):\n\t\t\tprint(1)\n\t\telse:\n\t\t\tprint(-1)\n\t\treturn\n\n\tfor i in range(m):\n\t\tk, f = map(int, input().split())\n\t\tlow = max(low, (k + f - 1... | [{"input": "10 3\n6 2\n2 1\n7 3\n", "output": "4\n"}, {"input": "8 4\n3 1\n6 2\n5 2\n2 1\n", "output": "-1\n"}, {"input": "8 3\n7 2\n6 2\n1 1\n", "output": "2\n"}, {"input": "4 2\n8 3\n3 1\n", "output": "2\n"}, {"input": "11 4\n16 4\n11 3\n10 3\n15 4\n", "output": "3\n"}, {"input": "16 6\n3 1\n16 4\n10 3\n9 3\n19 5\n8 ... | |
215 | Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.
Let A be a set of positions in the string. Let's call it pretty if following conditions are met: letters on positions from A in the string are all distinct and lowercase; the... | interview | [{"code": "def list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \nn = int(input()) \na = list(input())\nans = 0\nfor i in range(n):\n\tfor j in range(i,n):\n\t\tb = a[i:j+1]\n\t\tfor k in b:\n\t\t\tif k... | [{"input": "11\naaaaBaabAbA\n", "output": "2\n"}, {"input": "12\nzACaAbbaazzC\n", "output": "3\n"}, {"input": "3\nABC\n", "output": "0\n"}, {"input": "1\na\n", "output": "1\n"}, {"input": "2\naz\n", "output": "2\n"}, {"input": "200\nXbTJZqcbpYuZQEoUrbxlPXAPCtVLrRExpQzxzqzcqsqzsiisswqitswzCtJQxOavicSdBIodideVRKHPojCNHmb... | |
216 | You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences.
Let B be the sum of elements belonging to b, and C be the sum of elements belonging to c (if some of these sequences is empty, the... | interview | [{"code": "\nn=int(input())\narr= list(map(int,input().strip().split(' ')))\ns = 0\nfor i in range(n):\n s+=abs(arr[i])\nprint(s)", "passed": true, "time": 0.22, "memory": 14320.0, "status": "done"}, {"code": "n = int(input())\na = [int(v) for v in input().split()]\n\nprint(sum(abs(v) for v in a))\n", "passed": true,... | [{"input": "3\n1 -2 0\n", "output": "3\n"}, {"input": "6\n16 23 16 15 42 8\n", "output": "120\n"}, {"input": "1\n-1\n", "output": "1\n"}, {"input": "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -... | |
217 | A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ... | interview | [{"code": "def list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \na,b,f,k = map_input()\ntot = a*k\ns = 2*a-f\ncur = 0\ncnt = b\ngo = 0\nans = 0\nwhile cur < tot:\n\tgo = 1-go\n\tif(go == 1):\n\t\tif cnt <... | [{"input": "6 9 2 4\n", "output": "4\n"}, {"input": "6 10 2 4\n", "output": "2\n"}, {"input": "6 5 4 3\n", "output": "-1\n"}, {"input": "2 2 1 1\n", "output": "0\n"}, {"input": "10 4 6 10\n", "output": "-1\n"}, {"input": "3 1 1 1\n", "output": "-1\n"}, {"input": "2 1 1 1\n", "output": "1\n"}, {"input": "1000000 5192321... | |
218 | You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.
For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".
Note it is allowed to split the string s to the strings only of length p or... | interview | [{"code": "n, p, q = list(map(int, input().split(\" \")))\ns=input()\n\nc=-1\n\nfor i in range (n+1):\n for j in range (n+1):\n if p*i+q*j==n:\n c=i\n d=j\n break\n if c!=-1:\n break\n\nif c==-1:\n print(-1)\nelse:\n print(c+d)\n for i in range (c):\n ... | [{"input": "5 2 3\nHello\n", "output": "2\nHe\nllo\n"}, {"input": "10 9 5\nCodeforces\n", "output": "2\nCodef\norces\n"}, {"input": "6 4 5\nPrivet\n", "output": "-1\n"}, {"input": "8 1 1\nabacabac\n", "output": "8\na\nb\na\nc\na\nb\na\nc\n"}, {"input": "1 1 1\n1\n", "output": "1\n1\n"}, {"input": "10 8 1\nuTl9w4lcdo\n"... | |
219 | A sportsman starts from point x_{start} = 0 and runs to point with coordinate x_{finish} = m (on a straight line). Also, the sportsman can jump — to jump, he should first take a run of length of not less than s meters (in this case for these s meters his path should have no obstacles), and after that he can jump over a... | interview | [{"code": "n, m, s, d = list(map(int, input().split()))\n\nbeg = [float('-inf')]\nend = [float('-inf')]\n\na = [int(i) for i in input().split()]\n\nfor x in sorted(a):\n\tif (x - end[-1] > s + 1):\n\t\tbeg.append(x)\n\t\tend.append(x)\n\telse:\n\t\tend[-1] = x\n\nlast = 0\nR = []\nJ = []\n\nfor i in range(1, len(beg)):... | [{"input": "3 10 1 3\n3 4 7\n", "output": "RUN 2\nJUMP 3\nRUN 1\nJUMP 2\nRUN 2\n"}, {"input": "2 9 2 3\n6 4\n", "output": "IMPOSSIBLE\n"}, {"input": "10 100 2 8\n93 35 24 87 39 46 86 37 73 33\n", "output": "RUN 23\nJUMP 2\nRUN 7\nJUMP 8\nRUN 5\nJUMP 2\nRUN 25\nJUMP 2\nRUN 11\nJUMP 3\nRUN 4\nJUMP 2\nRUN 6\n"}, {"input":... | |
220 | Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?
-----Input-----
The first line of the input contains two integers s and x (2 ≤ s ≤ 10^12, 0 ≤ x ≤ 10^12), the sum and bitwise xor of the pair of positive integers, respectively.
---... | interview | [{"code": "s, x = list(map(int, input().split()))\nrem = int(s == x) * 2\np, t, cur = [], 0, 1\nfor i in range(64):\n if x % 2:\n t += 1\n s -= cur\n else:\n p.append(cur * 2)\n cur *= 2\n x //= 2\nfor i in p[::-1]:\n if s >= i: s -= i\nans = 0 if s else 2 ** t - rem\nprint(ans)\n", ... | [{"input": "9 5\n", "output": "4\n"}, {"input": "3 3\n", "output": "2\n"}, {"input": "5 2\n", "output": "0\n"}, {"input": "6 0\n", "output": "1\n"}, {"input": "549755813887 549755813887\n", "output": "549755813886\n"}, {"input": "2 0\n", "output": "1\n"}, {"input": "2 2\n", "output": "0\n"}, {"input": "433864631347 597... | |
222 | You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect).
In one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros.
Determine the minimum number of operations that you need to consistently ... | interview | [{"code": "ar=[]\nfor i in range(1,10**5):\n if(i*i>2*10**9):break\n ar.append(i*i)\ns=input()\nans=len(s)\nfor x in ar:\n s2=str(x)\n i=0\n for x in range(len(s)):\n if i<len(s2) and s[x]==s2[i]:\n i+=1\n if(i==len(s2)):\n ans=min(ans,len(s)-i)\nif(ans==len(s)):\n print(-1... | [{"input": "8314\n", "output": "2\n"}, {"input": "625\n", "output": "0\n"}, {"input": "333\n", "output": "-1\n"}, {"input": "1881388645\n", "output": "6\n"}, {"input": "1059472069\n", "output": "3\n"}, {"input": "1354124829\n", "output": "4\n"}, {"input": "149723943\n", "output": "4\n"}, {"input": "101\n", "output": "2... | |
224 | One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of ... | interview | [{"code": "import sys\n\nfin = sys.stdin\nfout = sys.stdout\nm = -1\ngl = {'A', 'E', 'I', 'O', 'U', 'Y'}\ns = fin.readline().strip()\ncur = -1\nfor i in range(len(s)):\n if s[i] in gl:\n m = max(m, i - cur)\n cur = i\nm = max(m, len(s) - cur)\nfout.write(str(m))", "passed": true, "time": 0.15, "memory"... | [{"input": "ABABBBACFEYUKOTT\n", "output": "4"}, {"input": "AAA\n", "output": "1"}, {"input": "A\n", "output": "1"}, {"input": "B\n", "output": "2"}, {"input": "AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOIKLMJNHGTRWSDZXCVBNMHGFDSXVWRTPPPLKMNBXIUOIUOIUOIUOOIU\n", "output": "39"}, {"input": "AEYUIOAEIYAEOUIYOEIUYEAOIUEO... | |
225 | Dawid has four bags of candies. The $i$-th of them contains $a_i$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?
Note, that you can't keep bags for yourself or ... | interview | [{"code": "arr=list(map(int,input().split()))\narr.sort()\nif(arr[0]+arr[1]+arr[2]==arr[3]):\n\tprint(\"YES\")\nelif(arr[0]+arr[3]==arr[1]+arr[2]):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "passed": true, "time": 0.14, "memory": 14584.0, "status": "done"}, {"code": "import sys\nfrom collections import defaultdict\... | [{"input": "1 7 11 5\n", "output": "YES\n"}, {"input": "7 3 2 5\n", "output": "NO\n"}, {"input": "3 14 36 53\n", "output": "YES\n"}, {"input": "30 74 41 63\n", "output": "YES\n"}, {"input": "92 69 83 97\n", "output": "NO\n"}, {"input": "26 52 7 19\n", "output": "YES\n"}, {"input": "72 52 62 62\n", "output": "YES\n"}, {... | |
226 | You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be ... | interview | [{"code": "n = int(input())\na = list(map(int, input().split()))\na = a[::-1]\nd = 0\nfor i in range(len(a)):\n d = max(0 + d, a[i] + (sum(a[:i]) - d))\nprint(sum(a)-d, d)\n", "passed": true, "time": 0.15, "memory": 14592.0, "status": "done"}, {"code": "n = int(input())\nX = list(map(int, input().split()))\n\nali = ... | [{"input": "3\n141 592 653\n", "output": "653 733\n"}, {"input": "5\n10 21 10 21 10\n", "output": "31 41\n"}, {"input": "1\n100000\n", "output": "0 100000\n"}, {"input": "50\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 10000... | |
227 | You've got a positive integer sequence a_1, a_2, ..., a_{n}. All numbers in the sequence are distinct. Let's fix the set of variables b_1, b_2, ..., b_{m}. Initially each variable b_{i} (1 ≤ i ≤ m) contains the value of zero. Consider the following sequence, consisting of n operations.
The first operation is assigning... | interview | [{"code": "def Solve(x,B):\n if((X,x,B) in Mem):\n return Mem[(X,x,B)]\n if(len(B)>X):\n return False\n if(x==len(L)):\n return True\n if(Form(L[x],B)):\n A=list(B)\n for e in range(len(B)):\n r=A[e]\n A[e]=L[x]\n if(Solve(x+1,tuple(sorted(... | [{"input": "5\n1 2 3 6 8\n", "output": "2\n"}, {"input": "3\n3 6 5\n", "output": "-1\n"}, {"input": "6\n2 4 8 6 10 18\n", "output": "3\n"}, {"input": "7\n1 2 4 5 3 6 7\n", "output": "3\n"}, {"input": "10\n11 22 44 88 132 264 66 33 165 55\n", "output": "5\n"}, {"input": "10\n201 402 804 603 1608 2010 1206 2412 4824 2211... | |
228 | Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly $\frac{n}{2}$ nonempty piles and independently remove a positi... | interview | [{"code": "n=int(input())\ns=list(map(int,input().split()))\nprint(\"Bob\"if s.count(min(s))>n/2 else\"Alice\")\n", "passed": true, "time": 0.15, "memory": 14424.0, "status": "done"}, {"code": "def judge(i):\n return \"Bob\" if cnt[i]>n//2 else \"Alice\"\nn=int(input())\na=list(map(int,input().split()))\ncnt=[0 for ... | [{"input": "2\n8 8\n", "output": "Bob\n"}, {"input": "4\n3 1 4 1\n", "output": "Alice\n"}, {"input": "4\n42 49 42 42\n", "output": "Bob\n"}, {"input": "8\n11 21 31 41 41 31 21 11\n", "output": "Alice\n"}, {"input": "10\n21 4 7 21 18 38 12 17 21 13\n", "output": "Alice\n"}, {"input": "12\n33 26 11 11 32 25 18 24 27 47 2... | |
229 | Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.
Filya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x and then he adds x to some elements of the array (no more than once), subtra... | interview | [{"code": "read = lambda: list(map(int, input().split()))\nn = int(input())\na = list(read())\ns = set()\nfor i in a:\n s.add(i)\nf1 = len(s) < 3\nf2 = len(s) == 3 and max(s) + min(s) == 2 * sorted(s)[1]\nprint('YES' if f1 or f2 else 'NO')\n", "passed": true, "time": 0.15, "memory": 14472.0, "status": "done"}, {"cod... | [{"input": "5\n1 3 3 2 1\n", "output": "YES\n"}, {"input": "5\n1 2 3 4 5\n", "output": "NO\n"}, {"input": "2\n1 2\n", "output": "YES\n"}, {"input": "3\n1 2 3\n", "output": "YES\n"}, {"input": "3\n1 1 1\n", "output": "YES\n"}, {"input": "2\n1 1000000000\n", "output": "YES\n"}, {"input": "4\n1 2 3 4\n", "output": "NO\n"}... | |
230 | Given is a string S of length N.
Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.
More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:
- ... | interview | [{"code": "n = int(input())\ns = input()\nj = 1\nresult = []\nfor i in range(n):\n while (j < n-1) and (s[i:j] in s[j:]):\n j += 1\n result.append(j-i-1)\nprint(max(result))", "passed": true, "time": 2.94, "memory": 14920.0, "status": "done"}, {"code": "def main():\n import sys\n input = sys.stdin.re... | [{"input": "5\nababa\n", "output": "2\n"}, {"input": "2\nxy\n", "output": "0\n"}, {"input": "13\nstrangeorange\n", "output": "5\n"}, {"input": "5000\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb... | |
231 | The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in the order from the beginning of the street to the end (in the picture: from ... | interview | [{"code": "n, a = list(map(int,input().split()))\nif a % 2 == 1:\n print(a // 2 + 1)\nelse:\n print((n-a) // 2 + 1)\n", "passed": true, "time": 0.2, "memory": 14324.0, "status": "done"}, {"code": "n, a = map(int, input().split())\n\nif a % 2:\n print(a//2 + 1)\nelse:\n print(n//2 - a//2 + 1)", "passed": tru... | [{"input": "4 2\n", "output": "2\n"}, {"input": "8 5\n", "output": "3\n"}, {"input": "2 1\n", "output": "1\n"}, {"input": "2 2\n", "output": "1\n"}, {"input": "10 1\n", "output": "1\n"}, {"input": "10 10\n", "output": "1\n"}, {"input": "100000 100000\n", "output": "1\n"}, {"input": "100000 2\n", "output": "50000\n"}, {... | |
232 | There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that the success of any peacekeeping mission depends on the colors of th... | interview | [{"code": "s = input().split()\nn, m = int(s[0]), int(s[1])\ncl = list(map(int, input().split()))\ncom = list(map(int, input().split()))\nres = False\nfor i in range(n):\n for j in range(i, n):\n e = True\n t = cl[i:j+1]\n for k in range(1, m+1):\n e = t.count(k)==com[k-1] and e\n if e:\n res = T... | [{"input": "5 2\n1 1 2 2 1\n1 2\n", "output": "YES\n"}, {"input": "1 1\n1\n1\n", "output": "YES\n"}, {"input": "2 1\n1 1\n1\n", "output": "YES\n"}, {"input": "2 1\n1 1\n2\n", "output": "YES\n"}, {"input": "2 2\n1 2\n1 1\n", "output": "YES\n"}, {"input": "3 3\n1 1 3\n0 1 2\n", "output": "NO\n"}, {"input": "4 4\n2 3 3 2\... | |
235 | After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.
This means the process of eating candies is the following: in the beginning Vasya cho... | interview | [{"code": "def can(n, k):\n total = n\n s = 0\n\n while n > 0:\n cur = min(n, k)\n s += cur\n n -= cur\n\n n -= n // 10\n\n return s * 2 >= total\n\nn = int(input())\n\nle = 0\nrg = n\n\nwhile rg - le > 1:\n mid = (rg + le) // 2\n\n if can(n, mid):\n rg = mid\n el... | [{"input": "68\n", "output": "3\n"}, {"input": "1\n", "output": "1\n"}, {"input": "2\n", "output": "1\n"}, {"input": "42\n", "output": "1\n"}, {"input": "43\n", "output": "2\n"}, {"input": "756\n", "output": "29\n"}, {"input": "999999972\n", "output": "39259423\n"}, {"input": "999999973\n", "output": "39259424\n"}, {"i... | |
236 | A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. $0$
You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as ... | interview | [{"code": "def main():\n s = input()\n links = s.count('-')\n pearls = s.count('o')\n if pearls == 0 or links % pearls == 0:\n print('YES')\n else:\n print('NO')\n\nmain()\n", "passed": true, "time": 0.24, "memory": 14484.0, "status": "done"}, {"code": "s = input()\na = s.count('o')\nb = s.... | [{"input": "-o-o--\n", "output": "YES\n"}, {"input": "-o---\n", "output": "YES\n"}, {"input": "-o---o-\n", "output": "NO\n"}, {"input": "ooo\n", "output": "YES\n"}, {"input": "---\n", "output": "YES\n"}, {"input": "--o-o-----o----o--oo-o-----ooo-oo---o--\n", "output": "YES\n"}, {"input": "-o--o-oo---o-o-o--o-o----oo---... | |
237 | n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | interview | [{"code": "n, m, k = map(int, input().split())\nans = 1\nm -= n\nleft = k - 1\nright = n - k\n\nput = 1\nwhile (m >= put):\n m -= put\n ans += 1\n put += (left > 0) + (right > 0)\n if (left): left -= 1\n if (right): right -= 1\n if (left == right == 0):\n ans += (m // put)\n break\nprint... | [{"input": "4 6 2\n", "output": "2\n"}, {"input": "3 10 3\n", "output": "4\n"}, {"input": "3 6 1\n", "output": "3\n"}, {"input": "3 3 3\n", "output": "1\n"}, {"input": "1 1 1\n", "output": "1\n"}, {"input": "1 1000000000 1\n", "output": "1000000000\n"}, {"input": "100 1000000000 20\n", "output": "10000034\n"}, {"input"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.