problem string | solutions list | tests string | starter_code string | metadata string | question string | data_source string | uid string | index int64 | ICL list | prompt list | ability string | reward_model dict | extra_info dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Solve the following coding problem using the programming language python:
There are some websites that are accessible through several different addresses. For example, for a long time Codeforces was accessible with two hostnames codeforces.com and codeforces.ru.
You are given a list of page addresses being queried. F... | [
"```python\n# Bartek Kostka\n# You are not prepared!\n\n#include \"bits/stdc++.h\"\n\nn = int(input())\nW = {}\nfor i in range(n):\n adr = input()\n adr = adr.split(\"/\")\n if adr[-1] == '':\n adr[-1] = '?'\n domena = \"/\".join(adr[:3])\n adres = \"/\".join(adr[3:])\n #print(domena, adre... | [{"type": "stdin_stdout", "input": "10\nhttp://abacaba.ru/test\nhttp://abacaba.ru/\nhttp://abacaba.com\nhttp://abacaba.com/test\nhttp://abacaba.de/\nhttp://abacaba.ru/test\nhttp://abacaba.de/test\nhttp://abacaba.com/\nhttp://abacaba.com/t\nhttp://abacaba.com/test\n", "output": "1\nhttp://abacaba.de http://abacaba.ru \n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
There are some websites that are accessible through severa... | livecodebench | deepcoder_0 | 0 | [
{
"answer": "```python\nimport math\nimport re\nfrom fractions import Fraction\nfrom collections import Counter\n\nclass Task:\n ips = []\n k = 0\n answer = ''\n \n def __init__(self):\n n, self.k = [int(x) for x in input().split()]\n self.ips = ['' for _ in range(n)]\n for i... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThe problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively.\n\nPolycarpus has found a job, he is a system administrator. One day he c... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"10\\nhttp://abacaba.ru/test\\nhttp://abacaba.ru/\\nhttp://abacaba.com\\nhttp://abacaba.com/test\\nhttp://abacaba.de/\\nhttp://abacaba.ru/test\\nhttp://abacaba.de/test\\nhttp://abacaba.com/\\nhttp://abacaba.com/t\\nhttp://abacaba.com/test\\n\", \"output\": ... | {
"index": 0,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThere are some websites... |
Solve the following coding problem using the programming language python:
Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if $\operatorname{mod}(x, b) \neq 0$ and $\frac{\opera... | [
"```python\na,b=map(int,input().split())\nprint(((b-1)*a*b//2+(a+1)*a*b*b*(b-1)//4)%1000000007)\n```"
] | [{"type": "stdin_stdout", "input": "1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 2\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "4 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4 2\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "4 3\n", "output": "102\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:
Dreamoon loves summing up something for no reason. One day... | livecodebench | deepcoder_1 | 1 | [
{
"answer": "```python\nimport sys\nimport math\nMAXNUM = math.inf\nMINNUM = -1 * math.inf\nASCIILOWER = 97\nASCIIUPPER = 65\nMODMAX = 1000000007\n\ndef getInt():\n\treturn int(sys.stdin.readline().rstrip())\n\ndef getInts():\n\treturn map(int, sys.stdin.readline().rstrip().split(' '))\n\ndef getString():\n\tre... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nDreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is ca... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"1 1\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 2\\n\", \"output\": \"8\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 1\\n\", \"output\": \"0\\n\", ... | {
"index": 1,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nDreamoon loves summing ... |
Solve the following coding problem using the programming language python:
Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except... | [
"```python\nl,r = map(int, input().split(\" \"))\nif l == r:\n print (l)\nelse:\n print (2)\n```"
] | [{"type": "stdin_stdout", "input": "19 29\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "39 91\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "76 134\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "93 95\n", "output": "2\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:
Tavak and Seyyed are good friends. Seyyed is very funny an... | livecodebench | deepcoder_2 | 2 | [
{
"answer": "(a, b) = map(int, input().split())\nprint(2 if a != b else a)\n",
"question": "Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.\n\nYou are given l and r. For all integers from l to r, inclusive, we wrote down all o... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.\n\nYou are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find th... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"19 29\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 6\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"39 91\\n\", \"output\": \"2\\n... | {
"index": 2,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nTavak and Seyyed are go... |
Solve the following coding problem using the programming language python:
"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (... | [
"```python\ns=input()\nans = 0\nfor i in range(len(s)):\n if s[i] == 'A':\n ans += s[:i].count('Q') * s[i:].count('Q')\nprint(ans)\n```"
] | [{"type": "stdin_stdout", "input": "QAQAQYSYIOIWIN\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "QAQQQZZYNOIWIN\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "QA\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "IAQVAQZLQBQVQFTQQQADAQJA\n", "output": "24\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:
"QAQ" is a word to denote an expression of crying. Imagine... | livecodebench | deepcoder_3 | 3 | [
{
"answer": "```python\n# QAQ\ndef crying(s):\n ans = 0\n for i in range(len(s)):\n if (s[i] != \"Q\"):\n continue\n for j in range(i + 1, len(s)):\n if s[j] != 'A':\n continue\n for k in range(j + 1, len(s)):\n if s[k] == 'Q':\n... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\n\"QAQ\" is a word to denote an expression of crying. Imagine \"Q\" as eyes with tears and \"A\" as a mouth.\n\nNow Diamond has given Bort a string consisting of only uppercase Engli... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"QAQAQYSYIOIWIN\\n\", \"output\": \"4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"QAQQQZZYNOIWIN\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"QA\\n\", \... | {
"index": 3,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\n\"QAQ\" is a word to de... |
Solve the following coding problem using the programming language python:
Codefortia is a small island country located somewhere in the West Pacific. It consists of $n$ settlements connected by $m$ bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time needed to pass each road to... | [
"```python\nimport heapq\nn,m,a,b=map(int,input().split())\ngraph={i:[] for i in range(n)}\nfor i in range(m):\n u,v,w=map(int,input().split())\n graph[u-1].append((v-1,w))\n graph[v-1].append((u-1,w))\ncomponents=[-1]*n\ncomp=-1\nfor i in range(n):\n if components[i]==-1:\n comp+=1\n comp... | [{"type": "stdin_stdout", "input": "5 5 20 25\n1 2 25\n2 3 25\n3 4 20\n4 5 20\n5 1 20\n", "output": "0 25 60 40 20\n"}, {"type": "stdin_stdout", "input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 5 13\n5 6 13\n6 1 13\n", "output": "0 13 26 39 26 13\n"}, {"type": "stdin_stdout", "input": "2 1 1 2\n2 1 1\n", "output"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Codefortia is a small island country located somewhere in ... | livecodebench | deepcoder_4 | 4 | [
{
"answer": "```python\nimport heapq\nn,m,a,b=map(int,input().split())\ngraph={i:[] for i in range(n)}\nfor i in range(m):\n u,v,w=map(int,input().split())\n graph[u-1].append((v-1,w))\n graph[v-1].append((u-1,w))\ncomponents=[-1]*n\ncomp=-1\nfor i in range(n):\n if components[i]==-1:\n comp+... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nCodefortia is a small island country located somewhere in the West Pacific. It consists of n settlements connected by m bidirectional gravel roads. Curiously enough, the beliefs of ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 5 20 25\\n1 2 25\\n2 3 25\\n3 4 20\\n4 5 20\\n5 1 20\\n\", \"output\": \"0 25 60 40 20\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"6 7 13 22\\n1 2 13\\n2 3 13\\n1 4 22\\n3 4 13\\n4 5 13\\n5 6 13\\n6 1 13\\n\", \"... | {
"index": 4,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nCodefortia is a small i... |
Solve the following coding problem using the programming language python:
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences... | [
"```python\nX, D = list(map(int, input().split()))\ncn = 1\nadd0 = 1 if (X&1) else 0\nans = []\nfor i in range(30,0,-1):\n\tif not (X & (1<<i)): continue\n\tans += [cn]*i\n\tadd0 += 1\n\tcn += D\nfor i in range(add0):\n\tans.append(cn)\n\tcn += D\nprint(len(ans))\nprint(' '.join(map(str, ans)))\n\n```"
] | [{"type": "stdin_stdout", "input": "10 5\n", "output": "6\n1 1 1 7 13 19 "}, {"type": "stdin_stdout", "input": "4 2\n", "output": "3\n1 1 4 "}, {"type": "stdin_stdout", "input": "4 1\n", "output": "3\n1 1 3 "}, {"type": "stdin_stdout", "input": "1 1\n", "output": "1\n1 "}, {"type": "stdin_stdout", "input": "63 1\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:
Pikachu had an array with him. He wrote down all the non-e... | livecodebench | deepcoder_5 | 5 | [
{
"answer": "```python\nX, d = map(int, input().split())\n\nx = X\nans = list()\nln = 0\nlast = 1\nwhile x > 0:\n if last >= 10 ** 18:\n print(-1)\n exit()\n\n i = 0\n while 2 ** (i + 1) - 1 <= x:\n i += 1\n\n t = 2 ** i - 1\n x -= t\n\n if ln + i > 10000:\n print(-... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nPikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2n - 1 non-empty subsequences in it. \n\nPikachu ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"10 5\\n\", \"output\": \"6\\n1 1 1 7 13 19 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 2\\n\", \"output\": \"3\\n1 1 4 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 1\\n\", \... | {
"index": 5,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nPikachu had an array wi... |
Solve the following coding problem using the programming language python:
Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an integer k from a segment [0, len(s) - 1]. He tells Vasya this stri... | [
"```python\nstr = input()\nl = len(str)\na = [0] * (2 * l)\npos = [[] for i in range(26)]\nfor i, c in enumerate(str):\n t = ord(c) - ord('a')\n a[i] = t\n a[i + l] = t\n pos[t].append(i)\nans = 0\nfor c in range(26):\n cur = 0\n for k in range(1, l):\n cnt = [0] * 26\n for i in pos[... | [{"type": "stdin_stdout", "input": "technocup\n", "output": "1.000000000000000\n"}, {"type": "stdin_stdout", "input": "tictictactac\n", "output": "0.333333333333333\n"}, {"type": "stdin_stdout", "input": "bbaabaabbb\n", "output": "0.100000000000000\n"}, {"type": "stdin_stdout", "input": "cbbbbcaaca\n", "output": "0.800... | 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 and Kolya play a game with a string, using the follo... | livecodebench | deepcoder_6 | 6 | [
{
"answer": "```python\ns = input()\nn = len(s)\nd = {}\nfor i in range(n):\n\tif s[i] not in d:\n\t\td[s[i]] = []\n\td[s[i]].append(s[i + 1:] + s[:i])\nres = 0\nfor (k, l) in d.items():\n\tans = 0\n\tfor j in range(n - 1):\n\t\t(seen, s1) = (set(), set())\n\t\tfor i in range(len(l)):\n\t\t\tif l[i][j] in s1:\n... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nVasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an in... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"technocup\\n\", \"output\": \"1.000000000000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"tictictactac\\n\", \"output\": \"0.333333333333333\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\"... | {
"index": 6,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nVasya and Kolya play a ... |
Solve the following coding problem using the programming language python:
In the evenings Donkey would join Shrek to look at the stars. They would sit on a log, sipping tea and they would watch the starry sky. The sky hung above the roof, right behind the chimney. Shrek's stars were to the right of the chimney and the... | [
"```python\nfrom bisect import *\nfrom math import *\n\nn = int(input())\na, b, c, d = list(map(int,input().replace('/',' ').split()))\n\nalpha = atan2(c,d) - atan2(a,b)\ntan_alpha = tan(alpha)\n\nlis = []\n\nfor x,y in sorted((y/tan_alpha - x,y) for x,y in [ (x,y) for x,y in [(b*x + a*y,-a*x + b*y) for x, y in [li... | [{"type": "stdin_stdout", "input": "15\n1/3 2/1\n3 1\n6 2\n4 2\n2 5\n4 5\n6 6\n3 4\n1 6\n2 1\n7 4\n9 3\n5 3\n1 3\n15 5\n12 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "15\n2/1 2/0\n3 1\n6 2\n9 3\n12 4\n15 5\n2 1\n4 2\n5 3\n7 4\n1 3\n3 4\n2 5\n4 5\n1 6\n6 6\n", "output": "1\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:
In the evenings Donkey would join Shrek to look at the sta... | livecodebench | deepcoder_7 | 7 | [
{
"answer": "```python\nimport bisect\n\ndef INPUT():\n\tglobal n, a, b, c, d\n\tn = int(input())\n\ta, b, c, d = [int(j) for i in input().split() for j in i.split(\"/\")]\n\tglobal y_alpha\n\ty_alpha = []\n\tfor _ in range(n):\n\t\tx, y = [int(x) for x in input().split()]\n\t\ty_alpha.append((b * y - a * x, c ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nIn the evenings Donkey would join Shrek to look at the stars. They would sit on a log, sipping tea and they would watch the starry sky. The sky hung above the roof, right behind the... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"15\\n1/3 2/1\\n3 1\\n6 2\\n4 2\\n2 5\\n4 5\\n6 6\\n3 4\\n1 6\\n2 1\\n7 4\\n9 3\\n5 3\\n1 3\\n15 5\\n12 4\\n\", \"output\": \"4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"15\\n2/1 2/0\\n3 1\\n6 2\\n9 3\\n12 4\\n15 ... | {
"index": 7,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIn the evenings Donkey ... |
Solve the following coding problem using the programming language python:
The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from n... | [
"```python\nx = input ()\n\nflag = 0\ns = 0\n\nfor each_item in x:\n if each_item == '0':\n if flag == 0:\n flag = 1;\n continue\n else:\n print (each_item, end = '')\n else:\n if (s == len (x) - 1 and flag == 0) :\n continue\n print (eac... | [{"type": "stdin_stdout", "input": "101\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "110010\n", "output": "11010\n"}, {"type": "stdin_stdout", "input": "10000\n", "output": "1000\n"}, {"type": "stdin_stdout", "input": "1111111110\n", "output": "111111111\n"}, {"type": "stdin_stdout", "input": "101001010111... | 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 Little Elephant has an integer a, written in the binar... | livecodebench | deepcoder_8 | 8 | [
{
"answer": "```python\ns = list(input())\nfor i in range(len(s)):\n\tif s[i] == '0':\n\t\tbreak\ndel s[i]\nprint(''.join(s))\n\n```",
"question": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has an integer a, written in the binary notation. He wants to w... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThe Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"101\\n\", \"output\": \"11\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"110010\\n\", \"output\": \"11010\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10000\\n\", \"output\": ... | {
"index": 8,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThe Little Elephant has... |
Solve the following coding problem using the programming language python:
It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, e... | [
"```python\ndef gcd(a, b):\n while b > 0:\n a, b = b, a % b\n return a\n\nn = int(input())\nA = list(map(int, input().split()))\n\nGCD = A[0]\nfor x in A[1:]:\n GCD = gcd(GCD, x)\nnum = max(A) // GCD - n\nif num % 2 == 0:\n print(\"Bob\")\nelse:\n print(\"Alice\")\n\n\n```"
] | [{"type": "stdin_stdout", "input": "2\n2 3\n", "output": "Alice\n"}, {"type": "stdin_stdout", "input": "2\n5 3\n", "output": "Alice\n"}, {"type": "stdin_stdout", "input": "3\n5 6 7\n", "output": "Bob\n"}, {"type": "stdin_stdout", "input": "10\n72 96 24 66 6 18 12 30 60 48\n", "output": "Bob\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:
It is so boring in the summer holiday, isn't it? So Alice ... | livecodebench | deepcoder_9 | 9 | [
{
"answer": "```python\nfrom sys import *\nfrom math import *\nfrom string import *\nfrom operator import *\nfrom functools import *\nfrom fractions import *\nfrom collections import *\nsetrecursionlimit(10 ** 7)\ndX = [-1, 1, 0, 0, -1, 1, -1, 1]\ndY = [0, 0, -1, 1, 1, -1, -1, 1]\nRI = lambda : list(map(int, in... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nIt is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n2 3\\n\", \"output\": \"Alice\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n5 3\\n\", \"output\": \"Alice\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n5 6 7\\n\", ... | {
"index": 9,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIt is so boring in the ... |
Solve the following coding problem using the programming language python:
Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data in parallel.
When viewed from the side, Mike's hard drive is an endless array of tracks. The tracks of the a... | [
"```python\nimport sys\nfrom itertools import *\nfrom math import *\ndef solve():\n n, m = map(int, input().split())\n h = list(map(int, input().split()))\n p = list(map(int, input().split()))\n ss, ll = 0, int(2.2e10)\n while ss < ll:\n avg = (ss + ll) // 2\n works = True\n hidx... | [{"type": "stdin_stdout", "input": "3 4\n2 5 6\n1 3 6 8\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 3\n1 2 3\n1 2 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 2\n165\n142 200\n", "output": "81\n"}, {"type": "stdin_stdout", "input": "1 2\n5000000000\n1 10000000000\n", "output": "1499999999... | 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:
Mad scientist Mike does not use slow hard disks. His modif... | livecodebench | deepcoder_10 | 10 | [
{
"answer": "```python\nimport sys\nfrom itertools import *\nfrom math import *\ndef solve():\n n, m = map(int, input().split())\n h = list(map(int, input().split()))\n p = list(map(int, input().split()))\n ss, ll = 0, int(2.2e10)\n while ss < ll:\n avg = (ss + ll) // 2\n works = Tr... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nMad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data in parallel.\n\nWhen viewed from the side, Mi... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 4\\n2 5 6\\n1 3 6 8\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 3\\n1 2 3\\n1 2 3\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": ... | {
"index": 10,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nMad scientist Mike doe... |
Solve the following coding problem using the programming language python:
A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya... | [
"```python\nfrom sys import stdin\n\n#stdin = open('input.txt')\n\nn = int(stdin.readline())\n\nseq = [int(x) for x in stdin.readline().split()]\ncarry = seq[0]\nresult = [carry]\n\nmark = False\ncur_len = 0\nmax_len = 0\n\ni = 1\nwhile i < len(seq) - 1:\n if mark:\n if seq[i] != seq[i + 1]:\n ... | [{"type": "stdin_stdout", "input": "4\n0 0 1 1\n", "output": "0\n0 0 1 1\n"}, {"type": "stdin_stdout", "input": "5\n0 1 0 1 0\n", "output": "2\n0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "3\n1 0 0\n", "output": "0\n1 0 0\n"}, {"type": "stdin_stdout", "input": "4\n1 0 0 1\n", "output": "0\n1 0 0 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 schoolboy named Vasya loves reading books on programming... | livecodebench | deepcoder_11 | 11 | [
{
"answer": "```python\ndef main():\n\tn = int(input())\n\ta = [int(i) for i in input().split()]\n\tflag = 0\n\tnow_begin = 0\n\tkek = 0\n\tans = [[-1] * 2 for i in range(n)]\n\tfor i in range(1, n - 1):\n\t\tif a[i] != a[i - 1] and a[i] != a[i + 1]:\n\t\t\tkek += 1\n\t\telse:\n\t\t\tflag = max((kek + 1) // 2, ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nA schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median fil... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n0 0 1 1\\n\", \"output\": \"0\\n0 0 1 1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n0 1 0 1 0\\n\", \"output\": \"2\\n0 0 0 0 0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"inp... | {
"index": 11,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nA schoolboy named Vasy... |
Solve the following coding problem using the programming language python:
For a vector $\vec{v} = (x, y)$, define $|v| = \sqrt{x^2 + y^2}$.
Allen had a bit too much to drink at the bar, which is at the origin. There are $n$ vectors $\vec{v_1}, \vec{v_2}, \cdots, \vec{v_n}$. Allen will make $n$ moves. As Allen's sense... | [
"```python\nimport random\n\nn = int(input())\nv = []\na = []\nfor i in range(n):\n a.append(i)\n\nfor _ in range(0, n):\n x, y = list(map(int, input().split()))\n v.append([x, y, x*x+y*y])\n\nwhile 1>0:\n x = 0\n y = 0\n ans = [0]*n\n random.shuffle(a)\n for i in range(n):\n if (x+v[... | [{"type": "stdin_stdout", "input": "3\n999999 0\n0 999999\n999999 0\n", "output": "1 1 -1 \n"}, {"type": "stdin_stdout", "input": "1\n-824590 246031\n", "output": "1 \n"}, {"type": "stdin_stdout", "input": "8\n-67761 603277\n640586 -396671\n46147 -122580\n569609 -2112\n400 914208\n131792 309779\n-850150 -486293\n5272 7... | 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:
For a vector $\vec{v} = (x, y)$, define $|v| = \sqrt{x^2 +... | livecodebench | deepcoder_12 | 12 | [
{
"answer": "```python\n\nimport random\nn = int(input())\n\nV = [tuple(map(int,input().split())) for i in range(n)]\n\ndist = lambda x,y:x*x+y*y\nindices = sorted((dist(*v),i) for i,v in enumerate(V))\n\nresult = [0]*n\nvx,vy = 0,0\n\nfor d,i in reversed(indices):\n x,y = V[i]\n _,c = min(((dist(vx+x,vy+y),1... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nFor a vector \\vec{v} = (x, y), define |v| = √{x^2 + y^2}.\n\nAllen had a bit too much to drink at the bar, which is at the origin. There are n vectors \\vec{v_1}, \\vec{v_2}, ⋅⋅⋅, ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n999999 0\\n0 999999\\n999999 0\\n\", \"output\": \"1 1 -1 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n-824590 246031\\n\", \"output\": \"1 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_st... | {
"index": 12,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nFor a vector $\\vec{v}... |
Solve the following coding problem using the programming language python:
Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h_{i} identical blocks. For clarification see picture for the first sample.
Limak will repeat the fo... | [
"```python\n\nx = int(input())\ny = list(map(int, input().split(' ')))\n\ny[0] = 1\ny[x-1] = 1\n\nz = y[:]\nfor i in range(1, x):\n z[i] = min(z[i], z[i-1] + 1)\n\nw = y[:]\nfor i in range(x-2, -1, -1):\n w[i] = min(w[i], w[i+1]+1)\n\nans = 0\nfor i in range(x):\n ans = max(ans, min(z[i], w[i]))\n\nprint(a... | [{"type": "stdin_stdout", "input": "6\n2 1 4 6 2 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n3 3 3 1 3 3 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n5128 5672 5805 5452 5882 5567 5032\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n1 2 2 3 5 5 5 4 2 1\n", "output": "5\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:
Limak is a little bear who loves to play. Today he is play... | livecodebench | deepcoder_13 | 13 | [
{
"answer": "```python\nx = int(input())\nmas = list(map(int, input().split(' ')))\nmas2 = [0] * x\nmas2[0] = 1\nfor i in range(1, x):\n\tmas2[i] = min(mas[i], mas2[i - 1] + 1)\nmas2[-1] = 1\nfor i in range(2, x + 1):\n\tmas2[-i] = min(mas[-i], mas2[-i + 1] + 1, mas2[-i])\nprint(max(mas2))\n\n```",
"questio... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nLimak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarificatio... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"6\\n2 1 4 6 2 2\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"7\\n3 3 3 1 3 3 3\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"7\\n51... | {
"index": 13,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nLimak is a little bear... |
Solve the following coding problem using the programming language python:
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answe... | [
"```python\nn=int(input())\nq=[]\nfor i in range(max(0,n-100),n+1):\n\tj=i\n\tres=i\n\twhile j:\n\t\tres+=j%10\n\t\tj//=10\n\tif res==n:\n\t\tq.append(i)\nprint(len(q))\nfor i in q:\n\tprint(i)\n```"
] | [{"type": "stdin_stdout", "input": "21\n", "output": "1\n15\n"}, {"type": "stdin_stdout", "input": "20\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "0\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:
Eighth-grader Vova is on duty today in the class. After cl... | livecodebench | deepcoder_14 | 14 | [
{
"answer": "```python\nimport sys\ntext = sys.stdin.read().strip()\nn = int(text)\nq = lambda x: sum([int(b) for b in str(x)])\ne = []\nfor i in range(max(0, n-81), n):\n if i + q(i) == n:\n e.append(i)\nprint(len(e))\nfor z in e:\n print(z)\n\n```",
"question": "Solve the following coding pro... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nEighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teache... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"21\\n\", \"output\": \"1\\n15\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"20\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n\", \"output\": \"0\\n\",... | {
"index": 14,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nEighth-grader Vova is ... |
Solve the following coding problem using the programming language python:
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' $\rightarrow$ 'y' $\rightarrow$ 'x' $\rightarrow \ldots \rightarrow$ 'b' $\rightarrow... | [
"```python\n#!/usr/bin/env python3\n\nimport re\n\ntry:\n while True:\n s = input()\n m = re.search(r\"[^a]\", s)\n if m is None:\n print(s[:-1], end=\"z\\n\")\n else:\n j = s.find('a', m.end())\n if j == -1:\n j = len(s)\n pr... | [{"type": "stdin_stdout", "input": "codeforces\n", "output": "bncdenqbdr\n"}, {"type": "stdin_stdout", "input": "abacaba\n", "output": "aaacaba\n"}, {"type": "stdin_stdout", "input": "babbbabaababbaa\n", "output": "aabbbabaababbaa\n"}, {"type": "stdin_stdout", "input": "bcbacaabcababaccccaaaabacbbcbbaa\n", "output": "a... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given a non-empty string s consisting of lowercase... | livecodebench | deepcoder_15 | 15 | [
{
"answer": "s = input()\ns1 = ''\nstart = False\nmetka = False\ni = 0\nwhile i < len(s) and (not start):\n\tif s[i] != 'a' and (not start):\n\t\ts1 += chr(ord(s[i]) - 1)\n\t\tmetka = True\n\telif s[i] == 'a' and (not metka):\n\t\ts1 += s[i]\n\telif s[i] == 'a' and metka:\n\t\ts1 += s[i:]\n\t\tstart = True\n\ti... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' $\\rightarrow$ 'y' $\\rightarrow$ 'x' $\\rightarrow \\ldots \\rightarrow$ 'b' $\\rightarrow$ 'a' $... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"codeforces\\n\", \"output\": \"bncdenqbdr\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"abacaba\\n\", \"output\": \"aaacaba\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"babbba... | {
"index": 15,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given a non-em... |
Solve the following coding problem using the programming language python:
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking... | [
"```python\nmod = 1000000007\n\ndef sum(x, y, k, add) :\n if k < add : return 0\n up = x + add\n if up > k : up = k\n add = add + 1\n return y * ( ( (add + up) * (up - add + 1) // 2 ) % mod ) % mod\n\ndef solve(x, y, k, add = 0) :\n if x == 0 or y == 0 : return 0\n if x > y :\n x, y = y,... | [{"type": "stdin_stdout", "input": "4\n1 1 1 1 1\n3 2 5 4 5\n1 1 5 5 10000\n1 4 2 5 2\n", "output": "1\n13\n93\n0\n"}, {"type": "stdin_stdout", "input": "10\n3 7 4 10 7\n6 1 7 10 18\n9 6 10 8 3\n1 8 3 10 3\n10 4 10 5 19\n8 9 9 10 10\n10 1 10 5 4\n8 1 9 4 18\n6 3 9 5 1\n6 6 9 6 16\n", "output": "22\n130\n0\n0\n25\n3\n0\... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
After a wonderful evening in the restaurant the time to go... | livecodebench | deepcoder_16 | 16 | [
{
"answer": "```python\nmod = 1000000007\ndef sum(x,y,k,add) :\n if k<add:return 0\n up=x+add\n if up>k:up=k\n add=add+1\n return y*(((add+up)*(up-add+1)//2)%mod)%mod\ndef solve(x,y,k,add=0) :\n if x==0 or y==0:return 0\n if x>y:x,y=y,x\n pw = 1\n while (pw<<1)<=y:pw<<=1\n if pw<=x... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nAfter a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n1 1 1 1 1\\n3 2 5 4 5\\n1 1 5 5 10000\\n1 4 2 5 2\\n\", \"output\": \"1\\n13\\n93\\n0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10\\n3 7 4 10 7\\n6 1 7 10 18\\n9 6 10 8 3\\n1 8 3 10 3\\n10 4 10 5 19\\n8 9 9 1... | {
"index": 16,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nAfter a wonderful even... |
Solve the following coding problem using the programming language python:
Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.
All children love to cry loudly at the reception at the dentist. We enumerate the children with integers f... | [
"```python\nimport sys\n\nn = int(input())\n\nv = [ list(map(int, input().split())) for i in range(n)]\n\nres = []\n\nfor i in range(n):\n\tif v[i][2] >= 0:\n\t\tres.append(i + 1)\n\t\tdec = 0\n\t\tfor j in range(i + 1, n):\n\t\t\tif v[j][2] >= 0:\n\t\t\t\tif v[i][0] > 0:\n\t\t\t\t\tv[j][2] -= v[i][0]\n\t\t\t\t\tv[... | [{"type": "stdin_stdout", "input": "5\n4 2 2\n4 1 2\n5 2 4\n3 3 5\n5 1 2\n", "output": "2\n1 3 "}, {"type": "stdin_stdout", "input": "5\n4 5 1\n5 3 9\n4 1 2\n2 1 8\n4 1 9\n", "output": "4\n1 2 4 5 "}, {"type": "stdin_stdout", "input": "10\n10 7 10\n3 6 11\n8 4 10\n10 1 11\n7 3 13\n7 2 13\n7 6 14\n3 4 17\n9 4 20\n5 2 24... | 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:
Gennady is one of the best child dentists in Berland. Toda... | livecodebench | deepcoder_17 | 17 | [
{
"answer": "```python\nn = int(input())\nC = [list(map(int, input().split())) for i in range(0, n)]\nans = []\nfor i in range(n):\n\t(v, d, p) = C[i]\n\tif p >= 0:\n\t\tcount = 0\n\t\td0 = 0\n\t\tfor j in range(i + 1, n):\n\t\t\tif C[j][2] >= 0:\n\t\t\t\tC[j][2] -= max(0, v - count) + d0\n\t\t\t\tif C[j][2] < ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nGennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.\n\nAll children love to cry loudly at the r... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5\\n4 2 2\\n4 1 2\\n5 2 4\\n3 3 5\\n5 1 2\\n\", \"output\": \"2\\n1 3 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n4 5 1\\n5 3 9\\n4 1 2\\n2 1 8\\n4 1 9\\n\", \"output\": \"4\\n1 2 4 5 \", \"metadata\": {\"func_na... | {
"index": 17,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nGennady is one of the ... |
Solve the following coding problem using the programming language python:
This problem is the most boring one you've ever seen.
Given a sequence of integers a_1, a_2, ..., a_{n} and a non-negative integer h, our goal is to partition the sequence into two subsequences (not necessarily consist of continuous elements).... | [
"```python\nn,m=map(int,input().split());a=list(map(int,input().split()));p=0;t=[0]*3\nfor i in range(n):\n if(a[i]<a[p]):p=i \nif(n==2):print('0\\n1 1\\n')\nelse:\n a.sort();t[0]=min(a[0]+a[1]+m,a[1]+a[2]);t[1]=max(a[0]+a[n-1]+m,a[n-2]+a[n-1]);t[2]=(a[n-2]+a[n-1])-(a[0]+a[1])\n if(t[1]-t[0]>t[2]):p=n\n ... | [{"type": "stdin_stdout", "input": "3 2\n1 2 3\n", "output": "1\n1 2 2 \n"}, {"type": "stdin_stdout", "input": "5 10\n0 1 0 2 1\n", "output": "3\n2 2 2 2 2 \n"}, {"type": "stdin_stdout", "input": "9 0\n11 22 33 44 55 66 77 88 99\n", "output": "154\n2 2 2 2 2 2 2 2 2 \n"}, {"type": "stdin_stdout", "input": "10 100\n2705... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
This problem is the most boring one you've ever seen.
Gi... | livecodebench | deepcoder_18 | 18 | [
{
"answer": "```python\nfrom sys import stdin\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nn, m = rints()\na = rints()\nmi = a.index(min(a))\n\nif n == 2:\n print('%d\\n%s' % (0, '1 1'))\nelse:\n a.sort()\n ans = ['1'] * n\n diff1 = (a[-1] + a[-2]) - (a[0] + a[1])\n diff2 = max(... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThis problem is the most boring one you've ever seen. \n\nGiven a sequence of integers a1, a2, ..., an and a non-negative integer h, our goal is to partition the sequence into two s... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 2\\n1 2 3\\n\", \"output\": \"1\\n1 2 2 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 10\\n0 1 0 2 1\\n\", \"output\": \"3\\n2 2 2 2 2 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"... | {
"index": 18,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThis problem is the mo... |
Solve the following coding problem using the programming language python:
Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if the chain of beads remain... | [
"```python\nimport math\n#import fractions\nfrom functools import reduce\n\nn = int(input())\nodd = -1\nbeads = [int(x) for x in input().split()]\nfor i in range(n):\n if beads[i]%2:\n if odd >= 0:\n print(0)\n print(''.join(chr(ord('a') + i)*beads[i] for i in range(n)))\n ... | [{"type": "stdin_stdout", "input": "3\n4 2 1\n", "output": "1\naabcbaa\n"}, {"type": "stdin_stdout", "input": "1\n4\n", "output": "4\naaaa\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n", "output": "0\nab\n"}, {"type": "stdin_stdout", "input": "1\n2\n", "output": "2\naa\n"}, {"type": "stdin_stdout", "input": "1\n3\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:
Ivan wants to make a necklace as a present to his beloved ... | livecodebench | deepcoder_19 | 19 | [
{
"answer": "```python\nimport math\n#import fractions\nfrom functools import reduce\n\nn = int(input())\nodd = -1\nbeads = [int(x) for x in input().split()]\nfor i in range(n):\n if beads[i]%2:\n if odd >= 0:\n print(0)\n print(''.join(chr(ord('a') + i)*beads[i] for i in range(n... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nIvan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cu... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n4 2 1\\n\", \"output\": \"1\\naabcbaa\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n4\\n\", \"output\": \"4\\naaaa\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n1 1... | {
"index": 19,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIvan wants to make a n... |
Solve the following coding problem using the programming language python:
Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.
Suppose the graph G is given. Subset A of its vertices is called a vertex cover of this graph, if for each edge u... | [
"```python\ndef main():\n n, m = list(map(int, input().split()))\n l = [[] for _ in range(n + 1)]\n for _ in range(m):\n u, v = list(map(int, input().split()))\n l[u].append(v)\n l[v].append(u)\n res = [0] * (n + 1)\n for u, x in enumerate(res):\n if not x:\n x,... | [{"type": "stdin_stdout", "input": "4 2\n1 2\n2 3\n", "output": "1\n2 \n2\n1 3 \n"}, {"type": "stdin_stdout", "input": "3 3\n1 2\n2 3\n1 3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 7\n3 2\n5 4\n3 4\n1 3\n1 5\n1 4\n2 5\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 11\n4 10\n8 10\n2 3\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:
Recently, Pari and Arya did some research about NP-Hard pr... | livecodebench | deepcoder_20 | 20 | [
{
"answer": "```python\nM=lambda:map(int,input().split())\nn,m=M()\ngraph=[set() for i in range(n)]\nfor _ in range(m):\n a,b=M()\n graph[a-1].add(b-1)\n graph[b-1].add(a-1)\nvisited=[-1 for i in range(n)]\nstack=[]\nfor i in range(n):\n if visited[i]==-1 and len(graph[i])>0:\n visited[i]=Tru... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nRecently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.\n\nSuppose the graph G is given. Subset A of its v... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 2\\n1 2\\n2 3\\n\", \"output\": \"1\\n2 \\n2\\n1 3 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 3\\n1 2\\n2 3\\n1 3\\n\", \"output\": \"-1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\"... | {
"index": 20,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nRecently, Pari and Ary... |
Solve the following coding problem using the programming language python:
Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a ne... | [
"```python\nn,m=map(int,input().split())\nif n==1and m==1:print('YES\\n1')\nelif n==3and m==3:\n print('YES')\n print(6, 1, 8)\n print(7,5,3)\n print(2,9,4)\nelif n<4and m<4:print('NO')\nelif n==1 or m==1:\n t=max(n,m)\n a=[i for i in range(2,t+1,2)]\n a+=[i for i in range(1,t+1,2)]\n print(... | [{"type": "stdin_stdout", "input": "2 4\n", "output": "YES\n5 4 7 2 \n3 6 1 8 \n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "YES\n1\n"}, {"type": "stdin_stdout", "input": "1 2\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 3\n", "ou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Students went into a class to write a test and sat in some... | livecodebench | deepcoder_21 | 21 | [
{
"answer": "```python\nimport bisect\n\ndef list_output(s): \n print(' '.join(map(str, s)))\n \ndef list_input(s='int'):\n if s == 'int':\n return list(map(int, input().split())) \n elif s == 'float':\n return list(map(float, input().split()))\n return list(map(str, input().s... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nStudents went into a class to write a test and sat in some way. The teacher thought: \"Probably they sat in this order to copy works of each other. I need to rearrange them in such ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2 4\\n\", \"output\": \"YES\\n5 4 7 2 \\n3 6 1 8 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 1\\n\", \"output\": \"NO\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1 1\\n\... | {
"index": 21,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nStudents went into a c... |
Solve the following coding problem using the programming language python:
Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!
The only thing Mrs. Smith remembered was that any permutation of $n$ can be a secret phone number. Only those permutations that minimize secret val... | [
"```python\nfrom math import sqrt\nn = int(input())\nk = int(sqrt(n))\nb = []\nlast = 0\nwhile last < n:\n b.append([last + j for j in range(k)])\n last = b[-1][-1] + 1\nk = len(b)\nfor i in range(k - 1, -1, -1):\n for j in b[i]:\n if j < n:\n print(1 + j, end=' ')\nprint()\n\n```"
] | [{"type": "stdin_stdout", "input": "4\n", "output": "3 4 1 2\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "2 1\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "3 2 1\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "4 5 2 3 1\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:
Mrs. Smith is trying to contact her husband, John Smith, b... | livecodebench | deepcoder_22 | 22 | [
{
"answer": "import math\nn = int(input())\nwidth = int(math.sqrt(n))\nstart = n - width + 1\nans = list()\nwhile True:\n\tstop = False\n\tfor v in range(start, start + width):\n\t\tif v > 0:\n\t\t\tans.append(v)\n\t\tif v < 1:\n\t\t\tstop = True\n\tstart -= width\n\tif stop:\n\t\tbreak\nprint(*ans)\n",
"qu... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!\n\nThe only thing Mrs. Smith remembered was that any permutation of $n$ can be a secret phone number. Only those permutations that minimize secret value might be... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n\", \"output\": \"3 4 1 2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n\", \"output\": \"2 1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n\", \"output\": \"1\\n\"... | {
"index": 22,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nMrs. Smith is trying t... |
Solve the following coding problem using the programming language python:
You're playing a game called Osu! Here's a simplified version of it. There are n clicks in a game. For each click there are two outcomes: correct or bad. Let us denote correct as "O", bad as "X", then the whole play can be encoded as a sequence ... | [
"```python\nn = input()\nread = input()\np = []\nfor x in read.split():\n p.append((float)(x))\n \nv = 0.0\nl = 0.0\nfor item in p:\n v = v*(1-item) + item*(v + 2*l + 1)\n l = (l + 1)*item\nprint(v)\n\n```"
] | [{"type": "stdin_stdout", "input": "3\n0.5 0.5 0.5\n", "output": "2.750000000000000\n"}, {"type": "stdin_stdout", "input": "4\n0.7 0.2 0.1 0.9\n", "output": "2.489200000000000\n"}, {"type": "stdin_stdout", "input": "5\n1 1 1 1 1\n", "output": "25.000000000000000\n"}, {"type": "stdin_stdout", "input": "10\n0.684846 0.15... | 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're playing a game called Osu! Here's a simplified vers... | livecodebench | deepcoder_23 | 23 | [
{
"answer": "```python\nn,a,b=int(input()),0,0\nfor i in map(float,input().split()):a,b=a+i*(1+b*2),i*(b+1)\nprint(a)\n\n```",
"question": "Solve the following coding problem using the programming language python:\n\nYou're playing a game called Osu! Here's a simplified version of it. There are n clicks in ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou're playing a game called Osu! Here's a simplified version of it. There are n clicks in a game. For each click there are two outcomes: correct or bad. Let us denote correct as \"... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n0.5 0.5 0.5\\n\", \"output\": \"2.750000000000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n0.7 0.2 0.1 0.9\\n\", \"output\": \"2.489200000000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"s... | {
"index": 23,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou're playing a game ... |
Solve the following coding problem using the programming language python:
Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has n clock stations, station number i is at point (x_{i... | [
"```python\nn, d = map(int, input().split())\na = [0] + list(map(int, input().split())) + [0]\nx = []\ny = []\nfor i in range(n):\n xx, yy = map(int, input().split())\n x += [xx]\n y += [yy]\nb = [-1] * n\nb[0] = 0\nc = True\nwhile c:\n c = False\n for i in range(n):\n for j in range(1, n):\n if i != j... | [{"type": "stdin_stdout", "input": "3 1000\n1000\n0 0\n0 1\n0 3\n", "output": "2000\n"}, {"type": "stdin_stdout", "input": "3 1000\n1000\n1 0\n1 1\n1 2\n", "output": "1000\n"}, {"type": "stdin_stdout", "input": "5 1421\n896 448 727\n-19 -40\n-87 40\n69 51\n-55 61\n-7 67\n", "output": "169099\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:
Yaroslav is playing a game called "Time". The game has a t... | livecodebench | deepcoder_24 | 24 | [
{
"answer": "```python\nimport sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\ndef solve():\n\tn, dc = mints()\n\ta = list(mints())\n\ta.append(0)\n\tx = [0]*n\n\ty = [0]*n\n\tfor i in range(n):\n\t\tx[i], y[i] ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYaroslav is playing a game called \"Time\". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also,... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 1000\\n1000\\n0 0\\n0 1\\n0 3\\n\", \"output\": \"2000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 1000\\n1000\\n1 0\\n1 1\\n1 2\\n\", \"output\": \"1000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \... | {
"index": 24,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYaroslav is playing a ... |
Solve the following coding problem using the programming language python:
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered ... | [
"```python\nt = input()\na, b = [i for i, d in enumerate(t, 1) if d == 'l'], [i for i, d in enumerate(t, 1) if d == 'r']\na.reverse()\nprint('\\n'.join(map(str, b)))\nprint('\\n'.join(map(str, a)))\n```"
] | [{"type": "stdin_stdout", "input": "llrlr\n", "output": "3\n5\n4\n2\n1\n"}, {"type": "stdin_stdout", "input": "rrlll\n", "output": "1\n2\n5\n4\n3\n"}, {"type": "stdin_stdout", "input": "lrlrr\n", "output": "2\n4\n5\n3\n1\n"}, {"type": "stdin_stdout", "input": "lllrlrllrl\n", "output": "4\n6\n9\n10\n8\n7\n5\n3\n2\n1\n"}... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Squirrel Liss lived in a forest peacefully, but unexpected... | livecodebench | deepcoder_25 | 25 | [
{
"answer": "s = input()\na = []\nn = len(s)\nfor i in range(n):\n\tif s[i] == 'r':\n\t\tprint(i + 1)\n\telse:\n\t\ta.append(i + 1)\na.reverse()\nfor i in a:\n\tprint(i)\n",
"question": "Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirr... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from 1 to n i... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"llrlr\\n\", \"output\": \"3\\n5\\n4\\n2\\n1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"rrlll\\n\", \"output\": \"1\\n2\\n5\\n4\\n3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\"... | {
"index": 25,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nSquirrel Liss lived in... |
Solve the following coding problem using the programming language python:
Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn t... | [
"```python\n\ndef solve(s):\n n = len(s)\n\n for i in range(n):\n s2 = s[i:] + s[:i]\n # print(s2)\n if s != s2 and s2[::-1] == s2:\n return 1\n\n for i in range( (n // 2) + 1, n):\n if s[i] != s[0]:\n return 2\n # print(s[i])\n return \"Impossibl... | [{"type": "stdin_stdout", "input": "nolon\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "otto\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "qqqq\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "kinnikkinnik\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "nnnnnnnnnnnnnnnnnn... | 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:
Reading books is one of Sasha's passions. Once while he wa... | livecodebench | deepcoder_26 | 26 | [
{
"answer": "```python\ns = input()\nif len(set(s[:len(s) // 2])) <= 1:\n\tprint('Impossible')\n\texit()\nfor i in range(1, len(s)):\n\tn = s[i:] + s[:i]\n\tif n == n[::-1] and n != s:\n\t\tprint(1)\n\t\texit()\nprint(2)\n\n```",
"question": "Solve the following coding problem using the programming language... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nReading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"nolon\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"otto\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"qqqq\\n\", \"output\": \"Impo... | {
"index": 26,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nReading books is one o... |
Solve the following coding problem using the programming language python:
A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are $\frac{n \cdot(n - 1)}{2}$ roads in total. It takes exactly y seconds to traverse any single road.
A spanning tree is... | [
"```python\nfrom collections import defaultdict\nfrom collections import deque\nfrom functools import reduce\nn, x, y = [int(x) for x in input().split()]\nE = defaultdict(set)\nfor i in range(n-1):\n u, v = [int(x) for x in input().split()]\n E[u].add(v)\n E[v].add(u)\n\nif x > y:\n for v in E:\n ... | [{"type": "stdin_stdout", "input": "5 2 3\n1 2\n1 3\n3 4\n5 3\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "5 3 2\n1 2\n1 3\n3 4\n5 3\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "50 23129 410924\n18 28\n17 23\n21 15\n18 50\n50 11\n32 3\n44 41\n50 31\n50 34\n5 14\n36 13\n22 40\n20 9\n9 43\n19 47\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 group of n cities is connected by a network of roads. Th... | livecodebench | deepcoder_27 | 27 | [
{
"answer": "```python\nfrom collections import defaultdict\nfrom collections import deque\nfrom functools import reduce\nn, x, y = [int(x) for x in input().split()]\nE = defaultdict(set)\nfor i in range(n-1):\n u, v = [int(x) for x in input().split()]\n E[u].add(v)\n E[v].add(u)\n\nif x > y:\n for ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nA group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are <image> roads in total. It takes exactly y seconds to ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 2 3\\n1 2\\n1 3\\n3 4\\n5 3\\n\", \"output\": \"9\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 3 2\\n1 2\\n1 3\\n3 4\\n5 3\\n\", \"output\": \"8\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_std... | {
"index": 27,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nA group of n cities is... |
Solve the following coding problem using the programming language python:
Dreamoon likes coloring cells very much.
There is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.
You are given an integer $m$ and $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \le l... | [
"```python\ndef main():\n import sys\n input = sys.stdin.readline\n\n N, M = list(map(int, input().split()))\n L = list(map(int, input().split()))\n\n if sum(L) < N:\n print(-1)\n return\n\n ans = [0] * M\n left = N\n for i in range(M-1, -1, -1):\n if left - L[i] >= i:\n... | [{"type": "stdin_stdout", "input": "5 3\n3 2 2\n", "output": "1 2 4\n"}, {"type": "stdin_stdout", "input": "10 1\n1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 2\n1 2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "200 50\n49 35 4... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Dreamoon likes coloring cells very much.
There is a row o... | livecodebench | deepcoder_28 | 28 | [
{
"answer": "(n, m, *l) = map(int, open(0).read().split())\nif sum(l) < n or any((i + x > n for (i, x) in enumerate(l))):\n\tprint(-1)\n\texit()\nfor i in range(m - 1):\n\tl[-i - 2] += l[-i - 1]\nprint(*[max(i + 1, n - l[i] + 1) for i in range(m)])\n",
"question": "Dreamoon likes coloring cells very much.\n... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Dreamoon likes coloring cells very much.\n\nThere is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.\n\nYou are given an integer $m$ and $m$ integers $l_1, l_2, \\ldots, l_m$ ($1 \\le l_i \\le... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 3\\n3 2 2\\n\", \"output\": \"1 2 4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10 1\\n1\\n\", \"output\": \"-1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1 1\\n1\\n\", ... | {
"index": 28,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nDreamoon likes colorin... |
Solve the following coding problem using the programming language python:
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a_0 = v, a_1, ..., a_{k}, and b_0 = v, b_1, ..., b_{k}. Additionally, vertices a_1, .... | [
"```python\nimport math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return list(map(int, input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\n\ndef m... | [{"type": "stdin_stdout", "input": "6\n1 2\n2 3\n2 4\n4 5\n1 6\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 2\n1 3\n3 4\n1 5\n5 6\n6 7\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3 1\n1 2\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:
Vanya wants to minimize a tree. He can perform the followi... | livecodebench | deepcoder_29 | 29 | [
{
"answer": "```python\nimport math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return list(map(int, input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return in... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nVanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"6\\n1 2\\n2 3\\n2 4\\n4 5\\n1 6\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"7\\n1 2\\n1 3\\n3 4\\n1 5\\n5 6\\n6 7\\n\", \"output\": \"-1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": ... | {
"index": 29,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nVanya wants to minimiz... |
Solve the following coding problem using the programming language python:
Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should mat... | [
"```python\nh = int(input())\na = list(map(int, input().split()))\n\nw, q = [], []\np = r = 0\n\nfor i in a:\n for j in range(i):\n w.append(r)\n q.append(r - (j and p > 1))\n\n p = i\n r += i\n\nif w == q:\n print('perfect')\nelse:\n print('ambiguous')\n print(*w)\n print(*q)\n\n... | [{"type": "stdin_stdout", "input": "2\n1 1 1\n", "output": "perfect\n"}, {"type": "stdin_stdout", "input": "2\n1 2 2\n", "output": "ambiguous\n0 1 1 3 3\n0 1 1 3 2\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 1 1 1 1 1 1 1 1\n", "output": "perfect\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 1 1 2 1 1 1 1 1\n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Sasha is taking part in a programming competition. In one ... | livecodebench | deepcoder_30 | 30 | [
{
"answer": "```python\nh = int(input())\na = list(map(int, input().split()))\np, c, f = 0, 0, False\ns1, s2 = [], []\nfor i in a:\n for j in range(i):\n s1.append(c)\n if j==i-1 and not f and p>=2 and i>=2:\n f = True\n s2.append(c-1)\n else:\n s2.append... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nSasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, b... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n1 1 1\\n\", \"output\": \"perfect\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n1 2 2\\n\", \"output\": \"ambiguous\\n0 1 1 3 3\\n0 1 1 3 2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdou... | {
"index": 30,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nSasha is taking part i... |
Solve the following coding problem using the programming language python:
You are given $n$ points on the plane. The polygon formed from all the $n$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $1... | [
"```python\nimport sys\ninput = sys.stdin.readline\n\nn = int(input())\nx = []\ny = []\nfor i in range(n):\n xi, yi = map(int, input().split())\n x.append(xi)\n y.append(yi)\nmin_x = min(x)\nmax_x = max(x)\nmin_y = min(y)\nmax_y = max(y)\nanswer = 0\nfor i in range(n):\n dx = max(max_x - x[i], x[i] - mi... | [{"type": "stdin_stdout", "input": "4\n2 4\n4 3\n3 0\n1 3\n", "output": "12 14 "}, {"type": "stdin_stdout", "input": "3\n0 0\n0 2\n2 0\n", "output": "8 "}, {"type": "stdin_stdout", "input": "8\n0 3\n2 2\n3 0\n2 -2\n0 -3\n-2 -2\n-3 0\n-2 2\n", "output": "20 24 24 24 24 24 "}, {"type": "stdin_stdout", "input": "4\n-10000... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given $n$ points on the plane. The polygon formed ... | livecodebench | deepcoder_31 | 31 | [
{
"answer": "```python\nn = int(input())\nnorth = -100000000\nsouth = 100000000\neast = -100000000\nwest = 100000000\nne = -200000000\nnw = -200000000\nse = -200000000\nsw = -200000000\nfor i in range(n):\n\t(x, y) = map(int, input().split())\n\tnorth = max(north, y)\n\teast = max(east, x)\n\tsouth = min(south,... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n2 4\\n4 3\\n3 0\\n1 3\\n\", \"output\": \"12 14 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n0 0\\n0 2\\n2 0\\n\", \"output\": \"8 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input... | {
"index": 31,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given $n$ poin... |
Solve the following coding problem using the programming language python:
The biggest event of the year – Cota 2 world championship "The Innernational" is right around the corner. $2^n$ teams will compete in a double-elimination format (please, carefully read problem statement even if you know what is it) to identify ... | [
"```python\nimport sys\ninput = sys.stdin.readline\n\nn,k=list(map(int,input().split()))\nif k==0:\n print(0)\n return\n\nA=sorted(map(int,input().split()))\n\n# DP[UL][n][left]\n# [left*pow(2,n),left*pow(2,n)+pow(2,n))の間のチームで,\n# ファンのチームが\n# UL=0: upperでもlowerでも勝ち残っている\n# UL=1: upperでのみ勝ち残っている\n# UL=2: lower... | [{"type": "stdin_stdout", "input": "3 1\n6\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3 3\n1 7 8\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "3 4\n1 3 5 7\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "10 10\n334 588 666 787 698 768 934 182 39 834\n", "output": "138\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:
The biggest event of the year – Cota 2 world championship ... | livecodebench | deepcoder_32 | 32 | [
{
"answer": "import sys\ninput = sys.stdin.readline\n(n, k) = list(map(int, input().split()))\nif k == 0:\n\tprint(0)\n\treturn\nA = sorted(map(int, input().split()))\nDP = [[[0] * ((1 << n) + 2) for i in range(n + 1)] for UL in range(3)]\nfor i in range(k):\n\tif A[i] % 2 == 1:\n\t\tDP[1][1][A[i]] = 1\n\t\tDP[... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: The biggest event of the year – Cota 2 world championship \"The Innernational\" is right around the corner. $2^n$ teams will compete in a double-elimination format (please, carefully read problem statement even if you know what is it) to identify the champio... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 1\\n6\\n\", \"output\": \"6\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 3\\n1 7 8\\n\", \"output\": \"11\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 4\\n1 3 5 7\\n\",... | {
"index": 32,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThe biggest event of t... |
Solve the following coding problem using the programming language python:
You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator.
Today you are late, so there are queues on some floors already. For each person you know... | [
"```python\n# python3\nimport sys\nfrom collections import namedtuple\n\n\ndef readline(): return list(map(int, input().split()))\n\n\ndef readlines():\n for line in sys.stdin.readlines():\n yield list(map(int, line.split()))\n\n\nclass State(namedtuple('State', 'payload time floor')):\n def hook(self,... | [{"type": "stdin_stdout", "input": "2\n3 5\n5 3\n", "output": "10"}, {"type": "stdin_stdout", "input": "2\n5 3\n3 5\n", "output": "12"}, {"type": "stdin_stdout", "input": "9\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 1\n", "output": "34"}, {"type": "stdin_stdout", "input": "50\n9 5\n2 6\n5 4\n7 5\n3 6\n5 8\n1 2\n6 1\n9... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You work in a big office. It is a 9 floor building with an... | livecodebench | deepcoder_33 | 33 | [
{
"answer": "```python\n# python3\nimport sys\nfrom collections import namedtuple\n\n\ndef readline(): return map(int, input().split())\n\n\ndef readlines():\n for line in sys.stdin.readlines():\n yield map(int, line.split())\n\n\nclass State(namedtuple('State', 'payload time floor')):\n def hook(s... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator.\n\nToday you are late, so... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n3 5\\n5 3\\n\", \"output\": \"10\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n5 3\\n3 5\\n\", \"output\": \"12\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"9\\n1 2\\n2 3\\n... | {
"index": 33,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou work in a big offi... |
Solve the following coding problem using the programming language python:
Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universa... | [
"```python\nimport sys\n\nn, m = [int(x) for x in input().split()]\n\nadj_for = [[] for _ in range(n)]\nadj_back = [[] for _ in range(n)]\n\nfor _ in range(m):\n a, b = [int(x) for x in sys.stdin.readline().split()]\n a -= 1\n b -= 1\n adj_for[a].append(b)\n adj_back[b].append(a)\n\n\nlens = [len(adj... | [{"type": "stdin_stdout", "input": "2 1\n1 2\n", "output": "1\nAE\n"}, {"type": "stdin_stdout", "input": "4 3\n1 2\n2 3\n3 1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 2\n1 3\n2 3\n", "output": "2\nAAE\n"}, {"type": "stdin_stdout", "input": "6 3\n1 3\n2 5\n4 6\n", "output": "3\nAAEAEE\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:
Logical quantifiers are very useful tools for expressing c... | livecodebench | deepcoder_34 | 34 | [
{
"answer": "```python\nimport sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input().strip()\n return(list(s[:len(s)]))\ndef invr():\n return(map(in... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nLogical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2 1\\n1 2\\n\", \"output\": \"1\\nAE\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 3\\n1 2\\n2 3\\n3 1\\n\", \"output\": \"-1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 ... | {
"index": 34,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nLogical quantifiers ar... |
Solve the following coding problem using the programming language python:
Toad Zitz has an array of integers, each integer is between $0$ and $m-1$ inclusive. The integers are $a_1, a_2, \ldots, a_n$.
In one operation Zitz can choose an integer $k$ and $k$ indices $i_1, i_2, \ldots, i_k$ such that $1 \leq i_1 < i_2 <... | [
"```python\nimport sys\ninput = sys.stdin.readline\n\nn,m=list(map(int,input().split()))\nA=list(map(int,input().split()))\n\n\nMIN=0\nMAX=m\n\nwhile MIN!=MAX:\n x=(MIN+MAX)//2\n #print(x,MIN,MAX)\n #print()\n\n M=0\n for a in A:\n #print(a,M)\n if a<=M and a+x>=M:\n continue... | [{"type": "stdin_stdout", "input": "5 3\n0 0 0 1 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 7\n0 6 1 3 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 10\n5 0 5 9 4 6 4 5 0 0\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "4 6\n0 3 5 1\n", "output": "3\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:
Toad Zitz has an array of integers, each integer is betwee... | livecodebench | deepcoder_35 | 35 | [
{
"answer": "import sys\n(N, M) = map(int, input().split(' '))\nA = list(map(int, sys.stdin.readline().split(' ')))\n\ndef check():\n\tlast = 0\n\tfor i in range(N):\n\t\tif A[i] < last:\n\t\t\tif last - A[i] > m:\n\t\t\t\tbreak\n\t\telif A[i] > last:\n\t\t\tif A[i] + m < M or (A[i] + m) % M < last:\n\t\t\t\tla... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Toad Zitz has an array of integers, each integer is between $0$ and $m-1$ inclusive. The integers are $a_1, a_2, \\ldots, a_n$.\n\nIn one operation Zitz can choose an integer $k$ and $k$ indices $i_1, i_2, \\ldots, i_k$ such that $1 \\leq i_1 < i_2 < \\ldots... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 3\\n0 0 0 1 2\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 7\\n0 6 1 3 2\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10 10\\n... | {
"index": 35,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nToad Zitz has an array... |
Solve the following coding problem using the programming language python:
Igor the analyst has adopted n little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into n pieces ... | [
"```python\nn, h = map(int,input().split())\nunit = h*h/n\nfor i in range(1,n):\n print((unit*i)**0.5, end=' ')\n```"
] | [{"type": "stdin_stdout", "input": "3 2\n", "output": "1.154700538379 1.632993161855\n"}, {"type": "stdin_stdout", "input": "2 100000\n", "output": "70710.678118654752\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "0.707106781187\n"}, {"type": "stdin_stdout", "input": "20 17\n", "output": "3.801315561750 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:
Igor the analyst has adopted n little bunnies. As we all k... | livecodebench | deepcoder_36 | 36 | [
{
"answer": "```python\nn = int(input())\nm = [[int(i) for i in input().split()] for i in range(n)]\n\n#l = [ sum(m[i]) for i in range(n) ]\n#l = l.index(max(l))\n\nprint(max([ sum(m[i]) for i in range(n) ]))\n```",
"question": "Solve the following coding problem using the programming language python:\n\nTh... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThere are n points on the plane, (x_1,y_1), (x_2,y_2), …, (x_n,y_n).\n\nYou need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 2\\n\", \"output\": \"1.154700538379 1.632993161855\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 100000\\n\", \"output\": \"70710.678118654752\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdou... | {
"index": 36,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIgor the analyst has a... |
Solve the following coding problem using the programming language python:
The life goes up and down, just like nice sequences. Sequence t_1, t_2, ..., t_{n} is called nice if the following two conditions are satisfied: t_{i} < t_{i} + 1 for each odd i < n; t_{i} > t_{i} + 1 for each even i < n.
For example, seque... | [
"```python\ndef main():\n n, l = int(input()), list(map(int, input().split()))\n if not (n & 1):\n l.append(0)\n l.append(150001)\n i, b, c, fails0, fails1 = 0, 0, 150001, [], []\n try:\n while True:\n a, b, c = b, c, l[i]\n if a >= b or b <= c:\n if... | [{"type": "stdin_stdout", "input": "5\n2 8 4 7 7\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n200 150 100 50\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10\n3 2 1 4 1 4 1 4 1 4\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "9\n1 2 3 4 5 6 7 8 9\n", "output": "0\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:
The life goes up and down, just like nice sequences. Seque... | livecodebench | deepcoder_37 | 37 | [
{
"answer": "```python\ndef main():\n n, l = int(input()), list(map(int, input().split()))\n if not (n & 1):\n l.append(0)\n l.append(150001)\n a, b, fails, res = 0, 150001, [], 0\n for i, c in enumerate(l, -1):\n if i & 1:\n if a >= b or b <= c:\n if len(f... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThe life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two conditions are satisfied: \n\n * ti < ti + 1 for each odd i < n; \... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5\\n2 8 4 7 7\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n200 150 100 50\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10\\n3 ... | {
"index": 37,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThe life goes up and d... |
Solve the following coding problem using the programming language python:
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Simila... | [
"```python\ndef main():\n n, a, b, t = list(map(int, input().split()))\n a1 = a + 1\n b += a1\n l, res = [b if c == \"w\" else a1 for c in input()], []\n l[0] = x = l[0] - a\n if t <= x:\n print(int(t == x))\n return\n f = res.append\n for dr in 0, 1:\n if dr:\n ... | [{"type": "stdin_stdout", "input": "4 2 3 10\nwwhw\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 2 4 13\nhhwhh\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5 2 4 1000\nhhwhh\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "3 1 100 10\nwhw\n", "output": "0\n"}, {"type": "stdin_stdout", "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Vasya's telephone contains n photos. Photo number 1 is cur... | livecodebench | deepcoder_38 | 38 | [
{
"answer": "```python\nimport bisect\n\ndef preview(n, a, b, t, S):\n\tt -= b + 1 if S[0] else 1\n\tS[0] = False\n\tif t < 0:\n\t\treturn 0\n\tR = []\n\ts = 0\n\tfor i in range(1, n):\n\t\ts += a + (b + 1 if S[i] else 1)\n\t\tif s > t:\n\t\t\tbreak\n\t\tR.append(s)\n\telse:\n\t\treturn n\n\tL = []\n\ts = 0\n\t... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nVasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. I... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 2 3 10\\nwwhw\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 2 4 13\\nhhwhh\\n\", \"output\": \"4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 2 4 1... | {
"index": 38,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nVasya's telephone cont... |
Solve the following coding problem using the programming language python:
Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e.... | [
"```python\nn = int(input())\narr = []\nfor i in range(n):\n l,r = map(int, input().split())\n arr.append([l,r])\n \nlts = []\nfor i in range(n):\n if arr[i][0] == 0:\n l = i\n j = i\n while arr[j][1] != 0:\n j = arr[j][1] - 1\n r = j\n lts.append([l,r])\n\n... | [{"type": "stdin_stdout", "input": "7\n4 7\n5 0\n0 0\n6 1\n0 2\n0 4\n1 0\n", "output": "4 7\n5 6\n0 5\n6 1\n3 2\n2 4\n1 0\n"}, {"type": "stdin_stdout", "input": "2\n2 0\n0 1\n", "output": "2 0\n0 1\n"}, {"type": "stdin_stdout", "input": "1\n0 0\n", "output": "0 0\n"}, {"type": "stdin_stdout", "input": "4\n0 2\n1 0\n0 4... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Doubly linked list is one of the fundamental data structur... | livecodebench | deepcoder_39 | 39 | [
{
"answer": "```python\nif __name__=='__main__':\n\tn=int(input())\n\tdl=[[0,0]]\n\tend=0\n\tfor i in range(n):\n\t\tdl.append(list(map(int,input().split())))\n\tfor i in range(1,n+1):\n\t\tif not dl[i][0]:\n\t\t\tdl[end][1]=i\n\t\t\tdl[i][0]=end\n\t\t\tj=i\n\t\t\twhile(dl[j][1]):\n\t\t\t\t#print(dl[j])\n\t\t\t... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nDoubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"7\\n4 7\\n5 0\\n0 0\\n6 1\\n0 2\\n0 4\\n1 0\\n\", \"output\": \"4 7\\n5 6\\n0 5\\n6 1\\n3 2\\n2 4\\n1 0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n2 0\\n0 1\\n\", \"output\": \"2 0\\n0 1\\n\", \"metadata\": {\... | {
"index": 39,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nDoubly linked list is ... |
Solve the following coding problem using the programming language python:
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're just a simple peasant. There'... | [
"```python\nn, m = map(int, input().split())\np, d = [0] * (n + 2), [0] * (n + 2)\nfor i in range(m):\n l, r, x = map(int, input().split())\n while l < x:\n if d[l]:\n k = d[l]\n d[l] = x - l\n l += k\n else:\n d[l], p[l] = x - l, x\n l += 1... | [{"type": "stdin_stdout", "input": "4 3\n1 2 1\n1 3 3\n1 4 4\n", "output": "3 1 4 0 "}, {"type": "stdin_stdout", "input": "8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1\n", "output": "0 8 4 6 4 8 6 1 "}, {"type": "stdin_stdout", "input": "2 1\n1 2 1\n", "output": "0 1 "}, {"type": "stdin_stdout", "input": "2 1\n1 2 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:
Hooray! Berl II, the king of Berland is making a knight to... | livecodebench | deepcoder_40 | 40 | [
{
"answer": "```python\n(n, m) = map(int, input().split())\n(p, d) = ([0] * (n + 2), list(range(1, n + 3)))\nfor i in range(m):\n\t(l, r, x) = map(int, input().split())\n\twhile l < x:\n\t\tif p[l]:\n\t\t\tk = d[l]\n\t\t\td[l] = x\n\t\t\tl = k\n\t\telse:\n\t\t\t(d[l], p[l]) = (x, x)\n\t\t\tl += 1\n\tl += 1\n\tr... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nHooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in thi... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 3\\n1 2 1\\n1 3 3\\n1 4 4\\n\", \"output\": \"3 1 4 0 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"8 4\\n3 5 4\\n3 7 6\\n2 8 8\\n1 8 1\\n\", \"output\": \"0 8 4 6 4 8 6 1 \", \"metadata\": {\"func_name\": null}}, {\... | {
"index": 40,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nHooray! Berl II, the k... |
Solve the following coding problem using the programming language python:
Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange them, h... | [
"```python\ndef main():\n n, k = map(int, input().split())\n a, b, c, d = (list(map(int, input().split())) for _ in 'abcd')\n ss, tt, n2, res = [*b, *c[::-1]], [*a, *d[::-1]], n * 2, []\n yx = [*[(2, i + 1) for i in range(n)], *[(3, i) for i in range(n, 0, -1)]]\n\n def park():\n for i, s, t, ... | [{"type": "stdin_stdout", "input": "4 5\n1 2 0 4\n1 2 0 4\n5 0 0 3\n0 5 0 3\n", "output": "6\n1 1 1\n2 1 2\n4 1 4\n3 4 4\n5 3 2\n5 4 2\n"}, {"type": "stdin_stdout", "input": "1 2\n1\n2\n1\n2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1 2\n1\n1\n2\n2\n", "output": "2\n1 1 1\n2 4 1\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:
Allen dreams of one day owning a enormous fleet of electri... | livecodebench | deepcoder_41 | 41 | [
{
"answer": "```python\nn, k = map(int, input().split())\n\ngrid = [\n list(map(int, input().split()))\n for _ in range(4)\n]\n\n\npossible = True\nif all(c != 0 for cars in (grid[1], grid[2]) for c in cars):\n if all(a != b for (a, b) in zip(grid[0], grid[1])):\n if all(a != b for (a, b) in zip... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nAllen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the dif... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 5\\n1 2 0 4\\n1 2 0 4\\n5 0 0 3\\n0 5 0 3\\n\", \"output\": \"6\\n1 1 1\\n2 1 2\\n4 1 4\\n3 4 4\\n5 3 2\\n5 4 2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1 2\\n1\\n2\\n1\\n2\\n\", \"output\": \"-1\\n\", \"metad... | {
"index": 41,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nAllen dreams of one da... |
Solve the following coding problem using the programming language python:
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.
There are n citizens in Kekoland, each person has c_{i} coins. Each day, Robin Hood will ta... | [
"```python\nimport sys\n\nn, k = map(int, sys.stdin.readline().split())\nnums = list(map(int, sys.stdin.readline().split()))\ntotal = sum(nums)\navg = int(total / n)\n\ndef check1(nums, target, K):\n for x in nums:\n if K < 0:\n return False\n if x < target:\n K -= target - x\... | [{"type": "stdin_stdout", "input": "4 1\n1 1 4 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 1\n2 2 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 20\n6 4 7 10 4 5 5 3 7 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "30 7\n3 3 2 2 2 2 3 4 4 5 2 1 1 5 5 3 4 3 2 1 3 4 3 2 2 5 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:
We all know the impressive story of Robin Hood. Robin Hood... | livecodebench | deepcoder_42 | 42 | [
{
"answer": "```python\nimport sys\nsys.stderr = sys.stdout\n\ndef hood(n, k, C):\n\tC.sort()\n\t(m, r) = divmod(sum(C), n)\n\tm1 = m + 1 if r else m\n\tc_lo = C[0]\n\tk_lo = k\n\tfor (i, c) in enumerate(C):\n\t\tif c_lo == m:\n\t\t\tbreak\n\t\tc_m = min(c, m)\n\t\tdc = c_m - c_lo\n\t\tdk = i * dc\n\t\tif k_lo ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nWe all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.\n\nThere are n citizens in K... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 1\\n1 1 4 2\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 1\\n2 2 2\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10 20\\n6 4 7 ... | {
"index": 42,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nWe all know the impres... |
Solve the following coding problem using the programming language python:
Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.
Initially, Bob chooses integer m, bit depth of the game, which means that all numbers in the game will cons... | [
"```python\nimport sys\ndef calc(b0, b1, q):\n if q == 0:\n return b0 ^ b1\n if q == 1:\n return b0 | b1\n if q == 2:\n return b0 & b1\nn, m = list(map(int,sys.stdin.readline().split()))\narr1 = {}\nopt = ['XOR', 'OR', 'AND']\narr2 = []\nfor j in range(n):\n a, b = list(map(str,sys.... | [{"type": "stdin_stdout", "input": "3 3\na := 101\nb := 011\nc := ? XOR b\n", "output": "011\n100\n"}, {"type": "stdin_stdout", "input": "5 1\na := 1\nbb := 0\ncx := ? OR a\nd := ? XOR ?\ne := d AND bb\n", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "2 10\nb := 0100101101\na := ? XOR b\n", "output": "0100101... | 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:
Bob recently read about bitwise operations used in compute... | livecodebench | deepcoder_43 | 43 | [
{
"answer": "```python\n#from math import *\nfrom sys import *\nfrom decimal import *\n\ndef main():\n n,k=(int(z) for z in stdin.readline().split())\n d=[]\n nm=[0]*n\n bt1=[False]*(n+1)\n bt2=[False]*(n+1)\n bt2[-1]=True\n nam=dict()\n nam[\"?\"]=-1\n for i in range(n):\n fl=... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nBob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.\n\nInitially, Bob chooses integer m, bit dep... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 3\\na := 101\\nb := 011\\nc := ? XOR b\\n\", \"output\": \"011\\n100\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 1\\na := 1\\nbb := 0\\ncx := ? OR a\\nd := ? XOR ?\\ne := d AND bb\\n\", \"output\": \"0\\n0\\n\"... | {
"index": 43,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nBob recently read abou... |
Solve the following coding problem using the programming language python:
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.
Metropolis airport is the main transport h... | [
"```python\nfrom heapq import heappush,heappop,heapify\nn,k=map(int,input().split())\n*l,=map(int,input().split())\nq=[(-l[i],i)for i in range(k)];heapify(q)\na=[0]*n\ns=0\nfor i in range(k,n):\n heappush(q,(-l[i],i))\n x,j=heappop(q)\n s-=x*(i-j)\n a[j]=i+1\nfor i in range(n,n+k):\n x,j=heappop(q)\n... | [{"type": "stdin_stdout", "input": "5 2\n4 2 1 10 2\n", "output": "20\n3 6 7 4 5 \n"}, {"type": "stdin_stdout", "input": "3 2\n3 1 2\n", "output": "11\n3 5 4 \n"}, {"type": "stdin_stdout", "input": "5 5\n5 5 9 100 3\n", "output": "321\n9 8 7 6 10 \n"}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "1\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:
Helen works in Metropolis airport. She is responsible for ... | livecodebench | deepcoder_44 | 44 | [
{
"answer": "```python\nfrom heapq import heappush,heappop,heapify\nn,k=map(int,input().split())\n*l,=map(int,input().split())\nq=[(-l[i],i)for i in range(k)]\nheapify(q)\na=[0]*n\ns=0\nfor i in range(k,n) :\n heappush(q,(-l[i],i))\n x,j=heappop(q)\n s-=x*(i-j)\n a[j]=i+1\nfor i in range(n,n+k) :\n ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nHelen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-t... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 2\\n4 2 1 10 2\\n\", \"output\": \"20\\n3 6 7 4 5 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 2\\n3 1 2\\n\", \"output\": \"11\\n3 5 4 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", ... | {
"index": 44,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nHelen works in Metropo... |
Solve the following coding problem using the programming language python:
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute ... | [
"```python\nn, m = list(map(int, input().split()))\nused = [1] * 2 * n\nfor i in range(m):\n\tx, y = list(map(int, input().split()))\n\tused[x - 1] = used[n + y - 1] = 0\n\t\nif n % 2 and used[n // 2]:\n\tused[n // 2 + n] = 0\nres = sum(used)\nfor i in [0, n - 1, n, 2 * n - 1]:\n\tres -= used[i]\nprint(res)\n\n\n``... | [{"type": "stdin_stdout", "input": "3 1\n2 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4 3\n3 1\n3 2\n3 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 1\n1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 3\n1 2\n2 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:
Gerald plays the following game. He has a checkered field ... | livecodebench | deepcoder_45 | 45 | [
{
"answer": "```python\nn, m = tuple(map(int, input().split(' ')))\nvb = set()\nhb = set()\nfor k in range(m):\n\ti, j = tuple(map(int, input().split(' ')))\n\thb.add(i-1)\n\tvb.add(j-1)\nc = 0\nfor i in range(1, n//2):\n\tc += 1 if i not in hb else 0\n\tc += 1 if n-i-1 not in hb else 0\n\tc += 1 if i not in vb... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nGerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not c... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 1\\n2 2\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 0\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 3\\n3 1\\n3 2\\n3 3\\n\"... | {
"index": 45,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nGerald plays the follo... |
Solve the following coding problem using the programming language python:
$n$ boys and $m$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $1$ to $n$ and all girls are numbered with integers from $1$ to $m$. For all $1 \leq i... | [
"```python\nn,m=map(int,input().split())\nb=list(map(int,input().split()))\ng=list(map(int,input().split()))\nif max(b)>min(g):\n print(-1)\nelse:\n maxi=0\n maxi2=0\n for guy in b:\n if guy>maxi:\n maxi2,maxi=maxi,guy\n elif guy>maxi2:\n maxi2=guy\n sumi=m*sum(b)+... | [{"type": "stdin_stdout", "input": "3 2\n1 2 1\n3 4\n", "output": "12"}, {"type": "stdin_stdout", "input": "2 2\n0 1\n1 0\n", "output": "-1"}, {"type": "stdin_stdout", "input": "2 3\n1 0\n1 1 2\n", "output": "4"}, {"type": "stdin_stdout", "input": "2 2\n0 0\n100000000 100000000\n", "output": "200000000"}, {"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:
$n$ boys and $m$ girls came to the party. Each boy present... | livecodebench | deepcoder_46 | 46 | [
{
"answer": "from sys import stdin, stdout\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: $n$ boys and $m$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $1$ to $n$ and all girls are numbered with integers from $1$ to $m$. For all $1 \\leq i \\leq n$ th... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 2\\n1 2 1\\n3 4\\n\", \"output\": \"12\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 2\\n0 1\\n1 0\\n\", \"output\": \"-1\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 3\\n1 0\... | {
"index": 46,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\n$n$ boys and $m$ girls... |
Solve the following coding problem using the programming language python:
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color c_{i}.
Now it's time for Timofey birthday, and his mother asked him to remov... | [
"```python\ndef main():\n n = int(input())\n edges = []\n for _ in range(n - 1):\n u, v = list(map(int, input().split()))\n u -= 1\n v -= 1\n edges.append((u, v))\n\n colors = list(map(int, input().split()))\n suspect = [(u, v) for (u, v) in edges if colors[u] != colors[v]... | [{"type": "stdin_stdout", "input": "4\n1 2\n2 3\n3 4\n1 2 1 1\n", "output": "YES\n2"}, {"type": "stdin_stdout", "input": "3\n1 2\n2 3\n1 2 3\n", "output": "YES\n2"}, {"type": "stdin_stdout", "input": "4\n1 2\n2 3\n3 4\n1 2 1 2\n", "output": "NO"}, {"type": "stdin_stdout", "input": "3\n2 1\n2 3\n1 2 3\n", "output": "YES... | 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 New Year Timofey and his friends cut down a tree of n... | livecodebench | deepcoder_47 | 47 | [
{
"answer": "```python\ndef main():\n\tn = int(input())\n\tpairs = []\n\tfor i in range(n - 1):\n\t\t(a, b) = list(map(int, input().split()))\n\t\tpairs.append([a - 1, b - 1])\n\tcolors = list(map(int, input().split()))\n\tbad_pairs_count = 0\n\tbad_points_counts = {0: 0}\n\tfor (a, b) in pairs:\n\t\tif colors[... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nEach New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.\n\nNow it... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n1 2\\n2 3\\n3 4\\n1 2 1 1\\n\", \"output\": \"YES\\n2\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n1 2\\n2 3\\n1 2 3\\n\", \"output\": \"YES\\n2\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdou... | {
"index": 47,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nEach New Year Timofey ... |
Solve the following coding problem using the programming language python:
Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type "d_{i} → t_{i}", that means "replace all digits d_{i} in string s with substrings equal to t_{i}". For examp... | [
"```python\nMOD = 10**9+7\n\ns = input()\nn = int(input())\nqs = [['',s]]+[input().split('->') for i in range(n)]\n\nds = {}\nfor i in range(10):\n ds[str(i)] = (10,i)\n\nfor i in range(n,-1,-1):\n out = 0\n mul = 1\n for d in qs[i][1]:\n out = (out * ds[d][0] + ds[d][1]) % MOD\n mul = (mu... | [{"type": "stdin_stdout", "input": "123123\n1\n2->00\n", "output": "10031003\n"}, {"type": "stdin_stdout", "input": "123123\n1\n3->\n", "output": "1212\n"}, {"type": "stdin_stdout", "input": "222\n2\n2->0\n0->7\n", "output": "777\n"}, {"type": "stdin_stdout", "input": "1000000008\n0\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:
Andrew and Eugene are playing a game. Initially, Andrew ha... | livecodebench | deepcoder_48 | 48 | [
{
"answer": "```python\nmod=pow(10,9)+7\ndef sub_and_eval(n):\n if n=='':\n return 0\n ans=v[int(n[0])]\n for i in range(1,len(n)):\n ans=(d[int(n[i])]*ans+v[int(n[i])])%mod\n return ans\ndef prod_d(n):\n ans=1\n for e in n:\n ans=ans*d[int(e)]%mod\n return ans\ns=input... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nAndrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type \"di → ti\", that means \"replace all digits... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"123123\\n1\\n2->00\\n\", \"output\": \"10031003\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"123123\\n1\\n3->\\n\", \"output\": \"1212\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input... | {
"index": 48,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nAndrew and Eugene are ... |
Solve the following coding problem using the programming language python:
You are given two binary strings $a$ and $b$ of the same length. You can perform the following two operations on the string $a$:
Swap any two bits at indices $i$ and $j$ respectively ($1 \le i, j \le n$), the cost of this operation is $|i - j... | [
"```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": "3\n100\n001\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n0101\n0011\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "8\n10001001\n01101110\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1\n0\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given two binary strings $a$ and $b$ of the same l... | livecodebench | deepcoder_49 | 49 | [
{
"answer": "```python\ndef solve(n, a, b):\n ans = 0\n i = 0\n while i < n:\n if a[i] != b[i]:\n if i < n-1 and a[i+1] != b[i+1] and a[i+1] != a[i]:\n ans += 1\n i += 2\n else:\n ans += 1\n i += 1\n else:\n... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou are given two binary strings a and b of the same length. You can perform the following two operations on the string a:\n\n * Swap any two bits at indices i and j respectively (... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n100\\n001\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n0101\\n0011\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"8\\n100010... | {
"index": 49,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given two bina... |
Solve the following coding problem using the programming language python:
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the mi... | [
"```python\n\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\n# so the ending sequence is b...ba...a\n\n# find length of ending sequence\n\nextra=0\nneed=0\nfor ch in input().strip():\n if ch=='a':\n need=(need*2+1)%1000000007\n else:\n extra=(extra+need)%1000000007\n\npri... | [{"type": "stdin_stdout", "input": "ab\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "aab\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "aaaaabaabababaaaaaba\n", "output": "17307\n"}, {"type": "stdin_stdout", "input": "abaabaaabbabaabab\n", "output": "1795\n"}, {"type": "stdin_stdout", "input": "abb... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
We have a string of letters 'a' and 'b'. We want to perfor... | livecodebench | deepcoder_50 | 50 | [
{
"answer": "```python\ndef mess():\n\tString = input()\n\tcount_it = 0\n\tCounter = 0\n\tfor i in String:\n\t\tif i == 'a':\n\t\t\tcount_it = count_it * 2 % Modulo\n\t\t\tcount_it += 1\n\t\telif i == 'b':\n\t\t\tCounter += count_it\n\treturn Counter\nModulo = 1000000007\nprint(mess() % Modulo)\n\n```",
"qu... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nWe have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings \"ab\" in the string and replace it with the string \"bba... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"ab\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"aab\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"aaaaabaabababaaaaaba\\n\", \"outp... | {
"index": 50,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nWe have a string of le... |
Solve the following coding problem using the programming language python:
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the... | [
"```python\nimport heapq\nn = int(input())\nd = list(map(int,input().split()))\npq = [-d[0]]\nheapq.heapify(pq)\nans = 0\nfor i in range(1,n):\n temp = i - d[i]\n heapq.heappush(pq,temp)\n if heapq.nsmallest(1,pq)[0] < temp:\n ans += temp - heapq.nsmallest(1,pq)[0]\n heapq.heappushpop(pq,temp... | [{"type": "stdin_stdout", "input": "7\n2 1 5 11 5 9 11\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "5\n5 4 3 2 1\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "2\n1 1000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n1000 1\n", "output": "1000\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:
Sonya was unable to think of a story for this problem, so ... | livecodebench | deepcoder_51 | 51 | [
{
"answer": "```python\nN = int(input())\ns = list(map(int, input().split()))\nfor i in range(N):\n\ts[i] -= i\nX = sorted(s)\ndp = [0] * N\nfor i in s:\n\tmi = 7e+77\n\tfor j in range(N):\n\t\tmi = min(mi, dp[j])\n\t\tdp[j] = mi + abs(i - X[j])\nprint(min(dp))\n\n```",
"question": "Solve the following codi... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nSonya was unable to think of a story for this problem, so here comes the formal description.\n\nYou are given the array containing n positive integers. At one turn you can pick any ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"7\\n2 1 5 11 5 9 11\\n\", \"output\": \"9\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n5 4 3 2 1\\n\", \"output\": \"12\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n1... | {
"index": 51,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nSonya was unable to th... |
Solve the following coding problem using the programming language python:
Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k... | [
"```python\ndef f(m):\n nonlocal dp, sdp\n l = 0\n for i in range(n):\n while l < n and v[l] < v[i] - m:\n l += 1\n if l - 1 > i - k:\n dp[i] = False\n else:\n dp[i] = (sdp[i - k + 1] != sdp[l - 1])\n sdp[i + 1] = sdp[i] + (1 if dp[i] else 0)\n ... | [{"type": "stdin_stdout", "input": "5 2\n50 110 130 40 120\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "4 1\n2 3 4 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1\n4\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 2\n7 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 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:
Evlampiy has found one more cool application to process ph... | livecodebench | deepcoder_52 | 52 | [
{
"answer": "```python\nfrom bisect import bisect_left, bisect_right\n\n\nclass Result:\n def __init__(self, index, value):\n self.index = index\n self.value = value\n\n\nclass BinarySearch:\n def __init__(self):\n pass\n\n @staticmethod\n def greater_than(num: int, func, size: ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nEvlampiy has found one more cool application to process photos. However the application has certain limitations.\n\nEach photo i has a contrast vi. In order for the processing to be... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 2\\n50 110 130 40 120\\n\", \"output\": \"20\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 1\\n2 3 4 1\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1... | {
"index": 52,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nEvlampiy has found one... |
Solve the following coding problem using the programming language python:
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows... | [
"```python\nrd = lambda: list(map(int, input().split()))\n\ndef root(x):\n if f[x]!=x: f[x] = root(f[x])\n return f[x]\n\nn, m = rd()\nN = list(range(n))\nf = list(N)\nlang = [0]*n\nfor i in N: lang[i] = set(rd()[1:])\nfor i in N:\n for j in N[:i]:\n rj = root(j)\n if lang[rj].intersection(lang[i]):\n ... | [{"type": "stdin_stdout", "input": "5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 2\n1 2\n0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 2\n0\n0\n", ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The "BerCorp" company has got n employees. These employees... | livecodebench | deepcoder_53 | 53 | [
{
"answer": "```python\nclass UnionFind:\n\n\tdef __init__(self, n, m):\n\t\tself.data = [i for i in range(n + m)]\n\t\tself.size = [0] * (m + n)\n\n\tdef union(self, u, v):\n\t\tup = self.find(u)\n\t\tvp = self.find(v)\n\t\tif up == vp:\n\t\t\treturn\n\t\tif self.size[up] <= self.size[vp]:\n\t\t\tself.data[up]... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThe \"BerCorp\" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 5\\n1 2\\n2 2 3\\n2 3 4\\n2 4 5\\n1 5\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"8 7\\n0\\n3 1 2 3\\n1 1\\n2 5 4\\n2 6 7\\n1 3\\n2 7 4\\n1 1\\n\", \"output\": \"2\\n\", \"metadata\": {\"fun... | {
"index": 53,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThe \"BerCorp\" compan... |
Solve the following coding problem using the programming language python:
3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is dead or alive
NEKO#ΦωΦ has just got a new maze game on her PC!
The game's main puzzle is a maze, in the forms of a $2 \times n$ rectangle grid. NEKO's task is to lead a Nekomimi girl fro... | [
"```python\nimport sys\nreadline = sys.stdin.readline\n\nN, Q = list(map(int, readline().split()))\nstate = [[False]*(N+2) for _ in range(2)]\n\ncnt = 0\n\nAns = [None]*Q\nfor qu in range(Q):\n r, c = list(map(int, readline().split()))\n r -= 1\n c -= 1\n state[r][c] = not state[r][c]\n res = state[r... | [{"type": "stdin_stdout", "input": "5 5\n2 3\n1 4\n2 4\n2 3\n1 4\n", "output": "Yes\nNo\nNo\nNo\nYes\n"}, {"type": "stdin_stdout", "input": "2 2\n2 1\n1 2\n", "output": "Yes\nNo\n"}, {"type": "stdin_stdout", "input": "2 4\n2 1\n1 2\n1 2\n1 2\n", "output": "Yes\nNo\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "4 1\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:
3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is d... | livecodebench | deepcoder_54 | 54 | [
{
"answer": "```python\nimport sys\ninput = sys.stdin.readline\n(n, q) = [int(item) for item in input().split()]\nblock = [[0] * (n + 6) for _ in range(2)]\nwall = 0\nfor _ in range(q):\n\t(x, y) = [int(item) - 1 for item in input().split()]\n\ty += 3\n\tinvx = (x + 1) % 2\n\tif block[x][y]:\n\t\tblock[x][y] = ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\n[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)\n\n[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/dj-mashiro-is-dea... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 5\\n2 3\\n1 4\\n2 4\\n2 3\\n1 4\\n\", \"output\": \"Yes\\nNo\\nNo\\nNo\\nYes\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 2\\n2 1\\n1 2\\n\", \"output\": \"Yes\\nNo\\n\", \"metadata\": {\"func_name\": null}}, {\... | {
"index": 54,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\n3R2 as DJ Mashiro - Ha... |
Solve the following coding problem using the programming language python:
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.
The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka... | [
"```python\nn, k = [int(c) for c in input().split()]\na = []\nfor i in range(k):\n ak = [int(c) for c in input().split()]\n a.append(ak[1:])\n\ntotal = k - 1\n\nfor ak in a:\n if ak[0] == 1:\n j = 1\n while j <= len(ak) - 1:\n if ak[j] != ak[j-1] + 1:\n break\n ... | [{"type": "stdin_stdout", "input": "3 2\n2 1 2\n1 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "7 3\n3 1 3 7\n2 2 5\n2 4 6\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "1 1\n1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 2\n1 2\n2 1 3\n", "output": "3\n"}, {"type": "stdin_stdout... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Andrewid the Android is a galaxy-famous detective. He is n... | livecodebench | deepcoder_55 | 55 | [
{
"answer": "```python\n(n, m) = [int(x) for x in input().split()]\na = []\nfor i in range(m):\n\ta.append([int(x) for x in input().split()][1:])\nb = []\ncurt = 0\nfor i in a:\n\tj = 0\n\tb.append([])\n\twhile j < len(i) and i[j] == j + 1:\n\t\tj += 1\n\tif j != 0:\n\t\tb[-1] = [j]\n\tb[-1] += [1] * (len(i) - ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\n\nThe main exhibit is a construction of n ma... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 2\\n2 1 2\\n1 3\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"7 3\\n3 1 3 7\\n2 2 5\\n2 4 6\\n\", \"output\": \"10\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"in... | {
"index": 55,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nAndrewid the Android i... |
Solve the following coding problem using the programming language python:
In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and mod... | [
"```python\nimport os\nimport random\nimport sys\nfrom typing import List, Dict\n\n\nclass Int:\n def __init__(self, val):\n self.val = val\n\n def get(self):\n return self.val + 111\n\nclass Unique:\n def __init__(self):\n self.s = set()\n\n def add(self, val : int):\n self.... | [{"type": "stdin_stdout", "input": "6\n0 1 3 7 15 31\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "2\n73 37\n", "output": "36\n"}, {"type": "stdin_stdout", "input": "2\n0 1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "8\n729541013 135019377 88372488 319157478 682081360 558614617... | 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 official contest this problem has a different state... | livecodebench | deepcoder_56 | 56 | [
{
"answer": "```python\nn = int(input())\nn_2 = n // 2\nx = sorted([int(tok) for tok in input().split()])\nres = min((x[j] - x[j - n_2] for j in range(n_2, n)))\nprint(res)\n\n```",
"question": "Solve the following coding problem using the programming language python:\n\nIn the official contest this problem... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nIn the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"6\\n0 1 3 7 15 31\\n\", \"output\": \"7\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n73 37\\n\", \"output\": \"36\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n0 10000... | {
"index": 56,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIn the official contes... |
Solve the following coding problem using the programming language python:
One Big Software Company has n employees numbered from 1 to n. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. The director, of course, doesn't have a superior.
We will ca... | [
"```python\nn = int(input())\nt = [list(map(int, input().split())) for q in range(n)]\nt[0][0] = 0\nn += 1\nu = [-1e7] * n\nv = [0] * n\nfor i, (j, a) in list(enumerate(t, 1))[::-1]:\n u[i] = max(u[i], v[i] + a)\n v[j], u[j] = max(v[j] + v[i], u[j] + u[i]), max(v[j] + u[i], u[j] + v[i])\nprint(u[1])\n```"
] | [{"type": "stdin_stdout", "input": "7\n-1 3\n1 2\n1 1\n1 4\n4 5\n4 3\n5 2\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "1\n-1 42\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "2\n-1 3\n1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n-1 3\n1 1\n1 2\n", "output": "6\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:
One Big Software Company has n employees numbered from 1 t... | livecodebench | deepcoder_57 | 57 | [
{
"answer": "```python\nn = int(input())\nt = [list(map(int, input().split())) for q in range(n)]\nt[0][0] = 0\nn += 1\nu = [-1e7] * n\nv = [0] * n\nfor i, (j, a) in list(enumerate(t, 1))[::-1]:\n u[i] = max(u[i], v[i] + a)\n v[j], u[j] = max(v[j] + v[i], u[j] + u[i]), max(v[j] + u[i], u[j] + v[i])\nprint... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nOne Big Software Company has n employees numbered from 1 to n. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superio... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"7\\n-1 3\\n1 2\\n1 1\\n1 4\\n4 5\\n4 3\\n5 2\\n\", \"output\": \"17\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n-1 42\\n\", \"output\": \"42\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout... | {
"index": 57,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nOne Big Software Compa... |
Solve the following coding problem using the programming language python:
The Fair Nut is going to travel to the Tree Country, in which there are $n$ cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a car ... | [
"```python\nimport sys\nreadline = sys.stdin.readline\n\nfrom collections import Counter \n\ndef getpar(Edge, p):\n N = len(Edge)\n par = [0]*N\n par[0] = -1\n par[p] -1\n stack = [p]\n visited = set([p])\n while stack:\n vn = stack.pop()\n for vf in Edge[vn]:\n if vf ... | [{"type": "stdin_stdout", "input": "3\n1 3 3\n1 2 2\n1 3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n6 3 2 5 0\n1 2 10\n2 3 3\n2 4 1\n1 5 1\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "1\n42\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "10\n11 43 11 96 18 53 25 89 31 41\n2 4 41... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
The Fair Nut is going to travel to the Tree Country, in wh... | livecodebench | deepcoder_58 | 58 | [
{
"answer": "```python\nfrom sys import stdin\ninput=lambda : stdin.readline().strip()\nfrom math import ceil,sqrt,factorial,gcd\nfrom collections import deque\nn=int(input())\nl=list(map(int,input().split()))\nvisited=set()\ngraph={i:set() for i in range(1,n+1)}\nd={}\npapa=[0 for i in range(n+1)]\nlevel=[[] f... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThe Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a t... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n1 3 3\\n1 2 2\\n1 3 2\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n6 3 2 5 0\\n1 2 10\\n2 3 3\\n2 4 1\\n1 5 1\\n\", \"output\": \"7\\n\", \"metadata\": {\"func_name\": null}}, {\"type\"... | {
"index": 58,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThe Fair Nut is going ... |
Solve the following coding problem using the programming language python:
You are given an array $a$ of $n$ integers.
You want to make all elements of $a$ equal to zero by doing the following operation exactly three times: Select a segment, for each number in this segment we can add a multiple of $len$ to it, where ... | [
"```python\nn=int(input())\nL=list(map(int,input().split()))\nif n==1:\n print(1,1)\n print(0)\n print(1,1)\n print(0)\n print(1,1)\n print(-L[0])\nelse:\n print(1,n-1)\n for i in range(n-1):print(L[i]*(n-1),end=' ')\n print()\n print(n,n)\n print(-L[n-1])\n print(1,n)\n for i... | [{"type": "stdin_stdout", "input": "4\n1 3 2 4\n", "output": "1 4\n-4 -12 -8 0\n1 3\n3 9 6 \n4 4\n-4\n"}, {"type": "stdin_stdout", "input": "1\n34688642\n", "output": "1 1\n-34688642\n1 1\n0\n1 1\n0\n"}, {"type": "stdin_stdout", "input": "2\n-492673762 -496405053\n", "output": "1 2\n985347524 0\n1 1\n-492673762 \n2 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:
You are given an array $a$ of $n$ integers.
You want to m... | livecodebench | deepcoder_59 | 59 | [
{
"answer": "```python\nfrom sys import stdin\n\n\ndef inp():\n return stdin.buffer.readline().rstrip().decode('utf8')\n\n\ndef itg():\n return int(stdin.buffer.readline())\n\n\ndef mpint():\n return map(int, stdin.buffer.readline().split())\n\n\n# ############################## import\n# #############... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou are given an array a of n integers.\n\nYou want to make all elements of a equal to zero by doing the following operation exactly three times:\n\n * Select a segment, for each n... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n1 3 2 4\\n\", \"output\": \"1 4\\n-4 -12 -8 0\\n1 3\\n3 9 6 \\n4 4\\n-4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n34688642\\n\", \"output\": \"1 1\\n-34688642\\n1 1\\n0\\n1 1\\n0\\n\", \"metadata\": {\"fu... | {
"index": 59,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given an array... |
Solve the following coding problem using the programming language python:
Karen has just arrived at school, and she has a math test today! [Image]
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. S... | [
"```python\n#!/usr/bin/env pypy3\n\nimport math\n\ndef make_nCr_mod(max_n=2*10**5 + 100, mod=10**9 + 7):\n fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)\n fact[0] = 1\n for i in range(max_n):\n fact[i + 1] = fact[i] * (i + 1) % mod\n\n inv_fact[-1] = pow(fact[-1], mod - 2, mod)\n for i... | [{"type": "stdin_stdout", "input": "5\n3 6 9 12 15\n", "output": "36\n"}, {"type": "stdin_stdout", "input": "4\n3 7 5 2\n", "output": "1000000006\n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "16\n985629174 189232688 48695377 692426437 952164554 243460498 173956955... | 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:
Karen has just arrived at school, and she has a math test ... | livecodebench | deepcoder_60 | 60 | [
{
"answer": "```python\nn = int(input())\np = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\nmode = 0\nif n % 4 == 3:\n\tn -= 1\n\tnew = []\n\tfor i in range(n):\n\t\tif mode == 0:\n\t\t\tnew.append(p[i] + p[i + 1])\n\t\telse:\n\t\t\tnew.append(p[i] - p[i + 1])\n\t\tmode = 1 - mode\n\tp = new\n\ndef calc0(... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nKaren has just arrived at school, and she has a math test today!\n\n<image>\n\nThe test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing ta... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5\\n3 6 9 12 15\\n\", \"output\": \"36\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n3 7 5 2\\n\", \"output\": \"1000000006\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\... | {
"index": 60,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nKaren has just arrived... |
Solve the following coding problem using the programming language python:
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (x_{i}, y_{i}).
They need to arrange a plan, but... | [
"```python\nfrom collections import Counter\nn = int(input())\npoints = Counter([tuple(map(int, input().split(' '))) for i in range(n)])\n\nx, y = Counter([k for k, v in points.elements()]), Counter([v for k, v in points.elements()])\n\nans = sum([v*(v-1)//2 for k, v in list(x.items())])+sum([v*(v-1)//2 for k, v in... | [{"type": "stdin_stdout", "input": "3\n1 1\n7 5\n1 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "10\n46 -55\n46 45\n46 45\n83 -55\n46 45\n83 -55\n46 45\n83 45\n83 45\n46 -55\n", "output": "33\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:
Watchmen are in a danger and Doctor Manhattan together wit... | livecodebench | deepcoder_61 | 61 | [
{
"answer": "def inc_val_of_dict(dictionary, key):\n\tif key not in dictionary:\n\t\tdictionary[key] = 0\n\tdictionary[key] += 1\n\ndef main():\n\tn = int(input())\n\tp_ctr = dict()\n\tx_ctr = dict()\n\ty_ctr = dict()\n\tfor _ in range(n):\n\t\t(x, y) = map(int, input().split())\n\t\tinc_val_of_dict(p_ctr, (x, ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi).\n\nThey need to arrange a plan, but there are some d... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n1 1\\n7 5\\n1 5\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"6\\n0 0\\n0 1\\n0 2\\n-1 1\\n0 1\\n1 1\\n\", \"output\": \"11\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_std... | {
"index": 61,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nWatchmen are in a dang... |
Solve the following coding problem using the programming language python:
Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door mus... | [
"```python\nfrom sys import*\n#\ndef check(u, d, l, r):\n used = [pointsx[i][1] for i in range(l)]\n used += [pointsx[-1 - i][1] for i in range(r)]\n used += [pointsy[i][1] for i in range(u)]\n used += [pointsy[-1 - i][1] for i in range(d)]\n if len(set(used)) > k:\n return DOHERA\n dx = po... | [{"type": "stdin_stdout", "input": "3 1\n1 1 2 2\n2 2 3 3\n3 3 4 4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4 1\n1 1 2 2\n1 9 2 10\n9 9 10 10\n9 1 10 2\n", "output": "64\n"}, {"type": "stdin_stdout", "input": "3 0\n1 1 2 2\n1 1 1000000000 1000000000\n1 3 8 12\n", "output": "249999999000000001\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:
Edo has got a collection of n refrigerator magnets!
He de... | livecodebench | deepcoder_62 | 62 | [
{
"answer": "```python\nfrom sys import *\n\ndef check(u, d, l, r):\n\tused = [pointsx[i][1] for i in range(l)]\n\tused += [pointsx[-1 - i][1] for i in range(r)]\n\tused += [pointsy[i][1] for i in range(u)]\n\tused += [pointsy[-1 - i][1] for i in range(d)]\n\tif len(set(used)) > k:\n\t\treturn DOHERA\n\tdx = po... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nEdo has got a collection of n refrigerator magnets!\n\nHe decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the doo... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 1\\n1 1 2 2\\n2 2 3 3\\n3 3 4 4\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 1\\n1 1 2 2\\n1 9 2 10\\n9 9 10 10\\n9 1 10 2\\n\", \"output\": \"64\\n\", \"metadata\": {\"func_name\": null}},... | {
"index": 62,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nEdo has got a collecti... |
Solve the following coding problem using the programming language python:
Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x_1, x_2, ..., x_{k} (k > 1) is such maximum element x_{j}, that the following inequality holds: $x_{j} \neq \opera... | [
"```python\ndef maximum_xor_secondary(sequence):\n stack, answer = [], 0\n for x in sequence:\n while stack:\n answer = max(answer, stack[-1] ^ x)\n if stack[-1] > x:\n break\n else:\n stack.pop()\n stack.append(x)\n\n return answ... | [{"type": "stdin_stdout", "input": "5\n5 2 1 4 3\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "5\n9 8 3 5 7\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "10\n76969694 71698884 32888447 31877010 65564584 87864180 7850891 1505323 17879621 15722446\n", "output": "128869996\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:
Bike loves looking for the second maximum element in the s... | livecodebench | deepcoder_63 | 63 | [
{
"answer": "from collections import deque\n\ndef ngr(a, n):\n\ts = deque()\n\tl = []\n\tfor j in range(n - 1, -1, -1):\n\t\tif len(s) == 0:\n\t\t\ts.append(a[j])\n\t\t\tl.append(-1)\n\t\telse:\n\t\t\twhile len(s) != 0 and s[len(s) - 1] <= a[j]:\n\t\t\t\ts.pop()\n\t\t\tif len(s) == 0:\n\t\t\t\tl.append(-1)\n\t\... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x_1, x_2, ..., x_{k} (k > 1) is such maximum element x_{j}, that the following inequality holds: $x_{j} \\neq \\operatorname{max... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5\\n5 2 1 4 3\\n\", \"output\": \"7\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n9 8 3 5 7\\n\", \"output\": \"15\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10\\n769696... | {
"index": 63,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nBike loves looking for... |
Solve the following coding problem using the programming language python:
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be w_{i}, then 0 < w_1 ≤ w_2 ≤ ... ≤... | [
"```python\nrd = lambda: list(map(int, input().split()))\n\nrd()\na = sorted(rd(), reverse=True)\nb = sorted(rd(), reverse=True)\nif len(a) > len(b): print(\"YES\"); return\nfor i in range(len(a)):\n if a[i] > b[i]: print(\"YES\"); return\nprint(\"NO\")\n```"
] | [{"type": "stdin_stdout", "input": "3 3 3\n2 2 2\n1 1 3\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4 7 9\n5 2 7 3\n3 5 2 7 3 8 7\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5 5 10\n8 2 8 5 9\n9 1 7 5 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "7 7 10\n8 2 8 10 6 9 10\n2 4 ... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
It is known that there are k fish species in the polar oce... | livecodebench | deepcoder_64 | 64 | [
{
"answer": "```python\n(n, m, k) = [int(x) for x in input().split()]\nalice = [int(x) for x in input().split()]\nbob = [int(x) for x in input().split()]\nalice.sort()\nbob.sort()\nbalance = 0\ni = n - 1\nj = m - 1\nwhile i >= 0 and j >= 0:\n\tif alice[i] > bob[j]:\n\t\tbalance += 1\n\t\ti -= 1\n\telif alice[i]... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nIt is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weig... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 3 3\\n2 2 2\\n1 1 3\\n\", \"output\": \"YES\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 7 9\\n5 2 7 3\\n3 5 2 7 3 8 7\\n\", \"output\": \"NO\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout... | {
"index": 64,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIt is known that there... |
Solve the following coding problem using the programming language python:
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.
We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors... | [
"```python\nn = int(input())\np = [tuple(map(int, input().split())) for i in range(n)]\n\ndef d(a, b):\n return (a[0]-b[0], a[1]-b[1], a[2]-b[2], a[3]-b[3], a[4]-b[4])\n\ndef m(a, b):\n t = 0\n for i in range(5):\n t += a[i] * b[i]\n return t\n\ngood_points = []\nfor i in range(n):\n good = Tr... | [{"type": "stdin_stdout", "input": "6\n0 0 0 0 0\n1 0 0 0 0\n0 1 0 0 0\n0 0 1 0 0\n0 0 0 1 0\n0 0 0 0 1\n", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "3\n0 0 1 2 0\n0 0 9 2 0\n0 0 5 9 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n0 0 0 0 0\n", "output": "1\n1\n"}, {"type": "stdin_stdout", "... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given set of n points in 5-dimensional space. The ... | livecodebench | deepcoder_65 | 65 | [
{
"answer": "```python\nd = lambda i, j, k: sum(((a - c) * (b - c) for (a, b, c) in zip(p[i], p[j], p[k]))) * (i != j)\nn = int(input())\nr = range(n)\np = [list(map(int, input().split())) for i in r]\nt = [k + 1 for k in r if all((d(i, j, k) <= 0 for i in r for j in r))] if n < 12 else []\nfor q in [len(t)] + ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.\n\nWe will call point a bad if there are different points b and c, ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"6\\n0 0 0 0 0\\n1 0 0 0 0\\n0 1 0 0 0\\n0 0 1 0 0\\n0 0 0 1 0\\n0 0 0 0 1\\n\", \"output\": \"1\\n1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n0 0 1 2 0\\n0 0 9 2 0\\n0 0 5 9 0\\n\", \"output\": \"0\\n\", \"me... | {
"index": 65,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given set of n... |
Solve the following coding problem using the programming language python:
Little X has n distinct integers: p_1, p_2, ..., p_{n}. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied: If number x belongs to set A, then number a - x must also belong to set A. If number ... | [
"```python\nfrom collections import defaultdict\n\ndef solve(n, a, b, xs):\n group = [None] * n\n id_ = {x: i for i, x in enumerate(xs)}\n if a == b:\n for x in xs:\n if a - x not in id_:\n return False\n group = [0] * n\n else:\n for i, x in enumerate(xs):... | [{"type": "stdin_stdout", "input": "4 5 9\n2 3 4 5\n", "output": "YES\n0 0 1 1\n"}, {"type": "stdin_stdout", "input": "3 3 4\n1 2 4\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "100 8883 915\n1599 4666 663 3646 754 2113 2200 3884 4082 1640 3795 2564 2711 2766 1122 4525 1779 2678 2816 2182 1028 2337 4918 127... | 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:
Little X has n distinct integers: p_1, p_2, ..., p_{n}. He... | livecodebench | deepcoder_66 | 66 | [
{
"answer": "```python\nclass DisjointSet:\n def __init__(self, n):\n self._fa = list(range(n))\n def union(self, x, y):\n x = self.get_father(x)\n y = self.get_father(y)\n self._fa[x] = y\n return y\n def get_father(self, x):\n y = self._fa[x]\n if self... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nLittle X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:\n\n * If number x belongs t... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 5 9\\n2 3 4 5\\n\", \"output\": \"YES\\n0 0 1 1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 3 4\\n1 2 4\\n\", \"output\": \"NO\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\":... | {
"index": 66,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nLittle X has n distinc... |
Solve the following coding problem using the programming language python:
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. Y... | [
"```python\nq = int(input())\n\n\n\ndef full_way(u):\n res = set()\n\n while u >= 1:\n res.add(u)\n u //= 2\n\n return res\n\n\ndef get_way(u, v):\n res1 = full_way(u)\n res2 = full_way(v)\n\n m = max(res1 & res2)\n\n res = set()\n for x in res1 | res2:\n if x > m:\n ... | [{"type": "stdin_stdout", "input": "7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4\n", "output": "94\n0\n32\n"}, {"type": "stdin_stdout", "input": "1\n2 666077344481199252 881371880336470888\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n1 1 63669439577744021 396980128\n1 2582240553355225 63... | 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:
Barney lives in NYC. NYC has infinite number of intersecti... | livecodebench | deepcoder_67 | 67 | [
{
"answer": "def main():\n\tfrom collections import Counter\n\td = Counter()\n\tfor _ in range(int(input())):\n\t\t(c, *l) = input().split()\n\t\tif c == '1':\n\t\t\t(v, u, w) = map(int, l)\n\t\t\twhile u != v:\n\t\t\t\tif u < v:\n\t\t\t\t\td[v] += w\n\t\t\t\t\tv //= 2\n\t\t\t\telse:\n\t\t\t\t\td[u] += w\n\t\t\... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearl... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"7\\n1 3 4 30\\n1 4 1 2\\n1 3 6 8\\n2 4 3\\n1 6 1 40\\n2 3 7\\n2 2 4\\n\", \"output\": \"94\\n0\\n32\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n2 666077344481199252 881371880336470888\\n\", \"output\": \"0\\n\"... | {
"index": 67,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nBarney lives in NYC. N... |
Solve the following coding problem using the programming language python:
Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.
There are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer tak... | [
"```python\nimport sys\n\nn_discounts = int(sys.stdin.readline())\ndiscount_values = [int(x) for x in sys.stdin.readline().split()]\nn_items = int(sys.stdin.readline())\nitem_values = [int(x) for x in sys.stdin.readline().split()]\n\nmin_discount_req = 10000000\nfor discount_value in discount_values:\n min_disco... | [{"type": "stdin_stdout", "input": "1\n2\n4\n50 50 100 100\n", "output": "200\n"}, {"type": "stdin_stdout", "input": "2\n2 3\n5\n50 50 50 50 50\n", "output": "150\n"}, {"type": "stdin_stdout", "input": "1\n1\n7\n1 1 1 1 1 1 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "60\n7 4 20 15 17 6 2 2 3 18 13 14 16 ... | 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:
Maxim always goes to the supermarket on Sundays. Today the... | livecodebench | deepcoder_68 | 68 | [
{
"answer": "def main():\n\tinput()\n\tq = min(map(int, input().split()))\n\tinput()\n\taa = sorted(map(int, input().split()), reverse=True)\n\tprint(sum(aa) - sum(aa[q::q + 2]) - sum(aa[q + 1::q + 2]))\nmain()\n",
"question": "Maxim always goes to the supermarket on Sundays. Today the supermarket has a spe... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.\n\nThere are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a specia... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"1\\n2\\n4\\n50 50 100 100\\n\", \"output\": \"200\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n2 3\\n5\\n50 50 50 50 50\\n\", \"output\": \"150\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdo... | {
"index": 68,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nMaxim always goes to t... |
Solve the following coding problem using the programming language python:
Nikita likes tasks on order statistics, for example, he can easily find the $k$-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an array there are such that a given number $x$ is the $k$-th num... | [
"```python\nfrom math import pi\nfrom cmath import exp\ndef fft(a, lgN, rot=1): # rot=-1 for ifft\n N = 1<<lgN\n assert len(a)==N\n rev = [0]*N\n for i in range(N):\n rev[i] = (rev[i>>1]>>1)+(i&1)*(N>>1)\n A = [a[rev[i]] for i in range(N)]\n h = 1\n while h<N:\n w_m = exp((0+1j) * rot * (pi / h))\n ... | [{"type": "stdin_stdout", "input": "5 3\n1 2 3 4 5\n", "output": "6 5 4 0 0 0 "}, {"type": "stdin_stdout", "input": "2 6\n-5 9\n", "output": "1 2 0 "}, {"type": "stdin_stdout", "input": "6 99\n-1 -1 -1 -1 -1 -1\n", "output": "0 6 5 4 3 2 1 "}, {"type": "stdin_stdout", "input": "5 -2\n-1 -1 -4 -5 1\n", "output": "4 5 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:
Nikita likes tasks on order statistics, for example, he ca... | livecodebench | deepcoder_69 | 69 | [
{
"answer": "```python\nfrom math import pi\nfrom cmath import exp\ndef fft(a, lgN, rot=1): # rot=-1 for ifft\n N = 1<<lgN\n assert len(a)==N\n rev = [0]*N\n for i in range(N):\n rev[i] = (rev[i>>1]>>1)+(i&1)*(N>>1)\n A = [a[rev[i]] for i in range(N)]\n h = 1\n while h<N:\n w_m = exp((0+1j) * rot *... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nNikita likes tasks on order statistics, for example, he can easily find the k-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 3\\n1 2 3 4 5\\n\", \"output\": \"6 5 4 0 0 0 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 6\\n-5 9\\n\", \"output\": \"1 2 0 \", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"6 9... | {
"index": 69,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nNikita likes tasks on ... |
Solve the following coding problem using the programming language python:
Slime and his $n$ friends are at a party. Slime has designed a game for his friends to play.
At the beginning of the game, the $i$-th player has $a_i$ biscuits. At each second, Slime will choose a biscuit randomly uniformly among all $a_1 + a_2... | [
"```python\nMOD = 998244353\n\nn = int(input())\n\na = list(map(int, input().split()))\ntot = sum(a)\n\ndef inv(x):\n return pow(x, MOD - 2, MOD)\n\nl = [0, pow(n, tot, MOD) - 1]\n\nfor i in range(1, tot):\n aC = i\n cC = (n - 1) * (tot - i)\n curr = (aC + cC) * l[-1]\n curr -= tot * (n - 1)\n cur... | [{"type": "stdin_stdout", "input": "2\n1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n0 0 0 0 35\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n8 4 2 0 1\n", "output": "801604029\n"}, {"type": "stdin_stdout", "input": "5\n2434... | 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:
Slime and his $n$ friends are at a party. Slime has design... | livecodebench | deepcoder_70 | 70 | [
{
"answer": "```python\nimport os\nimport sys\ninput = sys.stdin.buffer.readline\n#sys.setrecursionlimit(int(2e5)) \nfrom collections import deque\nimport math\n# list(map(int, input().split()))\n#####################################################################################\n\nclass CF(object):\n def... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nSlime and his n friends are at a party. Slime has designed a game for his friends to play.\n\nAt the beginning of the game, the i-th player has a_i biscuits. At each second, Slime w... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n1 1\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n1 2\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n0 0 0 0 35\\n\", \"o... | {
"index": 70,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nSlime and his $n$ frie... |
Solve the following coding problem using the programming language python:
Levko loves array a_1, a_2, ... , a_{n}, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:
Increase all elements fro... | [
"```python\nn, m = map(int, input().split())\na = [10**9 for _ in range(n)]\nextra = [0 for _ in range(n)]\nquery = list()\nfor _ in range(m):\n t, l, r, x = map(int, input().split())\n l -= 1\n r -= 1\n query.append((t, l, r, x))\n if t == 1:\n for j in range(l, r + 1):\n ... | [{"type": "stdin_stdout", "input": "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8\n", "output": "YES\n8 7 4 7 \n"}, {"type": "stdin_stdout", "input": "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 4\n1 1 1 2\n2 1 1 6\n1 1 1 1\n2 1 1 7\n", "output": "YES... | 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:
Levko loves array a_1, a_2, ... , a_{n}, consisting of int... | livecodebench | deepcoder_71 | 71 | [
{
"answer": "```python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nLevko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko pe... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 8\\n\", \"output\": \"YES\\n8 7 4 7 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 13\\n\", \"output\": \"NO\\n\... | {
"index": 71,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nLevko loves array a_1,... |
Solve the following coding problem using the programming language python:
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is dir... | [
"```python\nimport heapq\n\ndef coor_neighbor(coor, dxs, dys):\n x, y = coor\n for dx in dxs:\n for dy in dys:\n yield x + dx, y + dy\n\n\ndef coor_bottoms(coor):\n return coor_neighbor(coor, (-1, 0, 1), (-1, ))\n\n\ndef coor_tops(coor):\n return coor_neighbor(coor, (-1, 0, 1), (1, ))\... | [{"type": "stdin_stdout", "input": "3\n2 1\n1 0\n0 1\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n0 1\n0 2\n0 3\n0 4\n", "output": "2930\n"}, {"type": "stdin_stdout", "input": "10\n-1 2\n-3 0\n5 5\n4 4\n-2 1\n1 1\n3 3\n2 2\n0 0\n-1000000000 0\n", "output": "41236677\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:
Once Vasya and Petya assembled a figure of m cubes, each o... | livecodebench | deepcoder_72 | 72 | [
{
"answer": "```python\nimport heapq\n\ndef coor_neighbor(coor, dxs, dys):\n x, y = coor\n for dx in dxs:\n for dy in dys:\n yield x + dx, y + dy\n\n\ndef coor_bottoms(coor):\n return coor_neighbor(coor, (-1, 0, 1), (-1, ))\n\n\ndef coor_tops(coor):\n return coor_neighbor(coor, (-1... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nOnce Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coo... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n2 1\\n1 0\\n0 1\\n\", \"output\": \"19\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n0 0\\n0 1\\n0 2\\n0 3\\n0 4\\n\", \"output\": \"2930\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\... | {
"index": 72,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nOnce Vasya and Petya a... |
Solve the following coding problem using the programming language python:
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with $n$ elements. The $i$-th element is $a_i$ ($i$ = $1, 2, \ldots, n$). He gradually takes the first two leftmost elements f... | [
"```python\nimport sys\ninput = sys.stdin.readline\n\n\nfrom collections import deque\nN, Q = list(map(int, input().split()))\nque = deque([int(a) for a in input().split()])\nma = max(que)\n\nX = []\nk = -1\nc = 0\nwhile c <= k+N+5:\n a = deque.popleft(que)\n b = deque.popleft(que)\n \n X.append((a, b))... | [{"type": "stdin_stdout", "input": "5 3\n1 2 3 4 5\n1\n2\n10\n", "output": "1 2\n2 3\n5 2\n"}, {"type": "stdin_stdout", "input": "2 0\n0 0\n", "output": ""}, {"type": "stdin_stdout", "input": "2 1\n1 2\n1\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "3 2\n1000000 999999 999998\n98\n999999999999\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:
Recently, on the course of algorithms and data structures,... | livecodebench | deepcoder_73 | 73 | [
{
"answer": "```python\nimport sys\n(n, q) = list(map(int, input().split()))\na = list(map(int, input().split()))\nmx1 = max(a)\na1 = []\ndp = {}\nfor i in range(q):\n\ta1.append(int(input()))\nif a1 == []:\n\tmx = 0\nelse:\n\tmx = max(a1)\ncount = 0\nwhile 1:\n\tcount += 1\n\tval1 = a[0]\n\tval2 = a[1]\n\tif v... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nRecently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 3\\n1 2 3 4 5\\n1\\n2\\n10\\n\", \"output\": \"1 2\\n2 3\\n5 2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 0\\n0 0\\n\", \"output\": \"\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"in... | {
"index": 73,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nRecently, on the cours... |
Solve the following coding problem using the programming language python:
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Va... | [
"```python\n3\n\nimport sys\n\nn, l, r, ql, qr = list(map(int, sys.stdin.readline().strip().split()))\nw = [int(x) for x in sys.stdin.readline().strip().split()]\n\ns = [0]\nfor i in range(0, n):\n s.append(s[-1] + w[i])\n\ndef cost(left):\n right = n - left\n diff = left - right\n bonus = 0\n if dif... | [{"type": "stdin_stdout", "input": "3 4 4 19 1\n42 3 99\n", "output": "576\n"}, {"type": "stdin_stdout", "input": "4 7 2 3 9\n1 2 3 4\n", "output": "34\n"}, {"type": "stdin_stdout", "input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"type": "stdin_stdout", "input": "2 3 4 5 6\n1 2\n", "output": "11\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 has n items lying in a line. The items are consecuti... | livecodebench | deepcoder_74 | 74 | [
{
"answer": "```python\nimport sys\n\n\n\n\nn,L,r,QL,QR=map(int,sys.stdin.readline().split())\n\n\nW=list(map(int,sys.stdin.readline().split()))\n\nminn=10**10\nSumsL=[0]*n\nSumsR=[0]*n\n\ns=0\nfor i in range(n):\n s+=W[i]\n SumsL[i]=s\n\nfor i in range(n-1):\n ans=L*SumsL[i]+r*(s-SumsL[i])\n if(n-(... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nVasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Ea... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 4 4 19 1\\n42 3 99\\n\", \"output\": \"576\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 7 2 3 9\\n1 2 3 4\\n\", \"output\": \"34\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\"... | {
"index": 74,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nVasya has n items lyin... |
Solve the following coding problem using the programming language python:
Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color c_{i}. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is... | [
"```python\nn = int(input())\nC = list(map(int, input().split()))\n\ndp = [[0]*n for _ in range(n)]\nfor i in range(n) :\n dp[i][i] = 1\n\nfor i in range(n-2, -1, -1) :\n for j in range(i+1, n) :\n dp[i][j] = 1 + dp[i+1][j]\n if C[i] == C[i+1] : dp[i][j] = min( dp[i][j], 1 + (dp[i+2][j] if i+2 <... | [{"type": "stdin_stdout", "input": "3\n1 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1 2 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 4 4 2 3 2 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n", "outp... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Genos recently installed the game Zuma on his phone. In Zu... | livecodebench | deepcoder_75 | 75 | [
{
"answer": "```python\nfrom sys import stdin\nn = int(input())\ns = list(map(int, stdin.readline().strip().split()))\ndp = [[-1 for i in range(501)] for j in range(500)]\n\ndef sol(i, j):\n\tif i > j:\n\t\treturn 0\n\tif i == j:\n\t\treturn 1\n\tif dp[i][j] != -1:\n\t\treturn dp[i][j]\n\tx = 502\n\tif s[i] == ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nGenos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n1 2 1\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n1 2 3\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"7\\n1 4 4 2 3 2 1\\n... | {
"index": 75,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nGenos recently install... |
Solve the following coding problem using the programming language python:
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or... | [
"```python\nfrom operator import __or__, __and__, __xor__\nfrom sys import stdin, stdout\nn, b, c = int(stdin.readline()), 0, 1023\nm = {'|': __or__, '&': __and__, '^': __xor__}\nfor i in range(n):\n t, v = [i for i in stdin.readline().split()]\n b = m[t](b, int(v))\n c = m[t](c, int(v))\nx, o, a = 0, 0, 1... | [{"type": "stdin_stdout", "input": "3\n| 3\n^ 2\n| 1\n", "output": "2\n| 3\n^ 2\n"}, {"type": "stdin_stdout", "input": "3\n& 1\n& 3\n& 5\n", "output": "1\n& 1\n"}, {"type": "stdin_stdout", "input": "3\n^ 1\n^ 2\n^ 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n| 999\n^ 689\n", "output": "2\n| 999\n^ 689\... | 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 learned a new programming language CALPAS. A program... | livecodebench | deepcoder_76 | 76 | [
{
"answer": "```python\nn = int(input())\na, b = 1023, 0\n\nfor _ in range(n):\n c, d = input().split()\n d = int(d)\n\n if c == '|':\n a, b = a | d, b | d\n elif c == '&':\n a, b = a & d, b & d\n elif c == '^':\n a, b = a ^ d, b ^ d\n\nprint('2\\n| {}\\n^ {}'.format(a ^ b ^ ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nPetya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.\n\nIn the language, t... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n| 3\\n^ 2\\n| 1\\n\", \"output\": \"2\\n| 3\\n^ 2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n& 1\\n& 3\\n& 5\\n\", \"output\": \"1\\n& 1\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdou... | {
"index": 76,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nPetya learned a new pr... |
Solve the following coding problem using the programming language python:
In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a t... | [
"```python\nfrom itertools import combinations_with_replacement \nfrom collections import deque\n\n#sys.stdin = open(\"input_py.txt\",\"r\")\n\nn, m = map(int, input().split())\nG = [ [] for i in range(n)]\n\nfor i in range(m):\n x, y = map(int, input().split())\n x-=1; y-=1\n G[x].append(y)\n G[y].appe... | [{"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n1 3 2\n3 5 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n1 3 2\n2 4 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n1 3 2\n3 5 1\n", "output": "-1\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 some country there are exactly n cities and m bidirecti... | livecodebench | deepcoder_77 | 77 | [
{
"answer": "```python\nn, m = list(map(int, input().split()))\ntable = [False] * (n + 1)\nfor _ in range(m):\n a, b = list(map(int, input().split()))\n table[a] = table[b] = True\nprint(n - 1)\nfor i in range(1, n + 1):\n if not table[i]:\n for j in range(1, n + 1):\n if i != j:\n ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nA country has n cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities. Roads can be traversed either way. ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3 2\\n3 5 2\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3 2\\n2 4 2\\n\", \"output\": \"1\\n\", \"metadata\": {\"func_name\": nu... | {
"index": 77,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIn some country there ... |
Solve the following coding problem using the programming language python:
Sereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in other words, a string s of length n, consisting of characters "(" and ")".
Sereja needs to answer m queries, each of them is described by two integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ ... | [
"```python\nimport sys\ninput = sys.stdin.readline\n\ns = input()\n\nM = int(input())\n\n\ndef next_pow_2(n):\n p = 1\n while p < n:\n p <<= 1\n return p\n\n\ndef represented_range(node, size):\n l = node\n r = node\n while l < size:\n l = 2*l\n r = 2*r + 1\n return l-size,... | [{"type": "stdin_stdout", "input": "())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10\n", "output": "0\n0\n2\n10\n4\n6\n6\n"}, {"type": "stdin_stdout", "input": "(((((()((((((((((()((()(((((\n1\n8 15\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:
Sereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in... | livecodebench | deepcoder_78 | 78 | [
{
"answer": "```python\nimport sys\ninput = sys.stdin.readline\n\ns = input()\n\nM = int(input())\n\n\ndef next_pow_2(n):\n p = 1\n while p < n:\n p <<= 1\n return p\n\n\ndef represented_range(node, size):\n l = node\n r = node\n while l < size:\n l = 2*l\n r = 2*r + 1\n ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nSereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters \"(\" and \")\".\n\nSereja needs to answer m queries, each of the... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"())(())(())(\\n7\\n1 1\\n2 3\\n1 2\\n1 12\\n8 12\\n5 11\\n2 10\\n\", \"output\": \"0\\n0\\n2\\n10\\n4\\n6\\n6\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"(((((()((((((((((()((()(((((\\n1\\n8 15\\n\", \"output\": \"... | {
"index": 78,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nSereja has a bracket s... |
Solve the following coding problem using the programming language python:
There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konsta... | [
"```python\nn = int(input())\nif n % 2:\n print(\"contest\")\nelse:\n print(\"home\")\n```"
] | [{"type": "stdin_stdout", "input": "4\nSVO\nSVO->CDG\nLHR->SVO\nSVO->LHR\nCDG->SVO\n", "output": "home\n"}, {"type": "stdin_stdout", "input": "3\nSVO\nSVO->HKT\nHKT->SVO\nSVO->RAP\n", "output": "contest\n"}, {"type": "stdin_stdout", "input": "1\nESJ\nESJ->TSJ\n", "output": "contest\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 literally dozens of snooker competitions held ea... | livecodebench | deepcoder_79 | 79 | [
{
"answer": "```python\nimport sys,math\nfrom collections import deque\n#input = sys.stdin.buffer.readline\n\n\ndef solve():\t\n\treturn;\n\n\n# for _ in range(int(input())):\n# \tsolve()\n\n\nn = int(input())\nh = input()\n\ncnt=0\nfor i in range(n):\n\ts = input()\n\tif h==s[:3] or h==s[-3:]:\n\t\tcnt+=1\n\ni... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThere are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name \"snookah\")! When a competition take... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\nSVO\\nSVO->CDG\\nLHR->SVO\\nSVO->LHR\\nCDG->SVO\\n\", \"output\": \"home\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\nSVO\\nSVO->HKT\\nHKT->SVO\\nSVO->RAP\\n\", \"output\": \"contest\\n\", \"metadata\": {\"f... | {
"index": 79,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThere are literally do... |
Solve the following coding problem using the programming language python:
Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into o... | [
"```python\nn = int(input())\nfrom bisect import bisect_left\n\n\na = list(map(int, input().split()))\nss = []\nms = []\nfor i in range(n):\n k = a[i]\n ind = bisect_left(ms, -k)\n if ind == len(ms):\n ss.append([])\n ms.append(0)\n ss[ind].append(k)\n ms[ind] = -k\n\nfor s in ss:\n ... | [{"type": "stdin_stdout", "input": "5\n1 3 2 5 4\n", "output": "1 3 5 \n2 4 \n"}, {"type": "stdin_stdout", "input": "4\n4 3 2 1\n", "output": "4 \n3 \n2 \n1 \n"}, {"type": "stdin_stdout", "input": "4\n10 30 50 101\n", "output": "10 30 50 101 \n"}, {"type": "stdin_stdout", "input": "1\n1\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:
Ivan has an array consisting of n different integers. He d... | livecodebench | deepcoder_80 | 80 | [
{
"answer": "```python\nfrom sys import stdin\nfrom collections import deque\nfrom bisect import bisect_right as br\nn=int(stdin.readline().strip())\ns=list(map(int,stdin.readline().strip().split()))\narr=deque([s[0]])\nans=deque([[s[0]]])\nfor i in range(1,n):\n x=br(arr,s[i])\n if x==0:\n arr.ap... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nIvan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5\\n1 3 2 5 4\\n\", \"output\": \"1 3 5 \\n2 4 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n4 3 2 1\\n\", \"output\": \"4 \\n3 \\n2 \\n1 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\",... | {
"index": 80,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nIvan has an array cons... |
Solve the following coding problem using the programming language python:
When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately... | [
"```python\ndef main():\n import sys\n input = sys.stdin.readline\n \n n = int(input())\n arr = input()\n \n one = arr.count('n')\n zero = arr.count('z')\n \n ans = [1] * one + [0] * zero\n \n print(*ans)\n \n return 0\n\nmain()\n\n```"
] | [{"type": "stdin_stdout", "input": "4\nezor\n", "output": "0 \n"}, {"type": "stdin_stdout", "input": "10\nnznooeeoer\n", "output": "1 1 0 \n"}, {"type": "stdin_stdout", "input": "4\neorz\n", "output": "0 \n"}, {"type": "stdin_stdout", "input": "3\nnoe\n", "output": "1 \n"}, {"type": "stdin_stdout", "input": "40\noeerzz... | 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 Serezha was three years old, he was given a set of ca... | livecodebench | deepcoder_81 | 81 | [
{
"answer": "```python\nn = int(input())\ns = input()\nfor i in range(s.count('n')): print(1, end = ' ')\nfor i in range(s.count('z')): print(0, end = ' ')\n\n```",
"question": "Solve the following coding problem using the programming language python:\n\nWhen Serezha was three years old, he was given a set ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nWhen Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number i... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\nezor\\n\", \"output\": \"0 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"10\\nnznooeeoer\\n\", \"output\": \"1 1 0 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\neorz\... | {
"index": 81,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nWhen Serezha was three... |
Solve the following coding problem using the programming language python:
DZY loves planting, and he enjoys solving tree problems.
DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge ... | [
"```python\nn = int(input())\nedges = [[int(x) for x in input().split()] for i in range(n-1)]\nedges = sorted(edges)\nuse_count = [0]+[int(input()) for i in range(n)]\nlo,hi = 0,10000\ndef getpar(par,u):\n if par[par[u]] == par[u]:\n return par[u]\n par[u] = getpar(par,par[u])\n return par[u]\ndef u... | [{"type": "stdin_stdout", "input": "4\n1 2 1\n2 3 2\n3 4 3\n1\n1\n1\n1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n1 2 1\n2 3 2\n3 4 3\n4\n4\n4\n4\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 8886\n10 3 9362\n2\n5\... | 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:
DZY loves planting, and he enjoys solving tree problems.
... | livecodebench | deepcoder_82 | 82 | [
{
"answer": "```python\nn = int(input())\nedges = [[int(x) for x in input().split()] for i in range(n-1)]\nedges = sorted(edges)\nuse_count = [0]+[int(input()) for i in range(n)]\nlo,hi = 0,10000\ndef getpar(par,u):\n if par[par[u]] == par[u]:\n return par[u]\n par[u] = getpar(par,par[u])\n retu... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nDZY loves planting, and he enjoys solving tree problems.\n\nDZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). H... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n1 2 1\\n2 3 2\\n3 4 3\\n1\\n1\\n1\\n1\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n1 2 1\\n2 3 2\\n3 4 3\\n4\\n4\\n4\\n4\\n\", \"output\": \"3\\n\", \"metadata\": {\"func_name\": null}}... | {
"index": 82,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nDZY loves planting, an... |
Solve the following coding problem using the programming language python:
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the numbe... | [
"```python\n\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,m=list(map(int,input().split()))\n\nparty=[[] for _ in range(m+5)]\npc=sorted([list(map(int,input().split())) for _ in range(n)],key=lambda x:x[1])\nchoose=[0]*n\n\nfor i in range(n):\n party[pc[i][0]].append(i)\n\n\n\nwant=10... | [{"type": "stdin_stdout", "input": "1 2\n1 100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 5\n2 100\n3 200\n4 300\n5 400\n5 900\n", "output": "500\n"}, {"type": "stdin_stdout", "input": "5 5\n2 100\n3 200\n4 300\n5 800\n5 900\n", "output": "600\n"}, {"type": "stdin_stdout", "input": "5 5\n1 3\n1 6\n5 4\n... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
As you know, majority of students and teachers of Summer I... | livecodebench | deepcoder_83 | 83 | [
{
"answer": "```python\nn, m = map(int, input().split())\n\npc = [(0, 0) for _ in range(n)]\n\nparty_votes = [0 for _ in range(m)]\n\nfor i in range(n):\n p, c = map(int, input().split())\n pc[i] = (p - 1, c)\n party_votes[p - 1] += 1\n\npc.sort(key=lambda x: x[1])\n\nmin_cost = 10**20\n\nfor votes in ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nAs you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"1 2\\n1 100\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 5\\n2 100\\n3 200\\n4 300\\n5 400\\n5 900\\n\", \"output\": \"500\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdou... | {
"index": 83,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nAs you know, majority ... |
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 not larger than n. We'll denote as n the length of permutation p_1, p_2, ..., p_{n}.
Your task is to find such permutation ... | [
"```python\n3\n\nimport sys\n\ndef __starting_point():\n \n n, k = list(map(int, sys.stdin.readline().split()))\n l = []\n i = 1\n j = k + 1\n while i <= j:\n l.append(str(i))\n i += 1\n if j > i:\n l.append(str(j))\n j -= 1\n for i in range(k+2, n+1):... | [{"type": "stdin_stdout", "input": "3 2\n", "output": "1 3 2\n"}, {"type": "stdin_stdout", "input": "3 1\n", "output": "1 2 3\n"}, {"type": "stdin_stdout", "input": "5 2\n", "output": "1 3 2 4 5\n"}, {"type": "stdin_stdout", "input": "5 4\n", "output": "1 5 2 4 3\n"}, {"type": "stdin_stdout", "input": "10 4\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:
Permutation p is an ordered set of integers p_1, p_2, ... | livecodebench | deepcoder_84 | 84 | [
{
"answer": "```python\nfrom collections import Counter\nimport string\nimport math\nimport sys\nfrom fractions import Fraction\n\ndef array_int():\n\treturn [int(i) for i in sys.stdin.readline().split()]\n\ndef vary(arrber_of_variables):\n\tif arrber_of_variables == 1:\n\t\treturn int(sys.stdin.readline())\n\t... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nPermutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., p... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 2\\n\", \"output\": \"1 3 2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 1\\n\", \"output\": \"1 2 3\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 2\\n\", \"output\": \"... | {
"index": 84,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nPermutation p is an or... |
Solve the following coding problem using the programming language python:
There are $n$ water tanks in a row, $i$-th of them contains $a_i$ liters of water. The tanks are numbered from $1$ to $n$ from left to right.
You can perform the following operation: choose some subsegment $[l, r]$ ($1\le l \le r \le n$), and r... | [
"```python\nn = int(input())\nl = list(map(int, input().split()))\n\nstack = []\nfor v in l:\n currVal = v\n currSize = 1\n div = v\n \n while stack:\n nex, nexS, nDiv = stack[-1]\n\n if div < nDiv:\n currSize += nexS\n currVal += nex\n stack.pop()\n\n ... | [{"type": "stdin_stdout", "input": "4\n7 5 5 7\n", "output": "5.666666667\n5.666666667\n5.666666667\n7.000000000\n"}, {"type": "stdin_stdout", "input": "5\n7 8 8 10 12\n", "output": "7.000000000\n8.000000000\n8.000000000\n10.000000000\n12.000000000\n"}, {"type": "stdin_stdout", "input": "10\n3 9 5 5 1 7 5 3 8 7\n", "ou... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
There are $n$ water tanks in a row, $i$-th of them contain... | livecodebench | deepcoder_85 | 85 | [
{
"answer": "```python\ndef main():\n\tfrom sys import stdin, stdout\n\tans = []\n\tstdin.readline()\n\tfor ai in map(int, map(int, stdin.readline().split())):\n\t\tcnt = 1\n\t\twhile ans and ai * ans[-1][0] <= ans[-1][1] * cnt:\n\t\t\t(c, r) = ans.pop()\n\t\t\tai += r\n\t\t\tcnt += c\n\t\tans.append((cnt, ai))... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nThere are n water tanks in a row, i-th of them contains a_i liters of water. The tanks are numbered from 1 to n from left to right.\n\nYou can perform the following operation: choos... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n7 5 5 7\\n\", \"output\": \"5.666666667\\n5.666666667\\n5.666666667\\n7.000000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n7 8 8 10 12\\n\", \"output\": \"7.000000000\\n8.000000000\\n8.000000000\\n10.000... | {
"index": 85,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nThere are $n$ water ta... |
Solve the following coding problem using the programming language python:
Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.
It is an undirected weighted ... | [
"```python\nimport sys\ninput = lambda: sys.stdin.readline().rstrip()\n\nN, M = list(map(int, input().split()))\nD = [{} for _ in range(N)]\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n a -= 1\n b -= 1\n D[a][b] = 1\n D[b][a] = 1\n\nL = [i-1 for i in range(N)]\nR = [i+1 for i in rang... | [{"type": "stdin_stdout", "input": "6 11\n1 3\n1 4\n1 5\n1 6\n2 3\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 0\n", "output": "0\n"}, {"type": "stdin_std... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
Ujan has a lot of useless stuff in his drawers, a consider... | livecodebench | deepcoder_86 | 86 | [
{
"answer": "```python\nimport sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\n(n, m) = map(int, input().split())\nG = [set() for i in range(n)]\nfor i in range(m):\n\t(a, b) = map(int, input().split())\n\t(a, b) = (a - 1, b - 1)\n\tG[a].add(b)\n\tG[b].add(a)\nans = 0\nunused = set(range... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nUjan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebo... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"6 11\\n1 3\\n1 4\\n1 5\\n1 6\\n2 3\\n2 4\\n2 5\\n2 6\\n3 4\\n3 5\\n3 6\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 0\\n\", \"output\": \"0\\n\", \"metadata\": {\"func_name\": null}}, {\"type... | {
"index": 86,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nUjan has a lot of usel... |
Solve the following coding problem using the programming language python:
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.
Strictly speaking, it makes a photo of all points with coordinates... | [
"```python\n# \nimport collections, atexit, math, sys\nfrom functools import cmp_to_key\n#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )\n\nsys.setrecursionlimit(1000000)\ndef getIntList():\n return list(map(int, input().split())) \n\nimport bisect \ntry :\n #raise ModuleNotFoundError\n impor... | [{"type": "stdin_stdout", "input": "4\n4 1 3 2 3 2 1 3\n", "output": "1"}, {"type": "stdin_stdout", "input": "3\n5 8 5 5 7 5\n", "output": "0"}, {"type": "stdin_stdout", "input": "1\n553296794 23577639\n", "output": "0"}, {"type": "stdin_stdout", "input": "2\n100000001 95312501 97600001 1\n", "output": "228750000000000... | 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:
Pavel made a photo of his favourite stars in the sky. His ... | livecodebench | deepcoder_87 | 87 | [
{
"answer": "```python\nn = int(input())\na = [int(x) for x in input().split()]\na.sort()\ntop = [a[0], a[-1]]\nright = [a[n - 1], a[n]]\ncase2 = abs((top[0] - right[0]) * (top[1] - right[1]))\ncase1 = top[-1] - top[0]\nmny = 10000000000\nfor i in range(1, n):\n\tmny = min(mny, abs(a[i] - a[i + n - 1]))\ncase1 ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nPavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.\n\n... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n4 1 3 2 3 2 1 3\\n\", \"output\": \"1\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n5 8 5 5 7 5\\n\", \"output\": \"0\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n553296... | {
"index": 87,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nPavel made a photo of ... |
Solve the following coding problem using the programming language python:
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Ups... | [
"```python\n\ndef main():\n s = input()\n l = len(s)\n \n pretty_count = 0\n for i in range(l):\n left_paren_count = 0\n right_paren_count = 0\n wild_count = 0\n for j in range(i, l):\n if s[j] == '(':\n left_paren_count += 1\n elif s[j... | [{"type": "stdin_stdout", "input": "((?))\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "??()??\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "?????)(???\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "()()((?(()(((()()(())(((()((())))(()))(()(((((())))()))(((()()()))))))(((((()))))))))\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:
As Will is stuck in the Upside Down, he can still communic... | livecodebench | deepcoder_88 | 88 | [
{
"answer": "```python\ns = input()\n(res, n) = (0, len(s))\nfor i in range(n - 1):\n\t(j, c, q) = (i, 0, 0)\n\twhile j < n and c + q >= 0:\n\t\tif s[j] == '(':\n\t\t\tc += 1\n\t\telif s[j] == ')':\n\t\t\tc -= 1\n\t\telse:\n\t\t\tq += 1\n\t\tif c < q:\n\t\t\t(c, q) = (q, c)\n\t\tres += c == q\n\t\tj += 1\nprint... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nAs Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell h... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"((?))\\n\", \"output\": \"4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"??()??\\n\", \"output\": \"7\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"?????)(???\\n\", \"output\"... | {
"index": 88,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nAs Will is stuck in th... |
Solve the following coding problem using the programming language python:
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.
The killer starts with two po... | [
"```python\nimport sys\n\ns1, s2 = input().split()\nn = int(input())\n\nfor _ in range(n):\n print(s1, s2)\n killed, new = input().split()\n if s1 == killed:\n s1 = new\n else:\n s2 = new\n\nprint(s1, s2)\n\n```"
] | [{"type": "stdin_stdout", "input": "ross rachel\n4\nross joey\nrachel phoebe\nphoebe monica\nmonica chandler\n", "output": "ross rachel\njoey rachel\njoey phoebe\njoey monica\njoey chandler\n"}, {"type": "stdin_stdout", "input": "icm codeforces\n1\ncodeforces technex\n", "output": "icm codeforces\nicm technex\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:
Our beloved detective, Sherlock is currently trying to cat... | livecodebench | deepcoder_89 | 89 | [
{
"answer": "```python\ndef main():\n l = input().split()\n print(*l)\n for _ in range(int(input())):\n a, b = input().split()\n l[a == l[1]] = b\n print(*l)\n\n\nif __name__ == '__main__':\n main()\n\n```",
"question": "Solve the following coding problem using the programmi... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nOur beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strate... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"ross rachel\\n4\\nross joey\\nrachel phoebe\\nphoebe monica\\nmonica chandler\\n\", \"output\": \"ross rachel\\njoey rachel\\njoey phoebe\\njoey monica\\njoey chandler\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"ic... | {
"index": 89,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nOur beloved detective,... |
Solve the following coding problem using the programming language python:
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2^{w}_{i} pounds. In each step, Duff can lift some of the remaining weights and throw them... | [
"```python\nn = int(input())\na = [int(x) for x in input().split()]\nl = [0] * (10**6 + 100)\nfor x in a:\n\tl[x] += 1\ncur = 0\nans = 0\nfor x in l:\n\tcur += x\n\tif cur % 2:\n\t\tans += 1\n\tcur //= 2\nprint(ans)\n\n```"
] | [{"type": "stdin_stdout", "input": "5\n1 1 2 3 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n0 1 2 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1\n120287\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n28288 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2\n95745 95... | 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, Duff has been practicing weight lifting. As a ha... | livecodebench | deepcoder_90 | 90 | [
{
"answer": "```python\nfrom collections import *\nimport sys\nimport math\nfrom functools import reduce\n\ndef factors(n):\n\treturn set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\ndef li():\n\treturn [int(i) for i in input().rstrip('\\n').split(' ')]\n\ndef st():... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nRecently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, ... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"5\\n1 1 2 3 3\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n0 1 2 3\\n\", \"output\": \"4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"1\\n120287\\n\... | {
"index": 90,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nRecently, Duff has bee... |
Solve the following coding problem using the programming language python:
Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly n skills. Each skill is represented by a non-negative integer a_{i} — ... | [
"```python\nimport itertools\nimport bisect\n\nn, A, cf, cm, m = [int(x) for x in input().split()]\nskills = [int(x) for x in input().split()]\nsorted_skills = list(sorted((k, i) for i, k in enumerate(skills)))\nbottom_lift = [0 for i in range(n)]\nfor i in range(1, n):\n bottom_lift[i] = bottom_lift[i-1] + i * ... | [{"type": "stdin_stdout", "input": "3 5 10 1 5\n1 3 1\n", "output": "12\n2 5 2 \n"}, {"type": "stdin_stdout", "input": "3 5 10 1 339\n1 3 1\n", "output": "35\n5 5 5 \n"}, {"type": "stdin_stdout", "input": "2 6 0 1 4\n5 1\n", "output": "5\n5 5 \n"}, {"type": "stdin_stdout", "input": "1 1000000000 1000 1000 1000000000000... | 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:
Lesha plays the recently published new version of the lege... | livecodebench | deepcoder_91 | 91 | [
{
"answer": "```python\nimport bisect as bs\nimport heapq as hq\n\n\ndef force(cf, cm, f, m):\n return f*cf + m*cm\n\n\n# def perfect(sa, amax, m):\n# p = 0\n# while sa[-p-1] == amax:\n# p += 1\n# while sa[p] + m >= amax:\n# for _ in range(amax-sa[-p-1]):\n# yield p\n#... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nLesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly n skil... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3 5 10 1 5\\n1 3 1\\n\", \"output\": \"12\\n2 5 2 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3 5 10 1 339\\n1 3 1\\n\", \"output\": \"35\\n5 5 5 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_std... | {
"index": 91,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nLesha plays the recent... |
Solve the following coding problem using the programming language python:
You are given an array $a$ consisting of $n$ non-negative integers. You have to choose a non-negative integer $x$ and form a new array $b$ of size $n$ according to the following rule: for all $i$ from $1$ to $n$, $b_i = a_i \oplus x$ ($\oplus$ d... | [
"```python\nn = int(input())\nl = list(map(int, input().split()))\n\ninv = 0\nout = 0\nmult = 1\nfor i in range(32):\n curr = dict()\n opp = 0\n same = 0\n\n for v in l:\n if v ^ 1 in curr:\n if v & 1:\n opp += curr[v ^ 1]\n else:\n same += curr... | [{"type": "stdin_stdout", "input": "4\n0 1 3 2\n", "output": "1 0\n"}, {"type": "stdin_stdout", "input": "9\n10 7 9 10 7 5 5 3 5\n", "output": "4 14\n"}, {"type": "stdin_stdout", "input": "3\n8 10 3\n", "output": "0 8\n"}, {"type": "stdin_stdout", "input": "5\n1000000000 1000000000 1000000000 0 0\n", "output": "0 53687... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given an array $a$ consisting of $n$ non-negative ... | livecodebench | deepcoder_92 | 92 | [
{
"answer": "```python\nn=int(input())\nl=input().split()\nli=[int(i) for i in l]\nxori=0\nans=0\nmul=1\nfor i in range(32):\n hashi1=dict()\n hashi0=dict()\n inv1=0\n inv2=0\n for j in li:\n if(j//2 in hashi1 and j%2==0):\n inv1+=hashi1[j//2]\n if(j//2 in hashi0 and j%2=... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n non-negative integers. You have to choose a non-negative integer x and form a new array b of size n according to the following rule: for all... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n0 1 3 2\\n\", \"output\": \"1 0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"9\\n10 7 9 10 7 5 5 3 5\\n\", \"output\": \"4 14\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \... | {
"index": 92,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given an array... |
Solve the following coding problem using the programming language python:
Jeff has become friends with Furik. Now these two are going to play one quite amusing game.
At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p_1, p_2, ..., p_{n}. Then the guys take... | [
"```python\n3\n\nimport sys\n\nclass CumTree:\n \n def __init__(self, a, b):\n self.a = a\n self.b = b\n self.count = 0\n if a == b:\n return\n mid = (a + b) // 2\n self.levo = CumTree(a, mid)\n self.desno = CumTree(mid+1, b)\n \n def manjs... | [{"type": "stdin_stdout", "input": "2\n1 2\n", "output": "0.000000\n"}, {"type": "stdin_stdout", "input": "5\n3 5 2 4 1\n", "output": "13.000000\n"}, {"type": "stdin_stdout", "input": "16\n6 15 3 8 7 11 9 10 2 13 4 14 1 16 5 12\n", "output": "108.000000\n"}, {"type": "stdin_stdout", "input": "9\n1 7 8 5 3 4 6 9 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:
Jeff has become friends with Furik. Now these two are goin... | livecodebench | deepcoder_93 | 93 | [
{
"answer": "n = int(input())\nA = [int(i) for i in input().split()]\n\ndef mergesort(l):\n\tl = list(l)\n\tif len(l) <= 1:\n\t\treturn (l, 0)\n\t(left, linv) = mergesort(l[:len(l) // 2])\n\t(right, rinv) = mergesort(l[len(l) // 2:])\n\tlefti = 0\n\trighti = 0\n\ti = 0\n\tnuminversions = 0\n\twhile True:\n\t\ti... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Jeff has become friends with Furik. Now these two are going to play one quite amusing game.\n\nAt the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p1, p2, ..., pn. Then the guys take turns to make m... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n1 2\\n\", \"output\": \"0.000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n3 5 2 4 1\\n\", \"output\": \"13.000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"16\... | {
"index": 93,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nJeff has become friend... |
Solve the following coding problem using the programming language python:
DZY loves Physics, and he enjoys calculating density.
Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: $\left\{\begin{array}{ll}{\frac{v}{e}} ... | [
"```python\n\"\"\"\nCodeforces Round 254 Div 1 Problem A\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\ndef read(mode=2):\n # 0: String\n # 1: List of strings\n # 2: List of integers\n inputs = input().strip()\n if mode == 0:\n return inputs\n if mode == 1:\n return inpu... | [{"type": "stdin_stdout", "input": "1 0\n1\n", "output": "0.000000000000000\n"}, {"type": "stdin_stdout", "input": "2 1\n1 2\n1 2 1\n", "output": "3.000000000000000\n"}, {"type": "stdin_stdout", "input": "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63\n", "output": "2.965517241379311\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:
DZY loves Physics, and he enjoys calculating density.
Alm... | livecodebench | deepcoder_94 | 94 | [
{
"answer": "```python\n(n, m) = map(int, input().split())\nv = list(map(int, input().split()))\nmini = 0\nfor i in range(m):\n\t(a, b, c) = map(int, input().split())\n\tmini = max(mini, (v[a - 1] + v[b - 1]) / c)\nprint(mini)\n\n```",
"question": "Solve the following coding problem using the programming la... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nDZY loves Physics, and he enjoys calculating density.\n\nAlmost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph hav... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"1 0\\n1\\n\", \"output\": \"0.000000000000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2 1\\n1 2\\n1 2 1\\n\", \"output\": \"3.000000000000000\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdou... | {
"index": 94,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nDZY loves Physics, and... |
Solve the following coding problem using the programming language python:
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d... | [
"```python\ndef Search(L,aa,x):\n a=aa\n b=len(L)\n while(b-a>1):\n i=(b+a)//2\n if(L[i]>x):\n b=i\n elif(L[i]<x):\n a=i\n else:\n return (i+1)-aa-1\n return b-aa-1\n\nimport math\n\nn,d=list(map(int,input().split()))\n\nP=list(map(int,input()... | [{"type": "stdin_stdout", "input": "4 3\n1 2 3 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "4 2\n-3 -2 -1 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 19\n1 10 20 30 50\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 5\n31 36 43 47 48 50 56 69 71 86\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:
Little Petya likes points a lot. Recently his mom has pres... | livecodebench | deepcoder_95 | 95 | [
{
"answer": "```python\n(n, d) = map(int, input().split())\nnums = list(map(int, input().split()))\ncount = 0\nj = 0\nfor i in range(n):\n\twhile j < n and nums[j] - nums[i] <= d:\n\t\tj += 1\n\ttemp_length = j - i - 1\n\tcount += int(temp_length * (temp_length - 1) / 2)\nprint(count)\n\n```",
"question": "... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nLittle Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so tha... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4 3\\n1 2 3 4\\n\", \"output\": \"4\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4 2\\n-3 -2 -1 0\\n\", \"output\": \"2\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5 19\\n1 ... | {
"index": 95,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nLittle Petya likes poi... |
Solve the following coding problem using the programming language python:
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly a_{i} feet high.
[Image... | [
"```python\ndef read_data():\n n = int(input())\n hs = list(map(int, input().split()))\n return n, hs\n\n\ndef solve(n, hs):\n left = get_left_index(n, hs)\n right = get_right_index(n, hs)\n vals = [[] for i in range(n)]\n for h, l, r in zip(hs, left, right):\n vals[r - l - 2].append(h)\... | [{"type": "stdin_stdout", "input": "10\n1 2 3 4 5 4 3 2 1 6\n", "output": "6 4 4 3 3 2 2 1 1 1 \n"}, {"type": "stdin_stdout", "input": "3\n524125987 923264237 374288891\n", "output": "923264237 524125987 374288891 \n"}, {"type": "stdin_stdout", "input": "5\n585325539 365329221 412106895 291882089 564718673\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:
Mike is the president of country What-The-Fatherland. Ther... | livecodebench | deepcoder_96 | 96 | [
{
"answer": "```python\nfrom sys import stdin, stdout\ndef input(): return stdin.readline().strip()\ndef print(x, end='\\n'): stdout.write(str(x) + end)\n\nn, lst = int(input()), list(map(int, input().split()))\nnse, pse, stk, ans = [n for i in range(n)], [-1 for i in range(n)], [], [0 for i in range(n+1)]\nfor... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nMike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n fro... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"10\\n1 2 3 4 5 4 3 2 1 6\\n\", \"output\": \"6 4 4 3 3 2 2 1 1 1 \\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n524125987 923264237 374288891\\n\", \"output\": \"923264237 524125987 374288891 \\n\", \"metadata\":... | {
"index": 96,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nMike is the president ... |
Solve the following coding problem using the programming language python:
Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: The game starts with n piles of stones indexed from 1 to n. The i-th pile conta... | [
"```python\nn = int(input())\narr = [int(input()) for i in range(n)]\nb = [0 for i in range(n)]\ns = 0\nfor i in range(n):\n j = int((arr[i] << 1) ** 0.5)\n if j * (j + 1) > (arr[i] << 1):\n j -= 1\n s ^= j\nif s != 0:\n print('NO')\nelse:\n print('YES')\n\n```"
] | [{"type": "stdin_stdout", "input": "1\n5\n", "output": "NO"}, {"type": "stdin_stdout", "input": "2\n1\n2\n", "output": "YES"}, {"type": "stdin_stdout", "input": "3\n34\n44\n21\n", "output": "NO"}, {"type": "stdin_stdout", "input": "6\n34\n44\n21\n55\n1\n36\n", "output": "NO"}, {"type": "stdin_stdout", "input": "14\n34\... | 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:
Sam has been teaching Jon the Game of Stones to sharpen hi... | livecodebench | deepcoder_97 | 97 | [
{
"answer": "```python\nmemo = {}\n\n\ndef get_reachable_states(k, max_allowed):\n states = []\n for i in range(1, min(k,max_allowed) + 1):\n new_k = k - i\n states.append((new_k, i - 1))\n return states\n\n\ndef Grundy(k, max_allowed):\n if k == 0:\n return 0\n if (k, max_al... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nSam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: \n\n * The game... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"1\\n5\\n\", \"output\": \"NO\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"2\\n1\\n2\\n\", \"output\": \"YES\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"3\\n34\\n44\\n21\\n\", \"ou... | {
"index": 97,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nSam has been teaching ... |
Solve the following coding problem using the programming language python:
You are given an array consisting of n non-negative integers a_1, a_2, ..., a_{n}.
You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to n defining the order elements of the array a... | [
"```python\n__author__ = 'Think'\nn=int(input())\naints=[int(i) for i in input().split()]\npermutes=[int(i)-1 for i in input().split()]\nresults=[0]\n\nrebuilt={}\nm=0\nfor numby in range(n-1, 0, -1):\n\tp=permutes[numby]\n\tbelow=False\n\tabove=False\n\tif p-1 in rebuilt:\n\t\tbelow=True\n\tif p+1 in rebuilt:\n\t\... | [{"type": "stdin_stdout", "input": "4\n1 3 2 5\n3 4 1 2\n", "output": "5\n4\n3\n0\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n4 2 3 5 1\n", "output": "6\n5\n5\n1\n0\n"}, {"type": "stdin_stdout", "input": "8\n5 5 4 4 6 6 5 5\n5 2 8 7 1 3 4 6\n", "output": "18\n16\n11\n8\n8\n6\n6\n0\n"}, {"type": "stdin_stdout"... | null | null | You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.
Solve the following coding problem using the programming language python:
You are given an array consisting of n non-negative intege... | livecodebench | deepcoder_98 | 98 | [
{
"answer": "```python\nclass DSU:\n def __init__(self, n):\n self.par = list(range(n))\n self.arr = list(map(int, input().split()))\n self.siz = [1] * n\n self.sht = [0] * n\n self.max = 0\n def find(self, n):\n nn = n\n while nn != self.par[nn]:\n ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of n non-negative integers a1, a2, ..., an.\n\nYou are going to destroy integers in the array one by one. Thus, you are given the permutation of in... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"4\\n1 3 2 5\\n3 4 1 2\\n\", \"output\": \"5\\n4\\n3\\n0\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"5\\n1 2 3 4 5\\n4 2 3 5 1\\n\", \"output\": \"6\\n5\\n5\\n1\\n0\\n\", \"metadata\": {\"func_name\": null}}, {\"typ... | {
"index": 98,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nYou are given an array... |
Solve the following coding problem using the programming language python:
Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time.
Polycarp is good at marketing, so he has already collec... | [
"```python\nfrom bisect import bisect_left, insort_left\na = []\nn = int(input())\nfor _ in range(n):\n #print(a)\n s, d = list(map(int, input().split()))\n if len(a) == 0:\n print(s, s+d - 1)\n a.append((s, s + d - 1))\n continue\n p = bisect_left(a, (s, s + d - 1))\n #print('p'... | [{"type": "stdin_stdout", "input": "3\n9 2\n7 3\n2 4\n", "output": "9 10\n1 3\n4 7\n"}, {"type": "stdin_stdout", "input": "4\n1000000000 1000000\n1000000000 1000000\n100000000 1000000\n1000000000 1000000\n", "output": "1000000000 1000999999\n1 1000000\n100000000 100999999\n1000001 2000000\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:
Polycarp starts his own business. Tomorrow will be the fir... | livecodebench | deepcoder_99 | 99 | [
{
"answer": "```python\nt, p = 1, []\nfor i in range(int(input())):\n l, d = map(int, input().split())\n if t > l:\n for i, q in enumerate(p, 1):\n if q[0] <= l <= q[1] - d:\n p.insert(i, [l + d, q[1]])\n q[1] = l\n break\n else:\n ... | [
{
"content": "\nRelated Problem Solutions:\nQuestion: Solve the following coding problem using the programming language python:\n\nPolycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a give... | code | {
"ground_truth": "[{\"type\": \"stdin_stdout\", \"input\": \"3\\n9 2\\n7 3\\n2 4\\n\", \"output\": \"9 10\\n1 3\\n4 7\\n\", \"metadata\": {\"func_name\": null}}, {\"type\": \"stdin_stdout\", \"input\": \"4\\n1000000000 1000000\\n1000000000 1000000\\n100000000 1000000\\n1000000000 1000000\\n\", \"output\": \"10000000... | {
"index": 99,
"question": "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.\n\nSolve the following coding problem using the programming language python:\n\nPolycarp starts his ow... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.