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:
Alice and Bob got very bored during a long car trip so they decided to play a game. From the window they can see cars of different colors running past them. Cars are going one after another.
The game rules are like this. Firstly Alice chooses s... | [
"```python\nfrom sys import stdin, stdout\n\nn, k = map(int, stdin.readline().split())\nvalues = list(map(int, stdin.readline().split()))\n\nsze = max(values)\nused = [0 for i in range(sze + 1)]\nchallengers = [[] for i in range(n + 1)]\n\ni = 0\ncnt = 0\n \nfor i in range(n):\n if values[i] == k:\n cn... | [{"type": "stdin_stdout", "input": "4 1\n2 1 4 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 2\n2 2 4 5 3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 10\n1 2 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1 1\n2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 2\n2\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:
Alice and Bob got very bored during a long car trip so the... | [{"type": "stdin_stdout", "input": "4 1\n2 1 4 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 2\n2 2 4 5 3\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 10\n1 2 3\n", "output": "4\n", "metadata": {"func_name": null}}, {"type":... | livecodebench | deepcoder_500 | 500 |
Solve the following coding problem using the programming language python:
A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and a_{i} is the length of i-th segment. N... | [
"```python\nR=lambda:list(map(int,input().split()))\nn,x=R()\nprint('YES'if sum(R())+n-1==x else'NO')\n\n```"
] | [{"type": "stdin_stdout", "input": "2 4\n1 3\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "3 10\n3 3 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 10\n1 3\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1 10\n10\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 one-dimensional Japanese crossword can be represented as... | [{"type": "stdin_stdout", "input": "2 4\n1 3\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 10\n3 3 2\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 10\n1 3\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdi... | livecodebench | deepcoder_501 | 501 |
Solve the following coding problem using the programming language python:
You have unlimited number of coins with values $1, 2, \ldots, n$. You want to select some set of coins having the total value of $S$.
It is allowed to have multiple coins with the same value in the set. What is the minimum number of coins requ... | [
"```python\nn, m =list(map(int, input().split()))\nif m % n != 0:\n\tprint( m // n + 1)\nelse:\n\tprint(m // n)\n\n```"
] | [{"type": "stdin_stdout", "input": "5 11\n", "output": "3"}, {"type": "stdin_stdout", "input": "6 16\n", "output": "3"}, {"type": "stdin_stdout", "input": "14 28\n", "output": "2"}, {"type": "stdin_stdout", "input": "5 29\n", "output": "6"}, {"type": "stdin_stdout", "input": "10 24\n", "output": "3"}, {"type": "stdin_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 unlimited number of coins with values $1, 2, \ldo... | [{"type": "stdin_stdout", "input": "5 11\n", "output": "3", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 16\n", "output": "3", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "14 28\n", "output": "2", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 29... | livecodebench | deepcoder_502 | 502 |
Solve the following coding problem using the programming language python:
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s consi... | [
"```python\n\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\npossible=[0]*26\n\nfor i in input().strip():\n possible[ord(i)-97]+=1\n\n# make changes\ntemp=[]\nfor i in range(26):\n if possible[i]%2: temp.append(i)\nwhile len(temp)>1:\n possible[temp[0]]+=1\n possible[temp[-1]]-=1... | [{"type": "stdin_stdout", "input": "aabc\n", "output": "abba\n"}, {"type": "stdin_stdout", "input": "aabcd\n", "output": "abcba\n"}, {"type": "stdin_stdout", "input": "u\n", "output": "u\n"}, {"type": "stdin_stdout", "input": "ttttt\n", "output": "ttttt\n"}, {"type": "stdin_stdout", "input": "xxxvvvxxvv\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 string is called palindrome if it reads the same from le... | [{"type": "stdin_stdout", "input": "aabc\n", "output": "abba\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "aabcd\n", "output": "abcba\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "u\n", "output": "u\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "inp... | livecodebench | deepcoder_503 | 503 |
Solve the following coding problem using the programming language python:
A and B are preparing themselves for programming contests.
To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.
For each chess piece we know its we... | [
"```python\na = 0\nb = 0\nx = {'Q': 9, 'q':9, 'R':5, 'r':5, 'B':3, 'b':3, 'N':3, 'n':3, 'P': 1, 'p': 1}\nfor i in range(8):\n t = [i for i in input()]\n for i in t:\n if ord(i) >= 97 and i in x:\n a += x[i]\n elif i in x:\n b += x[i]\nif a == b:\n print(\"Draw\")\nelif a... | [{"type": "stdin_stdout", "input": "...QK...\n........\n........\n........\n........\n........\n........\n...rk...\n", "output": "White\n"}, {"type": "stdin_stdout", "input": "rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR\n", "output": "Draw\n"}, {"type": "stdin_stdout", "input": "rpppp... | 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 and B are preparing themselves for programming contests.... | [{"type": "stdin_stdout", "input": "...QK...\n........\n........\n........\n........\n........\n........\n...rk...\n", "output": "White\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR\n", "output": "Draw\n", "metadat... | livecodebench | deepcoder_504 | 504 |
Solve the following coding problem using the programming language python:
Jumbo Takahashi will play golf on an infinite two-dimensional grid.
The ball is initially at the origin (0, 0), and the goal is a grid point (a point with integer coordinates) (X, Y). In one stroke, Jumbo Takahashi can perform the following oper... | [
"```python\nk = int(input())\nx, y = list(map(int, input().split()))\nans = []\nif k % 2 == 0:\n if (x + y) % 2 == 1:\n print((-1))\n return\nx_reverse = False\ny_reverse = False\nif x < 0:\n x *= -1\n x_reverse = True\nif y < 0:\n y *= -1\n y_reverse = True\n\n\ndef app(a, b):\n non... | [{"type": "stdin_stdout", "input": "11\n-1 2\n", "output": "3\n7 4\n2 10\n-1 2\n"}, {"type": "stdin_stdout", "input": "4600\n52 149\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4\n9 9\n", "output": "5\n1 3\n4 2\n4 6\n6 8\n9 9\n"}, {"type": "stdin_stdout", "input": "9943\n-97653 -1777\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:
Jumbo Takahashi will play golf on an infinite two-dimensio... | [{"type": "stdin_stdout", "input": "11\n-1 2\n", "output": "3\n7 4\n2 10\n-1 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4600\n52 149\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n9 9\n", "output": "5\n1 3\n4 2\n4 6\n6 8\n9 9\n", "metadata":... | livecodebench | deepcoder_505 | 505 |
Solve the following coding problem using the programming language python:
Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible!
Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for... | [
"```python\nn = int(input())\nl, r = 0, 10**16\nD = [x ** 3.0 for x in range(2, 170417)]\nDD = [x*x*x for x in range(2, 170417)]\nwhile l < r:\n m = (l+r) // 2\n if sum(int(m/d) for d in D) < n:\n l = m + 1\n else:\n r = m;\nif sum(l//d for d in DD) == n:\n print(l);\nelse :\n print((-1... | [{"type": "stdin_stdout", "input": "1\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "8\n", "output": "54\n"}, {"type": "stdin_stdout", "input": "10\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "27\n", "output": "152\n"}, {"type": "stdin_stdout", "input": "28206\n", "output": "139840\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:
Bad news came to Mike's village, some thieves stole a bunc... | [{"type": "stdin_stdout", "input": "1\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8\n", "output": "54\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "27\n"... | livecodebench | deepcoder_506 | 506 |
Solve the following coding problem using the programming language python:
You are given two circles. Find the area of their intersection.
-----Input-----
The first line contains three integers x_1, y_1, r_1 ( - 10^9 ≤ x_1, y_1 ≤ 10^9, 1 ≤ r_1 ≤ 10^9) — the position of the center and the radius of the first circle.
... | [
"```python\n#!/usr/bin/env python3\n# 600D_circles.py - Codeforces.com/problemset/problem/600/D by Sergey 2015\n\nimport unittest\nimport sys\nimport math\nimport decimal\n\n###############################################################################\n# Circles Class (Main Program)\n#############################... | [{"type": "stdin_stdout", "input": "0 0 4\n6 0 4\n", "output": "7.25298806364175601379\n"}, {"type": "stdin_stdout", "input": "0 0 5\n11 0 5\n", "output": "0.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "0 0 10\n9 0 1\n", "output": "3.14159265358979311600\n"}, {"type": "stdin_stdout", "input": "0 0 2\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:
You are given two circles. Find the area of their intersec... | [{"type": "stdin_stdout", "input": "0 0 4\n6 0 4\n", "output": "7.25298806364175601379\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "0 0 5\n11 0 5\n", "output": "0.00000000000000000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "0 0 10\n9 0 1\n", "output": "3.1415... | livecodebench | deepcoder_507 | 507 |
Solve the following coding problem using the programming language python:
Chouti was doing a competitive programming competition. However, after having all the problems accepted, he got bored and decided to invent some small games.
He came up with the following game. The player has a positive integer $n$. Initially t... | [
"```python\nn=int(input())\nif n==2:\n print(2)\nelse:\n print(1)\n```"
] | [{"type": "stdin_stdout", "input": "8\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "158260522\n", "output": "1\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:
Chouti was doing a competitive programming competition. Ho... | [{"type": "stdin_stdout", "input": "8\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n", "o... | livecodebench | deepcoder_508 | 508 |
Solve the following coding problem using the programming language python:
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1... | [
"```python\nfrom collections import deque\n\nn = int(input())\np = list(map(int,input().split()))\na = list(map(int,input().split()))\nedge = [[] for i in range(n)]\nfor i in range(n-1):\n edge[p[i]-1].append(i+1)\n\n\ndp = [0 for i in range(n)]\nsize = [not edge[v] for v in range(n)]\n\nres = []\ndeq = deque([0... | [{"type": "stdin_stdout", "input": "3\n1 1\n3 1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1 1\n3 1 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3\n1 1\n2 0 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n1\n487981126 805590708\n", "output": "1293571834\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:
Bandits appeared in the city! One of them is trying to cat... | [{"type": "stdin_stdout", "input": "3\n1 1\n3 1 2\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n1 1\n3 1 3\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n1 1\n2 0 0\n", "output": "1\n", "metadata": {"func_name": null}}, {"type"... | livecodebench | deepcoder_509 | 509 |
Solve the following coding problem using the programming language python:
Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.
P... | [
"```python\ndef check(w, s):\n j = 0\n for i in range(len(s)):\n while j < len(w) and s[i] != w[j]:\n j += 1\n if j >= len(w) or s[i] != w[j]:\n return False\n j += 1\n return True\n\nn = int(input())\ns = input()\nt = input()\nst = []\ni = 0\nwhile i < n and s[i]... | [{"type": "stdin_stdout", "input": "7\nreading\ntrading\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\nsweet\nsheep\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\ntoy\ntry\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\nspare\nspars\n", "output": "2\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:
Analyzing the mistakes people make while typing search que... | [{"type": "stdin_stdout", "input": "7\nreading\ntrading\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\nsweet\nsheep\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\ntoy\ntry\n", "output": "2\n", "metadata": {"func_name": null}}, {... | livecodebench | deepcoder_510 | 510 |
Solve the following coding problem using the programming language python:
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. [Image]
There ar... | [
"```python\ndef sol():\n\n n = int(input())\n st = list(map(int, input().split(' ')))\n d = {}\n for x in range(n):\n d[x] = []\n\n st = [(st[i], i) for i in range(len(st))]\n st = sorted(st)\n\n for a0 in range(n - 1):\n u, v = map(int, input().split(' '))\n u, v = u - 1, ... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n", "output": "5"}, {"type": "stdin_stdout", "input": "7\n38 -29 87 93 39 28 -55\n1 2\n2 5\n3 2\n2 4\n1 7\n7 6\n", "output": "93"}, {"type": "stdin_stdout", "input": "5\n1 2 7 6 7\n1 5\n5 3\n3 4\n2 4\n", "output": "8"}, {"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:
Although Inzane successfully found his beloved bone, Zane,... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n", "output": "5", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "7\n38 -29 87 93 39 28 -55\n1 2\n2 5\n3 2\n2 4\n1 7\n7 6\n", "output": "93", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 2 7 6 7\n1 5\... | livecodebench | deepcoder_511 | 511 |
Solve the following coding problem using the programming language python:
The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...
What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $n$ cats are at... | [
"```python\nn, m = map(int, input().split())\nif m <= 1:\n print(1)\n return\nprint(min(m, n - m))\n```"
] | [{"type": "stdin_stdout", "input": "7 4\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "9 1\n", "output": "1\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:
The three friends, Kuro, Shiro, and Katie, met up again! I... | [{"type": "stdin_stdout", "input": "7 4\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 0\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 ... | livecodebench | deepcoder_512 | 512 |
Solve the following coding problem using the programming language python:
Hongcow likes solving puzzles.
One day, Hongcow finds two identical puzzle pieces, with the instructions "make a rectangle" next to them. The pieces can be described by an n by m grid of characters, where the character 'X' denotes a part of the... | [
"```python\n#!/usr/bin/env python3\n\ndef main():\n import re\n\n n, m = list(map(int, input().split()))\n left = right = -1\n for i in range(n):\n mt = re.search(r\"X+\", input())\n if mt is not None:\n t = mt.start()\n if t != left != -1:\n print(\"NO... | [{"type": "stdin_stdout", "input": "2 3\nXXX\nXXX\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 2\n.X\nXX\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5 5\n.....\n..X..\n.....\n.....\n.....\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1 500\n.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... | 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:
Hongcow likes solving puzzles.
One day, Hongcow finds two... | [{"type": "stdin_stdout", "input": "2 3\nXXX\nXXX\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2\n.X\nXX\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 5\n.....\n..X..\n.....\n.....\n.....\n", "output": "YES\n", "metadata": {... | livecodebench | deepcoder_513 | 513 |
Solve the following coding problem using the programming language python:
There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to... | [
"```python\na, b = list(map(int, input().split(' ')))\nc, d = list(map(int, input().split(' ')))\ne, f = list(map(int, input().split(' ')))\nx=[[a, b],[c,d],[e,f]]\nx.sort()\na, b, c, d, e, f = x[0][0], x[0][1], x[1][0], x[1][1], x[2][0], x[2][1]\nif (a==c==e or b==d==f):\n print(1)\n quit()\n\nif a == c:\n ... | [{"type": "stdin_stdout", "input": "1 -1\n1 1\n1 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "-1 -1\n-1 3\n4 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 1\n2 3\n3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000... | 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 three points marked on the coordinate plane. The... | [{"type": "stdin_stdout", "input": "1 -1\n1 1\n1 2\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "-1 -1\n-1 3\n4 3\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n2 3\n3 2\n", "output": "3\n", "metadata": {"func_name": null}}, {"t... | livecodebench | deepcoder_514 | 514 |
Solve the following coding problem using the programming language python:
An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components.
Build a connected undirected ... | [
"```python\nimport math,string,itertools,fractions,heapq,collections,re,array,bisect\nfrom itertools import chain, dropwhile, permutations, combinations\nfrom collections import defaultdict, deque\n\ndef VI(): return list(map(int,input().split()))\n\ndef main1(k):\n # works correctly, but too slow and generates ... | [{"type": "stdin_stdout", "input": "1\n", "output": "YES\n2 1\n1 2\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "YES\n10 15\n1 6\n1 2\n1 3\n2 4\n2 5\n3 4\n3 5\n4 5\n6 7\n6 8\n7 9\n7 10\n8 9\n8 10\n9 10\n"}, {"type": "stdin_stdout", "input": "10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "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:
An undirected graph is called k-regular, if the degrees of... | [{"type": "stdin_stdout", "input": "1\n", "output": "YES\n2 1\n1 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n", "output": "YES\n10 15\n1 6\n1 2\n1 3\n2 4\n2 5\n3 4\n3 5\n4 5\n6 7\n6 8\n7 9\n7 10\n8 9\n8 10\n9 10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1... | livecodebench | deepcoder_515 | 515 |
Solve the following coding problem using the programming language python:
You are given two strings $s$ and $t$, both consisting only of lowercase Latin letters.
The substring $s[l..r]$ is the string which is obtained by taking characters $s_l, s_{l + 1}, \dots, s_r$ without changing the order.
Each of the occurrenc... | [
"```python\n# \nimport collections, atexit, math, sys, bisect \n\nsys.setrecursionlimit(1000000)\ndef getIntList():\n return list(map(int, input().split())) \n\ntry :\n #raise ModuleNotFoundError\n import numpy\n def dprint(*args, **kwargs):\n print(*args, **kwargs, file=sys.stderr)\n ... | [{"type": "stdin_stdout", "input": "10 3 4\ncodeforces\nfor\n1 3\n3 10\n5 6\n5 7\n", "output": "0\n1\n0\n1\n"}, {"type": "stdin_stdout", "input": "15 2 3\nabacabadabacaba\nba\n1 15\n3 4\n2 14\n", "output": "4\n0\n3\n"}, {"type": "stdin_stdout", "input": "3 5 2\naaa\nbaaab\n1 3\n1 1\n", "output": "0\n0\n"}, {"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:
You are given two strings $s$ and $t$, both consisting onl... | [{"type": "stdin_stdout", "input": "10 3 4\ncodeforces\nfor\n1 3\n3 10\n5 6\n5 7\n", "output": "0\n1\n0\n1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "15 2 3\nabacabadabacaba\nba\n1 15\n3 4\n2 14\n", "output": "4\n0\n3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": ... | livecodebench | deepcoder_516 | 516 |
Solve the following coding problem using the programming language python:
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children... | [
"```python\nans = {}\n\ndef gen(n, k, d, used = False):\n if not ans.get((n, k, d, used)):\n if not n and used:\n ans[(n, k, d, used)] = 1\n else:\n ans[(n, k, d, used)] = sum(gen(n - x, k, d, used or x >= d) for x in range(1, min(n, k) + 1) if max(x, n - x) >= d or used)\n ... | [{"type": "stdin_stdout", "input": "3 3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3 3 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4 3 2\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "4 5 2\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "28 6 3\n", "output": "110682188\... | 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:
Quite recently a creative student Lesha had a lecture on t... | [{"type": "stdin_stdout", "input": "3 3 2\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3 3\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 3 2\n", "output": "6\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input... | livecodebench | deepcoder_517 | 517 |
Solve the following coding problem using the programming language python:
Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, en... | [
"```python\n# You lost the game.\n\nn = int(input())\ns = str(input())\n\nR = []\nb = 0\nfor i in range(n):\n if s[i] == \"B\":\n b += 1\n elif b > 0:\n R += [b]\n b = 0\nif b > 0:\n R += [b]\nprint(len(R))\nfor i in range(len(R)):\n print(R[i],end=\" \")\n\n```"
] | [{"type": "stdin_stdout", "input": "3\nBBW\n", "output": "1\n2 "}, {"type": "stdin_stdout", "input": "5\nBWBWB\n", "output": "3\n1 1 1 "}, {"type": "stdin_stdout", "input": "4\nWWWW\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\nBBBB\n", "output": "1\n4 "}, {"type": "stdin_stdout", "input": "13\nWBBBBWWBWB... | 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 Adaltik discovered japanese crosswords. Japanese ... | [{"type": "stdin_stdout", "input": "3\nBBW\n", "output": "1\n2 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\nBWBWB\n", "output": "3\n1 1 1 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\nWWWW\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_s... | livecodebench | deepcoder_518 | 518 |
Solve the following coding problem using the programming language python:
Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS).
Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-... | [
"```python\nn, m, p = [int(x) for x in input().split()]\nA = input().rstrip()\nB = input().rstrip()\n\npair = [0] * n\nstack = []\nfor (i, c) in enumerate(A):\n if c == '(':\n stack.append(i)\n else:\n j = stack.pop()\n pair[i] = j\n pair[j] = i\n\nstart = 0\npointer = p - 1\nleft ... | [{"type": "stdin_stdout", "input": "8 4 5\n(())()()\nRDLD\n", "output": "()\n"}, {"type": "stdin_stdout", "input": "12 5 3\n((()())(()))\nRRDLD\n", "output": "(()(()))\n"}, {"type": "stdin_stdout", "input": "8 8 8\n(())()()\nLLLLLLDD\n", "output": "()()\n"}, {"type": "stdin_stdout", "input": "4 2 2\n()()\nLD\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:
Recently Polycarp started to develop a text editor that wo... | [{"type": "stdin_stdout", "input": "8 4 5\n(())()()\nRDLD\n", "output": "()\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "12 5 3\n((()())(()))\nRRDLD\n", "output": "(()(()))\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 8 8\n(())()()\nLLLLLLDD\n", "output": "()()\... | livecodebench | deepcoder_519 | 519 |
Solve the following coding problem using the programming language python:
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. Th... | [
"```python\n\"\"\"\nCodeforces Round 241 Div 1 Problem A\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\nclass InputHandlerObject(object):\n inputs = []\n\n def getInput(self, n = 0):\n res = \"\"\n inputs = self.inputs\n if not inputs: inputs.extend(input().split(\" \"))\n ... | [{"type": "stdin_stdout", "input": "4\n>= 1 Y\n< 3 N\n<= -3 N\n> 55 N\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "2\n> 100 Y\n< -100 Y\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "4\n< 1 N\n> 1 N\n> 1 N\n> 1 N\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4\n<= 1 Y\n>= 1 Y\... | 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 TV show called "Guess a number!" is gathering popularity... | [{"type": "stdin_stdout", "input": "4\n>= 1 Y\n< 3 N\n<= -3 N\n> 55 N\n", "output": "17\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n> 100 Y\n< -100 Y\n", "output": "Impossible\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n< 1 N\n> 1 N\n> 1 N\n> 1 N\n", "outp... | livecodebench | deepcoder_520 | 520 |
Solve the following coding problem using the programming language python:
You are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'.
The period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$ won't always divide $a+b ... | [
"```python\nimport math\na,b= list(map(int,input().split()))\nn=a+b\nans,l=0,1\nwhile l<=n:\n g= n//l\n if a<g or b<g:\n l= (n//g) +1\n continue\n r= n//g\n a_low = (a+g)//(g+1)\n a_high = a//g\n b_low=(b+g)//(g+1)\n b_high = b//g\n if (a_low <= a_high and b_low <= b_high):\n ... | [{"type": "stdin_stdout", "input": "2 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5 3\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "2\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:
You are given $a$ uppercase Latin letters 'A' and $b$ lett... | [{"type": "stdin_stdout", "input": "2 4\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 3\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 ... | livecodebench | deepcoder_521 | 521 |
Solve the following coding problem using the programming language python:
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there a... | [
"```python\nn, k = list(map(int, input().split()))\na = input().split()\nnames = [chr(ord(\"A\") + i) for i in range(26)] + [chr(ord(\"A\") + i) + chr(ord('a') + i) for i in range(26)]\nans = [names[i] for i in range(n)]\nfor i in range(k - 1, n):\n\tif a[i - k + 1] == \"NO\":\n\t\tans[i] = ans[i - k + 1]\nprint(*a... | [{"type": "stdin_stdout", "input": "8 3\nNO NO YES YES YES NO\n", "output": "Ab Ac Ab Ac Af Ag Ah Ag \n"}, {"type": "stdin_stdout", "input": "9 8\nYES NO\n", "output": "Ab Ac Ad Ae Af Ag Ah Ai Ac \n"}, {"type": "stdin_stdout", "input": "3 2\nNO NO\n", "output": "Ab Ab Ab \n"}, {"type": "stdin_stdout", "input": "2 2\nYE... | 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 the army, it isn't easy to form a group of soldiers tha... | [{"type": "stdin_stdout", "input": "8 3\nNO NO YES YES YES NO\n", "output": "Ab Ac Ab Ac Af Ag Ah Ag \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9 8\nYES NO\n", "output": "Ab Ac Ad Ae Af Ag Ah Ai Ac \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2\nNO NO\n", "o... | livecodebench | deepcoder_522 | 522 |
Solve the following coding problem using the programming language python:
Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Litt... | [
"```python\na,b=list(map(int,input().split()))\ndef gcd(a,b):\n if(b==0):\n return a\n return gcd(b,a%b)\ndef burn(n):\n c=0\n while(n%2==0):\n c+=1\n n=n//2\n while(n%3==0):\n c+=1\n n=n//3\n while(n%5==0):\n c+=1\n n=n//5\n return [c,n]\nif(a==... | [{"type": "stdin_stdout", "input": "15 20\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "14 8\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "6 6\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1024\n", "output": "10\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:
Two little greedy bears have found two pieces of cheese in... | [{"type": "stdin_stdout", "input": "15 20\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "14 8\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 6\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input":... | livecodebench | deepcoder_523 | 523 |
Solve the following coding problem using the programming language python:
A group of $n$ dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of the... | [
"```python\n# import sys\n# sys.stdin = open(\"F:\\\\Scripts\\\\input\",\"r\")\n# sys.stdout = open(\"F:\\\\Scripts\\\\output\",\"w\")\n\n\nMOD = 10**9 + 7\nI = lambda:list(map(int,input().split()))\n\nn , a , b = I()\nl = I()\ncost = 0\nm = min(a,b)\nfor i in range(n//2):\n\tif l[i] + l[n-i-1] == 1:\n\t\tprint(-1)... | [{"type": "stdin_stdout", "input": "5 100 1\n0 1 2 1 2\n", "output": "101\n"}, {"type": "stdin_stdout", "input": "3 10 12\n1 2 0\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 12 1\n0 1 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 1 9\n1 2 1 0 1 0 1 0 0 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:
A group of $n$ dancers rehearses a performance for the clo... | [{"type": "stdin_stdout", "input": "5 100 1\n0 1 2 1 2\n", "output": "101\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 10 12\n1 2 0\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 12 1\n0 1 0\n", "output": "0\n", "metadata": {"func_name": null}}... | livecodebench | deepcoder_524 | 524 |
Solve the following coding problem using the programming language python:
You are given a cube of size k × k × k, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.
Your task is to paint each of k^3 unit cubes one of two colours (black or white), so that the following ... | [
"```python\nK = int(input())\nprint((\"-1\" if K & 1 else \"\".join([\"wb\\n\"[2 if k == K else (min(j, k, K - 1 - j,\n K - 1 - k) ^ i) & 1] for i in range(2) for j in range(K) for k in range(K +\n 1)]) * (K >> 1)))\n\n```"
] | [{"type": "stdin_stdout", "input": "1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "bb\nww\n\nbb\nww\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "bbbb\nbwwb\nbwwb\nbbbb\n\nwwww\nwbbw\nwbbw\nwwww\n\nbbbb\nbwwb\nbwwb\nbbb... | 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 cube of size k × k × k, which consists of ... | [{"type": "stdin_stdout", "input": "1\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "output": "bb\nww\n\nbb\nww\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "... | livecodebench | deepcoder_525 | 525 |
Solve the following coding problem using the programming language python:
Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a^2 is a divisor of x. [Image]
Malek has a number store! In his store, he has only divisors of positive... | [
"```python\nn = int(input())\nans = 1\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n //= i\n i += 1\nans *= n\nprint(ans)\n```"
] | [{"type": "stdin_stdout", "input": "10\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "12\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\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:
Duff is in love with lovely numbers! A positive integer x ... | [{"type": "stdin_stdout", "input": "10\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "12\n", "output": "6\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_526 | 526 |
Solve the following coding problem using the programming language python:
Bajtek, known for his unusual gifts, recently got an integer array $x_0, x_1, \ldots, x_{k-1}$.
Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy,... | [
"```python\nn = int(input())\na = list(map(int, input().split()))\nans = []\n\nfor k in range(1, n + 1):\n x = [0] * k\n\n x[0] = a[0]\n for i in range(1, k):\n x[i] = a[i] - a[i - 1]\n\n ok = True\n for i in range(k, n):\n if x[i % k] != a[i] - a[i - 1]:\n ok = False\n ... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "5\n1 2 3 4 5 "}, {"type": "stdin_stdout", "input": "5\n1 3 5 6 8\n", "output": "2\n3 5 "}, {"type": "stdin_stdout", "input": "3\n1 5 3\n", "output": "1\n3 "}, {"type": "stdin_stdout", "input": "1\n5\n", "output": "1\n1 "}, {"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:
Bajtek, known for his unusual gifts, recently got an integ... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "5\n1 2 3 4 5 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 3 5 6 8\n", "output": "2\n3 5 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n1 5 3\n", "output": "1\n3 ", "metadata": {"func_name": null}}... | livecodebench | deepcoder_527 | 527 |
Solve the following coding problem using the programming language python:
A positive integer is called a 2-3-integer, if it is equal to 2^{x}·3^{y} for some non-negative integers x and y. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, ... | [
"```python\na,b=map(int,input().split())\nans=0\nfor i in range(0,40):\n for j in range(0,40):\n if (2**i)*(3**j)>=a and (2**i)*(3**j)<=b:\n ans+=1\nprint(ans)\n```"
] | [{"type": "stdin_stdout", "input": "1 10\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "100 200\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1 2000000000\n", "output": "326\n"}, {"type": "stdin_stdout", "input": "1088391168 1934917632\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "10883... | 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 positive integer is called a 2-3-integer, if it is equal... | [{"type": "stdin_stdout", "input": "1 10\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100 200\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 2000000000\n", "output": "326\n", "metadata": {"func_name": null}}, {"type": "stdin_stdou... | livecodebench | deepcoder_528 | 528 |
Solve the following coding problem using the programming language python:
Each evening after the dinner the SIS's students gather together to play the game of Sport Mafia.
For the tournament, Alya puts candies into the box, which will serve as a prize for a winner. To do that, she performs $n$ actions. The first act... | [
"```python\nn,k=map(int,input().split())\nlow=1\nhigh=n\nimport sys\nwhile low<=high:\n mid=(low+high)//2\n if mid*(mid+1)//2 -(n-mid)>k:\n high=mid-1\n elif mid*(mid+1)//2-(n-mid)==k:\n print(n-mid)\n return\n else :\n low=mid+1\n```"
] | [{"type": "stdin_stdout", "input": "1 1\n", "output": "0"}, {"type": "stdin_stdout", "input": "9 11\n", "output": "4"}, {"type": "stdin_stdout", "input": "5 0\n", "output": "3"}, {"type": "stdin_stdout", "input": "3 2\n", "output": "1"}, {"type": "stdin_stdout", "input": "4 1\n", "output": "2"}, {"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:
Each evening after the dinner the SIS's students gather to... | [{"type": "stdin_stdout", "input": "1 1\n", "output": "0", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9 11\n", "output": "4", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 0\n", "output": "3", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2\n",... | livecodebench | deepcoder_529 | 529 |
Solve the following coding problem using the programming language python:
Imp likes his plush toy a lot.
[Image]
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machin... | [
"```python\nx, y = map(int, input().split())\n\nif y == 0:\n\tprint('No')\n\treturn\nelse:\n\ty -= 1\n\nif y == 0 and x:\n\tprint('No')\n\treturn\n\nif y > x or (x - y) & 1:\n\tprint('No')\nelse:\n\tprint('Yes')\n```"
] | [{"type": "stdin_stdout", "input": "6 3\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4 2\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "1000 1001\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1000000000 999999999\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "81452244 8... | 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 likes his plush toy a lot.
[Image]
Recently, he fo... | [{"type": "stdin_stdout", "input": "6 3\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 2\n", "output": "No\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1000 1001\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "... | livecodebench | deepcoder_530 | 530 |
Solve the following coding problem using the programming language python:
Petya loves computer games. Finally a game that he's been waiting for so long came out!
The main character of this game has n different skills, each of which is characterized by an integer a_{i} from 0 to 100. The higher the number a_{i} is, th... | [
"```python\nimport sys\n\ndef solve():\n n,k, = rv()\n a, = rl(1)\n res = 0\n count = [0] * 10\n for i in range(n):\n if a[i] < 100:\n count[10 - (a[i] % 10) - 1] += 1\n res += a[i] // 10\n for i in range(10):\n while count[i] > 0 and k >= i + 1:\n res +=... | [{"type": "stdin_stdout", "input": "2 4\n7 9\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 8\n17 15 19\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "2 2\n99 100\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "100 10000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | 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 loves computer games. Finally a game that he's been ... | [{"type": "stdin_stdout", "input": "2 4\n7 9\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 8\n17 15 19\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2\n99 100\n", "output": "20\n", "metadata": {"func_name": null}}, {"type": "std... | livecodebench | deepcoder_531 | 531 |
Solve the following coding problem using the programming language python:
На тренировку по подготовке к соревнованиям по программированию пришли n команд. Тренер для каждой команды подобрал тренировку, комплект задач для i-й команды занимает a_{i} страниц. В распоряжении тренера есть x листов бумаги, у которых обе сто... | [
"```python\nimport sys,math\nn,x,y=list(map(int,input().split()))\nz=list(map(int,input().split()))\nz.sort()\nans=0\nfor i in range(n):\n if z[i]%2==0:\n if x>=z[i]//2:\n x-=z[i]//2\n ans+=1\n else:\n z[i]-=x*2\n x=0\n y-=z[i]\n if ... | [{"type": "stdin_stdout", "input": "2 3 5\n4 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 3 5\n4 7\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6 3 5\n12 11 12 11 12 11\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 4 3\n12\n", "output": "0\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:
На тренировку по подготовке к соревнованиям по программиро... | [{"type": "stdin_stdout", "input": "2 3 5\n4 6\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 3 5\n4 7\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 3 5\n12 11 12 11 12 11\n", "output": "1\n", "metadata": {"func_name": null}}, {"... | livecodebench | deepcoder_532 | 532 |
Solve the following coding problem using the programming language python:
Ivan has number $b$. He is sorting through the numbers $a$ from $1$ to $10^{18}$, and for every $a$ writes $\frac{[a, \,\, b]}{a}$ on blackboard. Here $[a, \,\, b]$ stands for least common multiple of $a$ and $b$. Ivan is very lazy, that's why t... | [
"```python\n#JMD\n#Nagendra Jha-4096\n\n \nimport sys\nimport math\n\n#import fractions\n#import numpy\n \n###File Operations###\nfileoperation=0\nif(fileoperation):\n orig_stdout = sys.stdout\n orig_stdin = sys.stdin\n inputfile = open('W:/Competitive Programming/input.txt', 'r')\n outputfile = open('W... | [{"type": "stdin_stdout", "input": "1\n", "output": "1"}, {"type": "stdin_stdout", "input": "2\n", "output": "2"}, {"type": "stdin_stdout", "input": "16\n", "output": "5"}, {"type": "stdin_stdout", "input": "433494437\n", "output": "2"}, {"type": "stdin_stdout", "input": "10000000000\n", "output": "121"}, {"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:
Ivan has number $b$. He is sorting through the numbers $a$... | [{"type": "stdin_stdout", "input": "1\n", "output": "1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "output": "2", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "16\n", "output": "5", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "433494437\n",... | livecodebench | deepcoder_533 | 533 |
Solve the following coding problem using the programming language python:
In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by... | [
"```python\nn = int(input())\ns = input()\nl = 0\nans = 0\nwhile l < len(s) and s[l] == '<':\n ans += 1\n l += 1\n\nr = n - 1\nwhile r >= 0 and s[r] == '>':\n ans += 1\n r -= 1\n\nprint(ans)\n\n```"
] | [{"type": "stdin_stdout", "input": "4\n<<><\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n>>>>>\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "4\n>><<\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n<<>\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n<<<\n", "output": "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 new version of the famous Pinball game, one of the mo... | [{"type": "stdin_stdout", "input": "4\n<<><\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n>>>>>\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n>><<\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout",... | livecodebench | deepcoder_534 | 534 |
Solve the following coding problem using the programming language python:
In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length l_{i}.
Ilya decided to make a rectangle from the stic... | [
"```python\narr = [0] * (10 ** 6 + 1)\nn = int(input())\nfor i in input().split():\n arr[int(i)] += 1\ni = 10 ** 6\nj = i\nk = i\nc = 0\nwhile j > 0:\n if arr[j] % 2 == 1 and (arr[j] > 1 or c == 0):\n arr[j - 1] += 1\n c = 1\n else:\n c = 0\n j -= 1\nr = 0\nwhile i > 0 and k > 0:\n ... | [{"type": "stdin_stdout", "input": "4\n2 4 4 2\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\n2 2 3 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n100003 100004 100005 100006\n", "output": "10000800015\n"}, {"type": "stdin_stdout", "input": "8\n5 3 3 3 3 4 4 4\n", "output": "25\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:
In the evening, after the contest Ilya was bored, and he r... | [{"type": "stdin_stdout", "input": "4\n2 4 4 2\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n2 2 3 5\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n100003 100004 100005 100006\n", "output": "10000800015\n", "metadata": {"func_n... | livecodebench | deepcoder_535 | 535 |
Solve the following coding problem using the programming language python:
Petya has n positive integers a_1, a_2, ..., a_{n}.
His friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replaced all digits 0 with ... | [
"```python\n'''input\n3\naa\njj\naa\n'''\n\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())\nd = {}\npos = {}\nfor _ in range(n):\n\ts = list(input())\n\ts = s[::-1]\n\tfor i in ra... | [{"type": "stdin_stdout", "input": "3\nab\nde\naj\n", "output": "47\n"}, {"type": "stdin_stdout", "input": "5\nabcdef\nghij\nbdef\naccbd\ng\n", "output": "136542\n"}, {"type": "stdin_stdout", "input": "3\naa\njj\naa\n", "output": "44\n"}, {"type": "stdin_stdout", "input": "9\na\nb\nc\nd\nf\ng\nh\ni\nj\n", "output": "45... | 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 has n positive integers a_1, a_2, ..., a_{n}.
His ... | [{"type": "stdin_stdout", "input": "3\nab\nde\naj\n", "output": "47\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\nabcdef\nghij\nbdef\naccbd\ng\n", "output": "136542\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\naa\njj\naa\n", "output": "44\n", "metadata": {"fu... | livecodebench | deepcoder_536 | 536 |
Solve the following coding problem using the programming language python:
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.
Soon, monsters became hungry and began to eat each other.
One monster can eat ot... | [
"```python\nimport sys\n\na = [0,]\nb = [0,]\nans1 = []\nans2 = []\nn = int(input())\ns = input()\nnums = s.split()\nfor i in range(0, n):\n a.append(int(nums[i]))\n\nk = int(input())\ns = input()\nnums = s.split()\nfor i in range(0, k):\n b.append(int(nums[i]))\n\ndef f(x, y, z):\n #print(x,y,z)\n pos1... | [{"type": "stdin_stdout", "input": "6\n1 2 2 2 1 2\n2\n5 5\n", "output": "YES\n2 L\n1 R\n4 L\n3 L\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n1\n15\n", "output": "YES\n5 L\n4 L\n3 L\n2 L\n"}, {"type": "stdin_stdout", "input": "5\n1 1 1 3 3\n3\n2 1 6\n", "output": "NO"}, {"type": "stdin_stdout", "input": "5\n1... | 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 was an epidemic in Monstropolis and all monsters bec... | [{"type": "stdin_stdout", "input": "6\n1 2 2 2 1 2\n2\n5 5\n", "output": "YES\n2 L\n1 R\n4 L\n3 L\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n1\n15\n", "output": "YES\n5 L\n4 L\n3 L\n2 L\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 1 1 3 3\n3\n... | livecodebench | deepcoder_537 | 537 |
Solve the following coding problem using the programming language python:
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly on... | [
"```python\na, b = list(map(int, input().split()))\nif a==b: print(\"Yes\")\nelse: print(\"No\")\n\n```"
] | [{"type": "stdin_stdout", "input": "3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "2 1\n1 0\n2 2\n3 1\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "1 1\n3686 4362\n-7485 5112\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 2\n1152 -7324\n-5137 -35\... | 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 Rebel fleet is afraid that the Empire might want to st... | [{"type": "stdin_stdout", "input": "3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1\n1 0\n2 2\n3 1\n", "output": "No\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n3686 4362\n-7485 5112\n", "output": "Yes\n... | livecodebench | deepcoder_538 | 538 |
Solve the following coding problem using the programming language python:
Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большую степень числа 2.
По заданной последовательности целых положительных чисел a_1, a_2, ..., a_{n} требуется на... | [
"```python\nn = int(input())\nl = list(map(int, input().split()))\nmax1 = 1\nfor i in l:\n k = 1\n x = i\n while x % 2 == 0:\n k *= 2\n x //= 2\n max1 = max(max1, k)\nc = 0\nfor i in l:\n if i % max1 == 0:\n c += 1\nprint(max1, c)\n```"
] | [{"type": "stdin_stdout", "input": "5\n80 7 16 4 48\n", "output": "16 3\n"}, {"type": "stdin_stdout", "input": "4\n21 5 3 33\n", "output": "1 4\n"}, {"type": "stdin_stdout", "input": "10\n8 112 52 86 93 102 24 24 100 826791168\n", "output": "256 1\n"}, {"type": "stdin_stdout", "input": "3\n458297759 18 104\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:
Поликарп мечтает стать программистом и фанатеет от степене... | [{"type": "stdin_stdout", "input": "5\n80 7 16 4 48\n", "output": "16 3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n21 5 3 33\n", "output": "1 4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10\n8 112 52 86 93 102 24 24 100 826791168\n", "output": "256 1\n", "m... | livecodebench | deepcoder_539 | 539 |
Solve the following coding problem using the programming language python:
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the... | [
"```python\ndef main():\n n, m = map(int, input().split())\n res, delta = 0, 1\n while n < m:\n res += 1\n n *= 2\n delta *= 2\n while n > m:\n while n - delta >= m:\n res += 1\n n -= delta\n delta //= 2\n print(res)\n\n\ndef __starting_point()... | [{"type": "stdin_stdout", "input": "4 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 1\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "1 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 3\n", "output": "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:
Vasya has found a strange device. On the front panel of a ... | [{"type": "stdin_stdout", "input": "4 6\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 1\n", "output": "9\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 2\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2... | livecodebench | deepcoder_540 | 540 |
Solve the following coding problem using the programming language python:
As the name of the task implies, you are asked to do some work with segments and trees.
Recall that a tree is a connected undirected graph such that there is exactly one simple path between every pair of its vertices.
You are given $n$ segment... | [
"```python\nimport sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\n\nclass BIT_RSQ():\n def __init__(self, n):\n self.n = n\n self.data = [0]*(n+2)\n\n def add(self, i, v):\n while i <= self.n:\n self.data[i] += v\n i += i & -i\n\n def sum(... | [{"type": "stdin_stdout", "input": "6\n9 12\n2 11\n1 3\n6 10\n5 7\n4 8\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n1 3\n2 4\n5 9\n6 8\n7 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n5 8\n3 6\n2 9\n7 10\n1 4\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1\n1 2\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:
As the name of the task implies, you are asked to do some ... | [{"type": "stdin_stdout", "input": "6\n9 12\n2 11\n1 3\n6 10\n5 7\n4 8\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 3\n2 4\n5 9\n6 8\n7 10\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n5 8\n3 6\n2 9\n7 10\n1 4\n", "outpu... | livecodebench | deepcoder_541 | 541 |
Solve the following coding problem using the programming language python:
We get more and more news about DDoS-attacks of popular websites.
Arseny is an admin and he thinks that a website is under a DDoS-attack if the total number of requests for a some period of time exceeds $100 \cdot t$, where $t$ — the number of ... | [
"```python\ndef prog():\n n = int(input())\n inp = list(map(int,input().split()))\n ans = 0\n for i in range(len(inp)):\n x,y = 0 ,0\n for j in range(i,len(inp)):\n x+=inp[j]\n y+=100\n if(x>y):\n ans = max(ans,(j-i)+1)\n print(ans)\nprog(... | [{"type": "stdin_stdout", "input": "5\n100 200 1 1 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n101 99\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n41\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n1 91\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:
We get more and more news about DDoS-attacks of popular we... | [{"type": "stdin_stdout", "input": "5\n100 200 1 1 1\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n101 99\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": ... | livecodebench | deepcoder_542 | 542 |
Solve the following coding problem using the programming language python:
Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he... | [
"```python\nimport sys\n\nn, k = list(map(int, input().split(' ')))\n\ns = input()\n\ndef max_streak(s):\n result = 0\n\n for i in range(len(s)):\n j = i\n while j < len(s) and s[j] == 'N':\n j += 1\n\n result = max(result, j - i)\n\n return result\n\nfor i in range(n - k + ... | [{"type": "stdin_stdout", "input": "5 2\nNYNNY\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "6 1\n????NN\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "100 8\nNYNNY?YNNNNNN?NNNNNYNY?YYNYNN?NNNY??NNYNYNNNYNNNYNNNNNNNNY?NNNYNYN?NNNY?YY?NNYNN?NNNYNNYNNYN?NNYNYNN\n", "output": "YES\n"}, {"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:
Well, the series which Stepan watched for a very long time... | [{"type": "stdin_stdout", "input": "5 2\nNYNNY\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 1\n????NN\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100 8\nNYNNY?YNNNNNN?NNNNNYNY?YYNYNN?NNNY??NNYNYNNNYNNNYNNNNNNNNY?NNNYNYN?NNNY... | livecodebench | deepcoder_543 | 543 |
Solve the following coding problem using the programming language python:
We have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \leq i < N ) holds.
Takahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.
Let S and T be the sum of... | [
"```python\ndef solve():\n N, X, D = list(map(int, input().split()))\n\n if D == 0:\n if X == 0:\n print((1))\n else:\n print((N+1))\n return\n\n LRss = {}\n for k in range(N+1):\n m = X*k\n rem = m%D\n minCoef = m//D + k*(k-1)//2\n ... | [{"type": "stdin_stdout", "input": "3 4 2\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "2 3 -3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "100 14 20\n", "output": "49805\n"}, {"type": "stdin_stdout", "input": "17 3 -4\n", "output": "494\n"}, {"type": "stdin_stdout", "input": "7 5 5\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:
We have an integer sequence A of length N, where A_1 = X, ... | [{"type": "stdin_stdout", "input": "3 4 2\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 3 -3\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100 14 20\n", "output": "49805\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout... | livecodebench | deepcoder_544 | 544 |
Solve the following coding problem using the programming language python:
Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his r... | [
"```python\nread = lambda: map(int, input().split())\nn = int(input())\nfor i in range(n):\n name, x, y = input().split()\n x, y = int(x), int(y)\n if x >= 2400 and y > x:\n print('YES')\n return\nprint('NO')\n```"
] | [{"type": "stdin_stdout", "input": "3\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749\n", "output": "YES"}, {"type": "stdin_stdout", "input": "3\nApplejack 2400 2400\nFluttershy 2390 2431\nPinkie_Pie -2500 -2450\n", "output": "NO"}, {"type": "stdin_stdout", "input": "1\nDb -3373 3591\n", "output": "NO"},... | 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:
Codeforces user' handle color depends on his rating — it i... | [{"type": "stdin_stdout", "input": "3\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749\n", "output": "YES", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\nApplejack 2400 2400\nFluttershy 2390 2431\nPinkie_Pie -2500 -2450\n", "output": "NO", "metadata": {"func_name": null}}, {"type... | livecodebench | deepcoder_545 | 545 |
Solve the following coding problem using the programming language python:
In the city of Saint Petersburg, a day lasts for $2^{100}$ minutes. From the main station of Saint Petersburg, a train departs after $1$ minute, $4$ minutes, $16$ minutes, and so on; in other words, the train departs at time $4^k$ for each integ... | [
"```python\ns = int(input(), 2)\n\nt, ans = 1, 0\n\nwhile t < s:\n\tans += 1\n\tt *= 4\n\nprint(ans)\n\n```"
] | [{"type": "stdin_stdout", "input": "100000000\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "101\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10100\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1111010010000101100100001110011101111\n", "output": "19\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:
In the city of Saint Petersburg, a day lasts for $2^{100}$... | [{"type": "stdin_stdout", "input": "100000000\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "101\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10100\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "inp... | livecodebench | deepcoder_546 | 546 |
Solve the following coding problem using the programming language python:
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties:
the upper half of matrix c (rows with numbers fro... | [
"```python\nn,m = [int(i) for i in input().split()]\nl = []\nfor i in range(n):\n l.append(input().strip())\nwhile len(l)%2 == 0:\n mirror = True\n for i in range(len(l)//2):\n if l[i] != l[len(l)-1-i]:\n mirror = False\n break\n if mirror:\n l = l[:len(l)//2]\n el... | [{"type": "stdin_stdout", "input": "4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 3\n0 0 0\n0 0 0\n0 0 0\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "8 1\n0\n1\n1\n0\n0\n1\n1\n0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 4\n0 0 1 0\n0 0 1 0\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:
Let's assume that we are given a matrix b of size x × y, l... | [{"type": "stdin_stdout", "input": "4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3\n0 0 0\n0 0 0\n0 0 0\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 1\n0\n1\n1\n0\n0\n1\n1\n0\n", "output": "2\n"... | livecodebench | deepcoder_547 | 547 |
Solve the following coding problem using the programming language python:
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} (l_{i} ≤ r_{i}).
Restau... | [
"```python\ndef key_tri(argument):\n return argument[1]\n\nn = int(input())\nL = [list(map(int, input().split())) for _ in range(n)]\nL.sort(key=key_tri)\nr = 1\nt = L[0][1]\nfor k in range(1,n):\n if L[k][0]>t:\n r+=1\n t = L[k][1]\nprint(r)\n\n```"
] | [{"type": "stdin_stdout", "input": "2\n7 11\n4 7\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n2 3\n3 4\n4 5\n5 6\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n4 8\n1 5\n4 7\n2 5\n1 3\n6 8\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n1 1\n", "output": "1\n"}, {"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:
A restaurant received n orders for the rental. Each rental... | [{"type": "stdin_stdout", "input": "2\n7 11\n4 7\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n1 2\n2 3\n3 4\n4 5\n5 6\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n4 8\n1 5\n4 7\n2 5\n1 3\n6 8\n", "output": "2\n", "metadata":... | livecodebench | deepcoder_548 | 548 |
Solve the following coding problem using the programming language python:
Vova has taken his summer practice this year and now he should write a report on how it went.
Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pa... | [
"```python\ndef max(a, b):\n\tif a > b:\n\t\treturn a\n\telse:\n\t\treturn b\nn, k = map(int, input().split())\nx = [int(t) for t in input().split()]\ny = [int(t) for t in input().split()]\nf, s = 0, 0\nfor i in range(n):\n f = max(0, x[i] + f - k * y[i])\n s = max(0, y[i] + s - k * x[i])\n if f > k or s >... | [{"type": "stdin_stdout", "input": "2 2\n5 5\n2 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 2\n5 6\n2 2\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4 1\n4 1 10 1\n3 2 10 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "53 3\n2 3 1 2 2 6 1 5 6 1 5 3 1 1 6 4 3 2 4 1 1 4 4 3 5 ... | 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:
Vova has taken his summer practice this year and now he sh... | [{"type": "stdin_stdout", "input": "2 2\n5 5\n2 2\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2\n5 6\n2 2\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 1\n4 1 10 1\n3 2 10 1\n", "output": "YES\n", "metadata": {"func_name": ... | livecodebench | deepcoder_549 | 549 |
Solve the following coding problem using the programming language python:
100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet.
... | [
"```python\np=1048583\nq=1048589\nmodd=p*q*p*q\nn,k=tuple(map(int,input().split()))\na=[0]\nwenhao=0\ngai=0\nfor i in range(n+1):\n m=input()\n if m[0]=='?':\n a.append('?')\n wenhao+=1\n else:\n a.append(int(m))\n gai+=1\n\nif k==0:\n if (a[1]=='?' and gai&1==1) or a[1]==0:\... | [{"type": "stdin_stdout", "input": "1 2\n-1\n?\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "2 100\n-10000\n0\n1\n", "output": "Yes"}, {"type": "stdin_stdout", "input": "4 5\n?\n1\n?\n1\n?\n", "output": "No"}, {"type": "stdin_stdout", "input": "68 -9959\n-3666\n-3501\n9169\n5724\n1478\n-643\n-3039\n-5537\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:
100 years have passed since the last victory of the man ve... | [{"type": "stdin_stdout", "input": "1 2\n-1\n?\n", "output": "Yes\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 100\n-10000\n0\n1\n", "output": "Yes", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 5\n?\n1\n?\n1\n?\n", "output": "No", "metadata": {"func_name": null}}... | livecodebench | deepcoder_550 | 550 |
Solve the following coding problem using the programming language python:
Alice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose... | [
"```python\nfrom math import floor, sqrt\nimport bisect\n\nimport math\n\n\ndef rwh_primes2(n):\n # https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188\n \"\"\" Input n>=6, Returns a list of primes, 2 <= p < n \"\"\"\n correction = (n%6>1)\n n = {... | [{"type": "stdin_stdout", "input": "14\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "20\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "8192\n", "output": "8191\n"}, {"type": "stdin_stdout", "input": "1000000\n", "output": "998677\n"}, {"type": "stdin_stdout", "input": "959806\n", "output": "239958... | 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 and Bob begin their day with a quick game. They firs... | [{"type": "stdin_stdout", "input": "14\n", "output": "6\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "20\n", "output": "15\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8192\n", "output": "8191\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": ... | livecodebench | deepcoder_551 | 551 |
Solve the following coding problem using the programming language python:
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binar... | [
"```python\nn, p = list(map(int, input().split()))\nfor q in range(5757):\n s = bin(n)\n if n >= q >= s.count('1'):\n print(q)\n break\n n -= p\nelse:\n print(-1)\n\n```"
] | [{"type": "stdin_stdout", "input": "24 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "24 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "24 -1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "4 -7\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "-1\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:
Vasya will fancy any number as long as it is an integer po... | [{"type": "stdin_stdout", "input": "24 0\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "24 1\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "24 -1\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input":... | livecodebench | deepcoder_552 | 552 |
Solve the following coding problem using the programming language python:
Ania has a large integer $S$. Its decimal representation has length $n$ and doesn't contain any leading zeroes. Ania is allowed to change at most $k$ digits of $S$. She wants to do it in such a way that $S$ still won't contain any leading zeroes... | [
"```python\nn, k = list(map(int, input().split()))\ns = list(input())\nif len(s) == 1 and k:\n\tprint(0)\n\treturn\nif s[0] != '1' and k:\n\tk -= 1\n\ts[0] = '1'\nfor i in range(1, len(s)):\n\tif s[i] != '0' and k:\n\t\ts[i] = '0'\n\t\tk -= 1\n\tif not k:\n\t\tbreak\nprint(''.join(s))\n\n\n```"
] | [{"type": "stdin_stdout", "input": "5 3\n51528\n", "output": "10028\n"}, {"type": "stdin_stdout", "input": "3 2\n102\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 3\n76185080\n", "output": "10085080\n"}, {"type": "stdin_stdout", "input": "10... | 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:
Ania has a large integer $S$. Its decimal representation h... | [{"type": "stdin_stdout", "input": "5 3\n51528\n", "output": "10028\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2\n102\n", "output": "100\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_... | livecodebench | deepcoder_553 | 553 |
Solve the following coding problem using the programming language python:
Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the field on the intersection o... | [
"```python\n#Simple non-optimized class of matrices. Used with small dense matrices.\nimport functools\nimport itertools\nimport math\n\nclass NotAMatrixError(Exception):\n pass\n\nclass MatrixSizeError(Exception):\n def __init__(self, s1, s2):\n print('sizes do not match : ', s1, ', ', s2)\n\nclass No... | [{"type": "stdin_stdout", "input": "5 1 2 0 1 2\n", "output": "3 1"}, {"type": "stdin_stdout", "input": "1 1 1 -1 -1 2\n", "output": "1 1"}, {"type": "stdin_stdout", "input": "1 1 1 1 1 0\n", "output": "1 1"}, {"type": "stdin_stdout", "input": "2 2 1 -2 -2 5\n", "output": "1 2"}, {"type": "stdin_stdout", "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:
Our bear's forest has a checkered field. The checkered fie... | [{"type": "stdin_stdout", "input": "5 1 2 0 1 2\n", "output": "3 1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 1 -1 -1 2\n", "output": "1 1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 1 1 1 0\n", "output": "1 1", "metadata": {"func_name": null}}, {"type": "s... | livecodebench | deepcoder_554 | 554 |
Solve the following coding problem using the programming language python:
ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has ... | [
"```python\n# You lost the game.\ns = str(input())\nn = len(s)\nA = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nif n < 26:\n print(-1)\nelse:\n for i in range(n-25):\n ok = 1\n F = [0 for _ in range(26)]\n for j in range(26):\n if s[i:i+26].count(A[j]) > 1:\n ok = 0\n ... | [{"type": "stdin_stdout", "input": "ABC??FGHIJK???OPQR?TUVWXY?\n", "output": "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, {"type": "stdin_stdout", "input": "WELCOMETOCODEFORCESROUNDTHREEHUNDREDANDSEVENTYTWO\n", "output": "-1"}, {"type": "stdin_stdout", "input": "??????????????????????????\n", "output": "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},... | 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:
ZS the Coder loves to read the dictionary. He thinks that ... | [{"type": "stdin_stdout", "input": "ABC??FGHIJK???OPQR?TUVWXY?\n", "output": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "WELCOMETOCODEFORCESROUNDTHREEHUNDREDANDSEVENTYTWO\n", "output": "-1", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "?????... | livecodebench | deepcoder_555 | 555 |
Solve the following coding problem using the programming language python:
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off.
Th... | [
"```python\nn, m = list(map(int, input().split()))\nm += 2\nl = []\ndo = False\nfor i in range(n):\n\ts = input().strip()\n\tif s.find('1') != -1 or do:\n\t\tdo = True\n\t\tl.append(s)\nn = len(l)\nif n == 0:\n\tprint(0)\n\treturn\n\n\ndp = []\nfor i in range(n):\n\tdp.append([None] * 2)\n\nfor i in range(n):\n\tR ... | [{"type": "stdin_stdout", "input": "2 2\n0010\n0100\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "3 4\n001000\n000010\n000010\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "4 3\n01110\n01110\n01110\n01110\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "3 2\n0000\n0100\n0100\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:
Some people leave the lights at their workplaces on when t... | [{"type": "stdin_stdout", "input": "2 2\n0010\n0100\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 4\n001000\n000010\n000010\n", "output": "12\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 3\n01110\n01110\n01110\n01110\n", "output": "18\n", "meta... | livecodebench | deepcoder_556 | 556 |
Solve the following coding problem using the programming language python:
Medicine faculty of Berland State University has just finished their admission campaign. As usual, about $80\%$ of applicants are girls and majority of them are going to live in the university dormitory for the next $4$ (hopefully) years.
The d... | [
"```python\nimport sys\n\nrd = lambda : sys.stdin.readline().rstrip()\n\nn = int(rd())\nc = list(map(int, rd().split()))\na = list([int(x)-1 for x in rd().split()])\n\nvisited = [-1] * (n)\nres = 0\n\nfor i in range(n):\n trace = []\n \n t = i\n mn = 1e9\n while visited[t] == -1:\n visited[t] ... | [{"type": "stdin_stdout", "input": "5\n1 2 3 2 10\n1 3 4 3 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4\n1 10 2 10\n2 4 2 2\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "7\n1 1 1 1 1 1 1\n2 2 2 3 6 7 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n6 9 1 1 1 10 2 4 9 6\n5 3 4 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:
Medicine faculty of Berland State University has just fini... | [{"type": "stdin_stdout", "input": "5\n1 2 3 2 10\n1 3 4 3 3\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n1 10 2 10\n2 4 2 2\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "7\n1 1 1 1 1 1 1\n2 2 2 3 6 7 6\n", "output": "2\n", "me... | livecodebench | deepcoder_557 | 557 |
Solve the following coding problem using the programming language python:
Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided t... | [
"```python\nn, a, b = list(map(int, input().split()))\nans = a + b\nwhile ans < 0:\n ans += n\nans %= n\nif ans == 0:\n print(n)\nelse:\n print(ans)\n\n```"
] | [{"type": "stdin_stdout", "input": "6 2 -5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5 1 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3 2 7\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 1 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1 -1\n", "output": "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:
Vasya lives in a round building, whose entrances are numbe... | [{"type": "stdin_stdout", "input": "6 2 -5\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 1 3\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2 7\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "inpu... | livecodebench | deepcoder_558 | 558 |
Solve the following coding problem using the programming language python:
Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. W... | [
"```python\nimport sys\nimport math\n\nn = int(sys.stdin.readline())\nif n <= 2:\n print(1)\n return\n\na = [int(s) for s in sys.stdin.readline().split()]\n\nst = -1 # index of first positive number in current subset of a\ned = -1 # index last positive number in current subset of a \n # differation is (a[e... | [{"type": "stdin_stdout", "input": "9\n8 6 4 2 1 4 7 10 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "9\n-1 6 -1 2 -1 4 7 -1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 -1 -1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "7\n-1 -1 4 5 1 2 3\n", "output": "2\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:
Polycarpus develops an interesting theory about the interr... | [{"type": "stdin_stdout", "input": "9\n8 6 4 2 1 4 7 10 2\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9\n-1 6 -1 2 -1 4 7 -1 2\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n-1 -1 -1 -1 -1\n", "output": "1\n", "metadata": {"func... | livecodebench | deepcoder_559 | 559 |
Solve the following coding problem using the programming language python:
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal let... | [
"```python\nn, k = map(int,input().split())\ns = input()\nmaxi = 0\na = 0\nb = 0\nst = 0\nfor i in range(0, n):\n if s[i] == 'a': a += 1\n else: b+=1\n if min(a, b) > k:\n if s[st] == 'a': a-=1\n else: b-=1\n st += 1\n else: maxi += 1\nprint(maxi)\n```"
] | [{"type": "stdin_stdout", "input": "4 2\nabba\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8 1\naabaabaa\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1 0\na\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1\nb\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 0\nb\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:
High school student Vasya got a string of length n as a bi... | [{"type": "stdin_stdout", "input": "4 2\nabba\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 1\naabaabaa\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 0\na\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_st... | livecodebench | deepcoder_560 | 560 |
Solve the following coding problem using the programming language python:
Alice is the leader of the State Refactoring Party, and she is about to become the prime minister.
The elections have just taken place. There are $n$ parties, numbered from $1$ to $n$. The $i$-th party has received $a_i$ seats in the parliamen... | [
"```python\nn = int(input())\na = list(map(int, input().split()))\nb = [0]\nfor i in range(1, n):\n\tif a[i]*2 <= a[0]:\n\t\tb += [i]\nu=0\nv=0\nfor i in range(n):\n\tif i in b:\n\t\tu += a[i]\n\telse:\n\t\tv += a[i]\nif u > v:\n\tprint(len(b))\n\tfor x in b:\n\t\tprint(x+1, end=' ')\nelse:\n\tprint('0')\n```"
] | [{"type": "stdin_stdout", "input": "3\n100 50 50\n", "output": "3\n1 2 3\n"}, {"type": "stdin_stdout", "input": "3\n80 60 60\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n6 5\n", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "4\n51 25 99 25\n", "output": "3\n1 2 4\n"}, {"type": "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:
Alice is the leader of the State Refactoring Party, and sh... | [{"type": "stdin_stdout", "input": "3\n100 50 50\n", "output": "3\n1 2 3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n80 60 60\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n6 5\n", "output": "1\n1\n", "metadata": {"func_name": null}}, {"type"... | livecodebench | deepcoder_561 | 561 |
Solve the following coding problem using the programming language python:
3R2 - Standby for Action
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. $n$"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to ... | [
"```python\nn=int(input())\ntot=0\nfor i in range(n):\n tot+=1/(i+1)\nprint(tot)\n\n```"
] | [{"type": "stdin_stdout", "input": "1\n", "output": "1.000000000000\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1.500000000000\n"}, {"type": "stdin_stdout", "input": "100000\n", "output": "12.090146129863\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "1.833333333333\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:
3R2 - Standby for Action
Our dear Cafe's owner, JOE Mille... | [{"type": "stdin_stdout", "input": "1\n", "output": "1.000000000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "output": "1.500000000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "100000\n", "output": "12.090146129863\n", "metadata": {"func_name": null}}... | livecodebench | deepcoder_562 | 562 |
Solve the following coding problem using the programming language python:
Santa Claus has n candies, he dreams to give them as gifts to children.
What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants ... | [
"```python\nn = int(input())\nans = []\nnxt = 1\nwhile n > 0:\n x = nxt\n n -= nxt\n nxt += 1\n if n < nxt:\n x += n\n n = 0\n ans.append(str(x))\nprint(len(ans))\nprint(\" \".join(ans))\n\n```"
] | [{"type": "stdin_stdout", "input": "5\n", "output": "2\n1 4 \n"}, {"type": "stdin_stdout", "input": "9\n", "output": "3\n1 2 6 \n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n2 \n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n1 \n"}, {"type": "stdin_stdout", "input": "3\n", "output": "2\n1 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:
Santa Claus has n candies, he dreams to give them as gifts... | [{"type": "stdin_stdout", "input": "5\n", "output": "2\n1 4 \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9\n", "output": "3\n1 2 6 \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n2 \n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", ... | livecodebench | deepcoder_563 | 563 |
Solve the following coding problem using the programming language python:
The following problem is well-known: given integers n and m, calculate $2^{n} \operatorname{mod} m$,
where 2^{n} = 2·2·...·2 (n factors), and $x \operatorname{mod} y$ denotes the remainder of division of x by y.
You are asked to solve the "re... | [
"```python\nn = int(input())\nm = int(input())\n\nprint(m % (1 << n))\n```"
] | [{"type": "stdin_stdout", "input": "4\n42\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "1\n58\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "98765432\n23456789\n", "output": "23456789\n"}, {"type": "stdin_stdout", "input": "8\n88127381\n", "output": "149\n"}, {"type": "stdin_stdout", "input": "32\... | 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 following problem is well-known: given integers n and ... | [{"type": "stdin_stdout", "input": "4\n42\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n58\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "98765432\n23456789\n", "output": "23456789\n", "metadata": {"func_name": null}}, {"type": "... | livecodebench | deepcoder_564 | 564 |
Solve the following coding problem using the programming language python:
Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced.... | [
"```python\nn = int(input())\ns = input()\nt = []\nvowels = 'aeiouy'\nfor c in s:\n if t and t[-1] in vowels and c in vowels:\n continue\n else:\n t.append(c)\nprint(''.join(t))\n\n```"
] | [{"type": "stdin_stdout", "input": "5\nweird\n", "output": "werd\n"}, {"type": "stdin_stdout", "input": "4\nword\n", "output": "word\n"}, {"type": "stdin_stdout", "input": "5\naaeaa\n", "output": "a\n"}, {"type": "stdin_stdout", "input": "100\naaaaabbbbboyoyoyoyoyacadabbbbbiuiufgiuiuaahjabbbklboyoyoyoyoyaaaaabbbbbiuiui... | 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:
Victor tries to write his own text editor, with word corre... | [{"type": "stdin_stdout", "input": "5\nweird\n", "output": "werd\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\nword\n", "output": "word\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\naaeaa\n", "output": "a\n", "metadata": {"func_name": null}}, {"type": "stdin_s... | livecodebench | deepcoder_565 | 565 |
Solve the following coding problem using the programming language python:
There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.
The university team for the Olympiad consists of $a$ student-programmers and $b$ student-athletes. Determine the largest number ... | [
"```python\nn, a, b = list(map(int, input().split()))\ns = input()\ns += '*'\nn += 1\nm = []\ni = 0\ni1 = -1\nwhile i < len(s):\n if s[i] == '*':\n if i - i1 > 1:\n m.append(i - i1 - 1)\n i1 = i\n i += 1\nsm = a + b\nfor c in m:\n if c % 2 == 0:\n a = max(0, a - c // 2)\n ... | [{"type": "stdin_stdout", "input": "5 1 1\n*...*\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6 2 3\n*...*.\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "11 3 10\n.*....**.*.\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3 2 3\n***\n", "output": "0\n"}, {"type": "stdin_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:
There are $n$ consecutive seat places in a railway carriag... | [{"type": "stdin_stdout", "input": "5 1 1\n*...*\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 2 3\n*...*.\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "11 3 10\n.*....**.*.\n", "output": "7\n", "metadata": {"func_name": null}}, {... | livecodebench | deepcoder_566 | 566 |
Solve the following coding problem using the programming language python:
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her ... | [
"```python\nr=int(input())\nif r<=4:\n print(\"NO\")\nelif r%2==0:\n print(\"NO\")\nelse :\n print(1, (r-3)//2)\n```"
] | [{"type": "stdin_stdout", "input": "19\n", "output": "1 8\n"}, {"type": "stdin_stdout", "input": "16\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "NO\n"}, {"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:
Melody Pond was stolen from her parents as a newborn baby ... | [{"type": "stdin_stdout", "input": "19\n", "output": "1 8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "16\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\... | livecodebench | deepcoder_567 | 567 |
Solve the following coding problem using the programming language python:
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens.
Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought $n$ packets wit... | [
"```python\n\n\nn = int(input())\n\ntab = [int(x) for x in input().split()]\n\nif n < 2 or (n == 2 and tab[0] == tab[1]):\n print(-1)\nelse:\n print(1)\n print(tab.index(min(tab)) + 1)\n\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n1 2 1\n", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "2\n5 5\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1\n10\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 1 1 1 1 1 1 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:
There are quite a lot of ways to have fun with inflatable ... | [{"type": "stdin_stdout", "input": "3\n1 2 1\n", "output": "1\n1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n5 5\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n10\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout... | livecodebench | deepcoder_568 | 568 |
Solve the following coding problem using the programming language python:
Vasya has his favourite number $n$. He wants to split it to some non-zero digits. It means, that he wants to choose some digits $d_1, d_2, \ldots, d_k$, such that $1 \leq d_i \leq 9$ for all $i$ and $d_1 + d_2 + \ldots + d_k = n$.
Vasya likes b... | [
"```python\nimport getpass\nimport sys\n\n\ndef ria():\n return [int(i) for i in input().split()]\n\n\nif getpass.getuser() != 'frohenk':\n filename = 'half'\n # sys.stdin = open('input.txt')\n # sys.stdout = open('output.txt', 'w')\nelse:\n sys.stdin = open('input.txt')\n # sys.stdin.close()\n\nn... | [{"type": "stdin_stdout", "input": "1\n", "output": "1\n1 "}, {"type": "stdin_stdout", "input": "4\n", "output": "4\n1 1 1 1 "}, {"type": "stdin_stdout", "input": "27\n", "output": "27\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"type": "stdin_stdout", "input": "239\n", "output": "239\n1 1 1 1 1 1 1 1 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:
Vasya has his favourite number $n$. He wants to split it t... | [{"type": "stdin_stdout", "input": "1\n", "output": "1\n1 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n", "output": "4\n1 1 1 1 ", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "27\n", "output": "27\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ", "metadata":... | livecodebench | deepcoder_569 | 569 |
Solve the following coding problem using the programming language python:
A tuple of positive integers {x_1, x_2, ..., x_{k}} is called simple if for all pairs of positive integers (i, j) (1 ≤ i < j ≤ k), x_{i} + x_{j} is a prime.
You are given an array a with n positive integers a_1, a_2, ..., a_{n} (not ne... | [
"```python\ndef main():\n n = int(input())\n l = list(map(int, input().split()))\n seive = [False, True] * max(l)\n a = len(seive)\n for i in range(3, int(a ** .5) + 1, 2):\n if seive[i]:\n for j in range(i * i, a, i):\n seive[j] = False\n i = l.count(1)\n if i:... | [{"type": "stdin_stdout", "input": "2\n2 3\n", "output": "2\n3 2\n"}, {"type": "stdin_stdout", "input": "2\n2 2\n", "output": "1\n2\n"}, {"type": "stdin_stdout", "input": "3\n2 1 1\n", "output": "3\n1 1 2\n"}, {"type": "stdin_stdout", "input": "2\n83 14\n", "output": "2\n14 83\n"}, {"type": "stdin_stdout", "input": "10... | 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 tuple of positive integers {x_1, x_2, ..., x_{k}} is cal... | [{"type": "stdin_stdout", "input": "2\n2 3\n", "output": "2\n3 2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n2 2\n", "output": "1\n2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3\n2 1 1\n", "output": "3\n1 1 2\n", "metadata": {"func_name": null}}, {"type": "s... | livecodebench | deepcoder_570 | 570 |
Solve the following coding problem using the programming language python:
Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.
Some examples of beautiful n... | [
"```python\nfrom collections import Counter, defaultdict\nimport itertools\nimport sys\n\ndef main():\n n = int(input())\n ans = 1\n for k in range(1, 10):\n v = ((1 << k) - 1) * (1 << (k - 1))\n if n % v == 0:\n ans = v\n\n print(ans)\n\nmain()\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "992\n", "output": "496\n"}, {"type": "stdin_stdout", "input": "81142\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "76920\n", "output": "120\n"}, {"type": "stdin_stdout", "input": "2016\n", "output": "2016\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:
Recently Luba learned about a special kind of numbers that... | [{"type": "stdin_stdout", "input": "3\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "992\n", "output": "496\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "81142\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "... | livecodebench | deepcoder_571 | 571 |
Solve the following coding problem using the programming language python:
There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least a_{i} candies.
Jzzhu asks children to line up. Initially, the i-th child stands... | [
"```python\ndef main():\n from collections import deque\n \n n, m = [int(i) for i in input().split()]\n children = deque([0, int(v), i + 1] for i, v in enumerate(input().split()))\n \n while len(children) > 1:\n tmp = children.popleft()\n tmp[0] += m\n if tmp[1] > tmp[0]:\n ... | [{"type": "stdin_stdout", "input": "5 2\n1 3 1 4 2\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "6 4\n1 1 2 2 3 3\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "7 3\n6 1 5 4 2 3 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10 5\n2 7 3 6 2 5 1 3 4 5\n", "output": "4\n"}, {"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:
There are n children in Jzzhu's school. Jzzhu is going to ... | [{"type": "stdin_stdout", "input": "5 2\n1 3 1 4 2\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 4\n1 1 2 2 3 3\n", "output": "6\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "7 3\n6 1 5 4 2 3 1\n", "output": "4\n", "metadata": {"func_name": null}}... | livecodebench | deepcoder_572 | 572 |
Solve the following coding problem using the programming language python:
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum numb... | [
"```python\nn=int(input())\nans=0\nans+=n//100\nn%=100\nans+=n//20\nn%=20\nans+=n//10\nn%=10\nans+=n//5\nn%=5\nans+=n\nprint(ans)\n\n```"
] | [{"type": "stdin_stdout", "input": "125\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "43\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "10000000\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "1\n"}, {"typ... | 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:
Allen has a LOT of money. He has $n$ dollars in the bank. ... | [{"type": "stdin_stdout", "input": "125\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "43\n", "output": "5\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "10000000\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout",... | livecodebench | deepcoder_573 | 573 |
Solve the following coding problem using the programming language python:
Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length o... | [
"```python\nmod=10**9+7\nn,k=list(map(int,input().split()))\n\nA=[0]*(n+1)\nB=[0]*(n+1)\nC=[0]*(n+1)\nF=[0]*(n+1)\nG=[0]*(n+1)\n\nF[0]=G[0]=1\nfor i in range(1,n+1):\n\tG[i]=F[i]=F[i-1]*i%mod\n\tG[i]=pow(F[i],(mod-2),mod)\n\nfor i in range(0,n):\n\tif i*2>n:\n\t\tbreak\n\tB[i]=(F[n-i]*G[i]*G[n-i*2])%mod\nfor i in r... | [{"type": "stdin_stdout", "input": "1 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 2\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "4 1\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "7 4\n", "output": "328\n"}, {"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:
Permutation p is an ordered set of integers p_1, p_2, ..... | [{"type": "stdin_stdout", "input": "1 0\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 1\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 ... | livecodebench | deepcoder_574 | 574 |
Solve the following coding problem using the programming language python:
Arkady decided to buy roses for his girlfriend.
A flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red... | [
"```python\nn,k = list(map(int, input().split()))\nb = list(map(int,input().split()))\n\nSSSSSSSSSS = input()\n\nINF = 1000*1000*1000+123\nRRRR = [];\nWWWWWWW = [];\nOOOOOOOOO = [];\n\nfor i in range(n):\n if SSSSSSSSSS[i] == 'R':\n RRRR.append(b[i])\n elif SSSSSSSSSS[i] == 'W':\n WWWWWWW.append... | [{"type": "stdin_stdout", "input": "5 3\n4 3 4 1 6\nRROWW\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "5 2\n10 20 14 20 11\nRRRRR\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "11 5\n5 6 3 2 3 4 7 5 4 5 6\nRWOORWORROW\n", "output": "28\n"}, {"type": "stdin_stdout", "input": "15 10\n8560 6244 960... | 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:
Arkady decided to buy roses for his girlfriend.
A flower ... | [{"type": "stdin_stdout", "input": "5 3\n4 3 4 1 6\nRROWW\n", "output": "11\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 2\n10 20 14 20 11\nRRRRR\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "11 5\n5 6 3 2 3 4 7 5 4 5 6\nRWOORWORROW\n", "output"... | livecodebench | deepcoder_575 | 575 |
Solve the following coding problem using the programming language python:
A continued fraction of height n is a fraction of form $a_{1} + \frac{1}{a_{2} + \frac{1}{\ldots + \frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented as a finite fraction of hei... | [
"```python\n#!/usr/bin/env python3\n\nfrom fractions import Fraction\n\ndef __starting_point():\n p, q = list(map(int, input().split()))\n n = int(input())\n l = list(map(int, input().split()))\n\n f = Fraction(l[-1], 1)\n\n for x in l[-2::-1]:\n f = 1 / f\n f += x\n\n print([\"NO\",... | [{"type": "stdin_stdout", "input": "9 4\n2\n2 4\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "9 4\n3\n2 3 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "9 4\n3\n1 2 4\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "39088169 24157817\n36\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:
A continued fraction of height n is a fraction of form $a_... | [{"type": "stdin_stdout", "input": "9 4\n2\n2 4\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9 4\n3\n2 3 1\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9 4\n3\n1 2 4\n", "output": "NO\n", "metadata": {"func_name": null}}, {"ty... | livecodebench | deepcoder_576 | 576 |
Solve the following coding problem using the programming language python:
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us... | [
"```python\nt = input()\nk = t.find('=')\nn = 2 * k - len(t)\nif n == 2:\n if t[1] != '+': t = t[1: ] + '|'\n else: t = t[: k - 1] + t[k: ] + '|'\nelif n == -2: t = '|' + t[: -1]\nelif n != 0: t = 'Impossible'\nprint(t)\n```"
] | [{"type": "stdin_stdout", "input": "||+|=|||||\n", "output": "|||+|=||||\n"}, {"type": "stdin_stdout", "input": "|||||+||=||\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "|+|=||||||\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "||||+||=||||||\n", "output": "||||+||=||||||\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:
When new students come to the Specialized Educational and ... | [{"type": "stdin_stdout", "input": "||+|=|||||\n", "output": "|||+|=||||\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "|||||+||=||\n", "output": "Impossible\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "|+|=||||||\n", "output": "Impossible\n", "metadata": {"func_nam... | livecodebench | deepcoder_577 | 577 |
Solve the following coding problem using the programming language python:
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
-----Constraints-----
- All values in in... | [
"```python\nimport numpy as np\n\n\ndef solve(n, k):\n if k % 2 == 1:\n return 0\n k //= 2\n\n MOD = 10 ** 9 + 7\n\n dp = np.zeros((1, k + 1), dtype=np.int64)\n dp[0, 0] = 1\n for i in range(1, n + 1):\n max_d = min(i + 1, n - i + 1, k + 1)\n ndp = np.zeros((max_d, k + 1), dty... | [{"type": "stdin_stdout", "input": "3 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "39 14\n", "output": "74764168\n"}, {"type": "stdin_stdout", "input": "44 350\n", "output": "15060087\n"}, {"type": "stdin_stdout", "input": "22 444\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 0\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:
Let us define the oddness of a permutation p = {p_1,\ p_2,... | [{"type": "stdin_stdout", "input": "3 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "39 14\n", "output": "74764168\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "44 350\n", "output": "15060087\n", "metadata": {"func_name": null}}, {"type": "stdin_st... | livecodebench | deepcoder_578 | 578 |
Solve the following coding problem using the programming language python:
Snuke is introducing a robot arm with the following properties to his factory:
- The robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1... | [
"```python\nN = int(input())\nP = [tuple(map(int, input().split())) for _ in range(N)]\n\nodd = []\nfor (x, y) in P:\n dist = abs(x) + abs(y)\n odd.append(dist % 2 != 0)\n\nvalid = True\neven = False\nif all(odd):\n pass\nelif not any(odd):\n even = True\nelse:\n valid =False\n\nif valid:\n\n M = ... | [{"type": "stdin_stdout", "input": "3\n-1 0\n0 3\n2 -1\n", "output": "2\n1 2\nRL\nUU\nDR\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n1 0\n2 0\n3 0\n4 0\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n1 1\n", "output": "2\n1 1\nRU\nUR\n"}, {"type": "stdin_stdout", "input": "3\n-7 -3\n7 3\n-3 -7\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:
Snuke is introducing a robot arm with the following proper... | [{"type": "stdin_stdout", "input": "3\n-1 0\n0 3\n2 -1\n", "output": "2\n1 2\nRL\nUU\nDR\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5\n0 0\n1 0\n2 0\n3 0\n4 0\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2\n1 1\n1 1\n", "output": "2\n1 1\nRU\nU... | livecodebench | deepcoder_579 | 579 |
Solve the following coding problem using the programming language python:
Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.
There is a filler word ogo in Oleg's speech. Al... | [
"```python\nfrom sys import *\nn = int(input())\na = input()\ns = 0\ni = 0\nwhile i <= n-1:\n if s == 0:\n if a[i:i+3] == 'ogo':\n s = 1\n print('***', end = '')\n i+=3\n else:\n print(a[i], end = '')\n i += 1\n \n else:\n ... | [{"type": "stdin_stdout", "input": "7\naogogob\n", "output": "a***b\n"}, {"type": "stdin_stdout", "input": "13\nogogmgogogogo\n", "output": "***gmg***\n"}, {"type": "stdin_stdout", "input": "9\nogoogoogo\n", "output": "*********\n"}, {"type": "stdin_stdout", "input": "32\nabcdefogoghijklmnogoopqrstuvwxyz\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:
Polycarp has interviewed Oleg and has written the intervie... | [{"type": "stdin_stdout", "input": "7\naogogob\n", "output": "a***b\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "13\nogogmgogogogo\n", "output": "***gmg***\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "9\nogoogoogo\n", "output": "*********\n", "metadata": {"func_na... | livecodebench | deepcoder_580 | 580 |
Solve the following coding problem using the programming language python:
Let's introduce some definitions that will be needed later.
Let $prime(x)$ be the set of prime divisors of $x$. For example, $prime(140) = \{ 2, 5, 7 \}$, $prime(169) = \{ 13 \}$.
Let $g(x, p)$ be the maximum possible integer $p^k$ where $k$ i... | [
"```python\nx, n = list(map(int, input().split()))\n\ndef primeFactor(N):\n i, n, ret, d, sq = 2, N, {}, 2, 99\n while i <= sq:\n k = 0\n while n % i == 0: n, k, ret[i] = n//i, k+1, k+1\n if k > 0 or i == 97: sq = int(n**(1/2)+0.5)\n if i < 4: i = i * 2 - 1\n else: i, d = i+... | [{"type": "stdin_stdout", "input": "10 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "20190929 1605\n", "output": "363165664\n"}, {"type": "stdin_stdout", "input": "947 987654321987654321\n", "output": "593574252\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "1\n"}, {"type": "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:
Let's introduce some definitions that will be needed later... | [{"type": "stdin_stdout", "input": "10 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "20190929 1605\n", "output": "363165664\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "947 987654321987654321\n", "output": "593574252\n", "metadata": {"func_name":... | livecodebench | deepcoder_581 | 581 |
Solve the following coding problem using the programming language python:
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand... | [
"```python\nl=list(map(int,input().split()))\nl.insert(0,0)\nc1=[1,6,3,8,5,10,7,12,9,23,11,21,13,14,15,16,17,18,19,20,4,22,2,24]\nc2=[1,23,3,21,5,2,7,4,9,6,11,8,13,14,15,16,17,18,19,20,12,22,10,24]\nc3=[1,2,3,4,5,6,15,16,9,10,11,12,13,14,23,24,17,18,7,8,21,22,19,20]\nc4=[1,2,3,4,5,6,19,20,9,10,11,12,13,14,7,8,17,18... | [{"type": "stdin_stdout", "input": "2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\n", "output": "NO"}, {"type": "stdin_stdout", "input": "5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\n", "output": "YES"}, {"type": "stdin_stdout", "input": "2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO"}, {"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:
During the breaks between competitions, top-model Izabella... | [{"type": "stdin_stdout", "input": "2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\n", "output": "NO", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\n", "output": "YES", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 6 3 3 5... | livecodebench | deepcoder_582 | 582 |
Solve the following coding problem using the programming language python:
Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.
Unfortunately, you didn't manage to get into... | [
"```python\nfrom math import ceil\n\np,x,y = map(int, input().split())\nh = x\nwhile h >=y:\n h-=50\nh+=50\nfor i in range(h, 10000000000, 50):\n u = (i//50)%475\n d = []\n for j in range(25):\n u = (u * 96 + 42)%475\n d.append(26 + u)\n if p in d:\n k = i\n break\nif k-x>... | [{"type": "stdin_stdout", "input": "239 10880 9889\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "26 7258 6123\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "493 8000 8000\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "101 6800 6500\n", "output": "0\n"}, {"type": "stdin_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:
Not so long ago the Codecraft-17 contest was held on Codef... | [{"type": "stdin_stdout", "input": "239 10880 9889\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "26 7258 6123\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "493 8000 8000\n", "output": "24\n", "metadata": {"func_name": null}}, {"type... | livecodebench | deepcoder_583 | 583 |
Solve the following coding problem using the programming language python:
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length o... | [
"```python\n'''input\n1\n2\n3\n5\n'''\nn = int(input())\na = int(input())\nb = int(input())\nc = int(input())\ncur = 0\npos = 0\nfor i in range(n-1):\n if pos == 0:\n if a < b:\n pos = 1\n cur += a\n else:\n pos = 2\n cur += b \n elif pos == 1:\n ... | [{"type": "stdin_stdout", "input": "3\n2\n3\n1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n2\n3\n5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n1\n8\n3\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "7\n10\n5\n6\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "9\n9\n7\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:
Winnie-the-Pooh likes honey very much! That is why he deci... | [{"type": "stdin_stdout", "input": "3\n2\n3\n1\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n2\n3\n5\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10\n1\n8\n3\n", "output": "9\n", "metadata": {"func_name": null}}, {"type": "stdin... | livecodebench | deepcoder_584 | 584 |
Solve the following coding problem using the programming language python:
You have a given picture with size $w \times h$. Determine if the given picture has a single "+" shape or not. A "+" shape is described below:
A "+" shape has one center nonempty cell. There should be some (at least one) consecutive non-empt... | [
"```python\nh,w = map(int,input().split())\ns = [list(input()) for i in range(h)]\nhh = -1\ntmp = -1\nfor k,i in enumerate(s):\n a = i.count('*')\n if tmp < a:\n tmp = a\n hh = k\n\nt = [list(i) for i in list(zip(*s))]\nww = -1\ntmp = -1\nfor k,i in enumerate(t):\n a = i.count('*')\n if tm... | [{"type": "stdin_stdout", "input": "5 6\n......\n..*...\n.****.\n..*...\n..*...\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3 5\n..*..\n****.\n.*...\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "7 7\n.......\n...*...\n..****.\n...*...\n...*...\n.......\n.*.....\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:
You have a given picture with size $w \times h$. Determine... | [{"type": "stdin_stdout", "input": "5 6\n......\n..*...\n.****.\n..*...\n..*...\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 5\n..*..\n****.\n.*...\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "7 7\n.......\n...*...\n..****.\n... | livecodebench | deepcoder_585 | 585 |
Solve the following coding problem using the programming language python:
Given three numbers $n, a, b$. You need to find an adjacency matrix of such an undirected graph that the number of components in it is equal to $a$, and the number of components in its complement is $b$. The matrix must be symmetric, and all dig... | [
"```python\nn, a, b = map(int,input().split())\nif a>1 and b>1: print(\"NO\"); return\nif 2<=n<=3 and a == b == 1: print(\"NO\"); return\nprint(\"YES\")\n\nif b == 1:\n adj = [[0]*n for i in range(n)]\n conn = n\n for i in range(n):\n if conn == a: break\n adj[i][i+1] = adj[i+1][i] = 1\n ... | [{"type": "stdin_stdout", "input": "3 1 2\n", "output": "YES\n001\n001\n110\n"}, {"type": "stdin_stdout", "input": "3 3 3\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5 1 1\n", "output": "YES\n01000\n10100\n01010\n00101\n00010\n"}, {"type": "stdin_stdout", "input": "2 1 1\n", "output": "NO\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:
Given three numbers $n, a, b$. You need to find an adjacen... | [{"type": "stdin_stdout", "input": "3 1 2\n", "output": "YES\n001\n001\n110\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3 3\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 1 1\n", "output": "YES\n01000\n10100\n01010\n00101\n00010\n", "metadata"... | livecodebench | deepcoder_586 | 586 |
Solve the following coding problem using the programming language python:
The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.
The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c proble... | [
"```python\nc,d=list(map(int,input().split()))\n\nn,m=list(map(int,input().split()))\n\nk=int(input())\n\nz=0\nbest=10**10\nwhile(1):\n x=n*m-k\n x-=z*n\n best=min(best,z*c+(max(x,0)*d))\n if(x<0):\n break\n z+=1\nprint(best)\n \n\n```"
] | [{"type": "stdin_stdout", "input": "1 10\n7 2\n1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 2\n2 1\n2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 9\n2 2\n3\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "5 5\n8 8\n7\n", "output": "40\n"}, {"type": "stdin_stdout", "input": "1 8\n8... | 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 finalists of the "Russian Code Cup" competition in 221... | [{"type": "stdin_stdout", "input": "1 10\n7 2\n1\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 2\n2 1\n2\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8 9\n2 2\n3\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "st... | livecodebench | deepcoder_587 | 587 |
Solve the following coding problem using the programming language python:
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of... | [
"```python\n3\n\ns = input()\nn = len(s)\n\na, b = 0, 0\nd = dict()\nfor i in range(len(s)):\n if s[i] in d:\n a = d[s[i]]\n b = i\n d[s[i]] = i\n\nif a == b - 1:\n print(\"Impossible\")\nelse:\n ans = [[' '] * 13 for i in range(2)]\n if (b - a) % 2 == 1:\n for i in range((b - a)... | [{"type": "stdin_stdout", "input": "ABCDEFGHIJKLMNOPQRSGTUVWXYZ\n", "output": "YXWVUTGHIJKLM\nZABCDEFSRQPON\n"}, {"type": "stdin_stdout", "input": "BUVTYZFQSNRIWOXXGJLKACPEMDH\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "DYCEUXXKMGZOINVPHWQSRTABLJF\n", "output": "Impossible\n"}, {"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:
Let’s define a grid to be a set of tiles with 2 rows and 1... | [{"type": "stdin_stdout", "input": "ABCDEFGHIJKLMNOPQRSGTUVWXYZ\n", "output": "YXWVUTGHIJKLM\nZABCDEFSRQPON\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "BUVTYZFQSNRIWOXXGJLKACPEMDH\n", "output": "Impossible\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "DYCEUXXKMGZO... | livecodebench | deepcoder_588 | 588 |
Solve the following coding problem using the programming language python:
Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before.
It turns out that high school struggles are not gone... | [
"```python\nimport math\n\nx, y = [int(v) for v in input().split()]\n\nxly = x * math.log(y)\nylx = y * math.log(x)\n\nif abs(xly - ylx) < 1e-8:\n print('=')\nelif ylx < xly:\n print('<')\nelse:\n print('>')\n\n```"
] | [{"type": "stdin_stdout", "input": "5 8\n", "output": ">\n"}, {"type": "stdin_stdout", "input": "10 3\n", "output": "<\n"}, {"type": "stdin_stdout", "input": "6 6\n", "output": "=\n"}, {"type": "stdin_stdout", "input": "14 1\n", "output": ">\n"}, {"type": "stdin_stdout", "input": "2 4\n", "output": "=\n"}, {"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:
Year 2118. Androids are in mass production for decades now... | [{"type": "stdin_stdout", "input": "5 8\n", "output": ">\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "10 3\n", "output": "<\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 6\n", "output": "=\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1... | livecodebench | deepcoder_589 | 589 |
Solve the following coding problem using the programming language python:
Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish ... | [
"```python\nfrom math import *\nn, a = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort()\nif n == 1:\n print(0)\n \nelse:\n if a > A[-1]:\n print(abs(a - A[1]))\n elif a < A[0]:\n print(abs(a - A[-2]))\n else:\n per1 = abs(A[0] - A[-2])\n per2 = abs(... | [{"type": "stdin_stdout", "input": "3 10\n1 7 12\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "2 0\n11 -10\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "5 0\n0 0 1000 0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 0\n0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 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:
Vasya takes part in the orienteering competition. There ar... | [{"type": "stdin_stdout", "input": "3 10\n1 7 12\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "2 0\n11 -10\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 0\n0 0 1000 0 0\n", "output": "0\n", "metadata": {"func_name": null}}, {"typ... | livecodebench | deepcoder_590 | 590 |
Solve the following coding problem using the programming language python:
Let's consider equation:x^2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of... | [
"```python\nimport re\nimport itertools\nfrom collections import Counter, deque\n\nclass Task:\n maxDigitSum = 18 * 9\n n = 0\n answer = \"\" \n\t\n def getData(self):\n self.n = int(input())\n #inFile = open('input.txt', 'r')\n #inFile.readline().rstrip()\n #self.childs = in... | [{"type": "stdin_stdout", "input": "2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "110\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "8\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10000000100000000\n", "output": "100000000\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:
Let's consider equation:x^2 + s(x)·x - n = 0,
where x, ... | [{"type": "stdin_stdout", "input": "2\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "110\n", "output": "10\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4\n", "output": "-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "8\n"... | livecodebench | deepcoder_591 | 591 |
Solve the following coding problem using the programming language python:
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t.
Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George coul... | [
"```python\ns = input()\nt = input()\na, b = int(s[:2]), int(s[3:])\nc, d = int(t[:2]), int(t[3:])\na -= c\nb -= d\nif b < 0:\n a -= 1\n b = 60 + b\nif a < 0:\n a = 24 + a\nif a < 10:\n print(0, end = '')\nprint(a, ':', end = '', sep = '')\nif b < 10:\n print(0, end = '')\nprint(b)\n\n```"
] | [{"type": "stdin_stdout", "input": "05:50\n05:44\n", "output": "00:06\n"}, {"type": "stdin_stdout", "input": "00:00\n01:00\n", "output": "23:00\n"}, {"type": "stdin_stdout", "input": "00:01\n00:00\n", "output": "00:01\n"}, {"type": "stdin_stdout", "input": "23:59\n23:59\n", "output": "00:00\n"}, {"type": "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:
George woke up and saw the current time s on the digital c... | [{"type": "stdin_stdout", "input": "05:50\n05:44\n", "output": "00:06\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "00:00\n01:00\n", "output": "23:00\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "00:01\n00:00\n", "output": "00:01\n", "metadata": {"func_name": null}}... | livecodebench | deepcoder_592 | 592 |
Solve the following coding problem using the programming language python:
You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding... | [
"```python\nn = int(input())\na = list(map(int,input().split()))\nm = max(a)\n\ncurrent = 0\nlongest = 0\nfor x in a:\n if x == m:\n current +=1\n else:\n longest = max(current,longest)\n current = 0\nlongest = max(current,longest)\nprint (longest)\n\n\n```"
] | [{"type": "stdin_stdout", "input": "5\n6 1 6 6 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n1 1 0 1 1 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n2 2 2 2 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "6... | 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 array $a_1, a_2, \dots, a_n$. Find the subse... | [{"type": "stdin_stdout", "input": "5\n6 1 6 6 0\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6\n1 1 0 1 1 1\n", "output": "3\n", "metadata": {"func_name": null}}, {"type"... | livecodebench | deepcoder_593 | 593 |
Solve the following coding problem using the programming language python:
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.
There are $n$ bricks lined in a row on the ground. Chouti has got $m$ paint buckets of different colors at hand, so he painted each bri... | [
"```python\nimport math\nn,m,k=map(int,input().split())\nout=1\nfor i in range(k):\n out*=(m-1)\n out%=998244353\nout*=m\nout%=998244353\nout*=(math.factorial(n-1)//math.factorial(k)//math.factorial(n-1-k))\nout%=998244353\nprint(out)\n```"
] | [{"type": "stdin_stdout", "input": "3 3 0\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3 2 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3 3 2\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "123 45 67\n", "output": "212505593\n"}, {"type": "stdin_stdout", "input": "1234 567 890\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:
On his free time, Chouti likes doing some housework. He ha... | [{"type": "stdin_stdout", "input": "3 3 0\n", "output": "3\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 2 1\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "3 3 2\n", "output": "12\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "inpu... | livecodebench | deepcoder_594 | 594 |
Solve the following coding problem using the programming language python:
A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.
You're given a number. Determin... | [
"```python\nn = input()\ngood = True\nwhile n != '' and good:\n if n.endswith('144'):\n n = n[:-3]\n elif n.endswith('14'):\n n = n[:-2]\n elif n.endswith('1'):\n n = n[:-1]\n else:\n good = False\nprint('YES' if good else 'NO')\n\n```"
] | [{"type": "stdin_stdout", "input": "114114\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1111\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "441231\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "14\n", "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 magic number is a number formed by concatenation of numb... | [{"type": "stdin_stdout", "input": "114114\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1111\n", "output": "YES\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "441231\n", "output": "NO\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", ... | livecodebench | deepcoder_595 | 595 |
Solve the following coding problem using the programming language python:
Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b.
Dima put the chessboard in front o... | [
"```python\nn,m,i,j,a,b=list(map(int,input().split()))\n\nans=100000000000\n\nif((i,j)==(n,1) or (i,j)==(1,1) or (i,j)==(1,m) or (i,j)==(n,m)):\n print(0)\n\nelse:\n #Corner (1,1)\n\n hor=i-1\n ver=j-1\n\n if(hor%a==0 and ver%b==0):\n x=hor//a\n y=ver//b\n if(x%2==y%2 and a<=n-1 ... | [{"type": "stdin_stdout", "input": "5 7 1 3 2 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 5 2 3 1 1\n", "output": "Poor Inna and pony!\n"}, {"type": "stdin_stdout", "input": "1 1 1 1 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "23000 15500 100 333 9 1\n", "output": "15167\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:
Dima and Inna are doing so great! At the moment, Inna is s... | [{"type": "stdin_stdout", "input": "5 7 1 3 2 2\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 5 2 3 1 1\n", "output": "Poor Inna and pony!\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "1 1 1 1 1 1\n", "output": "0\n", "metadata": {"func_name": nul... | livecodebench | deepcoder_596 | 596 |
Solve the following coding problem using the programming language python:
ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiar... | [
"```python\nn, k = map(int, input().split())\na = set(map(int, input().split()))\nq = int(input())\n\n# def isIn(x, fm, to):\n# \tif fm >= to:\n# \t\treturn a[fm] == x\n# \tt = a[(fm+to) // 2]\n# \tif t > x:\n# \t\treturn isIn(x, fm, (fm+to) // 2 - 1)\n# \telif t < x:\n# \t\treturn isIn(x, (fm+to) // 2 + 1, to)\n# ... | [{"type": "stdin_stdout", "input": "6 20\n10 50 100 500 1000 5000\n8\n4200\n100000\n95000\n96000\n99000\n10100\n2015\n9950\n", "output": "6\n20\n19\n20\n-1\n3\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "5 2\n1 2 3 5 8\n8\n1\n3\n5\n7\n9\n11\n13\n15\n", "output": "1\n1\n1\n2\n2\n2\n2\n-1\n"}, {"type": "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:
ATMs of a well-known bank of a small country are arranged ... | [{"type": "stdin_stdout", "input": "6 20\n10 50 100 500 1000 5000\n8\n4200\n100000\n95000\n96000\n99000\n10100\n2015\n9950\n", "output": "6\n20\n19\n20\n-1\n3\n-1\n-1\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 2\n1 2 3 5 8\n8\n1\n3\n5\n7\n9\n11\n13\n15\n", "output": "1\n1\n1\n2\n2\n2\n2\... | livecodebench | deepcoder_597 | 597 |
Solve the following coding problem using the programming language python:
The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at... | [
"```python\n#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n s, x1, x2 = list(map(int, input().split()))\n t1, t2 = list(map(int, input().split()))\n p, d = list(map(int, input().split()))\n\n def travel(src, trg):\n nonlocal d\n ... | [{"type": "stdin_stdout", "input": "4 2 4\n3 4\n1 1\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "5 4 0\n1 2\n3 1\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "5 4 0\n5 14\n1 -1\n", "output": "55\n"}, {"type": "stdin_stdout", "input": "10 7 2\n7 9\n9 -1\n", "output": "45\n"}, {"type": "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:
The tram in Berland goes along a straight line from the po... | [{"type": "stdin_stdout", "input": "4 2 4\n3 4\n1 1\n", "output": "8\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 4 0\n1 2\n3 1\n", "output": "7\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 4 0\n5 14\n1 -1\n", "output": "55\n", "metadata": {"func_name": null}}... | livecodebench | deepcoder_598 | 598 |
Solve the following coding problem using the programming language python:
Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1.
You are given a positive integer x. Your task ... | [
"```python\nn, x = map(int, input().split())\nans = 0\nfor i in range(n, 0, -1):\n if x % i == 0 and x//i <= n:\n ans += 1\nprint(ans)\n```"
] | [{"type": "stdin_stdout", "input": "10 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6 12\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5 13\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "1\n"}, {"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:
Let's consider a table consisting of n rows and n columns.... | [{"type": "stdin_stdout", "input": "10 5\n", "output": "2\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "6 12\n", "output": "4\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "5 13\n", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": ... | livecodebench | deepcoder_599 | 599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.