task_type
stringclasses
1 value
problem
stringlengths
209
3.39k
answer
stringlengths
35
6.15k
problem_tokens
int64
60
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. ## Task Given a positive integer, `n`, return the number of possible ways such that `k` positive integers multiply to `n`. Order matters. **Examples** ``` n = 24 k = 2 (1, 24), (2, 12), (3, 8), (4, 6), (6, 4), (8, 3), (12, 2), (24, 1) -> 8 n = 100 k =...
{"functional": "_inputs = [[24, 2], [100, 1], [20, 3], [1, 2], [1000000, 3], [10, 2], [36, 4]]\n_outputs = [[8], [1], [18], [1], [784], [4], [100]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isins...
380
228
coding
Solve the programming task below in a Python markdown code block. Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only. Chef's canvas is N millimeters ...
{"inputs": ["3\n4\n1 5 5 5\n3\n1 1 1 5\n3\n5 5 2", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 5 2", "3\n4\n1 5 5 6\n4\n1 1 1 5\n3\n5 5 2", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 5 3", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 1 3", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n1 1 3", "3\n4\n2 5 5 5\n3\n1 2 1 5\n3\n1 1 3", "3\n4\n1 5 5 6\n3\n1 1 1 5\n3\n5 5 ...
679
318
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. We know that 4 and 7 are lucky digits. Also, a number is called lucky if it contains only lucky digits. You are given an integer k, return the kth lucky number represented as a string.   Please complete the following ...
{"functional": "def check(candidate):\n assert candidate(k = 4) == \"47\"\n assert candidate(k = 10) == \"477\"\n assert candidate(k = 1000) == \"777747447\"\n\n\ncheck(Solution().kthLuckyNumber)"}
97
76
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent...
{"functional": "def check(candidate):\n assert candidate(parent = [-1,0,0,1,1,2], s = \"abacbe\") == 3\n assert candidate(parent = [-1,0,0,0], s = \"aabc\") == 3\n\n\ncheck(Solution().longestPath)"}
185
73
coding
Solve the programming task below in a Python markdown code block. Berland scientists noticed long ago that the world around them depends on Berland population. Due to persistent research in this area the scientists managed to find out that the Berland chronology starts from the moment when the first two people came to ...
{"inputs": ["1\n", "9\n", "4\n", "6\n", "3\n", "2\n", "25\n", "24\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n1\n1\n0\n", "NO\n", "YES\n1\n3\n1\n145\n"]}
605
88
coding
Solve the programming task below in a Python markdown code block. Write a command line tool which takes a file path as input and prints the number of lines, number of words, number of characters in the file, userid of the owner of the file, groupid of owner of the file and last modification time of the file in UNIX tim...
{"inputs": ["/home/input\n"], "outputs": ["19\n402\n2612\n0\n0\n1358021928\n"]}
193
41
coding
Solve the programming task below in a Python markdown code block. Two friends David and Rojer were preparing for their weekly class-test. The are preparing for the math test, but because of continuously adding big integers and solving equations they got exhausted. They decided to take break and play a game. They play a...
{"inputs": ["3\nTHIS\nIS\nTOO\nFUNNY"], "outputs": ["true"]}
331
22
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding windo...
{"functional": "def check(candidate):\n assert candidate(nums = [1,3,-1,-3,5,3,6,7], k = 3) == [3,3,5,5,6,7]\n assert candidate(nums = [1], k = 1) == [1]\n\n\ncheck(Solution().maxSlidingWindow)"}
116
81
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef cooks nice receipes in the cafeteria of his company. The cafe contains N boxes with food enumerated from 1 to N and are placed in a circle in clocwise order (boxes 1 and...
{"inputs": ["3\n4\n1 1 1 1\n4\n3 0 0 0\n4\n0 0 0 2"], "outputs": ["4\n1\n2"]}
602
46
coding
Solve the programming task below in a Python markdown code block. Chef recorded a video explaining his favorite recipe. However, the size of the video is too large to upload on the internet. He wants to compress the video so that it has the minimum size possible. Chef's video has N frames initially. The value of the ...
{"inputs": ["4\n1\n5\n2\n1 1\n3\n1 2 3\n4\n2 1 2 2\n"], "outputs": ["1\n1\n3\n3"]}
559
47
coding
Solve the programming task below in a Python markdown code block. Given a string and an array of index numbers, return the characters of the string rearranged to be in the order specified by the accompanying array. Ex: scramble('abcd', [0,3,1,2]) -> 'acdb' The string that you will be returning back will have: 'a' a...
{"functional": "_inputs = [['abcd', [0, 3, 1, 2]], ['sc301s', [4, 0, 3, 1, 5, 2]], ['bskl5', [2, 1, 4, 3, 0]]]\n_outputs = [['acdb'], ['c0s3s1'], ['5sblk']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n ...
206
226
coding
Solve the programming task below in a Python markdown code block. Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces out of the...
{"inputs": ["FVF\nr \n", "FVF\nq \n", "FFV\nq \n", "VFF\nq \n", "VFG\nq \n", "GtPXu\nd\n", "GPtXu\nd\n", "XPtGu\nd\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
296
104
coding
Solve the programming task below in a Python markdown code block. Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift X[i] grams on day i. In order to improve his workout performance at the gym, he ca...
{"inputs": ["5 49\n22 23 7 17 49\n50\n102 55 77 3 977\n", "5 49\n22 23 11 17 49\n50\n102 55 77 3 977\n", "5 1\n1 1 1 2 9\n1000000000\n10 20 30 40 50\n", "5 49\n22 23 11 17 49\n50\n102 55 77 34 977\n", "5 1\n1 1 1 2 9\n1000000000\n10 20 30 76 50\n", "5 1\n1 1 2 2 9\n1000000000\n10 20 30 40 50\n", "5 1\n1 1 1 2 9\n100000...
544
374
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase. A subsequence of string $s$ is a string that can be derived from $s$ by deleting some of its symbols w...
{"inputs": ["1 5\nA\n", "1 1\nA\n", "1 4\nD\n", "1 4\nD\n", "1 1\nA\n", "1 5\nA\n", "1 7\nA\n", "1 4\nC\n"], "outputs": ["0", "1", "0", "0\n", "1\n", "0\n", "0\n", "0\n"]}
383
99
coding
Solve the programming task below in a Python markdown code block. You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can mo...
{"inputs": ["1 1\n1 1\n0 0\n.\n", "1 1\n1 1\n0 0\n.\n", "1 1\n1 1\n31 42\n.\n", "1 1\n1 1\n31 42\n.\n", "1 7\n1 1\n0 3\n.......\n", "1 7\n1 1\n0 3\n.......\n", "4 4\n2 2\n0 1\n....\n..*.\n....\n....\n", "4 4\n2 2\n0 1\n....\n..*.\n....\n....\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "4\n", "4\n", "7\n", "7\n"]}
521
194
coding
Solve the programming task below in a Python markdown code block. # Task Consider an array of integers `a`. Let `min(a)` be its minimal element, and let `avg(a)` be its mean. Define the center of the array `a` as array `b` such that: ``` - b is formed from a by erasing some of its elements. - For each i, |b[i] - avg(...
{"functional": "_inputs = [[[8, 3, 4, 5, 2, 8]], [[1, 3, 2, 1]], [[10, 11, 12, 13, 14]]]\n_outputs = [[[4, 5]], [[1, 2, 1]], [[10, 11, 12, 13, 14]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isin...
305
233
coding
Solve the programming task below in a Python markdown code block. Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T'). Ribonucleic acid, RNA, is the primary messenger mol...
{"functional": "_inputs = [['TTTT'], ['GCAT'], ['GACCGCCGCC'], ['GATTCCACCGACTTCCCAAGTACCGGAAGCGCGACCAACTCGCACAGC'], ['CACGACATACGGAGCAGCGCACGGTTAGTACAGCTGTCGGTGAACTCCATGACA'], ['AACCCTGTCCACCAGTAACGTAGGCCGACGGGAAAAATAAACGATCTGTCAATG'], ['GAAGCTTATCCGTTCCTGAAGGCTGTGGCATCCTCTAAATCAGACTTGGCTACGCCGTTAGCCGAGGGCTTAGCGTTGAGT...
227
696
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.   Please complete the following python code precisely: ```python class Solutio...
{"functional": "def check(candidate):\n assert candidate(s = \"Let's take LeetCode contest\") == \"s'teL ekat edoCteeL tsetnoc\"\n assert candidate( s = \"Mr Ding\") == \"rM gniD\"\n\n\ncheck(Solution().reverseWords)"}
72
69
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. This is a very easy warm-up problem. You are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occurr...
{"inputs": ["4\nacab\nzzqzqq\nabc\nkklkwwww", "4\nacab\nzzqzqq\ncba\nkklkwwww", "4\nacbb\nzzqzqq\ncba\nkkmkwvww", "4\ncbba\nqrzqyz\nbab\nkllkxwvw", "4\naccc\nqrzqyz\nbab\nkklkxwvw", "4\nabbb\nzzqzqq\ncba\nkkmkwwww", "4\ncbbb\nqqzqyz\nbab\nkllkxwvw", "4\nadac\nzzqypr\nabc\nkklkwwww"], "outputs": ["YES\nYES\nNO\nYES", "Y...
245
244
coding
Solve the programming task below in a Python markdown code block. Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children. Takahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time? -----C...
{"inputs": ["7", "3", "4", "0", "9", "1", "8", "2"], "outputs": ["YES\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
158
62
coding
Solve the programming task below in a Python markdown code block. Berland annual chess tournament is coming! Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers sho...
{"inputs": ["1\n3 3\n", "1\n2 3\n", "1\n2 1\n", "1\n8 6\n", "1\n2 3\n", "1\n2 1\n", "1\n8 6\n", "1\n2 5\n"], "outputs": ["NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]}
378
102
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. If the depth of a tree is smaller than 5, then this tree can be represented by an array of three-digit integers. You are given an ascending array nums consisting of three-digit integers representing a binary tree with...
{"functional": "def check(candidate):\n assert candidate(nums = [113, 215, 221]) == 12\n assert candidate(nums = [113, 221]) == 4\n\n\ncheck(Solution().pathSum)"}
203
63
coding
Solve the programming task below in a Python markdown code block. Print all the integers that satisfies the following in ascending order: - Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. -----Constraints----- - 1 \leq A \leq B \leq 10^9 ...
{"inputs": ["3 4 2", "1 4 4", "0 0 3", "1 1 4", "6 8 3", "3 6 2", "0 8 3", "1 4 1"], "outputs": ["3\n4\n", "1\n2\n3\n4\n", "0\n", "1\n", "6\n7\n8\n", "3\n4\n5\n6\n", "0\n1\n2\n6\n7\n8\n", "1\n4\n"]}
225
124
coding
Solve the programming task below in a Python markdown code block. _Friday 13th or Black Friday is considered as unlucky day. Calculate how many unlucky days are in the given year._ Find the number of Friday 13th in the given year. __Input:__ Year as an integer. __Output:__ Number of Black Fridays in the year as an i...
{"functional": "_inputs = [[1634], [2873], [1586]]\n_outputs = [[2], [2], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n...
144
177
coding
Solve the programming task below in a Python markdown code block. Given a non-negative number, return the next bigger polydivisible number, or an empty value like `null` or `Nothing`. A number is polydivisible if its first digit is cleanly divisible by `1`, its first two digits by `2`, its first three by `3`, and so o...
{"functional": "_inputs = [[0], [10], [11], [1234], [123220], [998], [999], [1234567890], [3608528850368400786036724], [3608528850368400786036725]]\n_outputs = [[1], [12], [12], [1236], [123252], [1020], [1020], [1236004020], [3608528850368400786036725], [None]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isins...
108
328
coding
Solve the programming task below in a Python markdown code block. Nitika was once reading a history book and wanted to analyze it. So she asked her brother to create a list of names of the various famous personalities in the book. Her brother gave Nitika the list. Nitika was furious when she saw the list. The names of ...
{"inputs": ["3\ngandhi\nmahatma gandhI\nMohndas KaramChand gandhi\n\n"], "outputs": ["Gandhi \nM. Gandhi \nM. K. Gandhi "]}
452
52
coding
Solve the programming task below in a Python markdown code block. Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off. You...
{"inputs": ["1\n1\n", "1\n1\n", "1\n5\n", "1\n9\n", "1\n3\n", "1\n4\n", "1\n8\n", "1\n6\n"], "outputs": ["16\n", "16\n", "20\n", "24\n", "18\n", "19\n", "23\n", "21\n"]}
383
94
coding
Solve the programming task below in a Python markdown code block. We call a positive integer number fair if it is divisible by each of its nonzero digits. For example, $102$ is fair (because it is divisible by $1$ and $2$), but $282$ is not, because it isn't divisible by $8$. Given a positive integer $n$. Find the mini...
{"inputs": ["1\n239\n", "1\n2317839669\n", "1\n123456780079\n", "1\n8973589164975\n", "1\n9876543210000\n", "1\n1023456790441\n", "1\n1000000002897001\n", "1\n99999999999999999\n"], "outputs": ["240\n", "2317840224\n", "123456780720\n", "8973589166640\n", "9876543211080\n", "1023456791700\n", "1000000002898008\n", "999...
361
264
coding
Solve the programming task below in a Python markdown code block. SaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum number of groups the array can be divided into, such that the product of any pair of integers in the same gr...
{"inputs": ["1\n0\n", "1\n0\n", "1\n-1\n", "1\n-2\n", "2\n5 5\n", "2\n2 0\n", "2\n0 2\n", "2\n0 1\n"], "outputs": ["1\n", "1 ", "1\n", "1\n", "3 0\n", "3 0\n", "3 0\n", "3 0\n"]}
358
103
coding
Solve the programming task below in a Python markdown code block. You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top ...
{"inputs": ["2 3\n...\n.#.\n...", "2 3\n...\n.#.\n..-", "2 3\n/..\n.#.\n..-", "2 3\n/..\n.#.\n..,", "3 3\n...\n/#.\n...", "2 3\n...\n.#.\n..,", "3 3\n../\n/#.\n...", "3 3\n-..\n.#.\n..."], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n"]}
296
135
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Shlok and Sachin are good friends. Shlok wanted to test Sachin, so he wrote down a string $S$ with length $N$ and one character $X$. He wants Sachin ...
{"inputs": ["2\n3\nabb b\n6\nabcabc c"], "outputs": ["5\n15"]}
462
26
coding
Solve the programming task below in a Python markdown code block. Kulyash is given an integer N. His task is to break N into some number of (integer) powers of 2. TO achieve this, he can perform the following operation several times (possibly, zero): Choose an integer X which he already has, and break X into 2 intege...
{"inputs": ["2\n3\n4\n"], "outputs": ["1\n0\n"]}
318
20
coding
Solve the programming task below in a Python markdown code block. Let us play a game of cards. As you all know there are 52 cards in a regular deck, but our deck is somewhat different. Our deck consists of N cards. Each card simply contains a unique number from 1 to N. Initially all the cards are kept on the table, fac...
{"inputs": ["3 4\n1 2 3", "5 12\n4 -2 3 -1 5"], "outputs": ["0", "2\n2 3"]}
601
43
coding
Solve the programming task below in a Python markdown code block. There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i. Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly...
{"inputs": ["3\n2 2 1\n1 2\n2 3", "3\n1 1 1\n1 2\n2 3", "3\n1 2 0\n1 2\n2 3", "3\n2 2 2\n1 2\n2 3", "3\n2 1 1\n1 2\n2 3", "3\n0 2 0\n1 2\n2 3", "3\n3 1 1\n1 2\n2 3", "3\n2 2 0\n1 2\n2 3"], "outputs": ["NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n"]}
372
174
coding
Solve the programming task below in a Python markdown code block. As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of ad...
{"inputs": ["2 5 2\n1 1 1\n9 -7 0\n1 0 -3\n0 0 0", "2 7 2\n1 1 1\n9 -7 0\n1 0 -3\n0 0 0", "2 5 2\n1 1 1\n7 -7 1\n1 0 -3\n0 0 0", "3 5 3\n1 2 1\n4 -11 0\n1 1 1\n0 0 0", "3 5 3\n1 2 1\n4 -15 0\n2 0 1\n0 0 0", "3 4 6\n2 2 1\n4 -15 0\n2 0 1\n0 0 0", "3 5 3\n1 2 1\n4 -11 0\n1 1 0\n0 0 0", "2 5 3\n1 2 1\n4 -11 0\n2 0 1\n0 0 ...
636
434
coding
Solve the programming task below in a Python markdown code block. The goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$. Write a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to comp...
{"inputs": ["6\n0 1\n18 0\n18 0\n3 3\n1 8\n2 7", "6\n0 1\n18 0\n18 0\n3 3\n1 8\n4 7", "6\n0 11\n70 0\n18 5\n5 3\n1 8\n2 5", "6\n0 11\n70 0\n18 5\n3 3\n1 8\n2 5", "6\n0 11\n26 0\n18 5\n3 3\n1 8\n2 5", "6\n0 11\n26 0\n18 5\n3 3\n1 8\n2 4", "6\n0 11\n26 0\n18 5\n3 3\n1 8\n2 7", "6\n0 11\n18 0\n18 5\n3 3\n1 8\n2 7"], "outp...
253
276
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You own a Goal Parser that can interpret a string command. The command consists of an alphabet of "G", "()" and/or "(al)" in some order. The Goal Parser will interpret "G" as the string "G", "()" as the string "o", an...
{"functional": "def check(candidate):\n assert candidate(command = \"G()(al)\") == \"Goal\"\n assert candidate(command = \"G()()()()(al)\") == \"Gooooal\"\n assert candidate(command = \"(al)G(al)()()G\") == \"alGalooG\"\n\n\ncheck(Solution().interpret)"}
136
79
coding
Solve the programming task below in a Python markdown code block. Your job is to write function last_digits(n,d) which return the last `d` digits of an integer `n` as a list. `n` will be from 0 to 10^10 Examples: `last_digits(1,1) --> [1]` `last_digits(1234,2) --> [3,4]` `last_digits(637547,6) --> [6,3,7,5,4,...
{"functional": "_inputs = [[1, 1], [123767, 4], [0, 1], [34625647867585, 10], [1234, 0], [24134, -4], [1343, 5]]\n_outputs = [[[1]], [[3, 7, 6, 7]], [[0]], [[5, 6, 4, 7, 8, 6, 7, 5, 8, 5]], [[]], [[]], [[1, 3, 4, 3]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ...
194
282
coding
Solve the programming task below in a Python markdown code block. Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are n cockroaches living in Anatoly's room. Anatoly just made...
{"inputs": ["1\nr\n", "1\nb\n", "1\nr\n", "1\nb\n", "2\nrb\n", "2\nbr\n", "2\nrr\n", "2\nbb\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "1\n"]}
390
86
coding
Solve the programming task below in a Python markdown code block. Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he n...
{"inputs": ["3\n5 3 2\n", "3\n1 2 2\n", "3\n5 4 2\n", "3\n5 7 2\n", "3\n3 7 2\n", "3\n5 5 2\n", "3\n5 4 3\n", "3\n3 0 2\n"], "outputs": ["3\n", "1\n", "1\n", "3\n", "3\n", "3\n", "2\n", "1\n"]}
208
118
coding
Solve the programming task below in a Python markdown code block. You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character with...
{"inputs": ["1\n5", "1\n4", "1\n0", "1\n6", "1\n2", "1\n3", "1\n7", "1\n1"], "outputs": ["1\n", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n", "0\n"]}
428
78
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed integer array arr and an integer k. The array arr is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the...
{"functional": "def check(candidate):\n assert candidate(arr = [1,4,1,3], k = 2) == 1\n assert candidate(arr = [2,5,5,7], k = 3) == 5\n\n\ncheck(Solution().makeSubKSumEqual)"}
168
68
coding
Solve the programming task below in a Python markdown code block. Write a program that reads numbers until -1 is not given. The program finds how many of the given numbers are more than 30, $N$. It also finds the average weighted sum of even numbers, $A$. The weight of the $i$th number is defined as the position of the...
{"inputs": ["1\n33 100 77 42 12 -1"], "outputs": ["4 38.91"]}
384
36
coding
Solve the programming task below in a Python markdown code block. Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$. You are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \le x < y \le r$ and $l \le LCM...
{"inputs": ["1\n411 2649\n", "1\n542 9298\n", "1\n248 2649\n", "1\n431 2649\n", "1\n431 4578\n", "1\n2465 5273\n", "1\n1025 9298\n", "1\n4695 6427\n"], "outputs": ["411 822\n", "542 1084\n", "248 496\n", "431 862\n", "431 862\n", "2465 4930\n", "1025 2050\n", "-1 -1\n"]}
316
194
coding
Solve the programming task below in a Python markdown code block. There are $n$ students numerated from $1$ to $n$. The level of the $i$-th student is $a_i$. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ...
{"inputs": ["1 2 9\n5\n", "1 2 9\n5\n", "2 3 1\n1 6\n", "2 5 1\n1 8\n", "2 3 1\n1 6\n", "2 5 1\n1 8\n", "2 1 1\n1 6\n", "2 9 1\n1 8\n"], "outputs": ["1", "1\n", "2", "2", "2\n", "2\n", "2", "1\n"]}
680
126
coding
Solve the programming task below in a Python markdown code block. You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B - A. -----Constraints----- - All values in input are integers. - 1 \leq A \leq B \leq 20 -----Input----- Input is given from Standard Input in the follow...
{"inputs": ["1 0", "1 2", "4 6", "3 6", "4 4", "5 1", "1 6", "1 1"], "outputs": ["1\n", "3\n", "2\n", "9\n", "8\n", "-4\n", "7\n", "2"]}
152
77
coding
Solve the programming task below in a Python markdown code block. You have to write a function that describe Leo: ```python def leo(oscar): pass ``` if oscar was (integer) 88, you have to return "Leo finally won the oscar! Leo is happy". if oscar was 86, you have to return "Not even for Wolf of wallstreet?!" if it w...
{"functional": "_inputs = [[88], [87], [86]]\n_outputs = [['Leo finally won the oscar! Leo is happy'], ['When will you give Leo an Oscar?'], ['Not even for Wolf of wallstreet?!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol...
152
192
coding
Solve the programming task below in a Python markdown code block. Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length a_{i}. Mishka can put a box i into another box j if the following conditions are met: i-th box is not put into another box; j-th box doesn't contain any other...
{"inputs": ["1\n1\n", "1\n9\n", "1\n5\n", "1\n2\n", "1\n2\n", "1\n1\n", "1\n5\n", "1\n9\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
334
86
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y': if the ith character is 'Y', it means that customers come at the ith hour whereas ...
{"functional": "def check(candidate):\n assert candidate(customers = \"YYNY\") == 2\n assert candidate(customers = \"NNNNN\") == 0\n assert candidate(customers = \"YYYY\") == 4\n\n\ncheck(Solution().bestClosingTime)"}
213
62
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you replace the number operations[i][0] with operations[i][1]. It is gua...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]]) == [3,2,7,1]\n assert candidate(nums = [1,2], operations = [[1,3],[2,1],[3,2]]) == [2,1]\n\n\ncheck(Solution().arrayChange)"}
139
91
coding
Solve the programming task below in a Python markdown code block. To get on the Shinkansen, you need two tickets, a "ticket" and a "limited express ticket". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen, one ticket can be used as both a tic...
{"inputs": ["0 0 0", "1 1 0", "1 0 0", "0 1 0", "0 0 0", "0 1 0", "1 0 0", "1 1 0"], "outputs": ["Close\n", "Open\n", "Close\n", "Close\n", "Close\n", "Close\n", "Close\n", "Open\n"]}
416
94
coding
Solve the programming task below in a Python markdown code block. We have a sequence of k numbers: d_0,d_1,...,d_{k - 1}. Process the following q queries in order: - The i-th query contains three integers n_i, x_i, and m_i. Let a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \begin{eqnarray} a_j = \...
{"inputs": ["3 1\n2 1 4\n5 3 2", "3 1\n3 1 3\n5 3 2", "3 1\n3 1 4\n5 3 2", "3 1\n3 1 4\n5 3 2\n", "7 2\n42 28 8 0 9 214 1000000010\n1001001011 2 5\n0000001001 0 4\n1011010001 0 1", "7 1\n39 18 39 0 9 214 1000000010\n1001001010 0 5\n0000000001 0 2\n1010010000 0 9", "7 1\n39 18 39 0 9 214 1000000010\n1001000010 0 5\n0000...
632
453
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given n orders, each order consists of a pickup and a delivery service. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).  Since the answer may be too large, return...
{"functional": "def check(candidate):\n assert candidate(n = 1) == 1\n assert candidate(n = 2) == 6\n assert candidate(n = 3) == 90\n\n\ncheck(Solution().countOrders)"}
106
56
coding
Solve the programming task below in a Python markdown code block. Given is a string S of length N-1. Each character in S is `<` or `>`. A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1): * If S_i= `<`: a_i<a_{i+1} * If...
{"inputs": [">><", "><>", "<<>", "<>>", "<>>><<<<<><<>>><", "<>>>><<<<><<<>><", "<>><<<><<<<>>>><", "<<>><<><<<<>>>><"], "outputs": ["4\n", "2\n", "3\n", "3", "29\n", "28\n", "26\n", "24\n"]}
231
88
coding
Solve the programming task below in a Python markdown code block. An architect, Devunky, who lives in Water Deven, has been asked to renovate an old large hospital. In some countries, people don't want to use numbers that are disliked as numerophobia (4 and 9 are famous in Japan). However, the room numbers in this hos...
{"inputs": ["15\n100\n1000000000\n1\n0", "15\n110\n1000000000\n1\n0", "15\n101\n1000000000\n3\n0", "15\n110\n1000000000\n0\n0", "15\n101\n1001000000\n3\n0", "15\n100\n1000000000\n0\n0", "15\n111\n1001000000\n3\n0", "15\n000\n1000000000\n0\n0"], "outputs": ["19\n155\n9358757000\n1\n", "19\n178\n9358757000\n1\n", "19\n15...
512
345
coding
Solve the programming task below in a Python markdown code block. The magic sum of 3s is calculated on an array by summing up odd numbers which include the digit `3`. Write a function `magic_sum` which accepts an array of integers and returns the sum. *Example:* `[3, 12, 5, 8, 30, 13]` results in `16` (`3` + `13`) If...
{"functional": "_inputs = [[[3]], [[3, 13]], [[30, 34, 330]], [[3, 12, 5, 8, 30, 13]], [[]], [None]]\n_outputs = [[3], [16], [0], [16], [0], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinsta...
131
218
coding
Solve the programming task below in a Python markdown code block. Find the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter. -----Constraints----- - 2\leq K\leq 100 - K is an integer. -----Input----- Input is given ...
{"inputs": ["2", "0", "7", "4", "5", "8", "6", "3"], "outputs": ["1\n", "0\n", "12\n", "4\n", "6\n", "16\n", "9", "2"]}
149
62
coding
Solve the programming task below in a Python markdown code block. The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings...
{"inputs": ["3\n3\n010\n5\n10001\n7\n0000000"], "outputs": ["0\n1\n7"]}
305
40
coding
Solve the programming task below in a Python markdown code block. Write a function that takes a string and returns an array of the repeated characters (letters, numbers, whitespace) in the string. If a charater is repeated more than once, only show it once in the result array. Characters should be shown **by the orde...
{"functional": "_inputs = [['apple'], ['limbojackassin the garden'], ['11pinguin'], ['Claustrophobic'], ['apPle'], ['11 pinguin'], ['pippi'], ['Pippi'], ['kamehameha'], ['']]\n_outputs = [[['p']], [['a', 's', 'i', ' ', 'e', 'n']], [['1', 'i', 'n']], [['o']], [[]], [['1', 'i', 'n']], [['p', 'i']], [['p', 'i']], [['a', '...
203
270
coding
Solve the programming task below in a Python markdown code block. A flower shop has got n bouquets, and the i-th bouquet consists of a_{i} flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets. Vasya thinks that a bouquet is large if it is made of two or more initial bouquets, an...
{"inputs": ["1\n1\n", "1\n2\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n4\n", "1\n0\n", "3\n7 4 9\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n"]}
465
90
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr. The bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray...
{"functional": "def check(candidate):\n assert candidate(arr = [0]) == 1\n assert candidate(arr = [1,1,2]) == 3\n assert candidate(arr = [1,2,4]) == 6\n\n\ncheck(Solution().subarrayBitwiseORs)"}
124
67
coding
Solve the programming task below in a Python markdown code block. # Task Two integer numbers are added using the column addition method. When using this method, some additions of digits produce non-zero carries to the next positions. Your task is to calculate the number of non-zero carries that will occur while adding...
{"functional": "_inputs = [[543, 3456], [1927, 6426], [9999, 1], [1234, 5678]]\n_outputs = [[0], [2], [4], [2]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if...
249
206
coding
Solve the programming task below in a Python markdown code block. Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N. But he couldn't see some parts of the list. Invisible part is denoted `?`. Please calculate all possible index of the handle name of Mr.X when you sort ...
{"inputs": ["2\ntourist\neptr\ne", "2\nssvuhnr\nerrs\nf", "2\nhupouvt\netor\ni", "2\nsourist\neptr\ne", "2\nsourist\neqtr\ne", "2\nsourist\netqr\ne", "2\nsourisu\netqr\ne", "2\nsourisu\netqr\nd"], "outputs": ["1\n", "2\n", "3\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
487
136
coding
Solve the programming task below in a Python markdown code block. Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place! This contest consists of n problems, and Pasha solves ith problem in a_{i} time units (his solutions are...
{"inputs": ["1\n1\n0\n", "1\n2\n0\n", "1\n4\n0\n", "1\n5\n0\n", "1\n1\n0\n", "1\n2\n0\n", "1\n4\n0\n", "1\n5\n0\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
684
103
coding
Solve the programming task below in a Python markdown code block. Lumpy is a bus driver. Today, the conductor is absent so Lumpy has to do the conductor's job as well. There are N creatures in the bus. Sometimes the creatures don't carry change and can't pay the exact amount of the fare. Each creature in the bus today ...
{"inputs": ["3\n3 3 0\n1 2 2\n3 2 1\n1 2 1\n4 5 4\n2 3 4 5"], "outputs": ["2\n3\n3"]}
636
54
coding
Solve the programming task below in a Python markdown code block. Check Tutorial tab to know how to solve. Task Given an integer, $n$, perform the following conditional actions: If $n$ is odd, print Weird If $n$ is even and in the inclusive range of $2$ to $5$, print Not Weird If $n$ is even and in the inclusive ...
{"inputs": ["3\n", "24\n"], "outputs": ["Weird\n", "Not Weird\n"]}
252
25
coding
Solve the programming task below in a Python markdown code block. An integer $\boldsymbol{d}$ is a divisor of an integer $n$ if the remainder of $n\div d=0$. Given an integer, for each digit that makes up the integer determine whether it is a divisor. Count the number of divisors occurring within the integer. Ex...
{"inputs": ["2\n12\n1012\n"], "outputs": ["2\n3\n"]}
483
24
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums. For each element from left to right in instructions, insert it int...
{"functional": "def check(candidate):\n assert candidate(instructions = [1,5,6,2]) == 1\n assert candidate(instructions = [1,2,3,6,5,4]) == 3\n assert candidate(instructions = [1,3,3,3,2,4,2,1,2]) == 4\n\n\ncheck(Solution().createSortedArray)"}
234
91
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have a graph of n nodes labeled from 0 to n - 1. You are given an integer n and a list of edges where edges[i] = [ai, bi] indicates that there is an undirected edge between nodes ai and bi in the graph. Return tru...
{"functional": "def check(candidate):\n assert candidate(n = 5, edges = [[0,1],[0,2],[0,3],[1,4]]) == True\n assert candidate(n = 5, edges = [[0,1],[1,2],[2,3],[1,3],[1,4]]) == False\n\n\ncheck(Solution().validTree)"}
127
83
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. On an infinite plane, a robot initially stands at (0, 0) and faces north. Note that: The north direction is the positive direction of the y-axis. The south direction is the negative direction of the y-axis. The east ...
{"functional": "def check(candidate):\n assert candidate(instructions = \"GGLLGG\") == True\n assert candidate(instructions = \"GG\") == False\n assert candidate(instructions = \"GL\") == True\n\n\ncheck(Solution().isRobotBounded)"}
210
60
coding
Solve the programming task below in a Python markdown code block. Problem In 1333, the greatest scientist in human history, Dr. Ushishi, developed an artificial intelligence with an ID of ai1333 in order to pass on his wisdom to posterity. For the next 100 years, ai1333 brought great benefits to humankind, but on the ...
{"inputs": ["0", "-1", "-2", "-4", "-7", "-6", "-3", "-5"], "outputs": ["ai1333", "ai1333\n", "ai1333\n", "ai1333\n", "ai1333\n", "ai1333\n", "ai1333\n", "ai1333\n"]}
337
93
coding
Solve the programming task below in a Python markdown code block. Recently Chef joined a new company. In this company, the employees have to work for X hours each day from Monday to Thursday. Also, in this company, Friday is called Chill Day — employees only have to work for Y hours (Y < X) on Friday. Saturdays and Sun...
{"inputs": ["3\n10 5\n12 2\n8 7\n"], "outputs": ["45\n50\n39\n"]}
452
35
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array arr, count how many elements x there are, such that x + 1 is also in arr. If there are duplicates in arr, count them separately.   Please complete the following python code precisely: ```python ...
{"functional": "def check(candidate):\n assert candidate(arr = [1,2,3]) == 2\n assert candidate(arr = [1,1,3,3,5,5,7,7]) == 0\n\n\ncheck(Solution().countElements)"}
84
61
coding
Solve the programming task below in a Python markdown code block. Given a number X between 0 to 1000000006 find smallest positive integer Y such that the products of digits of Y modulo 1000000007 is X. Input Format A single integer - X Output Format A single integer - Y Input Constraint 0 ≤ X ≤ 1000000006 Proble...
{"inputs": ["0", "16", "220703118"], "outputs": ["10", "28", "5555555555555"]}
151
47
coding
Solve the programming task below in a Python markdown code block. Pushok the dog has been chasing Imp for a few hours already. $48$ Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a lot of noise. We...
{"inputs": ["1\ns\n", "1\ns\n", "2\nh\ns\n", "2\nh\ns\n", "4\nssh\nhs\ns\nhhhs\n", "4\nssh\nhs\ns\nshhh\n", "4\nssh\nhs\ns\nhhsh\n", "4\nshs\nhs\ns\nshhh\n"], "outputs": ["0\n", "0", "1\n", "1", "18\n", "21\n", "19\n", "20\n"]}
390
121
coding
Solve the programming task below in a Python markdown code block. A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not. The next prime number after x is the smallest prime number greater than x. For example, the next prime numbe...
{"inputs": ["2 6\n", "7 8\n", "5 9\n", "2 3\n", "3 7\n", "3 9\n", "5 6\n", "5 7\n"], "outputs": ["NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "YES\n"]}
400
86
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a restaurant with a single chef. You are given an array customers, where customers[i] = [arrivali, timei]: arrivali is the arrival time of the ith customer. The arrival times are sorted in non-decreasing ord...
{"functional": "def check(candidate):\n assert candidate(customers = [[1,2],[2,5],[4,3]]) == 5.00000\n assert candidate(customers = [[5,2],[5,4],[10,3],[20,1]]) == 3.25000\n\n\ncheck(Solution().averageWaitingTime)"}
204
84
coding
Solve the programming task below in a Python markdown code block. 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 w...
{"functional": "_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], [[]], [{}], ['']]\n_outputs = [['MAS'], ['PEMDAS'], ['HMWWAWCIAWCCW'], ['UNY'], ['Not letters'], ['Not letters'], [...
178
256
coding
Solve the programming task below in a Python markdown code block. In McD's Burger, n hungry burger fans are ordering burgers. The ith order is placed by the ith fan at ti time and it takes di time to procees. What is the order in which the fans will get their burgers? Input Format On the first line you will get n, th...
{"inputs": ["2\n1 1\n1 1", "3\n1 3\n2 3\n3 3", "5\n8 1\n4 2\n5 6\n3 1\n4 3", "25\n122470 725261\n193218 693005\n355776 603340\n830347 284246\n974815 823134\n251206 572501\n55509 927152\n299590 651593\n222305 641645\n984018 463771\n494787 286091\n217190 833029\n820867 380896\n744986 630663\n875880 667\n449199 520904\n92...
356
495
coding
Solve the programming task below in a Python markdown code block. You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try t...
{"inputs": ["1\n0\n", "1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n-1\n", "1\n-2\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]}
365
88
coding
Solve the programming task below in a Python markdown code block. Write a function, `gooseFilter` / `goose-filter` / `goose_filter` /` GooseFilter`, that takes an array of strings as an argument and returns a filtered array containing the same elements but with the 'geese' removed. The geese are any strings in the fol...
{"functional": "_inputs = [[['Mallard', 'Hook Bill', 'African', 'Crested', 'Pilgrim', 'Toulouse', 'Blue Swedish']], [['Mallard', 'Barbary', 'Hook Bill', 'Blue Swedish', 'Crested']], [['African', 'Roman Tufted', 'Toulouse', 'Pilgrim', 'Steinbacher']]]\n_outputs = [[['Mallard', 'Hook Bill', 'Crested', 'Blue Swedish']], [...
275
274
coding
Solve the programming task below in a Python markdown code block. Let's call a non-empty sequence of positive integers a_1, a_2... a_{k} coprime if the greatest common divisor of all elements of this sequence is equal to 1. Given an array a consisting of n positive integers, find the number of its coprime subsequences...
{"inputs": ["1\n1\n", "1\n1\n", "3\n1 2 3\n", "3\n1 2 5\n", "3\n1 1 5\n", "3\n1 1 1\n", "3\n1 2 3\n", "1\n100000\n"], "outputs": ["1\n", "1", "5\n", "5\n", "6\n", "7\n", "5", "0\n"]}
346
109
coding
Solve the programming task below in a Python markdown code block. ## Enough is enough! Alice and Bob were on a holiday. Both of them took many pictures of the places they've been, and now they want to show Charlie their entire collection. However, Charlie doesn't like these sessions, since the motive usually repeats. ...
{"functional": "_inputs = [[[20, 37, 20, 21], 1], [[1, 1, 3, 3, 7, 2, 2, 2, 2], 3], [[1, 2, 3, 1, 1, 2, 1, 2, 3, 3, 2, 4, 5, 3, 1], 3], [[1, 1, 1, 1, 1], 5], [[], 5]]\n_outputs = [[[20, 37, 21]], [[1, 1, 3, 3, 7, 2, 2, 2]], [[1, 2, 3, 1, 1, 2, 2, 3, 3, 4, 5]], [[1, 1, 1, 1, 1]], [[]]]\nimport math\ndef _deep_eq(a, b, t...
430
354
coding
Solve the programming task below in a Python markdown code block. If I give you a date, can you tell me what day that date is? For example, december 8th, 2015 is a tuesday. Your job is to write the function ```day(d)``` which takes a string representation of a date as input, in the format YYYYMMDD. The example would b...
{"functional": "_inputs = [['20151208'], ['20140728'], ['20160229'], ['20160301'], ['19000228'], ['19000301']]\n_outputs = [['Tuesday'], ['Monday'], ['Monday'], ['Tuesday'], ['Wednesday'], ['Thursday']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return mat...
192
225
coding
Solve the programming task below in a Python markdown code block. Let's imagine that you're playing the following simple computer game. The screen displays n lined-up cubes. Each cube is painted one of m colors. You are allowed to delete not more than k cubes (that do not necessarily go one after another). After that, ...
{"inputs": ["1 1 0\n1\n", "3 1 2\n1 1 1\n", "10 2 2\n1 1 1 2 1 2 1 2 1 1\n", "10 2 2\n1 2 1 2 1 1 2 1 1 2\n", "10 3 2\n1 2 1 1 3 2 1 1 2 2\n", "20 6 3\n4 1 2 6 3 3 2 5 2 5 2 1 1 4 1 2 2 1 1 4\n", "20 2 5\n2 2 1 2 1 2 1 2 1 1 2 1 2 2 1 2 2 1 2 1\n", "20 3 5\n2 2 3 1 2 2 3 3 3 2 1 2 3 1 1 3 3 3 2 3\n"], "outputs": ["1", ...
359
288
coding
Solve the programming task below in a Python markdown code block. Ashley likes playing with strings. She gives Mojo a fun problem to solve. In her imaginary string world, a string of even length is called as "Doublindrome" if both halves of the string are palindromes (both halves have length equal to half of original ...
{"inputs": ["1\n8\nabbacddc"], "outputs": ["YES"]}
348
19
coding
Solve the programming task below in a Python markdown code block. The process of mammoth's genome decoding in Berland comes to its end! One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unr...
{"inputs": ["4\nAGCT\n", "4\nAA??\n", "4\n????\n", "4\n??A?\n", "4\n?C??\n", "4\nT???\n", "4\n???G\n", "4\n??AC\n"], "outputs": ["AGCT\n", "===\n", "ACGT\n", "CGAT\n", "ACGT\n", "TACG\n", "ACTG\n", "GTAC\n"]}
427
108
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed string word of length n consisting of digits, and a positive integer m. The divisibility array div of word is an integer array of length n such that: div[i] = 1 if the numeric value of word[...
{"functional": "def check(candidate):\n assert candidate(word = \"998244353\", m = 3) == [1,1,0,0,0,1,1,0,0]\n assert candidate(word = \"1010\", m = 10) == [0,1,0,1]\n\n\ncheck(Solution().divisibilityArray)"}
140
91
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules: Sort the values at odd indices of nums in non-increasing order. For example, if nums = [4,1,2,3] before ...
{"functional": "def check(candidate):\n assert candidate(nums = [4,1,2,3]) == [2,3,4,1]\n assert candidate(nums = [2,1]) == [2,1]\n\n\ncheck(Solution().sortEvenOdd)"}
216
62
coding
Solve the programming task below in a Python markdown code block. *`This kata is a tribute/fanwork to the TV-show: Supernatural`* Balls! Those wayward Winchester boys are in trouble again, hunting something down in New Orleans. You are Bobby Singer, you know how "idjits" they can be, so you have to prepare. They wil...
{"functional": "_inputs = [['vampire'], ['pagan god'], ['werepuppy']]\n_outputs = [['Behead it with a machete, idjits!'], ['It depends on which one it is, idjits!'], ['I have friggin no idea yet, idjits!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return...
489
205
coding
Solve the programming task below in a Python markdown code block. Impliment the reverse function, which takes in input n and reverses it. For instance, `reverse(123)` should return `321`. You should do this without converting the inputted number into a string. Also feel free to reuse/extend the following starter code: ...
{"functional": "_inputs = [[1234], [4321], [1001], [1010], [12005000]]\n_outputs = [[4321], [1234], [1001], [101], [50021]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):...
80
211
coding
Solve the programming task below in a Python markdown code block. # Task A media access control address (MAC address) is a unique identifier assigned to network interfaces for communications on the physical network segment. The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six gr...
{"functional": "_inputs = [['00-1B-63-84-45-E6'], ['Z1-1B-63-84-45-E6'], ['not a MAC-48 address'], ['FF-FF-FF-FF-FF-FF'], ['00-00-00-00-00-00'], ['G0-00-00-00-00-00'], ['12-34-56-78-9A-BC'], ['02-03-04-05-06-07-'], ['02-03-04-05'], ['02-03-04-FF-00-F0']]\n_outputs = [[True], [False], [False], [True], [True], [False], [...
268
346
coding
Solve the programming task below in a Python markdown code block. ## Task In this kata you'll be given a string of English digits "collapsed" together, like this: `zeronineoneoneeighttwoseventhreesixfourtwofive` Your task is to split the string back to digits: `zero nine one one eight two seven three six four two fi...
{"functional": "_inputs = [['three'], ['eightsix'], ['fivefourseven'], ['ninethreesixthree'], ['foursixeighttwofive'], ['fivethreefivesixthreenineonesevenoneeight'], ['threesevensevensixninenineninefiveeighttwofiveeightsixthreeeight'], ['zeroonetwothreefourfivesixseveneightnine']]\n_outputs = [['three'], ['eight six'],...
164
298
coding
Solve the programming task below in a Python markdown code block. There is a chess board of size $n \times m$. The rows are numbered from $1$ to $n$, the columns are numbered from $1$ to $m$. Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knigh...
{"inputs": ["3\n1 7\n8 8\n3 3\n", "4\n1 1\n1 1\n1 1\n1 6\n", "62\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\...
372
1,096
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Arrays have fallen out of Chef's good books, and he plans to destroy all arrays he possesses. He is left with the last array A, consisting of N positive integers. In order t...
{"inputs": ["3\n2\n1 2\n2\n1 1\n3\n1 2 3", "3\n2\n1 2\n2\n1 1\n3\n1 4 3", "3\n2\n0 2\n2\n1 0\n3\n1 4 3", "3\n2\n1 2\n2\n1 1\n3\n0 0 0", "3\n2\n1 4\n2\n0 1\n3\n0 0 0", "3\n2\n1 0\n2\n1 1\n3\n1 4 3", "3\n2\n1 2\n2\n1 1\n3\n1 2 0", "3\n2\n0 2\n2\n1 1\n3\n1 4 3"], "outputs": ["1\n2\n2", "1\n2\n2\n", "1\n1\n2\n", "1\n2\n3\n...
419
253
coding
Solve the programming task below in a Python markdown code block. Fox Ciel studies number theory. She thinks a non-empty set S contains non-negative integers is perfect if and only if for any $a, b \in S$ (a can be equal to b), $(a \text{xor} b) \in S$. Where operation xor means exclusive or operation (http://en.wikip...
{"inputs": ["1\n", "2\n", "3\n", "4\n", "8\n", "5\n", "6\n", "0\n"], "outputs": ["2\n", "3\n", "5\n", "6\n", "17\n", "8\n", "11\n", "1\n"]}
327
72
coding
Solve the programming task below in a Python markdown code block. Riley is a very bad boy, but at the same time, he is a yo-yo master. So, he decided to use his yo-yo skills to annoy his friend Anton. Anton's room can be represented as a grid with $n$ rows and $m$ columns. Let $(i, j)$ denote the cell in row $i$ and c...
{"inputs": ["7\n2 3 1 1\n4 4 1 2\n3 5 2 2\n5 1 2 1\n3 1 3 1\n1 1 1 1\n1000000000 1000000000 1000000000 50\n"], "outputs": ["1 1 2 3\n1 1 4 4\n1 1 3 5\n1 1 5 1\n1 1 3 1\n1 1 1 1\n1 1 1000000000 1000000000\n"]}
709
170
coding
Solve the programming task below in a Python markdown code block. There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services me...
{"inputs": ["4\n1 2 3 4\n2\n2 3\n2 2\n", "4\n1 2 3 4\n2\n2 1\n2 2\n", "4\n1 2 3 0\n2\n2 3\n2 2\n", "4\n0 3 3 4\n2\n2 1\n2 2\n", "4\n1 0 2 4\n2\n2 1\n2 2\n", "4\n1 0 3 0\n2\n2 0\n2 2\n", "4\n1 0 2 5\n2\n2 1\n2 2\n", "4\n1 0 2 2\n2\n2 1\n2 2\n"], "outputs": ["3 3 3 4 ", "2 2 3 4\n", "3 3 3 3\n", "2 3 3 4\n", "2 2 2 4\n",...
618
261
coding
Solve the programming task below in a Python markdown code block. One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some...
{"inputs": ["2\n0 0\n0 0\n", "2\n0 0\n0 0\n", "2\n0 0\n0 1\n", "2\n1 0\n0 1\n", "2\n1 0\n0 0\n", "2\n0 1\n0 1\n", "2\n1 0\n1 0\n", "2\n0 1\n1 1\n"], "outputs": ["0\n", "0\n", "1\n", "2\n", "1\n", "0\n", "0\n", "1\n"]}
621
134
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi. Return true if each integer in the inclusive range [le...
{"functional": "def check(candidate):\n assert candidate(ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5) == True\n assert candidate(ranges = [[1,10],[10,20]], left = 21, right = 21) == False\n\n\ncheck(Solution().isCovered)"}
154
85