problem stringlengths 35 13.2k | solutions listlengths 1 3.42k | tests stringlengths 120 74M | starter_code stringclasses 0
values | metadata stringclasses 1
value | question stringlengths 600 13.8k | ground_truth stringlengths 450 74M | data_source stringclasses 1
value | uid stringlengths 11 15 | index int64 0 17.1k |
|---|---|---|---|---|---|---|---|---|---|
Solve the following coding problem using the programming language python:
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute l_1 to minute r_1 inclusive. Also, during the minute k she p... | [
"```python\nread = lambda: list(map(int, input().split()))\nl1, r1, l2, r2, k = read()\nR = min(r1, r2)\nL = max(l1, l2)\nans = max(R - L + 1, 0)\nif L <= k <= R: ans = max(ans - 1, 0)\nprint(ans)\n\n```"
] | [{"type": "stdin_stdout", "input": "1 10 9 20 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 100 50 200 75\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "6 6 5 8 9\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1000000000 1 1000000000 1\n", "output": "999999999\n"}, {"type": "stdin_... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Today an outstanding event is going to happen in the fores... | [{"type": "stdin_stdout", "input": "1 10 9 20 1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 100 50 200 75\n", "output": "50\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 6 5 8 9\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "... | livecodebench | deepcoder_300 | 300 |
Solve the following coding problem using the programming language python:
The process of mammoth's genome decoding in Berland comes to its end!
One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or... | [
"```python\n\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn=int(input())\nif n%4: print(\"===\")\nelse:\n t=input().strip()\n a=[n//4]*4\n for i in t:\n if i=='A': a[0]-=1\n elif i=='C': a[1]-=1\n elif i=='G': a[2]-=1\n elif i=='T': a[3]-=1\n if min... | [{"type": "stdin_stdout", "input": "8\nAG?C??CT\n", "output": "AGACGTCT\n"}, {"type": "stdin_stdout", "input": "4\nAGCT\n", "output": "AGCT\n"}, {"type": "stdin_stdout", "input": "6\n????G?\n", "output": "===\n"}, {"type": "stdin_stdout", "input": "4\nAA??\n", "output": "===\n"}, {"type": "stdin_stdout", "input": "4\n?... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The process of mammoth's genome decoding in Berland comes ... | [{"type": "stdin_stdout", "input": "8\nAG?C??CT\n", "output": "AGACGTCT\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\nAGCT\n", "output": "AGCT\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n????G?\n", "output": "===\n", "metadata": {"func_name": null}}, {"type"... | livecodebench | deepcoder_301 | 301 |
Solve the following coding problem using the programming language python:
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 ... | [
"```python\ndef 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... | [{"type": "stdin_stdout", "input": "xx..\n.oo.\nx...\noox.\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "x.ox\nox..\nx.o.\noo.x\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "x..x\n..oo\no...\nx.xo\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "o.x.\no...\n.x..\nooxx\n", "output": "N... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Ilya is an experienced player in tic-tac-toe on the 4 × 4 ... | [{"type": "stdin_stdout", "input": "xx..\n.oo.\nx...\noox.\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "x.ox\nox..\nx.o.\noo.x\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "x..x\n..oo\no...\nx.xo\n", "output": "YES\n", "metadata... | livecodebench | deepcoder_302 | 302 |
Solve the following coding problem using the programming language python:
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the... | [
"```python\ndef 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... | [{"type": "stdin_stdout", "input": "3\n1 3 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n2 2 3 4 5\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n72 32 17 46 82\n", "output": "NO\n"}, {"type": "stdin_stdout", "input"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Vasya has an array a consisting of positive integer number... | [{"type": "stdin_stdout", "input": "3\n1 3 2\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n2 2 3 4 5\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": ... | livecodebench | deepcoder_303 | 303 |
Solve the following coding problem using the programming language python:
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of the oddity and recover her weight, a special... | [
"```python\nimport 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 r... | [{"type": "stdin_stdout", "input": "4 2\n11 0 0 14\n5 4\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "6 1\n2 3 0 8 9 10\n5\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "4 1\n8 94 0 4\n89\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\n", "output": "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A few years ago, Hitagi encountered a giant crab, who stol... | [{"type": "stdin_stdout", "input": "4 2\n11 0 0 14\n5 4\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 1\n2 3 0 8 9 10\n5\n", "output": "No\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 1\n8 94 0 4\n89\n", "output": "Yes\n", "metadata": {"func_... | livecodebench | deepcoder_304 | 304 |
Solve the following coding problem using the programming language python:
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 al... | [
"```python\nx,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\n```"
] | [{"type": "stdin_stdout", "input": "1 6 2\n4 3 3\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5 1 1\n4 3 2\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 1 100000\n4 2 99995\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 2 3\n3 2 1\n", "output": "YES\n"}, {"type": "stdin_stdout",... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The Duck song
For simplicity, we'll assume that there are... | [{"type": "stdin_stdout", "input": "1 6 2\n4 3 3\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 1 1\n4 3 2\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 100000\n4 2 99995\n", "output": "NO\n", "metadata": {"func_name": null}... | livecodebench | deepcoder_305 | 305 |
Solve the following coding problem using the programming language python:
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the... | [
"```python\n# A\n\ninput()\nl = list(map(int, list(input())))\n\nif (1 in l or 4 in l or 7 in l or 0 in l) and (1 in l or 2 in l or 3 in l) and (3 in l or 6 in l or 9 in l or 0 in l) and (7 in l or 0 in l or 9 in l):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n586\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2\n09\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "9\n123456789\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3\n911\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3\n089\n", "outpu... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
While swimming at the beach, Mike has accidentally dropped... | [{"type": "stdin_stdout", "input": "3\n586\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n09\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9\n123456789\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_std... | livecodebench | deepcoder_306 | 306 |
Solve the following coding problem using the programming language python:
Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.
Shop, where Noora... | [
"```python\nn, f = list(map(int, input().split(' ')))\nres = 0\nwow = []\nfor a0 in range(n):\n k, l = list(map(int, input().split(' ')))\n res += min(k, l)\n wow.append(min(2*k, l) - min(k, l))\nwow = sorted(wow)\ni = len(wow)-1\nfor a0 in range(f):\n res += wow[i]\n i -= 1\nprint(res)\n\n```"
] | [{"type": "stdin_stdout", "input": "4 2\n2 1\n3 5\n2 3\n1 5\n", "output": "10"}, {"type": "stdin_stdout", "input": "4 1\n0 2\n0 3\n3 5\n0 6\n", "output": "5"}, {"type": "stdin_stdout", "input": "1 1\n5 8\n", "output": "8"}, {"type": "stdin_stdout", "input": "2 1\n8 12\n6 11\n", "output": "19"}, {"type": "stdin_stdout",... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Summer holidays! Someone is going on trips, someone is vis... | [{"type": "stdin_stdout", "input": "4 2\n2 1\n3 5\n2 3\n1 5\n", "output": "10", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 1\n0 2\n0 3\n3 5\n0 6\n", "output": "5", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n5 8\n", "output": "8", "metadata": {"func_name": null}... | livecodebench | deepcoder_307 | 307 |
Solve the following coding problem using the programming language python:
It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing... | [
"```python\n# 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)\n```"
] | [{"type": "stdin_stdout", "input": "5 2\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "1 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "100000 2\n", "output": "399990\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 3\n", "output": "27\n"}, {... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
It is a balmy spring afternoon, and Farmer John's n cows a... | [{"type": "stdin_stdout", "input": "5 2\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 10\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100000 2\n", "output": "399990\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", ... | livecodebench | deepcoder_308 | 308 |
Solve the following coding problem using the programming language python:
Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as ma... | [
"```python\nn, m, k, l = map(int, input().split())\ncnt = (k + l + m - 1) // m\nif cnt * m > n:\n print(-1)\nelse:\n print(cnt)\n```"
] | [{"type": "stdin_stdout", "input": "20 15 2 3\n", "output": "1"}, {"type": "stdin_stdout", "input": "10 11 2 4\n", "output": "-1"}, {"type": "stdin_stdout", "input": "2 1 1 1\n", "output": "2"}, {"type": "stdin_stdout", "input": "10 2 9 7\n", "output": "-1"}, {"type": "stdin_stdout", "input": "530897800469409942 582203... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Ivan is collecting coins. There are only $N$ different col... | [{"type": "stdin_stdout", "input": "20 15 2 3\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 11 2 4\n", "output": "-1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1 1 1\n", "output": "2", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "... | livecodebench | deepcoder_309 | 309 |
Solve the following coding problem using the programming language python:
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that... | [
"```python\nh, 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 p... | [{"type": "stdin_stdout", "input": "5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1 2\nBB\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 3\nWWW\nWWW\nWWW\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Polycarp has a checkered sheet of paper of size n × m. Pol... | [{"type": "stdin_stdout", "input": "5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 2\nBB\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3\nWWW\nWWW\nWWW\n", "output": "1\n", "metadata": {"func_na... | livecodebench | deepcoder_310 | 310 |
Solve the following coding problem using the programming language python:
There is a beautiful garden of stones in Innopolis.
Its most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.
EJOI participants have visited this place twice.
When they first visited it, the number of stones in piles wa... | [
"```python\nn = 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')\n```"
] | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n2 1 4 3 5\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5\n1 1 1 1 1\n1 0 1 0 1\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3\n2 3 9\n1 7 9\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "40\n361 372 139 808 561 460 421 961 727 719 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
There is a beautiful garden of stones in Innopolis.
Its m... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n2 1 4 3 5\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 1 1 1 1\n1 0 1 0 1\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n2 3 9\n1 7 9\n", "output": "No\n", "metadata": {"... | livecodebench | deepcoder_311 | 311 |
Solve the following coding problem using the programming language python:
Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.
There are $n$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Prese... | [
"```python\n# Contest: Codeforces Round #593 (Div. 2) (https://codeforces.com/contest/1236)\n# Problem: B: Alice and the List of Presents (https://codeforces.com/contest/1236/problem/B)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\nM = 10**9 + 7\nn, m = r... | [{"type": "stdin_stdout", "input": "1 3\n", "output": "7"}, {"type": "stdin_stdout", "input": "2 2\n", "output": "9"}, {"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "751201557"}, {"type": "stdin_stdout", "input": "489132389 96\n", "output": "496937"}, {"type": "stdin_stdout", "input": "46281772... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Alice got many presents these days. So she decided to pack... | [{"type": "stdin_stdout", "input": "1 3\n", "output": "7", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2\n", "output": "9", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "751201557", "metadata": {"func_name": null}}, {"type": "stdin_s... | livecodebench | deepcoder_312 | 312 |
Solve the following coding problem using the programming language python:
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding ... | [
"```python\nn = int(input())\nif n % 4 == 0:\n temp = n // 4\n m = temp * 3\n k = temp * 5\nelif n % 2 == 0:\n n //= 2\n m = n**2 // 2\n k = m + 1\n m *= 2\n k *= 2\nelse:\n m = n**2 // 2\n k = m + 1\nif 3 > n:\n print(\"-1\")\nelse:\n print(m,k)\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n", "output": "4 5"}, {"type": "stdin_stdout", "input": "6\n", "output": "8 10"}, {"type": "stdin_stdout", "input": "1\n", "output": "-1"}, {"type": "stdin_stdout", "input": "17\n", "output": "144 145"}, {"type": "stdin_stdout", "input": "67\n", "output": "2244 2245"}, {"type": "st... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Katya studies in a fifth grade. Recently her class studied... | [{"type": "stdin_stdout", "input": "3\n", "output": "4 5", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n", "output": "8 10", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "-1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "17\n", "... | livecodebench | deepcoder_313 | 313 |
Solve the following coding problem using the programming language python:
Imp is watching a documentary about cave painting. [Image]
Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1... | [
"```python\ndef 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()\n```"
] | [{"type": "stdin_stdout", "input": "4 4\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "5 3\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "744 18\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "47879 10\n", "output": "Yes\n"}... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Imp is watching a documentary about cave painting. [Image]... | [{"type": "stdin_stdout", "input": "4 4\n", "output": "No\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 3\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input"... | livecodebench | deepcoder_314 | 314 |
Solve the following coding problem using the programming language python:
Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to crea... | [
"```python\nn,p=list(map(int,input().split()))\nnums=[0]+list(map(int,input().split()))\nmod=10**9+7\n\nf=[[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(n+1)]\n\n_2=[0]*(n+1)\n_2[0]=1\nfor i in range(1,n+1):\n _2[i]=(_2[i-1]<<1)%mod\n \nf[0][0][0][0]=1\nif nums[1]!=0:\n f[1][1][0][1]+=1\nif ... | [{"type": "stdin_stdout", "input": "3 1\n-1 0 1\n", "output": "6"}, {"type": "stdin_stdout", "input": "2 1\n1 0\n", "output": "1"}, {"type": "stdin_stdout", "input": "1 1\n-1\n", "output": "2"}, {"type": "stdin_stdout", "input": "1 0\n-1\n", "output": "0"}, {"type": "stdin_stdout", "input": "1 1\n0\n", "output": "1"}, ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Kuro has recently won the "Most intelligent cat ever" cont... | [{"type": "stdin_stdout", "input": "3 1\n-1 0 1\n", "output": "6", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1\n1 0\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n-1\n", "output": "2", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "... | livecodebench | deepcoder_315 | 315 |
Solve the following coding problem using the programming language python:
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 ... | [
"```python\nimport 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)\... | [{"type": "stdin_stdout", "input": "3 595\n43 2\n300 4\n554 10\n", "output": "281\n"}, {"type": "stdin_stdout", "input": "1 1\n1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 50\n20 0\n3 1\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "5 240\n13 0\n50 25\n60 5\n155 70\n165 70\n", "output": "26... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The mayor of the Central Town wants to modernize Central S... | [{"type": "stdin_stdout", "input": "3 595\n43 2\n300 4\n554 10\n", "output": "281\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n1 1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 50\n20 0\n3 1\n", "output": "30\n", "metadata": {"func_name": nu... | livecodebench | deepcoder_316 | 316 |
Solve the following coding problem using the programming language python:
You have a set of items, each having some integer weight not greater than $8$. You denote that a subset of items is good if total weight of items in the subset does not exceed $W$.
You want to calculate the maximum possible weight of a good sub... | [
"```python\nimport time\nimport random\nW = int(input())\nM = [int(a) for a in input().split()]\nA = [0] * 8\nsTime = time.time()\n\ns = 0\nmi = 10**20\nfor i in range(8):\n if s + M[i]*(i+1) <= W:\n s += M[i]*(i+1)\n A[i] = M[i]\n else:\n t = (W-s)//(i+1)\n s += t*(i+1)\n A... | [{"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 7 8\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "0\n0 0 0 0 0 0 0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n0 4 1 0 0 9 8 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "27\n0 0 0 0 0 5 0 0\n", "output": "24\n"}, {"type": "s... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You have a set of items, each having some integer weight n... | [{"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 7 8\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "0\n0 0 0 0 0 0 0 0\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n0 4 1 0 0 9 8 3\n", "output": "3\n", "metadata": {"func_name"... | livecodebench | deepcoder_317 | 317 |
Solve the following coding problem using the programming language python:
Someone gave Alyona an array containing n positive integers a_1, a_2, ..., a_{n}. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona c... | [
"```python\nx=int(input())\nl=list(map(int, input().split(' ')))\nl.sort()\na=1\nfor i in l:\n if i>=a:\n a+=1\nprint(a)\n\n```"
] | [{"type": "stdin_stdout", "input": "5\n1 3 3 3 6\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n2\n", "output"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Someone gave Alyona an array containing n positive integer... | [{"type": "stdin_stdout", "input": "5\n1 3 3 3 6\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n2 1\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout",... | livecodebench | deepcoder_318 | 318 |
Solve the following coding problem using the programming language python:
Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ ... | [
"```python\nn = 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... | [{"type": "stdin_stdout", "input": "5\n73452\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4\n1248\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2\n00\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3\n555\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "8\n00020200\n", "ou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Recently Vasya found a golden ticket — a sequence which co... | [{"type": "stdin_stdout", "input": "5\n73452\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n1248\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n00\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdou... | livecodebench | deepcoder_319 | 319 |
Solve the following coding problem using the programming language python:
Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they... | [
"```python\ns = 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!\")\n```"
] | [{"type": "stdin_stdout", "input": "wjmzbmr\n", "output": "CHAT WITH HER!\n"}, {"type": "stdin_stdout", "input": "xiaodao\n", "output": "IGNORE HIM!\n"}, {"type": "stdin_stdout", "input": "sevenkplus\n", "output": "CHAT WITH HER!\n"}, {"type": "stdin_stdout", "input": "pezu\n", "output": "CHAT WITH HER!\n"}, {"type": "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Those days, many boys use beautiful girls' photos as avata... | [{"type": "stdin_stdout", "input": "wjmzbmr\n", "output": "CHAT WITH HER!\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "xiaodao\n", "output": "IGNORE HIM!\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "sevenkplus\n", "output": "CHAT WITH HER!\n", "metadata": {"func_n... | livecodebench | deepcoder_320 | 320 |
Solve the following coding problem using the programming language python:
This morning, Roman woke up and opened the browser with $n$ opened tabs numbered from $1$ to $n$. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too... | [
"```python\nn, k = list(map(int, input().split()))\n\nt = list(map(int, input().split()))\n\nd = [0 for _ in range(n)]\n\nfor _ in range(n):\n for i in range(n):\n if i % k != _ % k:\n d[_] += t[i]\n\nprint(max(abs(d[_]) for _ in range(n)))\n\n```"
] | [{"type": "stdin_stdout", "input": "4 2\n1 1 -1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "14 3\n-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "4 2\n1 1 1 -1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 2\n-1 1 -1 -1\n", "output": "2\n"}, {"ty... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
This morning, Roman woke up and opened the browser with $n... | [{"type": "stdin_stdout", "input": "4 2\n1 1 -1 1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "14 3\n-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1\n", "output": "9\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 2\n1 1 1 -1\n", "output": "2\n", "metadata": ... | livecodebench | deepcoder_321 | 321 |
Solve the following coding problem using the programming language python:
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listenin... | [
"```python\nimport 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)... | [{"type": "stdin_stdout", "input": "4 1 2\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "2 1 5\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3 1 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "5 5 5\n", "output": "60\n"}, {"type": "stdin_stdout", "input": "4 0 0\n", "output": "0\n"}, {"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
R3D3 spent some time on an internship in MDCS. After earni... | [{"type": "stdin_stdout", "input": "4 1 2\n", "output": "12\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1 5\n", "output": "6\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 1 1\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "inpu... | livecodebench | deepcoder_322 | 322 |
Solve the following coding problem using the programming language python:
The circle line of the Roflanpolis subway has $n$ stations.
There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(... | [
"```python\nn, a, x, b, y = map(int, input().split())\n\nwhile a != x and b != y and a != b:\n\tif a == b:\n\t\tbreak\n\n\ta = a % n + 1\n\tb = b - 1 if b - 1 else n\n\nprint(\"YNEOS\"[a != b::2])\n```"
] | [{"type": "stdin_stdout", "input": "5 1 4 3 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 2 1 9 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4 3 4 2 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "100 2 97 84 89\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The circle line of the Roflanpolis subway has $n$ stations... | [{"type": "stdin_stdout", "input": "5 1 4 3 2\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 2 1 9 10\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 3 4 2 1\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "std... | livecodebench | deepcoder_323 | 323 |
Solve the following coding problem using the programming language python:
Unlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers.
For example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 2^0 + 3^1, 17 = 2^3 + 3^... | [
"```python\nx,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)\... | [{"type": "stdin_stdout", "input": "2 3 1 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3 5 10 22\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "2 3 3 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 2 1 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 2 1 1000000\n", "o... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Unlucky year in Berland is such a year that its number n c... | [{"type": "stdin_stdout", "input": "2 3 1 10\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 5 10 22\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 3 3 5\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout... | livecodebench | deepcoder_324 | 324 |
Solve the following coding problem using the programming language python:
Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.
Beroffice works only with small English letters (i.e. with 26 letters from ... | [
"```python\ns = input()\nst = {'a', 'e', 'i', 'o', 'u', ' '}\nres = \"\"\n\ndef check(s):\n\tif (len(s) < 3):\n\t\treturn True\n\tif (s[-1] not in st and s[-2] not in st and s[-3] not in st) and (s[-1] != s[-2] or s[-2] != s[-3] or s[-1] != s[-3]):\n\t\treturn False\n\treturn True\n\nfor item in s:\n\tif not check(... | [{"type": "stdin_stdout", "input": "hellno\n", "output": "hell no \n"}, {"type": "stdin_stdout", "input": "abacaba\n", "output": "abacaba \n"}, {"type": "stdin_stdout", "input": "asdfasdf\n", "output": "asd fasd f \n"}, {"type": "stdin_stdout", "input": "ooo\n", "output": "ooo \n"}, {"type": "stdin_stdout", "input": "m... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Beroffice text editor has a wide range of features that he... | [{"type": "stdin_stdout", "input": "hellno\n", "output": "hell no \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "abacaba\n", "output": "abacaba \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "asdfasdf\n", "output": "asd fasd f \n", "metadata": {"func_name": null}}, {... | livecodebench | deepcoder_325 | 325 |
Solve the following coding problem using the programming language python:
Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions.
Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of ... | [
"```python\nn, 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... | [{"type": "stdin_stdout", "input": "20 3 2\n10 99\n2 4 3\n20 10 40\n4 15\n10 80\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "20 3 2\n10 99\n2 4 3\n200 100 400\n4 15\n100 800\n", "output": "200\n"}, {"type": "stdin_stdout", "input": "10 3 3\n10 33\n1 7 6\n17 25 68\n2 9 10\n78 89 125\n", "output": "10\n"}, {... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Anton is playing a very interesting computer game, but now... | [{"type": "stdin_stdout", "input": "20 3 2\n10 99\n2 4 3\n20 10 40\n4 15\n10 80\n", "output": "20\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "20 3 2\n10 99\n2 4 3\n200 100 400\n4 15\n100 800\n", "output": "200\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 3 3\n... | livecodebench | deepcoder_326 | 326 |
Solve the following coding problem using the programming language python:
Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than ... | [
"```python\nN = int(input())\nif N in [1, 2, 4, 5, 9, 10, 20, 21, 41, 42, 84, 85, 169, 170, 340, 341, 681, 682, 1364, 1365, 2729, 2730, 5460, 5461, 10921, 10922, 21844, 21845, 43689, 43690, 87380, 87381, 174761, 174762, 349524, 349525, 699049, 699050]:\n print(1)\nelse:\n print(0)\n\n\n```"
] | [{"type": "stdin_stdout", "input": "4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "7\n", "output": "0\n"}, {"type": "stdin_stdout",... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Recall that a binary search tree is a rooted binary tree, ... | [{"type": "stdin_stdout", "input": "4\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n", "o... | livecodebench | deepcoder_327 | 327 |
Solve the following coding problem using the programming language python:
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.
Lara is going to explore... | [
"```python\nn, m, k = map(int, input().split())\nans = 0, 0\nif k < n:\n ans = k + 1, 1\nelse:\n k -= n\n r = n - k // (m - 1)\n if r % 2:\n c = m - k % (m - 1)\n else:\n c = 2 + k % (m - 1)\n ans = r, c\nprint(*ans)\n```"
] | [{"type": "stdin_stdout", "input": "4 3 0\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "4 3 11\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "4 3 7\n", "output": "3 2\n"}, {"type": "stdin_stdout", "input": "1000000000 2 1999999999\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "10000... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You might have heard about the next game in Lara Croft ser... | [{"type": "stdin_stdout", "input": "4 3 0\n", "output": "1 1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 3 11\n", "output": "1 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 3 7\n", "output": "3 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout",... | livecodebench | deepcoder_328 | 328 |
Solve the following coding problem using the programming language python:
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 d... | [
"```python\nimport math\nx = int(input())\n\nans = 10**13\nab = [1, 1]\nfor i in range(1, int(x**(1/2))+1):\n if x % i == 0:\n a = x//i\n b = i\n\n g = math.gcd(a, b)\n a *= g\n b *= g\n if ans > max(a, b):\n ans = max(a, b)\n ab = [a, b]\n\nprint(a... | [{"type": "stdin_stdout", "input": "2\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "6\n", "output": "2 3\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "1 4\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "24\n", "output": "8 3\n"}, {"type": "std... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Today, Osama gave Fadi an integer $X$, and Fadi was wonder... | [{"type": "stdin_stdout", "input": "2\n", "output": "1 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n", "output": "2 3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n", "output": "1 4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\... | livecodebench | deepcoder_329 | 329 |
Solve the following coding problem using the programming language python:
Berland annual chess tournament is coming!
Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organ... | [
"```python\nn = int(input())\nz = list(map(int, input().split()))\nz.sort()\nif z[n - 1] < z[n]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n\n```"
] | [{"type": "stdin_stdout", "input": "2\n1 3 2 4\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\n3 3\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n1 1 1 1 2 2 3 3 3 3\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n1 1 1 1 1 2 2 2 2 2\n", "output": "YES\n"}, {"type": "stdin_stdou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Berland annual chess tournament is coming!
Organizers hav... | [{"type": "stdin_stdout", "input": "2\n1 3 2 4\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n3 3\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 1 1 1 2 2 3 3 3 3\n", "output": "NO\n", "metadata": {"func_name": null}}, {"ty... | livecodebench | deepcoder_330 | 330 |
Solve the following coding problem using the programming language python:
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... | [
"```python\nimport fractions\n\nn = int(input())\nA = [int(x) for x in input().split()]\nB = []\nfor i in range(n-1):\n B.append(A[i])\n if fractions.gcd(A[i], A[i+1]) != 1:\n B.append(1)\nB.append(A[-1])\nprint(len(B) - n)\nprint(' '.join(map(str, B)))\n\n\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n2 7 28\n", "output": "1\n2 7 1 28\n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "0\n1\n"}, {"type": "stdin_stdout", "input": "1\n548\n", "output": "0\n548\n"}, {"type": "stdin_stdout", "input": "1\n963837006\n", "output": "0\n963837006\n"}, {"type": "stdin_stdout", "i... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given an array of n elements, you must make it a c... | [{"type": "stdin_stdout", "input": "3\n2 7 28\n", "output": "1\n2 7 1 28\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "0\n1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n548\n", "output": "0\n548\n", "metadata": {"func_name": null}}, {"type": ... | livecodebench | deepcoder_331 | 331 |
Solve the following coding problem using the programming language python:
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, ... | [
"```python\n# 割り切る数は、Aの総和の約数である\n# 自分自身を除く約数について大きい順にすべて試して、当てはまるものがあれば答え\n\n# 8,20を7の倍数に近づけるとき、\n# 8 -> mod 7が1であり、-1か+6で7の倍数になる\n# 20 -> mod 7が6であり、-6か+1で7の倍数になる\n# -1と+1をペアにすることが出来て、この操作回数1をK = 3から引くと2となり、これが偶数ならOK\n\nimport sys\nreadline = sys.stdin.readline\n\nN,K = map(int,readline().split())\nA = list(map(in... | [{"type": "stdin_stdout", "input": "2 3\n8 20\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "2 10\n3 5\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "4 5\n10 1 2 22\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "8 7\n1 7 5 6 8 2 6 5\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
We have a sequence of N integers: A_1, A_2, \cdots, A_N.
Y... | [{"type": "stdin_stdout", "input": "2 3\n8 20\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 10\n3 5\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 5\n10 1 2 22\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdi... | livecodebench | deepcoder_332 | 332 |
Solve the following coding problem using the programming language python:
Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.
Assume that we have a cat with a numbe... | [
"```python\ndef main():\n x = int(input())\n n = x.bit_length()\n t = 0\n ans = []\n while True:\n if (x + 1) & (x) == 0:\n break\n if t & 1:\n x += 1\n else:\n for i in range(n - 1, -1, -1):\n if not (1 << i) & x:\n ... | [{"type": "stdin_stdout", "input": "39\n", "output": "4\n5 3 "}, {"type": "stdin_stdout", "input": "1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1000000\n", "output": "7\n14 6 9 15 "}, {"type": "stdin_stdout", "input": "524288\n", "output": "1\n19... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Cat Furrier Transform is a popular algorithm among cat pro... | [{"type": "stdin_stdout", "input": "39\n", "output": "4\n5 3 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "7\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100... | livecodebench | deepcoder_333 | 333 |
Solve the following coding problem using the programming language python:
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water a... | [
"```python\nn, 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)\n```"
] | [{"type": "stdin_stdout", "input": "3 6\n2 3 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6 7\n1 2 3 4 5 6\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "5 97\n1 10 50 97 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5 97\n1 10 50 100 2\n", "output": "97\n"}, {"type": "stdin_stdout"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Luba thinks about watering her garden. The garden can be r... | [{"type": "stdin_stdout", "input": "3 6\n2 3 5\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 7\n1 2 3 4 5 6\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 97\n1 10 50 97 2\n", "output": "1\n", "metadata": {"func_name": null}}, {"... | livecodebench | deepcoder_334 | 334 |
Solve the following coding problem using the programming language python:
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper t... | [
"```python\nfrom math import *\nfrom sys import *\nfrom queue import *\nfrom decimal import *\n\nn,k=(int(z) for z in input().split())\ns=input()\ni=0\nwhile i<len(s) and s[i] not in [\"G\",\"T\"]:\n i+=1\ni+=k\nwhile i<len(s) and s[i] not in [\"G\",\"T\",\"#\"]:\n i+=k\nif i>=len(s) or s[i]==\"#\":\n print(\"NO... | [{"type": "stdin_stdout", "input": "5 2\n#G#T#\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "6 1\nT....G\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "7 3\nT..#..G\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "6 2\n..GT..\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
On the way to Rio de Janeiro Ostap kills time playing with... | [{"type": "stdin_stdout", "input": "5 2\n#G#T#\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 1\nT....G\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "7 3\nT..#..G\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type":... | livecodebench | deepcoder_335 | 335 |
Solve the following coding problem using the programming language python:
It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guy... | [
"```python\ny1, 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}\")\n```"
] | [{"type": "stdin_stdout", "input": "4 10 13 10 3 1\n", "output": "4.3750000000\n"}, {"type": "stdin_stdout", "input": "1 4 6 2 2 1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 10 15 17 9 2\n", "output": "11.3333333333\n"}, {"type": "stdin_stdout", "input": "4 9 30 3 3 1\n", "output": "-1\n"}, {"type": "s... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
It's a beautiful April day and Wallace is playing football... | [{"type": "stdin_stdout", "input": "4 10 13 10 3 1\n", "output": "4.3750000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 4 6 2 2 1\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 10 15 17 9 2\n", "output": "11.3333333333\n", "metadata": {"fun... | livecodebench | deepcoder_336 | 336 |
Solve the following coding problem using the programming language python:
Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation!
Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only t... | [
"```python\na = 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\n```"
] | [{"type": "stdin_stdout", "input": "3 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 0 1000000000000000000\n", "output": "999999999999999999\n"}, {"type": "stdi... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Vasiliy spent his vacation in a sanatorium, came back and ... | [{"type": "stdin_stdout", "input": "3 2 1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 0 0\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input... | livecodebench | deepcoder_337 | 337 |
Solve the following coding problem using the programming language python:
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 ... | [
"```python\ndef 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 =... | [{"type": "stdin_stdout", "input": "hi\nbob\n", "output": "-\n"}, {"type": "stdin_stdout", "input": "abca\naccepted\n", "output": "ac\n"}, {"type": "stdin_stdout", "input": "abacaba\nabcdcba\n", "output": "abcba\n"}, {"type": "stdin_stdout", "input": "lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm\n", "output": "-\n"}, {"type": "s... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given two strings a and b. You have to remove the ... | [{"type": "stdin_stdout", "input": "hi\nbob\n", "output": "-\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "abca\naccepted\n", "output": "ac\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "abacaba\nabcdcba\n", "output": "abcba\n", "metadata": {"func_name": null}}, {"ty... | livecodebench | deepcoder_338 | 338 |
Solve the following coding problem using the programming language python:
Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.
You are given $n$ operati... | [
"```python\nn = int(input())\ns = input()\nb = 0\nfor i in s:\n if i == '+':\n b += 1\n else:\n b -= 1\n b = max(b, 0)\nprint(b)\n```"
] | [{"type": "stdin_stdout", "input": "3\n---\n", "output": "0"}, {"type": "stdin_stdout", "input": "4\n++++\n", "output": "4"}, {"type": "stdin_stdout", "input": "2\n-+\n", "output": "1"}, {"type": "stdin_stdout", "input": "5\n++-++\n", "output": "3"}, {"type": "stdin_stdout", "input": "1\n+\n", "output": "1"}, {"type": ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Vasya has a pile, that consists of some number of stones. ... | [{"type": "stdin_stdout", "input": "3\n---\n", "output": "0", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n++++\n", "output": "4", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n-+\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": ... | livecodebench | deepcoder_339 | 339 |
Solve the following coding problem using the programming language python:
Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.
Kolya is hungr... | [
"```python\nn=int(input())\na=int(input())\nb=int(input())\nc=int(input())\nr=n//a\nif n > c:\n r=max(r,(r-b+c)//a+1,(n-c)//(b-c)+((n-c)%(b-c)+c)//a)\nprint(r)\n```"
] | [{"type": "stdin_stdout", "input": "10\n11\n9\n8\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n5\n6\n1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2\n2\n2\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10\n3\n3\n1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n1\n2... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Kolya Gerasimov loves kefir very much. He lives in year 19... | [{"type": "stdin_stdout", "input": "10\n11\n9\n8\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10\n5\n6\n1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n2\n2\n1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "std... | livecodebench | deepcoder_340 | 340 |
Solve the following coding problem using the programming language python:
Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then the... | [
"```python\nn = int(input())\nk1 = list(map(int, input().split()[1:]))\nk2 = list(map(int, input().split()[1:]))\n\ni = 0\nwhile True:\n if len(k1) == 0 or len(k2) == 0:\n break\n if i > 10000:\n break\n if k1[0] > k2[0]:\n k1 = k1[1:] + k2[0:1] + k1[0:1]\n k2 = k2[1:]\n else... | [{"type": "stdin_stdout", "input": "4\n2 1 3\n2 4 2\n", "output": "6 2"}, {"type": "stdin_stdout", "input": "3\n1 2\n2 1 3\n", "output": "-1"}, {"type": "stdin_stdout", "input": "5\n4 5 3 2 4\n1 1\n", "output": "1 1"}, {"type": "stdin_stdout", "input": "6\n2 6 5\n4 1 2 3 4\n", "output": "6 1"}, {"type": "stdin_stdout",... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Two bored soldiers are playing card war. Their card deck c... | [{"type": "stdin_stdout", "input": "4\n2 1 3\n2 4 2\n", "output": "6 2", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n1 2\n2 1 3\n", "output": "-1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n4 5 3 2 4\n1 1\n", "output": "1 1", "metadata": {"func_name": null}}, {"... | livecodebench | deepcoder_341 | 341 |
Solve the following coding problem using the programming language python:
You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a ... | [
"```python\ns = 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 ... | [{"type": "stdin_stdout", "input": "abacaba\n", "output": "Too weak\n"}, {"type": "stdin_stdout", "input": "X12345\n", "output": "Too weak\n"}, {"type": "stdin_stdout", "input": "CONTEST_is_STARTED!!11\n", "output": "Correct\n"}, {"type": "stdin_stdout", "input": "1zA__\n", "output": "Correct\n"}, {"type": "stdin_stdou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You have probably registered on Internet sites many times.... | [{"type": "stdin_stdout", "input": "abacaba\n", "output": "Too weak\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "X12345\n", "output": "Too weak\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "CONTEST_is_STARTED!!11\n", "output": "Correct\n", "metadata": {"func_name":... | livecodebench | deepcoder_342 | 342 |
Solve the following coding problem using the programming language python:
In Berland each high school student is characterized by academic performance — integer value between 1 and 5.
In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academi... | [
"```python\nn = 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... | [{"type": "stdin_stdout", "input": "4\n5 4 4 4\n5 5 4 5\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n1 1 1 1 1 1\n5 5 5 5 5 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n5\n3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n", "output": "4... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
In Berland each high school student is characterized by ac... | [{"type": "stdin_stdout", "input": "4\n5 4 4 4\n5 5 4 5\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n1 1 1 1 1 1\n5 5 5 5 5 5\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n5\n3\n", "output": "-1\n", "metadata": {"func_name": ... | livecodebench | deepcoder_343 | 343 |
Solve the following coding problem using the programming language python:
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the ... | [
"```python\na, 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\n```"
] | [{"type": "stdin_stdout", "input": "3 3\n><>\nv^v\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4 6\n<><>\nv^v^v^\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 2\n<>\nv^\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 2\n>>\n^v\n", "output": "NO\n"}, {"type": "stdin_stdout", "inp... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Imagine a city with n horizontal streets crossing m vertic... | [{"type": "stdin_stdout", "input": "3 3\n><>\nv^v\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 6\n<><>\nv^v^v^\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2\n<>\nv^\n", "output": "YES\n", "metadata": {"func_name": null}}, ... | livecodebench | deepcoder_344 | 344 |
Solve the following coding problem using the programming language python:
Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false.
Implication is written by using character '$\rightarrow$', and the arg... | [
"```python\nx = 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 == ... | [{"type": "stdin_stdout", "input": "4\n0 1 1 0\n", "output": "YES\n0->1->1->0\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1\n0\n", "output": "YES\n0\n"}, {"type": "stdin_stdout", "input": "4\n0 0 0 0\n", "output": "YES\n0->(0->0)->0\n"}, {"type": "stdin_stdou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Implication is a function of two logical arguments, its va... | [{"type": "stdin_stdout", "input": "4\n0 1 1 0\n", "output": "YES\n0->1->1->0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n1 1\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n0\n", "output": "YES\n0\n", "metadata": {"func_name": null}}, {"type... | livecodebench | deepcoder_345 | 345 |
Solve the following coding problem using the programming language python:
You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise,... | [
"```python\na, 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\n```"
] | [{"type": "stdin_stdout", "input": "12 5\n", "output": "0 1\n"}, {"type": "stdin_stdout", "input": "31 12\n", "output": "7 12\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 7\n", "output": "8 7\n"}, {"type": "stdin_stdout", "input": "31960284556200 8515664064180\n", "output": "14928956427840 8515664064180\... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You have two variables a and b. Consider the following seq... | [{"type": "stdin_stdout", "input": "12 5\n", "output": "0 1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "31 12\n", "output": "7 12\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1000000000000000000 7\n", "output": "8 7\n", "metadata": {"func_name": null}}, {"type": ... | livecodebench | deepcoder_346 | 346 |
Solve the following coding problem using the programming language python:
Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.
-----Input-----
The only line contains three space-separated integers k,... | [
"```python\ns=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\n```"
] | [{"type": "stdin_stdout", "input": "1 1 10\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "2 -4 4\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1 1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 0 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 0 1\n", "output": "2\n"}, {... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Find the number of k-divisible numbers on the segment [a, ... | [{"type": "stdin_stdout", "input": "1 1 10\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 -4 4\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "in... | livecodebench | deepcoder_347 | 347 |
Solve the following coding problem using the programming language python:
Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...
Your tas... | [
"```python\na = int(input())\ns = \"\"\nfor i in range(1, a+1):\n s += str(i)\nprint(s[a-1])\n```"
] | [{"type": "stdin_stdout", "input": "7\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "21\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "3\n"}, {"type": "stdin_stdout"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Let's write all the positive integer numbers one after ano... | [{"type": "stdin_stdout", "input": "7\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "21\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "... | livecodebench | deepcoder_348 | 348 |
Solve the following coding problem using the programming language python:
A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then playe... | [
"```python\nn, 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\")\n```"
] | [{"type": "stdin_stdout", "input": "13\n8380011223344\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15\n807345619350641\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "19\n8181818181111111111\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "29\n88811188118181818118111111111\n", "output"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A telephone number is a sequence of exactly $11$ digits su... | [{"type": "stdin_stdout", "input": "13\n8380011223344\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "15\n807345619350641\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "19\n8181818181111111111\n", "output": "YES\n", "metadata": {"fu... | livecodebench | deepcoder_349 | 349 |
Solve the following coding problem using the programming language python:
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in ... | [
"```python\nMOD = 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 ... | [{"type": "stdin_stdout", "input": "4 1 2\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "123 42 24\n", "output": "824071958\n"}, {"type": "stdin_stdout", "input": "1 1 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000 501 501\n", "output": "646597996\n"}, {"type": "stdin_stdout", "input": "1000 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Andrey thinks he is truly a successful developer, but in r... | [{"type": "stdin_stdout", "input": "4 1 2\n", "output": "6\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "123 42 24\n", "output": "824071958\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 0\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_std... | livecodebench | deepcoder_350 | 350 |
Solve the following coding problem using the programming language python:
Andrey received a postcard from Irina. It contained only the words "Hello, Andrey!", and a strange string consisting of lowercase Latin letters, snowflakes and candy canes. Andrey thought that this string is an encrypted message, and decided to ... | [
"```python\ns = input()\nk = int(input())\nc = 0\np = 0\nhas_star = False\nfor i in range(len(s)):\n if s[i] in ['*', '?']:\n if s[i] == '*':\n has_star = True\n c -= 1\n else:\n p += 1\n c += 1\nif k < c:\n print(\"Impossible\")\nelif (not has_star) and (k > p):\n ... | [{"type": "stdin_stdout", "input": "hw?ap*yn?eww*ye*ar\n12\n", "output": "hwapppyewyar"}, {"type": "stdin_stdout", "input": "ab?a\n2\n", "output": "aa"}, {"type": "stdin_stdout", "input": "ab?a\n3\n", "output": "aba"}, {"type": "stdin_stdout", "input": "ababb\n5\n", "output": "ababb"}, {"type": "stdin_stdout", "input":... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Andrey received a postcard from Irina. It contained only t... | [{"type": "stdin_stdout", "input": "hw?ap*yn?eww*ye*ar\n12\n", "output": "hwapppyewyar", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "ab?a\n2\n", "output": "aa", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "ab?a\n3\n", "output": "aba", "metadata": {"func_name": null}}, {"... | livecodebench | deepcoder_351 | 351 |
Solve the following coding problem using the programming language python:
Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.
One of the project's know-how is a camera rotating around its optical axis on shooting. People ... | [
"```python\nn = (-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)\n```"
] | [{"type": "stdin_stdout", "input": "60\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "-60\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "44\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "45\n", "output": "0\n"}, {"type": "stdin_std... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Vasya started working in a machine vision company of IT Ci... | [{"type": "stdin_stdout", "input": "60\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "-60\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "0\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "44\n"... | livecodebench | deepcoder_352 | 352 |
Solve the following coding problem using the programming language python:
Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x ... | [
"```python\na, 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\n```"
] | [{"type": "stdin_stdout", "input": "4 4 0\n2 1 2\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5 6 1\n2 7 2\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "3 3 3\n2 2 2\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 0 0\n0 0 0\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Carl is a beginner magician. He has a blue, b violet and c... | [{"type": "stdin_stdout", "input": "4 4 0\n2 1 2\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 6 1\n2 7 2\n", "output": "No\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3 3\n2 2 2\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"typ... | livecodebench | deepcoder_353 | 353 |
Solve the following coding problem using the programming language python:
Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.
First he gave Amr two positive integers n and k... | [
"```python\nn,k,m=list(map(int,input().split()))\nd,r,p,P=0,0,1%k,(10**(n-1))*9\nF=[0]*k\nF[0]=1\nwhile d<n:\n\td+=1\n\tP//=10\n\tE=[0]*k\n\tif P==0:P=1\n\ti=1\n#\tprint(\"E=\",E)\n#\tprint(\"F=\",F)\n\twhile i<10:\n\t\tj=(-i*p)%k\n\t\tf=0\n\t\twhile f<k:\n\t\t\tE[f]+=F[j]\n\t\t\tf+=1\n\t\t\tj+=1\n\t\t\tif j==k:j=0... | [{"type": "stdin_stdout", "input": "1 2 1000\n", "output": "4"}, {"type": "stdin_stdout", "input": "2 2 1000\n", "output": "45"}, {"type": "stdin_stdout", "input": "5 3 1103\n", "output": "590"}, {"type": "stdin_stdout", "input": "2 17 10000\n", "output": "5"}, {"type": "stdin_stdout", "input": "3 9 10000\n", "output":... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Amr doesn't like Maths as he finds it really boring, so he... | [{"type": "stdin_stdout", "input": "1 2 1000\n", "output": "4", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2 1000\n", "output": "45", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 3 1103\n", "output": "590", "metadata": {"func_name": null}}, {"type": "stdin_stdout", ... | livecodebench | deepcoder_354 | 354 |
Solve the following coding problem using the programming language python:
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.
Th... | [
"```python\nn, 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,... | [{"type": "stdin_stdout", "input": "1 3\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "3 2\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "5 0\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "4 2\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "0 1000000\n", "output": "3000000\n"}, {... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Students in a class are making towers of blocks. Each stud... | [{"type": "stdin_stdout", "input": "1 3\n", "output": "9\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 0\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4... | livecodebench | deepcoder_355 | 355 |
Solve the following coding problem using the programming language python:
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 ... | [
"```python\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \nn = int(input()) \na = []\nfor _ in range(n):\n\ta.append(int(input()))\nb = list(set(a[::]))\nif(len(b) == 2 and a.count(a[0]) == ... | [{"type": "stdin_stdout", "input": "4\n11\n27\n27\n11\n", "output": "YES\n11 27\n"}, {"type": "stdin_stdout", "input": "2\n6\n6\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "6\n10\n20\n30\n20\n10\n20\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "6\n1\n1\n2\n2\n3\n3\n", "output": "NO\n"}, {"type"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Petya and Vasya decided to play a game. They have n cards ... | [{"type": "stdin_stdout", "input": "4\n11\n27\n27\n11\n", "output": "YES\n11 27\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n6\n6\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n10\n20\n30\n20\n10\n20\n", "output": "NO\n", "metadata": {"func_n... | livecodebench | deepcoder_356 | 356 |
Solve the following coding problem using the programming language python:
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 thr... | [
"```python\nimport 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... | [{"type": "stdin_stdout", "input": "2 2\n5 8\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1 2\n7 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 2\n4 4\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1 4\n2 2 1 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10000 100... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Daenerys Targaryen has an army consisting of k groups of s... | [{"type": "stdin_stdout", "input": "2 2\n5 8\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 2\n7 1\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 2\n4 4\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_s... | livecodebench | deepcoder_357 | 357 |
Solve the following coding problem using the programming language python:
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 fro... | [
"```python\nn = int(input())\na = list(map(int,input().split()))\nt = 0\nmn = 1000000000\nfor i in range(1,100):\n cur = 0\n for j in range(n):\n cur += max(0,abs(i-a[j])-1)\n if cur < mn:\n mn = cur\n t = i\nprint(t,mn)\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n10 1 4\n", "output": "3 7\n"}, {"type": "stdin_stdout", "input": "5\n1 1 2 2 3\n", "output": "2 0\n"}, {"type": "stdin_stdout", "input": "1\n5\n", "output": "4 0\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "1 0\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1\n", ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Salem gave you $n$ sticks with integer positive lengths $a... | [{"type": "stdin_stdout", "input": "3\n10 1 4\n", "output": "3 7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 1 2 2 3\n", "output": "2 0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n5\n", "output": "4 0\n", "metadata": {"func_name": null}}, {"type": "stdin... | livecodebench | deepcoder_358 | 358 |
Solve the following coding problem using the programming language python:
Карта звёздного неба представляет собой прямоугольное поле, состоящее из n строк по m символов в каждой строке. Каждый символ — это либо «.» (означает пустой участок неба), либо «*» (означает то, что в этом месте на небе есть звезда).
Новое из... | [
"```python\nn, 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 :... | [{"type": "stdin_stdout", "input": "4 4\n....\n..*.\n...*\n..**\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 3\n*.*\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2 1\n.\n*\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1\n*\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Карта звёздного неба представляет собой прямоугольное поле... | [{"type": "stdin_stdout", "input": "4 4\n....\n..*.\n...*\n..**\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 3\n*.*\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1\n.\n*\n", "output": "1\n", "metadata": {"func_name": null}}, {"... | livecodebench | deepcoder_359 | 359 |
Solve the following coding problem using the programming language python:
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1... | [
"```python\nN, T = list(map(int, input().split()))\nA = [int(a) for a in input().split()]\nif sum(A) > N//2:\n A = [1-a for a in A][::-1]\nK = sum(A)\nS = sum(A[-K:])\nM = K + 1\nP = 10**9+7\ninv = pow(N*(N-1)//2, P-2, P)\nX = [[0]*M for _ in range(M)]\nfor i in range(M):\n if i > 0: X[i-1][i] = ((K-i+1)**2*i... | [{"type": "stdin_stdout", "input": "3 2\n0 1 0\n", "output": "333333336"}, {"type": "stdin_stdout", "input": "5 1\n1 1 1 0 0\n", "output": "0"}, {"type": "stdin_stdout", "input": "6 4\n1 0 0 1 1 0\n", "output": "968493834"}, {"type": "stdin_stdout", "input": "3 2\n1 1 1\n", "output": "1"}, {"type": "stdin_stdout", "inp... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A girl named Sonya is studying in the scientific lyceum of... | [{"type": "stdin_stdout", "input": "3 2\n0 1 0\n", "output": "333333336", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 1\n1 1 1 0 0\n", "output": "0", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 4\n1 0 0 1 1 0\n", "output": "968493834", "metadata": {"func_name": null... | livecodebench | deepcoder_360 | 360 |
Solve the following coding problem using the programming language python:
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... | [
"```python\nx, 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\n```"
] | [{"type": "stdin_stdout", "input": "6 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "22 4\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "4 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "57 27\n", "output": "4\n"}, {"type": "s... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Memory is now interested in the de-evolution of objects, s... | [{"type": "stdin_stdout", "input": "6 3\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 5\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "22 4\n", "output": "6\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4... | livecodebench | deepcoder_361 | 361 |
Solve the following coding problem using the programming language python:
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$
A matrix is called degenerate if its determinant is equal to zero.
The norm ||A|| of a m... | [
"```python\ndef seg(x, y, h):\n A = [x - h, x + h]\n B = [y - h, y + h]\n Z = []\n for a in A:\n for b in B:\n Z.append(a * b)\n Z.sort()\n return (Z[0], Z[-1])\n\ndef check(a, b, c, d, h):\n x1, y1 = seg(a, d, h)\n x2, y2 = seg(b, c, h)\n return max(x1, x2) <= min(y1, y... | [{"type": "stdin_stdout", "input": "1 2\n3 4\n", "output": "0.2000000000\n"}, {"type": "stdin_stdout", "input": "1 0\n0 1\n", "output": "0.5000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 0\n0 1000000000\n", "output": "500000000.0000000000\n"}, {"type": "stdin_stdout", "input": "8205 9482\n11 -63\n", "outp... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The determinant of a matrix 2 × 2 is defined as follows:$\... | [{"type": "stdin_stdout", "input": "1 2\n3 4\n", "output": "0.2000000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 0\n0 1\n", "output": "0.5000000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1000000000 0\n0 1000000000\n", "output": "500000000.0000000000\n... | livecodebench | deepcoder_362 | 362 |
Solve the following coding problem using the programming language python:
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... | [
"```python\nn, 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 ... | [{"type": "stdin_stdout", "input": "4 1 2\n1 2 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4 1 1\n1 1 2 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 1 1\n1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 1 2\n2 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 1 3\... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
In a small restaurant there are a tables for one person an... | [{"type": "stdin_stdout", "input": "4 1 2\n1 2 1 1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 1 1\n1 1 2 1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 1\n1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "... | livecodebench | deepcoder_363 | 363 |
Solve the following coding problem using the programming language python:
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 th... | [
"```python\na,b,c,n=list(map(int,input().split()))\nx=a+b-c\nprint(n-x if c<=a and c<=b and x<n else -1)\n\n```"
] | [{"type": "stdin_stdout", "input": "10 10 5 20\n", "output": "5"}, {"type": "stdin_stdout", "input": "2 2 0 4\n", "output": "-1"}, {"type": "stdin_stdout", "input": "2 2 2 1\n", "output": "-1"}, {"type": "stdin_stdout", "input": "98 98 97 100\n", "output": "1"}, {"type": "stdin_stdout", "input": "1 5 2 10\n", "output":... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Each student eagerly awaits the day he would pass the exam... | [{"type": "stdin_stdout", "input": "10 10 5 20\n", "output": "5", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2 0 4\n", "output": "-1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2 2 1\n", "output": "-1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "... | livecodebench | deepcoder_364 | 364 |
Solve the following coding problem using the programming language python:
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 r... | [
"```python\nx = int(input())\nif x%2==1:\n print(0)\n quit()\nif x%2 ==0:\n x//=2\n if x%2==0:\n print(x//2-1)\n else:\n print(x//2)\n\n```"
] | [{"type": "stdin_stdout", "input": "6\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "20\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "0\n"}, {"type": "stdin_stdout"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Pasha has a wooden stick of some positive integer length n... | [{"type": "stdin_stdout", "input": "6\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "20\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "... | livecodebench | deepcoder_365 | 365 |
Solve the following coding problem using the programming language python:
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 l... | [
"```python\ndef doit():\n xx = input().split()\n n = int(xx[0])\n s = int(xx[1])\n v = [int(k) for k in input().split()]\n\n S = sum(v)\n newS = S - s\n if newS < 0:\n return -1\n return min(newS//n, min(v))\n \nprint(doit())\n\n```"
] | [{"type": "stdin_stdout", "input": "3 3\n4 3 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3 4\n5 3 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 7\n1 2 3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 2\n1\n", "out... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The Fair Nut likes kvass very much. On his birthday parent... | [{"type": "stdin_stdout", "input": "3 3\n4 3 5\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 4\n5 3 4\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 7\n1 2 3\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin... | livecodebench | deepcoder_366 | 366 |
Solve the following coding problem using the programming language python:
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 c... | [
"```python\nfrom math import *\n\nh1, h2 = [int(i) for i in input().split()]\na, b = [int(i) for i in input().split()]\na *= 12\nb *= 12\nif a <= b and h2 - h1 > (a // 12 * 8):\n print(-1)\n return\nh1 += (a // 12 * 8)\nif h1 >= h2:\n print(0)\n return\nday = int(ceil((h2 - h1) / (a - b)))\nprint(day)\n... | [{"type": "stdin_stdout", "input": "10 30\n2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 13\n1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 19\n1 2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1 50\n5 4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1000\n2 1\... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The 9-th grade student Gabriel noticed a caterpillar on a ... | [{"type": "stdin_stdout", "input": "10 30\n2 1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 13\n1 1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 19\n1 2\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin... | livecodebench | deepcoder_367 | 367 |
Solve the following coding problem using the programming language python:
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? [Ima... | [
"```python\nimport 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... | [{"type": "stdin_stdout", "input": "10 3 5 2 3\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "5 3 1 6 7\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "982068341 55 57 106 109\n", "output": "513558662\n"}, {"type": "stdin_stdout", "input": "930064129 32726326 25428197 83013449 64501049\n", "output":... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A sweet little monster Om Nom loves candies very much. One... | [{"type": "stdin_stdout", "input": "10 3 5 2 3\n", "output": "16\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 3 1 6 7\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "982068341 55 57 106 109\n", "output": "513558662\n", "metadata": {"func_name": nul... | livecodebench | deepcoder_368 | 368 |
Solve the following coding problem using the programming language python:
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:... | [
"```python\nn = 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 e... | [{"type": "stdin_stdout", "input": "5\nDDRRR\n", "output": "D\n"}, {"type": "stdin_stdout", "input": "6\nDDRRRR\n", "output": "R\n"}, {"type": "stdin_stdout", "input": "1\nD\n", "output": "D\n"}, {"type": "stdin_stdout", "input": "1\nR\n", "output": "R\n"}, {"type": "stdin_stdout", "input": "2\nDR\n", "output": "D\n"},... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
There are n employees in Alternative Cake Manufacturing (A... | [{"type": "stdin_stdout", "input": "5\nDDRRR\n", "output": "D\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\nDDRRRR\n", "output": "R\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\nD\n", "output": "D\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", ... | livecodebench | deepcoder_369 | 369 |
Solve the following coding problem using the programming language python:
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 ... | [
"```python\ndef 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\n```"
] | [{"type": "stdin_stdout", "input": "17 15 5 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "14 16 7 22\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4 2 6 4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\n", "o... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Monocarp has decided to buy a new TV set and hang it on th... | [{"type": "stdin_stdout", "input": "17 15 5 3\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "14 16 7 22\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 2 6 4\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdo... | livecodebench | deepcoder_370 | 370 |
Solve the following coding problem using the programming language python:
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 numbe... | [
"```python\nn, 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]... | [{"type": "stdin_stdout", "input": "6 9\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "38 11\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000\n",... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The number "zero" is called "love" (or "l'oeuf" to be prec... | [{"type": "stdin_stdout", "input": "6 9\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "38 11\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 2\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "... | livecodebench | deepcoder_371 | 371 |
Solve the following coding problem using the programming language python:
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 n... | [
"```python\nimport 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\n... | [{"type": "stdin_stdout", "input": "7 5 3\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "1000000000 1 2019\n", "output": "500000001500000001\n"}, {"type": "stdin_stdout", "input": "100 100000 1\n", "output": "101\n"}, {"type": "stdin_stdout", "input": "6 4 5\n", "output": "10\n"}, {"type": "stdin_stdout", "i... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A frog is initially at position $0$ on the number line. Th... | [{"type": "stdin_stdout", "input": "7 5 3\n", "output": "19\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1000000000 1 2019\n", "output": "500000001500000001\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100 100000 1\n", "output": "101\n", "metadata": {"func_name": ... | livecodebench | deepcoder_372 | 372 |
Solve the following coding problem using the programming language python:
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, th... | [
"```python\ndef read_ints():\n\treturn [int(i) for i in input().split()]\n\nn = read_ints()\na = read_ints()\nif len(a) % 2 and a[0] % 2 and a[-1] % 2:\n\tprint('Yes')\nelse:\n\tprint('No')\n```"
] | [{"type": "stdin_stdout", "input": "3\n1 3 5\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5\n1 0 1 5 1\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3\n4 3 1\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "4\n3 9 9 3\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "1\n1\n",... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Where do odds begin, and where do they end? Where does hop... | [{"type": "stdin_stdout", "input": "3\n1 3 5\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 0 1 5 1\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n4 3 1\n", "output": "No\n", "metadata": {"func_name": null}}, {"type": "std... | livecodebench | deepcoder_373 | 373 |
Solve the following coding problem using the programming language python:
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 ar... | [
"```python\nfrom 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):\... | [{"type": "stdin_stdout", "input": "3\n1 2 -3\n", "output": "YES\n3\n1 1\n2 2\n3 3\n"}, {"type": "stdin_stdout", "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"}, {"type": "stdin_stdout", "input": "1\n0\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4\n1 2 3... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
One spring day on his way to university Lesha found an arr... | [{"type": "stdin_stdout", "input": "3\n1 2 -3\n", "output": "YES\n3\n1 1\n2 2\n3 3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "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", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n0\... | livecodebench | deepcoder_374 | 374 |
Solve the following coding problem using the programming language python:
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... | [
"```python\nn1 = 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:... | [{"type": "stdin_stdout", "input": "3454\n", "output": "YES\n344\n"}, {"type": "stdin_stdout", "input": "10\n", "output": "YES\n0\n"}, {"type": "stdin_stdout", "input": "111111\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "8996988892\n", "output": "YES\n8\n"}, {"type": "stdin_stdout", "input": "5555555555\n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given a non-negative integer n, its decimal repres... | [{"type": "stdin_stdout", "input": "3454\n", "output": "YES\n344\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10\n", "output": "YES\n0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "111111\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdou... | livecodebench | deepcoder_375 | 375 |
Solve the following coding problem using the programming language python:
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, t... | [
"```python\ndef 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 + ... | [{"type": "stdin_stdout", "input": "10 3\n6 2\n2 1\n7 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8 4\n3 1\n6 2\n5 2\n2 1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "8 3\n7 2\n6 2\n1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 2\n8 3\n3 1\n", "output": "2\n"}, {"type": "std... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
In a building where Polycarp lives there are equal number ... | [{"type": "stdin_stdout", "input": "10 3\n6 2\n2 1\n7 3\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 4\n3 1\n6 2\n5 2\n2 1\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 3\n7 2\n6 2\n1 1\n", "output": "2\n", "metadata": {"func_... | livecodebench | deepcoder_376 | 376 |
Solve the following coding problem using the programming language python:
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any s... | [
"```python\nf = []\nfor i in range(2):\n f.append(list(input()))\n\n\nanswer = 0\n\nn = len(f[0])\nfor i in range(n):\n if f[0][i] == f[1][i] == '0' and i + 1 < n:\n if f[0][i + 1] == '0':\n answer += 1\n f[0][i + 1] = 'X'\n elif f[1][i + 1] == '0':\n answer += 1... | [{"type": "stdin_stdout", "input": "00\n00\n", "output": "1"}, {"type": "stdin_stdout", "input": "00X00X0XXX0\n0XXX0X00X00\n", "output": "4"}, {"type": "stdin_stdout", "input": "0X0X0\n0X0X0\n", "output": "0"}, {"type": "stdin_stdout", "input": "0XXX0\n00000\n", "output": "2"}, {"type": "stdin_stdout", "input": "0\n0\n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Bishwock is a chess figure that consists of three squares ... | [{"type": "stdin_stdout", "input": "00\n00\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "00X00X0XXX0\n0XXX0X00X00\n", "output": "4", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "0X0X0\n0X0X0\n", "output": "0", "metadata": {"func_name": null}}, {"type": "... | livecodebench | deepcoder_377 | 377 |
Solve the following coding problem using the programming language python:
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: let... | [
"```python\ndef 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\... | [{"type": "stdin_stdout", "input": "11\naaaaBaabAbA\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "12\nzACaAbbaazzC\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\nABC\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\na\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\naz\n", "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Polycarp loves lowercase letters and dislikes uppercase on... | [{"type": "stdin_stdout", "input": "11\naaaaBaabAbA\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "12\nzACaAbbaazzC\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\nABC\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": ... | livecodebench | deepcoder_378 | 378 |
Solve the following coding problem using the programming language python:
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 t... | [
"```python\n\nn=int(input())\narr= list(map(int,input().strip().split(' ')))\ns = 0\nfor i in range(n):\n s+=abs(arr[i])\nprint(s)\n```"
] | [{"type": "stdin_stdout", "input": "3\n1 -2 0\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n16 23 16 15 42 8\n", "output": "120\n"}, {"type": "stdin_stdout", "input": "1\n-1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given a sequence a consisting of n integers. You m... | [{"type": "stdin_stdout", "input": "3\n1 -2 0\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n16 23 16 15 42 8\n", "output": "120\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n-1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "s... | livecodebench | deepcoder_379 | 379 |
Solve the following coding problem using the programming language python:
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 im... | [
"```python\ndef 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 ... | [{"type": "stdin_stdout", "input": "6 9 2 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "6 10 2 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6 5 4 3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 2 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 4 6 10\n", "output"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A bus moves along the coordinate line Ox from the point x ... | [{"type": "stdin_stdout", "input": "6 9 2 4\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 10 2 4\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 5 4 3\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout"... | livecodebench | deepcoder_380 | 380 |
Solve the following coding problem using the programming language python:
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".
... | [
"```python\na, b, c = map(int, input().split(' '))\nx = input()\nfor i in range(105):\n for j in range(105):\n if i*b+j*c == a:\n print(i+j)\n for k in range(i):\n print(x[:b])\n x = x[b:]\n for l in range(j):\n print(x[:c])\n ... | [{"type": "stdin_stdout", "input": "5 2 3\nHello\n", "output": "2\nHe\nllo\n"}, {"type": "stdin_stdout", "input": "10 9 5\nCodeforces\n", "output": "2\nCodef\norces\n"}, {"type": "stdin_stdout", "input": "6 4 5\nPrivet\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "8 1 1\nabacabac\n", "output": "8\na\nb\na\n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given the string s of length n and the numbers p, ... | [{"type": "stdin_stdout", "input": "5 2 3\nHello\n", "output": "2\nHe\nllo\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 9 5\nCodeforces\n", "output": "2\nCodef\norces\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 4 5\nPrivet\n", "output": "-1\n", "metadata": {... | livecodebench | deepcoder_381 | 381 |
Solve the following coding problem using the programming language python:
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 m... | [
"```python\nn, 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(b... | [{"type": "stdin_stdout", "input": "3 10 1 3\n3 4 7\n", "output": "RUN 2\nJUMP 3\nRUN 1\nJUMP 2\nRUN 2\n"}, {"type": "stdin_stdout", "input": "2 9 2 3\n6 4\n", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "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\nJUM... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A sportsman starts from point x_{start} = 0 and runs to po... | [{"type": "stdin_stdout", "input": "3 10 1 3\n3 4 7\n", "output": "RUN 2\nJUMP 3\nRUN 1\nJUMP 2\nRUN 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 9 2 3\n6 4\n", "output": "IMPOSSIBLE\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 100 2 8\n93 35 24 87 39 46 86... | livecodebench | deepcoder_382 | 382 |
Solve the following coding problem using the programming language python:
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), th... | [
"```python\ns, 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)... | [{"type": "stdin_stdout", "input": "9 5\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "6 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "549755813887 549755813887\n", "output": ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Two positive integers a and b have a sum of s and a bitwis... | [{"type": "stdin_stdout", "input": "9 5\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 2\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 ... | livecodebench | deepcoder_383 | 383 |
Solve the following coding problem using the programming language python:
Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over.
This time Miroslav laid out $n$ skewers parallel to each other, and e... | [
"```python\nn, k = map(int, input().split())\nif n <= k + k + 1:\n print(1)\n print((n + 1) // 2)\nelse:\n answer = -1\n answer_n = 10**100\n for i in range(min(k + 1, n)):\n t = n - (k + i + 1)\n if t % (k + k + 1) >= k + 1:\n if 2 + t // (k + k + 1) < answer_n:\n ... | [{"type": "stdin_stdout", "input": "7 2\n", "output": "2\n1 6 \n"}, {"type": "stdin_stdout", "input": "5 1\n", "output": "2\n1 4 \n"}, {"type": "stdin_stdout", "input": "10 0\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 \n"}, {"type": "stdin_stdout", "input": "10 1\n", "output": "4\n1 4 7 10 \n"}, {"type": "stdin_stdout", "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Long story short, shashlik is Miroslav's favorite food. Sh... | [{"type": "stdin_stdout", "input": "7 2\n", "output": "2\n1 6 \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 1\n", "output": "2\n1 4 \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 0\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 \n", "metadata": {"func_name": null}}, ... | livecodebench | deepcoder_384 | 384 |
Solve the following coding problem using the programming language python:
Let's define a function $f(p)$ on a permutation $p$ as follows. Let $g_i$ be the greatest common divisor (GCD) of elements $p_1$, $p_2$, ..., $p_i$ (in other words, it is the GCD of the prefix of length $i$). Then $f(p)$ is the number of distinc... | [
"```python\np=10**9+7\nimport math\ndef inv(k,p):\n prod=1\n while k>1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i... | [{"type": "stdin_stdout", "input": "2\n", "output": "1"}, {"type": "stdin_stdout", "input": "3\n", "output": "4"}, {"type": "stdin_stdout", "input": "6\n", "output": "120"}, {"type": "stdin_stdout", "input": "10\n", "output": "15120"}, {"type": "stdin_stdout", "input": "64\n", "output": "676169815"}, {"type": "stdin_st... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Let's define a function $f(p)$ on a permutation $p$ as fol... | [{"type": "stdin_stdout", "input": "2\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n", "output": "4", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n", "output": "120", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10\n", "outp... | livecodebench | deepcoder_385 | 385 |
Solve the following coding problem using the programming language python:
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 vowe... | [
"```python\n# You lost the game.\n\ns = str(input())\nn = len(s)\nd = -1\nr = 0\nV = \"AEIOUY\"\nfor i in range(n):\n if V.count(s[i]):\n r = max(r,i-d)\n d = i\nprint(max(r, n-d))\n\n```"
] | [{"type": "stdin_stdout", "input": "ABABBBACFEYUKOTT\n", "output": "4"}, {"type": "stdin_stdout", "input": "AAA\n", "output": "1"}, {"type": "stdin_stdout", "input": "A\n", "output": "1"}, {"type": "stdin_stdout", "input": "B\n", "output": "2"}, {"type": "stdin_stdout", "input": "AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEO... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
One day, the Grasshopper was jumping on the lawn and found... | [{"type": "stdin_stdout", "input": "ABABBBACFEYUKOTT\n", "output": "4", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "AAA\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "A\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input"... | livecodebench | deepcoder_386 | 386 |
Solve the following coding problem using the programming language python:
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,... | [
"```python\nn = int(input())\na = list(map(int, input().split()))\na = a[::-1]\nd = 0\nfor i in range(len(a)):\n d = max(0 + d, a[i] + (sum(a[:i]) - d))\nprint(sum(a)-d, d)\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n141 592 653\n", "output": "653 733\n"}, {"type": "stdin_stdout", "input": "5\n10 21 10 21 10\n", "output": "31 41\n"}, {"type": "stdin_stdout", "input": "1\n100000\n", "output": "0 100000\n"}, {"type": "stdin_stdout", "input": "50\n100000 100000 100000 100000 100000 100000 100000 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You may have heard of the pie rule before. It states that ... | [{"type": "stdin_stdout", "input": "3\n141 592 653\n", "output": "653 733\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n10 21 10 21 10\n", "output": "31 41\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n100000\n", "output": "0 100000\n", "metadata": {"func_name... | livecodebench | deepcoder_387 | 387 |
Solve the following coding problem using the programming language python:
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 follow... | [
"```python\ndef 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(so... | [{"type": "stdin_stdout", "input": "5\n1 2 3 6 8\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n3 6 5\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "6\n2 4 8 6 10 18\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 2 4 5 3 6 7\n", "output": "3\n"}, {"type": "stdin_stdout", "input": ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You've got a positive integer sequence a_1, a_2, ..., a_{n... | [{"type": "stdin_stdout", "input": "5\n1 2 3 6 8\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n3 6 5\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n2 4 8 6 10 18\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": ... | livecodebench | deepcoder_388 | 388 |
Solve the following coding problem using the programming language python:
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 a... | [
"```python\nread = lambda: list(map(int, input().split()))\nn = int(input())\na = list(read())\ns = set()\nfor i in a:\n s.add(i)\nf1 = len(s) < 3\nf2 = len(s) == 3 and max(s) + min(s) == 2 * sorted(s)[1]\nprint('YES' if f1 or f2 else 'NO')\n\n```"
] | [{"type": "stdin_stdout", "input": "5\n1 3 3 2 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3\n1 2 3\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3\n1 1 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Today, hedgehog Filya went to school for the very first ti... | [{"type": "stdin_stdout", "input": "5\n1 3 3 2 1\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "s... | livecodebench | deepcoder_389 | 389 |
Solve the following coding problem using the programming language python:
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 t... | [
"```python\nn, a = list(map(int,input().split()))\nif a % 2 == 1:\n print(a // 2 + 1)\nelse:\n print((n-a) // 2 + 1)\n\n```"
] | [{"type": "stdin_stdout", "input": "4 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "8 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 1\n", "output": "1\n"}, {"type": "std... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The main street of Berland is a straight line with n house... | [{"type": "stdin_stdout", "input": "4 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 5\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 ... | livecodebench | deepcoder_390 | 390 |
Solve the following coding problem using the programming language python:
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-kno... | [
"```python\ns = 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 re... | [{"type": "stdin_stdout", "input": "5 2\n1 1 2 2 1\n1 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1 1\n1\n1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 1\n1 1\n1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 1\n1 1\n2\n", "output": "YES\n"}, {"type": "stdin_stdout", "inp... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
There is unrest in the Galactic Senate. Several thousand s... | [{"type": "stdin_stdout", "input": "5 2\n1 1 2 2 1\n1 2\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n1\n1\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1\n1 1\n1\n", "output": "YES\n", "metadata": {"func_name": null}}, {... | livecodebench | deepcoder_391 | 391 |
Solve the following coding problem using the programming language python:
Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.
R... | [
"```python\nx = 0\ny = 0\nfor _ in range(int(input())):\n a, b = list(map(int, input().split()))\n x += (a > b)\n y += (b > a)\nif x > y:\n print(\"Mishka\")\nelif y > x:\n print(\"Chris\")\nelse:\n print(\"Friendship is magic!^^\")\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n3 5\n2 1\n4 2\n", "output": "Mishka"}, {"type": "stdin_stdout", "input": "2\n6 1\n1 6\n", "output": "Friendship is magic!^^"}, {"type": "stdin_stdout", "input": "3\n1 5\n3 3\n2 2\n", "output": "Chris"}, {"type": "stdin_stdout", "input": "6\n4 1\n4 2\n5 3\n5 1\n5 3\n4 1\n", "output... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Mishka is a little polar bear. As known, little bears love... | [{"type": "stdin_stdout", "input": "3\n3 5\n2 1\n4 2\n", "output": "Mishka", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n6 1\n1 6\n", "output": "Friendship is magic!^^", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n1 5\n3 3\n2 2\n", "output": "Chris", "metadata": {... | livecodebench | deepcoder_392 | 392 |
Solve the following coding problem using the programming language python:
One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he ra... | [
"```python\nr, c = list(map(int, input().split()))\n\nb = [list(input()) for i in range(r)]\nfor y in range(r):\n for x in range(c):\n if b[y][x] == '.':\n b[y][x] = '0'\n\nok = True\nfor Y in range(r):\n for X in range(c):\n if not b[Y][X].isdigit():\n continue\n p ... | [{"type": "stdin_stdout", "input": "3 3\n111\n1*1\n111\n", "output": "YES"}, {"type": "stdin_stdout", "input": "2 4\n*.*.\n1211\n", "output": "NO"}, {"type": "stdin_stdout", "input": "1 10\n.....1*1..\n", "output": "YES"}, {"type": "stdin_stdout", "input": "1 1\n4\n", "output": "NO"}, {"type": "stdin_stdout", "input": ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
One day Alex decided to remember childhood when computers ... | [{"type": "stdin_stdout", "input": "3 3\n111\n1*1\n111\n", "output": "YES", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 4\n*.*.\n1211\n", "output": "NO", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 10\n.....1*1..\n", "output": "YES", "metadata": {"func_name": null}}... | livecodebench | deepcoder_393 | 393 |
Solve the following coding problem using the programming language python:
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... | [
"```python\ndef 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 ... | [{"type": "stdin_stdout", "input": "68\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "42\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "43\n", "output": "2\n"}, {"type": "stdin_stdou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
After passing a test, Vasya got himself a box of $n$ candi... | [{"type": "stdin_stdout", "input": "68\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "42\n", ... | livecodebench | deepcoder_394 | 394 |
Solve the following coding problem using the programming language python:
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 a... | [
"```python\ndef 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\n```"
] | [{"type": "stdin_stdout", "input": "-o-o--\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "-o---\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "-o---o-\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "ooo\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "---\n", "output": "YES\n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
A necklace can be described as a string of links ('-') and... | [{"type": "stdin_stdout", "input": "-o-o--\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "-o---\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "-o---o-\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout"... | livecodebench | deepcoder_395 | 395 |
Solve the following coding problem using the programming language python:
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 ... | [
"```python\nn, 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\n... | [{"type": "stdin_stdout", "input": "4 6 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 10 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3 6 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3 3 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1 1\n", "output": "1\n"}, {"t... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
n hobbits are planning to spend the night at Frodo's house... | [{"type": "stdin_stdout", "input": "4 6 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 10 3\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 6 1\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "inpu... | livecodebench | deepcoder_396 | 396 |
Solve the following coding problem using the programming language python:
You are given an array $a_1, a_2, \dots , a_n$ and two integers $m$ and $k$.
You can choose some subarray $a_l, a_{l+1}, \dots, a_{r-1}, a_r$.
The cost of subarray $a_l, a_{l+1}, \dots, a_{r-1}, a_r$ is equal to $\sum\limits_{i=l}^{r} a_i - k... | [
"```python\nN, M, K = list(map(int, input().split()))\nA = [int(a) for a in input().split()]\nS = [0]\nfor a in A:\n S.append(S[-1]+M*a-K)\nMI = [(10**50)] * M\nans = 0\nfor i in range(N+1):\n MI[i%M] = min(MI[i%M], S[i])\n for j in range(M):\n ans = max(ans, (S[i]-MI[(i-j)%M] - K*((-j)%M))//M)\npri... | [{"type": "stdin_stdout", "input": "7 3 10\n2 -4 15 -3 4 8 3\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "5 2 1000\n-13 -4 -9 -20 -11\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 10 10\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "4999999990\n"}, {"type": "stdin_stdout... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given an array $a_1, a_2, \dots , a_n$ and two int... | [{"type": "stdin_stdout", "input": "7 3 10\n2 -4 15 -3 4 8 3\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 2 1000\n-13 -4 -9 -20 -11\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 10 10\n1000000000 1000000000 1000000000 100000000... | livecodebench | deepcoder_397 | 397 |
Solve the following coding problem using the programming language python:
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible... | [
"```python\nimport math\nn, m = list(map(int, input().split()))\nif n == 0 : \n print(0, 1)\n print(0, m)\n print(0, 0)\n print(0, m - 1)\nelif m == 0 : \n print(1, 0)\n print(n, 0)\n print(0, 0)\n print(n - 1, 0)\nelse :\n l = math.sqrt((n - 1) ** 2 + m ** 2) + math.sqrt(n ** 2 + m ** 2)... | [{"type": "stdin_stdout", "input": "1 1\n", "output": "1 1\n0 0\n1 0\n0 1\n"}, {"type": "stdin_stdout", "input": "0 10\n", "output": "0 1\n0 10\n0 0\n0 9\n"}, {"type": "stdin_stdout", "input": "10 10\n", "output": "10 9\n0 0\n10 10\n1 0\n"}, {"type": "stdin_stdout", "input": "100 100\n", "output": "0 1\n100 100\n0 0\n9... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given a rectangular grid of lattice points from (0... | [{"type": "stdin_stdout", "input": "1 1\n", "output": "1 1\n0 0\n1 0\n0 1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "0 10\n", "output": "0 1\n0 10\n0 0\n0 9\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 10\n", "output": "10 9\n0 0\n10 10\n1 0\n", "metadata": {... | livecodebench | deepcoder_398 | 398 |
Solve the following coding problem using the programming language python:
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets so... | [
"```python\ndef main():\n\tn, m, mn, mx = map(int, input().split())\n\tA = list(map(int, input().split()))\n\ta = min(A)\n\tb = max(A)\n\tif a < mn or b > mx:\n\t\tprint(\"Incorrect\")\n\t\treturn\n\tcnt = 0\n\tif a > mn:\n\t\tcnt += 1\n\tif b < mx:\n\t\tcnt += 1\n\tif m + cnt <= n:\n\t\tprint(\"Correct\")\n\telse:... | [{"type": "stdin_stdout", "input": "2 1 1 2\n1\n", "output": "Correct\n"}, {"type": "stdin_stdout", "input": "3 1 1 3\n2\n", "output": "Correct\n"}, {"type": "stdin_stdout", "input": "2 1 1 3\n2\n", "output": "Incorrect\n"}, {"type": "stdin_stdout", "input": "3 1 1 5\n3\n", "output": "Correct\n"}, {"type": "stdin_stdou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Not so long ago company R2 bought company R1 and consequen... | [{"type": "stdin_stdout", "input": "2 1 1 2\n1\n", "output": "Correct\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 1 1 3\n2\n", "output": "Correct\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1 1 3\n2\n", "output": "Incorrect\n", "metadata": {"func_name": null... | livecodebench | deepcoder_399 | 399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.