Dataset Viewer
Auto-converted to Parquet Duplicate
problem_id
int64
2
2.71k
question
stringlengths
208
5.74k
solutions
stringlengths
838
165k
input_output
stringlengths
84
43.9M
difficulty
stringclasses
1 value
url
stringlengths
37
49
starter_code
stringclasses
1 value
2
Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are not. You are given current year in Berland. Your task is to find how long...
["def main():\n s = input()\n n = len(s)\n t = int(str(int(s[0]) + 1) + '0' * (n - 1))\n\n print(t - int(s))\n\nmain()\n", "s = input()\nx = int(s)\ny = int(str(int(s[0]) + 1) + '0' * (len(s) - 1))\nprint(y - x)", "n = int(input())\n\nfor i in range(0,11):\n for j in range(1,10):\n m = j*10**i\n ...
{ "inputs": [ "4\n", "201\n", "4000\n", "9\n", "10\n", "1\n", "100000000\n", "900000000\n", "999999999\n", "1000000000\n", "9999999\n", "100000001\n", "3660\n", "21\n", "900000001\n", "62911\n", "11\n", "940302010\n", "91\n", "101\n", ...
interview
https://codeforces.com/problemset/problem/808/A
3
You have a long fence which consists of $n$ sections. Unfortunately, it is not painted, so you decided to hire $q$ painters to paint it. $i$-th painter will paint all sections $x$ such that $l_i \le x \le r_i$. Unfortunately, you are on a tight budget, so you may hire only $q - 2$ painters. Obviously, only painters yo...
["from collections import defaultdict as dd\nimport math\ndef nn():\n\treturn int(input())\n\ndef li():\n\treturn list(input())\n\ndef mi():\n\treturn list(map(int, input().split()))\n\ndef lm():\n\treturn list(map(int, input().split()))\n\n\nn, q=mi()\n\nints=[]\n\n\nfor _ in range(q):\n\tst, end=mi()\n\tints.append((...
{ "inputs": [ "7 5\n1 4\n4 5\n5 6\n6 7\n3 5\n", "4 3\n1 1\n2 2\n3 4\n", "4 4\n1 1\n2 2\n2 3\n3 4\n", "3 3\n1 3\n1 1\n2 2\n", "6 3\n1 6\n1 3\n4 6\n", "3 3\n1 1\n2 3\n2 3\n", "3 4\n1 3\n1 1\n2 2\n3 3\n", "233 3\n1 2\n2 3\n3 4\n", "5 3\n5 5\n1 3\n3 5\n", "4 5\n1 4\n1 1\n2 2\n3 3\n...
interview
https://codeforces.com/problemset/problem/1132/C
5
Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) for her studies, and she wants to close all the tabs that don't belong to this se...
["n, pos, l, r = map(int, input().split())\n\nif l > 1 and r < n:\n if l <= pos and pos <= r:\n if pos - l < r - pos:\n print(pos - l + 1 + r - l + 1)\n else:\n print(r - pos + 1 + r - l + 1)\n elif pos > r:\n print(pos - r + 1 + r - l + 1)\n else:\n print(l - ...
{ "inputs": [ "6 3 2 4\n", "6 3 1 3\n", "5 2 1 5\n", "100 1 1 99\n", "100 50 1 99\n", "100 99 1 99\n", "100 100 1 99\n", "100 50 2 100\n", "100 1 100 100\n", "100 50 50 50\n", "6 4 2 5\n", "100 5 2 50\n", "10 7 3 9\n", "7 4 2 5\n", "43 16 2 18\n", "100 5...
interview
https://codeforces.com/problemset/problem/915/B
7
Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale: "Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best builders were building that ba...
["n, m = map(int, input().split())\nif (m >= n): print(n)\nelse:\n c = n - m\n l = 0\n r = 10 ** 18\n while r - l > 1:\n md = (r + l) // 2\n if (1 + md) * md // 2 < c:\n l = md\n else:\n r = md\n print(r + m)", "n, m = map(int, input().split())\n\ndef calc(n):\n...
{ "inputs": [ "5 2\n", "8 1\n", "32 5\n", "1024 1024\n", "58044 52909\n", "996478063 658866858\n", "570441179141911871 511467058318039545\n", "1 1\n", "1000000000000000000 1000000000000000000\n", "1000000000000000000 999999999999997145\n", "1 1000000000000000000\n", "10...
interview
https://codeforces.com/problemset/problem/785/C
8
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from $1$ to $9$). In this problem, we use one digit and one lowercase letter, which is the fir...
["cards=list(input().split())\nlm=[0]*9\nlp=[0]*9\nls=[0]*9\nfor item in cards:\n if item[1]=='m':\n lm[int(item[0])-1]+=1\n elif item[1]=='p':\n lp[int(item[0])-1]+=1\n else :\n ls[int(item[0])-1]+=1\nif max(lm)==3 or max(lp)==3 or max(ls)==3:\n print(0)\nelse :\n flag=0\n def se...
{ "inputs": [ "1s 2s 3s\n", "9m 9m 9m\n", "3p 9m 2p\n", "8p 2s 9m\n", "5s 8m 5s\n", "9s 4s 3m\n", "4p 8m 9s\n", "8s 5s 7p\n", "4p 7p 2p\n", "3p 2p 3p\n", "5s 9p 5s\n", "9m 6s 1p\n", "4m 2p 8m\n", "8p 6s 4p\n", "9s 6m 7p\n", "4m 1p 3m\n", "8s 8m 1p\n"...
interview
https://codeforces.com/problemset/problem/1191/B
10
On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars. -----Input----- The first line of the input ...
["n=int(input())\nr=n%7\nd=n//7\nprint(2*d+max(0,r-5),2*d+min(r,2))\n", "minday = maxday = 0\n\nfor i in range(int(input())) :\n k = i % 7\n if k == 0 or k == 1 : maxday += 1\n if k == 5 or k == 6 : minday += 1\n\nprint(minday, maxday)", "__author__ = 'Andrey'\nn = int(input())\nk = n // 7\nc = n % 7\nprint(2 ...
{ "inputs": [ "14\n", "2\n", "1\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "11\n", "12\n", "13\n", "1000000\n", "16\n", "17\n", "18\n", "19\n", "20\n", "21\n", "22\n", "23\n", "24\n", "25\n", "26\...
interview
https://codeforces.com/problemset/problem/670/A
12
Vova has won $n$ trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row. The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two trophies (not necessarily adjacent ones) to make the arrangement a...
["n = int(input())\nA = input()\nx = A.count('G')\nnum_1 = 0\nnum_2 = 0\nmax_num = 0\nflag = 0\nfor i in range(n):\n if A[i] == 'G' and flag == 0:\n num_1 += 1\n elif A[i] == 'G' and flag == 1:\n num_2 += 1\n elif A[i] == 'S' and flag == 0:\n flag = 1\n else:\n if num_1 + num_2 +...
{ "inputs": [ "10\nGGGSGGGSGG\n", "4\nGGGG\n", "3\nSSS\n", "11\nSGGGGSGGGGS\n", "300\nSSGSGSSSGSGSSSSGGSGSSGGSGSGGSSSGSSGSGGSSGGSGSSGGSGGSSGSSSGSGSGSSGSGGSSSGSSGSSGGGGSSGSSGSSGSGGSSSSGGGGSSGSSSSSSSSGSSSSGSGSSSSSSSSGSGSSSSGSSGGSSGSGSSSSSSGSGSSSGGSSGSGSSGSSSSSSGGGSSSGSGSGSGGSGGGSSGSGSSSGSSGGSSGSSGGG...
interview
https://codeforces.com/problemset/problem/1082/B
16
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are regular bracket sequences; ")...
["cnt1 = int(input())\ncnt2 = int(input())\ncnt3 = int(input())\ncnt4 = int(input())\nif cnt1 != cnt4:\n\tprint(0)\n\treturn\n\nif (cnt3 != 0 and cnt1 == 0):\n\tprint(0)\n\treturn\n\nprint(1)", "cnt = [int(input()) for _ in range(4)]\n\nif cnt[0] != cnt[3]:\n\tprint(0)\nelif cnt[2] > 0 and cnt[0] == 0:\n\tprint(0)\nels...
{ "inputs": [ "3\n1\n4\n3\n", "0\n0\n0\n0\n", "1\n2\n3\n4\n", "1000000000\n1000000000\n1000000000\n1000000000\n", "1000000000\n1000000000\n1000000000\n999999999\n", "1000000000\n999999999\n1000000000\n1000000000\n", "0\n1000000000\n0\n0\n", "0\n0\n1\n0\n", "4\n3\n2\n1\n", "1\n2...
interview
https://codeforces.com/problemset/problem/1132/A
18
"Petya recieved a gift of a string s with length up to 10^5 characters for his birthday. He took two(...TRUNCATED)
"[\"from collections import deque\\nS = input()\\nmn = [ 300 for i in range( len( S ) ) ]\\nfor i in(...TRUNCATED)
"{\n \"inputs\": [\n \"cab\\n\",\n \"acdb\\n\",\n \"a\\n\",\n \"ab\\n\",\n \"ba\\n\"(...TRUNCATED)
interview
https://codeforces.com/problemset/problem/797/C
20
"Karen is getting ready for a new school day!\n\n [Image] \n\nIt is currently hh:mm, given in a 24-h(...TRUNCATED)
"[\"s = input()\\nh = int(s[:2])\\nm = int(s[3:])\\n\\ndef ispalin(h, m):\\n s = \\\"%02d:%02d\\\(...TRUNCATED)
"{\n \"inputs\": [\n \"05:39\\n\",\n \"13:31\\n\",\n \"23:59\\n\",\n \"13:32\\n\",\n (...TRUNCATED)
interview
https://codeforces.com/problemset/problem/816/A
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
52