problem stringlengths 29 13.2k | solutions listlengths 1 4.84k | tests stringlengths 120 74M | starter_code stringclasses 0
values | metadata stringclasses 1
value | question stringlengths 594 13.8k | ground_truth stringlengths 450 74M | data_source stringclasses 1
value | uid stringlengths 11 15 | index int64 0 17.8k | ICL listlengths 1 3 |
|---|---|---|---|---|---|---|---|---|---|---|
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... | [{"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... | 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... |
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... | [{"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", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input": "4 ... | 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... |
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... | [{"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", "metadata": {"func_name": null}}, {"type": "stdin_stdout", "input":... | 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... |
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... | [{"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", "output": "0\n", "metadata": {"func_name": null}}, {"type": "stdin_... | 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... |
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 ... | [{"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", "output": "0 13 26 39 26 13\n", "metadata": {"func_name": null... | 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+... |
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... | [{"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", "output": "3\n1 1 3 ", "metadata": {"func_name": null}}, {"type": "... | 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(-... |
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... | [{"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", "input": "bbaabaabbb\n", "output": "0.100000000000000\n", "... | 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... |
"Solve the following coding problem using the programming language python:\n\nIn the evenings Donkey(...TRUNCATED) | ["```python\nfrom bisect import *\nfrom math import *\n\nn = int(input())\na, b, c, d = list(map(int(...TRUNCATED) | "[{\"type\": \"stdin_stdout\", \"input\": \"15\\n1/3 2/1\\n3 1\\n6 2\\n4 2\\n2 5\\n4 5\\n6 6\\n3 4\\(...TRUNCATED) | null | null | "You are an expert Python programmer. You will be given a question (problem specification) and will (...TRUNCATED) | "[{\"type\": \"stdin_stdout\", \"input\": \"15\\n1/3 2/1\\n3 1\\n6 2\\n4 2\\n2 5\\n4 5\\n6 6\\n3 4\\(...TRUNCATED) | livecodebench | deepcoder_7 | 7 | [{"answer":"```python\nimport bisect\n\ndef INPUT():\n\tglobal n, a, b, c, d\n\tn = int(input())\n\t(...TRUNCATED) |
"Solve the following coding problem using the programming language python:\n\nThe Little Elephant ha(...TRUNCATED) | ["```python\nx = input ()\n\nflag = 0\ns = 0\n\nfor each_item in x:\n if each_item == '0':\n (...TRUNCATED) | "[{\"type\": \"stdin_stdout\", \"input\": \"101\\n\", \"output\": \"11\\n\"}, {\"type\": \"stdin_std(...TRUNCATED) | null | null | "You are an expert Python programmer. You will be given a question (problem specification) and will (...TRUNCATED) | "[{\"type\": \"stdin_stdout\", \"input\": \"101\\n\", \"output\": \"11\\n\", \"metadata\": {\"func_n(...TRUNCATED) | livecodebench | deepcoder_8 | 8 | [{"answer":"```python\ns = list(input())\nfor i in range(len(s)):\n\tif s[i] == '0':\n\t\tbreak\ndel(...TRUNCATED) |
"Solve the following coding problem using the programming language python:\n\nIt is so boring in the(...TRUNCATED) | ["```python\ndef gcd(a, b):\n while b > 0:\n a, b = b, a % b\n return a\n\nn = int(inpu(...TRUNCATED) | "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n2 3\\n\", \"output\": \"Alice\\n\"}, {\"type\": \"st(...TRUNCATED) | null | null | "You are an expert Python programmer. You will be given a question (problem specification) and will (...TRUNCATED) | "[{\"type\": \"stdin_stdout\", \"input\": \"2\\n2 3\\n\", \"output\": \"Alice\\n\", \"metadata\": {\(...TRUNCATED) | livecodebench | deepcoder_9 | 9 | [{"answer":"```python\nfrom sys import *\nfrom math import *\nfrom string import *\nfrom operator im(...TRUNCATED) |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 10