problem stringlengths 29 7.23k | tests stringlengths 101 74M | solutions sequencelengths 1 6.38k |
|---|---|---|
There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values — red, green, or blue). All candies inside a single box have the same color (and it is ... | {"inputs": ["5 3 10\n1 2 3 4 5\nRGBRR\n", "2 1 15\n5 6\nRG\n", "6 1 21\n4 2 3 5 1 6\nRGBGRB\n", "6 1 21\n6 5 4 3 2 1\nRGBRGB\n", "1 1 10\n10\nR\n", "2 1 10\n5 5\nRG\n", "2 1 10\n5 6\nRR\n", "5 3 10\n1 2 3 4 5\nRGBRG\n", "9 1 6\n1 1 1 3 3 3 2 2 2\nRGGBRRGBB\n", "50 39 2000\n48 43 26 24 46 37 15 30 39 34 4 14 29 34 8 18 ... | [
"INF = 10000000000.0\nmax_n = 50\nmax_k = 2000\n\ndef main():\n\t(n, s, k) = map(int, input().split())\n\ts -= 1\n\tbuf = [''] * (max_n + 1)\n\tdp = [[0 for i in range(max_n + 1)] for j in range(max_k + 1)]\n\tr = list(map(int, input().split()))\n\tc = input()\n\tanswer = INF\n\tfor i in range(len(c)):\n\t\tbuf[i] ... |
If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written.
Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict how many years it will take before your ... | {"inputs": ["9714431", "16612328", "23422731", "754526", "955577", "75547", "2112", "799", "88", "32523857", "4787", "1859551", "135661", "3675", "156692", "167918384", "83994", "4837847", "14513597", "15282598", "12659326", "1468417", "6280", "115464", "52376853", "2315", "3641224", "97187", "836", "195884", "36250", ... | [
"def sub(maxs, mins):\n\tfor i in range(len(maxs)):\n\t\tif maxs[i] != mins[i]:\n\t\t\tif i == len(maxs) - 1:\n\t\t\t\treturn int(maxs[i]) - int(mins[i])\n\t\t\tif i == len(maxs) - 2:\n\t\t\t\treturn int(maxs[i:i + 2]) - int(mins[i:i + 2])\n\t\t\treturn 10\n\treturn 0\n\ndef checkEqual(S):\n\tans = 8\n\tfor k in ra... |
An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethe... | {"fn_name": "is_anagram", "inputs": [["foefet", "toffee"], ["Buckethead", "DeathCubeK"], ["Twoo", "WooT"], ["dumble", "bumble"], ["ound", "round"], ["apple", "pale"]], "outputs": [[true], [true], [true], [false], [false], [false]]} | [
"def is_anagram(test, original):\n\treturn sorted(original.lower()) == sorted(test.lower())\n",
"from collections import Counter\n\ndef is_anagram(test, original):\n\treturn Counter(test.lower()) == Counter(original.lower())\n",
"def is_anagram(test, original):\n\treturn sorted(test.upper()) == sorted(original.... |
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water d... | {"inputs": ["3\n0 1 1\n", "4\n0 0 1 2\n", "2\n0 0\n", "4\n0 1 1 0\n", "3\n0 1 0\n", "2\n0 1\n", "8\n0 0 2 0 3 0 3 2\n", "3\n0 1 2\n", "10\n0 0 2 2 3 2 3 3 1 3\n", "6\n0 0 0 2 0 1\n", "10\n0 1 2 0 4 5 3 6 0 5\n", "4\n0 0 1 1\n", "3\n0 0 0\n", "9\n0 1 0 1 1 4 0 4 8\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2... | [
"n = int(input())\nabove = list(map(int, input().split()))\ntotal = [x + 1 for x in above]\nfor i in range(0, n - 1)[::-1]:\n\ttotal[i] = max(total[i], total[i + 1] - 1)\nfor i in range(1, n):\n\ttotal[i] = max(total[i], total[i - 1])\nbelow = [t - a - 1 for (t, a) in zip(total, above)]\nprint(sum(below))\n",
"fr... |
You are given an array $a_1, a_2, \dots, a_n$. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements $a_i = a_{i + 1}$ (if there is at least one such pair). Replace them by one element with value $a_i + 1$.
After each such operation, the length of the array wil... | {"inputs": ["5\n4 3 2 2 3\n", "7\n3 3 4 4 4 3 3\n", "3\n1 3 5\n", "1\n1000\n", "15\n67 67 65 65 66 66 66 68 67 67 67 65 65 66 70\n", "15\n17 17 18 17 16 16 17 17 15 15 13 12 12 14 15\n", "20\n10 6 25 38 8 4 22 40 28 45 23 33 18 39 28 26 40 4 14 47\n", "20\n6 5 5 7 12 12 12 12 7 41 35 28 28 28 28 13 12 12 7 6\n", "20\n6... | [
"from collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, itertools, math\nsys.setrecursionlimit(10 ** 5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\n\ndef LI():\n\treturn list(map(int, input().split()))\n\ndef LF():\n\treturn list... |
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins.
Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different col... | {"inputs": ["1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 38... | [
"from heapq import heappushpop\nimport sys\n(X, Y, Z) = map(int, sys.stdin.readline().split())\nN = X + Y + Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key=lambda x: x[0] - x[1], reverse=True)\nGB = [None] * N\nQ = [a - c for (a, _, c) in ABC[:X]]\nQ.sort()\ngs = sum((a for (... |
Implement a function called makeAcronym that returns the first letters of each word in a passed in string.
Make sure the letters returned are uppercase.
If the value passed in is not a string return 'Not a string'.
If the value passed in is a string which contains characters other than spaces and alphabet letters, r... | {"fn_name": "make_acronym", "inputs": [["My aunt sally"], ["Please excuse my dear aunt Sally"], ["How much wood would a woodchuck chuck if a woodchuck could chuck wood"], ["Unique New York"], ["a42"], ["1111"], [64], [[]], [{}], [""]], "outputs": [["MAS"], ["PEMDAS"], ["HMWWAWCIAWCCW"], ["UNY"], ["Not letters"], ["Not ... | [
"def make_acronym(phrase):\n\ttry:\n\t\treturn ''.join((word[0].upper() if word.isalpha() else 0 for word in phrase.split()))\n\texcept AttributeError:\n\t\treturn 'Not a string'\n\texcept TypeError:\n\t\treturn 'Not letters'\n",
"from operator import itemgetter\n\ndef make_acronym(phrase):\n\tif type(phrase) != ... |
"When little Petya grew up and entered the university, he started to take part in АСМ contests. L(...TRUNCATED) | "{\"inputs\": [\"7 6\\nAlena\\nOlya\\nVanya\\nBrus\\nJohn\\nAlice\\nMariana\\nAlena John\\nAlena Ali(...TRUNCATED) | ["tmp = input().split(' ')\nN_ppl = int(tmp[0])\nN_cstrt = int(tmp[1])\nppl_to_id = {}\nid_ppl = [0](...TRUNCATED) |
"# Solve For X\n\nYou will be given an equation as a string and you will need to [solve for X](https(...TRUNCATED) | "{\"fn_name\": \"solve_for_x\", \"inputs\": [[\"x - 5 = 20\"], [\"5 * x + 5 = 30\"], [\"20 = 5 * x -(...TRUNCATED) | ["from itertools import count\n\ndef solve_for_x(equation):\n\treturn next((x for n in count(0) for (...TRUNCATED) |
"Write a function that takes an array/list of numbers and returns a number such that \n\nExplanation(...TRUNCATED) | "{\"fn_name\": \"total\", \"inputs\": [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4]], [[1, 2, 3]], [[4, 4, 52, 2(...TRUNCATED) | ["def total(arr):\n\twhile len(arr) > 1:\n\t\tarr = [x + y for (x, y) in zip(arr, arr[1:])]\n\tretur(...TRUNCATED) |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 90