problem_id int64 0 4.72k | problem_content stringlengths 152 5.64k | code_prompt stringclasses 1
value | difficulty stringclasses 3
values | solutions stringlengths 98 1.12M | test_cases stringlengths 70 1.03M |
|---|---|---|---|---|---|
0 | An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $091$), a colon (ASCII code $058$), some (possibly zero) vertical line characters (ASCII code $124$), another colon, ... | interview | [{"code": "s = input()\nn = len(s)\nind = -1\nf = False\nfor i in range(n):\n if s[i] == '[':\n f = True\n elif s[i] == ':':\n if f:\n ind = i\n break\nbind = -1\nf = False\nfor i in range(n-1,-1,-1):\n if s[i] == ']':\n f = True\n elif s[i] == ':':\n if f:\... | [{"input": "|[a:b:|]\n", "output": "4\n"}, {"input": "|]:[|:]\n", "output": "-1\n"}, {"input": ":][:\n", "output": "-1\n"}, {"input": ":[]:\n", "output": "-1\n"}, {"input": "[[:]]\n", "output": "-1\n"}, {"input": "[::]\n", "output": "4\n"}, {"input": "]:|:[\n", "output": "-1\n"}, {"input": ":::::]\n", "output": "-1\n"}... | |
1 | Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.
Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them.
-----Input-----
The first line contains the positive inte... | interview | [{"code": "num = list(map(int, input()))\nbest = num[:]\nfor i in range(-1, -len(num) - 1, -1):\n if num[i] == 0:\n continue\n num[i] -= 1\n for j in range(i + 1, 0):\n num[j] = 9\n if sum(num) > sum(best):\n best = num[:]\ns = ''.join(map(str, best)).lstrip('0')\nprint(s)\n", "passed":... | [{"input": "100\n", "output": "99\n"}, {"input": "48\n", "output": "48\n"}, {"input": "521\n", "output": "499\n"}, {"input": "1\n", "output": "1\n"}, {"input": "2\n", "output": "2\n"}, {"input": "3\n", "output": "3\n"}, {"input": "39188\n", "output": "38999\n"}, {"input": "5\n", "output": "5\n"}, {"input": "6\n", "outp... | |
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... | interview | [{"code": "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", "passed": true, "time": 0.16, "memory": 15128.0, "status": "done"}, {"code": "s = input()\nx = int(s)\ny = int(str(int(s[0]) + 1) + '0' * (len(s) - 1))\nprint(y - x)", "passed"... | [{"input": "4\n", "output": "1\n"}, {"input": "201\n", "output": "99\n"}, {"input": "4000\n", "output": "1000\n"}, {"input": "9\n", "output": "1\n"}, {"input": "10\n", "output": "10\n"}, {"input": "1\n", "output": "1\n"}, {"input": "100000000\n", "output": "100000000\n"}, {"input": "900000000\n", "output": "100000000\n... | |
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... | interview | [{"code": "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... | [{"input": "7 5\n1 4\n4 5\n5 6\n6 7\n3 5\n", "output": "7\n"}, {"input": "4 3\n1 1\n2 2\n3 4\n", "output": "2\n"}, {"input": "4 4\n1 1\n2 2\n2 3\n3 4\n", "output": "3\n"}, {"input": "3 3\n1 3\n1 1\n2 2\n", "output": "3\n"}, {"input": "6 3\n1 6\n1 3\n4 6\n", "output": "6\n"}, {"input": "3 3\n1 1\n2 3\n2 3\n", "output": ... | |
4 | Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every x minutes until hh: mm is reached, and only then he will wake up. He wants to kno... | interview | [{"code": "x=int(input())\nh,m=list(map(int,input().split()))\ndef ok(mm):\n while mm<0: mm+=1440\n hh=mm//60\n mm=mm%60\n return hh%10==7 or hh//10==7 or mm%10==7 or mm//10==7\nfor y in range(999):\n if ok(h*60+m-y*x):\n print(y)\n return\n", "passed": true, "time": 0.17, "memory": 15204.0, "status": "done"... | [{"input": "3\n11 23\n", "output": "2\n"}, {"input": "5\n01 07\n", "output": "0\n"}, {"input": "34\n09 24\n", "output": "3\n"}, {"input": "2\n14 37\n", "output": "0\n"}, {"input": "14\n19 54\n", "output": "9\n"}, {"input": "42\n15 44\n", "output": "12\n"}, {"input": "46\n02 43\n", "output": "1\n"}, {"input": "14\n06 41... | |
5 | "Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n f(...TRUNCATED) | interview | "[{\"code\": \"n, pos, l, r = map(int, input().split())\\n\\nif l > 1 and r < n:\\n if l <= pos a(...TRUNCATED) | "[{\"input\": \"6 3 2 4\\n\", \"output\": \"5\\n\"}, {\"input\": \"6 3 1 3\\n\", \"output\": \"1\\n\(...TRUNCATED) | |
6 | "You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like r(...TRUNCATED) | interview | "[{\"code\": \"for _ in range(int(input())):\\n n, x = list(map(int, input().split()))\\n A = (...TRUNCATED) | "[{\"input\": \"3\\n3 10\\n6 3\\n8 2\\n1 4\\n4 10\\n4 1\\n3 2\\n2 6\\n1 100\\n2 15\\n10 11\\n14 100\(...TRUNCATED) | |
7 | "Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right(...TRUNCATED) | interview | "[{\"code\": \"n, m = map(int, input().split())\\nif (m >= n): print(n)\\nelse:\\n c = n - m\\n (...TRUNCATED) | "[{\"input\": \"5 2\\n\", \"output\": \"4\\n\"}, {\"input\": \"8 1\\n\", \"output\": \"5\\n\"}, {\"i(...TRUNCATED) | |
8 | "Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in(...TRUNCATED) | interview | "[{\"code\": \"cards=list(input().split())\\nlm=[0]*9\\nlp=[0]*9\\nls=[0]*9\\nfor item in cards:\\n (...TRUNCATED) | "[{\"input\": \"1s 2s 3s\\n\", \"output\": \"0\\n\"}, {\"input\": \"9m 9m 9m\\n\", \"output\": \"0\\(...TRUNCATED) | |
9 | "Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has(...TRUNCATED) | interview | "[{\"code\": \"#!/usr/bin/env python3\\n\\n\\nd = int(input().strip())\\n[n, m] = list(map(int, inpu(...TRUNCATED) | "[{\"input\": \"2\\n3 2\\n3 1 3 2\\n1 2 2 2\\n1 0 0 1\\n\", \"output\": \"1\\n\"}, {\"input\": \"3\\(...TRUNCATED) |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 10