problem
stringlengths
14
4.09k
solution
stringlengths
1
802k
task_type
stringclasses
3 values
problem_tokens
int64
5
895
Solve the programming task below in a Python markdown code block. Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters. Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as ...
{"inputs": ["g\n", "@\n", "h\n", "?\n", "f\n", "w@\n", "jj\n", "@@\n"], "outputs": ["No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n", "No solution\n"]}
coding
334
Solve the programming task below in a Python markdown code block. DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment. Your task is to find the longest subsegment of a, such...
{"inputs": ["1\n3\n", "1\n1\n", "1\n4\n", "1\n42\n", "1\n19\n", "2\n1 2\n", "2\n1 1\n", "2\n1 4\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "2\n"]}
coding
257
Solve the programming task below in a Python markdown code block. Let's learn some new Python concepts! You have to generate a list of the first $N$ fibonacci numbers, $\mbox{o}$ being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list. Concept The ...
{"inputs": ["5\n"], "outputs": ["[0, 1, 1, 8, 27]\n"]}
coding
403
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa. The string is called alternating if no two adjacent characters are equal. For exam...
{"functional": "def check(candidate):\n assert candidate(s = \"0100\") == 1\n assert candidate(s = \"10\") == 0\n assert candidate(s = \"1111\") == 2\n\n\ncheck(Solution().minOperations)"}
coding
134
Solve the programming task below in a Python markdown code block. Chef has a stick of length L. Chef wants to break the stick into K parts such that each part has a non-zero length. Let the lengths of the K parts be A_{1}, A_{2}, \ldots, A_{K} (Note that A_{1} + A_{2} + \ldots + A_{K} = L and A_{i} is a positive inte...
{"inputs": ["2\n4 3\n2 2\n"], "outputs": ["1\n0\n"]}
coding
516
Solve the programming task below in a Python markdown code block. There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation. An adjacency-list representation consists of an array $Adj[|V|]$ ...
{"inputs": ["4\n1 2 2 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 0 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 1 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 1 4\n2 1 2\n3 0\n4 1 3", "4\n1 2 0 4\n2 1 2\n3 0\n4 1 3", "4\n1 2 0 4\n2 1 4\n3 0\n0 1 3", "4\n1 2 0 4\n2 1 3\n3 0\n4 1 3", "4\n1 2 0 4\n2 1 3\n3 0\n4 1 4"], "outputs": ["0 1 0 1\n1 0 0 0\n0 0 0 0\n0 0...
coding
462
Solve the programming task below in a Python markdown code block. ### Vaccinations for children under 5 You have been put in charge of administrating vaccinations for children in your local area. Write a function that will generate a list of vaccines for each child presented for vaccination, based on the child's age an...
{"functional": "_inputs = [['12 weeks', 'up-to-date', 'december'], ['12 months', '16 weeks', 'june'], ['40 months', '12 months', 'october']]\n_outputs = [[['fiveInOne', 'rotavirus']], [['fiveInOne', 'hibMenC', 'measlesMumpsRubella', 'meningitisB', 'pneumococcal']], [['hibMenC', 'measlesMumpsRubella', 'meningitisB', 'of...
coding
707
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. You must implement a solution with a linear runtime complexity and...
{"functional": "def check(candidate):\n assert candidate(nums = [2,2,3,2]) == 3\n assert candidate(nums = [0,1,0,1,0,1,99]) == 99\n\n\ncheck(Solution().singleNumber)"}
coding
97
Solve the programming task below in a Python markdown code block. A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that w...
{"inputs": ["abc\nxyy\n", "abc\nyyx\n", "abc\nyzx\n", "acb\nyzx\n", "adb\nyzx\n", "abc\nxyz\n", "bbcd\ndabc\n", "bdcb\ndabc\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1", "-1\n", "-1\n"]}
coding
337
Solve the programming task below in a Python markdown code block. problem Given the squares of $ R * C $. Each square is either an empty square or a square with a hole. The given square meets the following conditions. * The cells with holes are connected. (You can move a square with a hole in the cross direction to a...
{"inputs": ["3 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "3 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "2 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "4 2\n.....\n.#.#/\n.###.\n.#.#.\n.....", "0 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "4 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "0 1\n.....\n.#.#.\n.##\".\n.#.#.\n.....", "2 1\n.....\n...
coding
230
Solve the programming task below in a Python markdown code block. There is enough money available on ATM in nominal value 10, 20, 50, 100, 200 and 500 dollars. You are given money in nominal value of `n` with `1<=n<=1500`. Try to find minimal number of notes that must be used to repay in dollars, or output -1 if it i...
{"functional": "_inputs = [[770], [550], [10], [1250], [125], [666], [42]]\n_outputs = [[4], [2], [1], [4], [-1], [-1], [-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)...
coding
121
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a positive integer n. We call an integer k fair if the number of even digits in k is equal to the number of odd digits in it. Return the smallest fair integer that is greater than or equal to n.   Please...
{"functional": "def check(candidate):\n assert candidate(n = 2) == 10\n assert candidate(n = 403) == 1001\n\n\ncheck(Solution().closestFair)"}
coding
94
Solve the programming task below in a Python markdown code block. The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h_1 cm from the ground. On the height h_2 cm (h_2 > h_1) on the same tree hung an apple and the caterpilla...
{"inputs": ["1 9\n1 1\n", "1 2\n4 3\n", "1 9\n1 2\n", "1 2\n4 3\n", "1 9\n1 1\n", "1 9\n1 2\n", "1 5\n1 1\n", "1 2\n2 2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
coding
507
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based)...
{"functional": "def check(candidate):\n assert candidate(nums = [4,2,3]) == True\n assert candidate(nums = [4,2,1]) == False\n\n\ncheck(Solution().checkPossibility)"}
coding
115
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...
coding
632
Solve the programming task below in a Python markdown code block. Base on the fairy tale [Diamonds and Toads](https://en.wikipedia.org/wiki/Diamonds_and_Toads) from Charles Perrault. In this kata you will have to complete a function that take 2 arguments: - A string, that correspond to what the daugther says. - A str...
{"functional": "_inputs = [['Ruby and Crystal', 'good'], ['This string contain some Ruby and some Crystal in it', 'good'], ['Python and Squirrel', 'evil'], ['This string contain some Python and some Squirrel in it', 'evil']]\n_outputs = [[{'ruby': 3, 'crystal': 2}], [{'ruby': 4, 'crystal': 3}], [{'python': 2, 'squirrel...
coding
318
Solve the programming task below in a Python markdown code block. Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $s$ of length $n$ and $t$ of length $m$. A sequence $p_1, p_2, \ldots, p_m$, where $1 \leq p_1 < p_2 < \ldots < p_m \leq n$, is called be...
{"inputs": ["2 2\nab\nab\n", "2 2\nba\nba\n", "2 2\nab\nab\n", "3 3\ncad\ncad\n", "3 3\ncad\ncad\n", "5 2\naaaaa\naa\n", "4 3\ndbbd\ndbd\n", "5 2\nddaca\nda\n"], "outputs": ["1\n", "1\n", "\n1\n", "1\n", "1\n", "4\n", "2\n", "4\n"]}
coding
518
Solve the programming task below in a Python markdown code block. Team RCB has earned X points in the games it has played so far in this year's IPL. To qualify for the playoffs they must earn at least a total of Y points. They currently have Z games left, in each game they earn 2 points for a win, 1 point for a draw, a...
{"inputs": ["3\n4 10 8\n3 6 1 \n4 8 2 "], "outputs": ["YES\nNO\nYES\n"]}
coding
444
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have ...
{"functional": "def check(candidate):\n assert candidate(stones = [2,7,4,1,8,1]) == 1\n assert candidate(stones = [31,26,33,21,40]) == 5\n\n\ncheck(Solution().lastStoneWeightII)"}
coding
187
Solve the programming task below in a Python markdown code block. You are given an unrooted tree of $n$ nodes numbered from $\mbox{1}$ to $n$. Each node $\boldsymbol{i}$ has a color, $c_i$. Let $d(i,j)$ be the number of different colors in the path between node $\boldsymbol{i}$ and node $j$. For each node $\boldsymbo...
{"inputs": ["5\n1 2 3 2 3\n1 2\n2 3\n2 4\n1 5\n"], "outputs": ["10\n9\n11\n9\n12\n"]}
coding
646
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list.   Please complete the following python code precisely: ```python class Soluti...
{"functional": "def check(candidate):\n assert candidate(timePoints = [\"23:59\",\"00:00\"]) == 1\n assert candidate(timePoints = [\"00:00\",\"23:59\",\"00:00\"]) == 0\n\n\ncheck(Solution().findMinDifference)"}
coding
83
Solve the programming task below in a Python markdown code block. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bul...
{"inputs": ["0 0 0 0 0\n0 0 0 0 0\n0 0\n", "0 0 0 0 0\n0 0 0 0 0\n0 0\n", "0 1 0 0 0\n0 0 0 0 0\n0 0\n", "0 0 0 0 0\n0 0 0 0 0\n20 0\n", "0 0 0 0 0\n0 0 0 0 0\n20 0\n", "0 0 0 0 0\n0 0 0 0 0\n20 1\n", "119 0 0 0 0\n2 0 0 0 0\n5 5\n", "0 119 0 0 0\n0 2 0 0 0\n5 5\n"], "outputs": ["7500\n", "7500\n", "7496\n", "9500\n", ...
coding
738
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ integers. Indices of the array start from zero (i. e. the first element is $a_0$, the second one is $a_1$, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall that t...
{"inputs": ["3\n5\n17 6 4 4 4\n7\n19 5 13 11 12 13 5\n1\n213567876\n", "3\n5\n17 6 4 4 4\n7\n19 5 13 11 12 13 5\n1\n213567876\n", "3\n5\n27 6 4 4 4\n7\n19 5 13 11 12 13 5\n1\n213567876\n", "3\n5\n27 6 4 4 4\n7\n36 2 13 11 12 13 8\n1\n213567876\n", "3\n5\n27 6 4 4 4\n7\n19 2 13 11 12 13 5\n1\n213567876\n", "3\n5\n27 6 4...
coding
520
Solve the programming task below in a Python markdown code block. Patlu has recently got a new problem based on Pallindromes. A Pallindrome is a number that is same from front and back, example $121$ is pallindrome but $123$ is not . He wants to calculate sum of all $N$ digit number which are Pallindromic in nature and...
{"inputs": ["2\n1\n2"], "outputs": ["9\n99"]}
coding
238
Solve the programming task below in a Python markdown code block. Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category. Given the number of participants in each department, create a ...
{"inputs": ["8 4 1", "8 8 1", "3 7 1", "6 7 1", "6 0 1", "2 1 1", "2 2 1", "10 4 1"], "outputs": ["13\n", "17\n", "11\n", "14\n", "7\n", "4\n", "5\n", "15\n"]}
coding
236
Solve the programming task below in a Python markdown code block. Li and Lu have $n$ integers, $a_1,a_2,\ldots,a_n$, that they want to divide fairly between the two of them. They decide that if Li gets integers with indices $I=\{i_1,i_2,\ldots,i_k\}$ (which implies that Lu gets integers with indices $J=\{1,\ldots,n\}\s...
{"inputs": ["4 2\n4 3 1 2\n", "4 1\n3 3 3 1\n"], "outputs": [" 6\n", "2\n"]}
coding
529
Solve the programming task below in a Python markdown code block. Welcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and it is easy to catch a cold. The da...
{"inputs": ["42 25\n3 -2\n62 0\n2 30\n0 4\n0 0\n27 -2", "42 25\n3 -2\n62 0\n2 30\n0 2\n0 0\n27 -2", "42 25\n5 -1\n118 0\n2 9\n1 2\n-1 0\n5 -2", "42 25\n5 -1\n118 0\n2 9\n1 2\n-2 0\n5 -2", "42 25\n5 -1\n142 0\n2 9\n1 2\n-2 0\n5 -2", "42 25\n5 -1\n142 0\n2 9\n1 2\n-2 0\n5 -4", "42 25\n5 -1\n142 0\n2 9\n1 3\n-2 0\n5 -4", ...
coding
301
Solve the programming task below in a Python markdown code block. Your coworker was supposed to write a simple helper function to capitalize a string (that contains a single word) before they went on vacation. Unfortunately, they have now left and the code they gave you doesn't work. Fix the helper function they wrote...
{"functional": "_inputs = [['word'], ['i'], ['glasswear']]\n_outputs = [['Word'], ['I'], ['Glasswear']]\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) ...
coding
148
Solve the programming task below in a Python markdown code block. Chef had a sequence of positive integers with length $N + K$. He managed to calculate the arithmetic average of all elements of this sequence (let's denote it by $V$), but then, his little brother deleted $K$ elements from it. All deleted elements had th...
{"inputs": ["3\n3 3 4\n2 7 3\n3 1 4\n7 6 5\n3 3 4\n2 8 3"], "outputs": ["4\n-1\n-1"]}
coding
424
Solve the programming task below in a Python markdown code block. Problem statement AOR Ika-chan is in a bad mood lately. Apparently, I don't like the ratio of the number of followers to the number of followers of "Ikatta". Currently, AOR Ika-chan has $ A $ followers, $ B $ followers, and a ratio of $ A: B $. Therefo...
{"inputs": ["7 4 3", "30 7 1", "37 7 1", "35 7 1", "35 1 1", "7 26 3", "35 2 1", "19 2 2"], "outputs": ["1\n", "23\n", "30\n", "28\n", "34\n", "6\n", "33\n", "15\n"]}
coding
571
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. All bandits are afraid of Sheriff. Sheriff constantly fights crime, but when bandits lay low, he gets bored and starts to entertain himself. This time Sheriff gathered all the bandits in his ga...
{"inputs": ["2\n3\n1 2 3\n5\n2 3 1 5 4", "2\n2\n1 2 3\n5\n2 3 1 5 4", "2\n3\n1 2 3\n5\n4 3 1 5 2", "2\n3\n2 1 3\n5\n4 3 1 5 2", "2\n2\n1 2 3\n5\n4 3 1 5 2", "2\n1\n1 2 3\n5\n2 3 1 5 4", "2\n1\n1 2 3\n5\n4 3 1 5 2", "2\n2\n2 1 3\n5\n4 3 1 5 2"], "outputs": ["1\n6", "1\n6\n", "1\n5\n", "2\n5\n", "1\n5\n", "1\n6\n", "1\n5...
coding
516
Solve the programming task below in a Python markdown code block. Let's say we have a number, `num`. Find the number of values of `n` such that: there exists `n` consecutive **positive** values that sum up to `num`. A positive number is `> 0`. `n` can also be 1. ```python #Examples num = 1 #1 return 1 num = 15 #15, (...
{"functional": "_inputs = [[1], [15], [48], [97]]\n_outputs = [[1], [4], [2], [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 len(a) != len(b): return Fal...
coding
215
Solve the programming task below in a Python markdown code block. Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ). Consider a sequence A satisfying the following conditions: - A is a sequence of N positive integers. - 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M. Let us d...
{"inputs": ["10 10 1\n1 10 9 1", "10 10 1\n1 10 9 1\n", "10 10 1\n1 10 12 1", "3 4 3\n2 3 3 100\n1 2 2 10\n2 3 2 10", "3 4 3\n1 1 3 100\n1 2 2 10\n2 3 2 10", "3 4 2\n2 3 1 100\n1 2 2 10\n2 3 2 14", "3 4 2\n2 3 3 101\n1 2 2 16\n2 3 2 14", "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10"], "outputs": ["1", "1\n", "0\n", "100\n", "...
coding
462
Solve the programming task below in a Python markdown code block. Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once. He serves them in the form of a stack. A pancake can be treated as a circular disk with some radius. Chef needs to take care that when he places a pancake on the top...
{"inputs": ["2\n1\n2"], "outputs": ["1\n2"]}
coding
258
Solve the programming task below in a Python markdown code block. Given two strings, the first being a random string and the second being the same as the first, but with three added characters somewhere in the string (three same characters), Write a function that returns the added character ### E.g ``` string1 = "he...
{"functional": "_inputs = [['hello', 'checlclo'], ['aabbcc', 'aacccbbcc'], ['abcde', '2db2a2ec']]\n_outputs = [['c'], ['c'], ['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, ...
coding
283
Solve the programming task below in a Python markdown code block. You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1. -----Constraints----- -...
{"inputs": ["z\n", "aaaa\n", "atcoder\n", "fukuokayamaguchi\n"], "outputs": ["z\n", "aa\n", "acdr\n", "fkoaaauh\n"]}
coding
161
Solve the programming task below in a Python markdown code block. Given a number $n$, give the last digit of sum of all the prime numbers from 1 to $n$ inclusive. -----Input:----- - First line contains number of testcase $t$. - Each testcase contains of a single line of input, number $n$. -----Output:----- Last digi...
{"inputs": ["1\n10"], "outputs": ["7"]}
coding
134
Solve the programming task below in a Python markdown code block. Today is your birthday. You have decided to give away candies to your friends. You have N friends and M candies. Suppose the 1^{st} friend has L buckets, 2^{nd} has L+1 buckets, 3^{rd} has L+2 buckets, and so on — in general, the i^{th} friend has L + ...
{"inputs": ["4\n2 8 2\n3 9 2\n3 10 2\n4 100 10"], "outputs": ["0\n1\n0\n9"]}
coding
702
Solve the programming task below in a Python markdown code block. You are given a following process. There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a squa...
{"inputs": ["1 1\n1\n", "2 1\n2\n", "2 1\n1\n", "2 1\n2\n", "1 1\n1\n", "2 1\n1\n", "2 2\n2 2\n", "4 2\n1 2\n"], "outputs": ["1\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "0\n"]}
coding
412
Solve the programming task below in a Python markdown code block. Write a program to obtain 2 numbers $($ $A$ $and$ $B$ $)$ and an arithmetic operator $(C)$ and then design a $calculator$ depending upon the operator entered by the user. So for example if C="+", you have to sum the two numbers. If C="-", you have to sub...
{"inputs": ["8\n2\n/", "5\n3\n+"], "outputs": ["4.0", "8"]}
coding
337
Solve the programming task below in a Python markdown code block. The characters of Chima need your help. Their weapons got mixed up! They need you to write a program that accepts the name of a character in Chima then tells which weapon he/she owns. For example: for the character `"Laval"` your program should return t...
{"functional": "_inputs = [['Laval'], ['Crominus'], ['Lagravis'], ['Cragger'], ['Tormak'], ['LiElla'], [\"G'loona\"], ['Stinkin gorillas'], ['qwertyuiopasdfghjklzxcvbnm']]\n_outputs = [['Laval-Shado Valious'], ['Crominus-Grandorius'], ['Lagravis-Blazeprowlor'], ['Cragger-Vengdualize'], ['Tormak-Tygafyre'], ['LiElla-Roa...
coding
179
Solve the programming task below in a Python markdown code block. Our hardworking chef is bored of sleeping in his restaurants. He has decided to settle down. The first thing he must do is to find a suitable location to build a palatial home. Think of the city as a two-dimensional grid. There are N restaurants in t...
{"inputs": ["3\n5\n0 0\n0 0\n1 0\n0 1\n0 -1\n5\n31 3\n30 -6\n20 15\n25 18\n25 38\n1\n0 0\n1 1", "3\n5\n0 0\n0 0\n1 0\n0 1\n0 -1\n5\n31 5\n30 -6\n20 15\n25 18\n25 38\n1\n0 0\n1 1", "3\n5\n0 0\n-1 0\n1 0\n0 1\n0 -1\n5\n4 7\n30 -41\n20 8\n26 18\n25 38\n2\n0 0\n1 1", "3\n5\n0 0\n0 0\n1 0\n0 1\n0 -1\n5\n31 5\n30 -6\n26 15\n...
coding
423
Solve the programming task below in a Python markdown code block. Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip ...
{"inputs": ["2\n55\n", "2\n87\n", "2\n74\n", "2\n41\n", "2\n66\n", "2\n24\n", "3\n101\n", "3\n101\n"], "outputs": ["10\n", "15\n", "11\n", "5\n", "12\n", "6\n", "11\n", "11\n"]}
coding
414
Solve the programming task below in a Python markdown code block. Modify the spacify function so that it returns the given string with spaces inserted between each character. ```python spacify("hello world") # returns "h e l l o w o r l d" ``` Also feel free to reuse/extend the following starter code: ```python def ...
{"functional": "_inputs = [[''], ['a'], ['Pippi']]\n_outputs = [[''], ['a'], ['P i p p i']]\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): r...
coding
80
Solve the programming task below in a Python markdown code block. Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad. The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad are locate...
{"inputs": ["5 2 6 3\n", "3 1 5 6\n", "8 3 3 2\n", "1 3 2 5\n", "2 3 1 6\n", "9 6 2 5\n", "1 1 1 1\n", "1 2 1 1\n"], "outputs": ["2\n", "8\n", "2\n", "8\n", "10\n", "3\n", "2\n", "1\n"]}
coding
572
Solve the programming task below in a Python markdown code block. The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This li...
{"inputs": ["2 2\n0\n0\n", "2 2\n0\n0\n", "2 2\n1 2\n0\n", "3 3\n0\n0\n0\n", "3 3\n0\n0\n0\n", "3 2\n0\n0\n0\n", "3 4\n0\n0\n0\n", "2 2\n1 2\n0\n"], "outputs": ["2\n", "2", "1\n", "3\n", "3", "3\n", "3\n", "1"]}
coding
493
Solve the programming task below in a Python markdown code block. The Government of Siruseri is no different from any other when it comes to being "capital-centric" in its policies. Recently the government decided to set up a nationwide fiber-optic network to take Siruseri into the digital age. And as usual, this decis...
{"inputs": ["4\n0 7 8 10\n7 0 4 5\n8 4 0 6\n10 5 6 0"], "outputs": ["9"]}
coding
723
Solve the programming task below in a Python markdown code block. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the scor...
{"inputs": ["1\n6\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n5\n", "1\n8\n", "1\n20\n", "1\n19\n"], "outputs": ["6\n", "2\n", "4\n", "3\n", "5\n", "8\n", "20\n", "19\n"]}
coding
523
Solve the programming task below in a Python markdown code block. ###Lucky number Write a function to find if a number is lucky or not. If the sum of all digits is 0 or multiple of 9 then the number is lucky. `1892376 => 1+8+9+2+3+7+6 = 36`. 36 is divisble by 9, hence number is lucky. Function will return `true` fo...
{"functional": "_inputs = [[1892376], [189237], [18922314324324234423437], [189223141324324234423437], [1892231413243242344321432142343423437], [0]]\n_outputs = [[True], [False], [False], [True], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n r...
coding
132
Solve the programming task below in a Python markdown code block. A tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is believed to bring bad luck. Your ta...
{"inputs": ["3 1\n4 4\n0 0", "3 1\n6 4\n0 0", "3 4\n4 1\n0 0", "3 1\n4 2\n0 0", "3 2\n6 4\n0 0", "3 7\n4 1\n0 0", "4 4\n4 1\n0 0", "4 1\n4 2\n0 0"], "outputs": ["0\n2\n", "0\n3\n", "4\n1\n", "0\n4\n", "3\n3\n", "0\n1\n", "2\n1\n", "1\n4\n"]}
coding
249
Solve the programming task below in a Python markdown code block. Ambar is a gardener and have many water jugs in his garden. The shape of water jug is a cone placed on the top of a cylinder (the radius and height of cylinder and cone and is "r"). There is a jug for each value of "r'. "r" varies from 1 to "n" ("n" be...
{"inputs": ["100"], "outputs": ["106824622"]}
coding
181
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Eugene loves sequences, especially arithmetic progressions. One day he was asked to solve a difficult problem. If a sequence of numbers A_{1}, A_{2}, ... , A_{N} form an ari...
{"inputs": ["2\n1 1 0 4\n4 7 2 4", "2\n1 1 0 4\n2 7 2 4", "2\n1 1 1 3\n14 7 2 4", "2\n1 1 1 2\n14 7 2 4", "2\n1 1 1 4\n14 7 2 4", "2\n1 1 0 4\n14 7 2 4", "2\n1 1 1 4\n2 10 2 0", "2\n1 1 1 4\n3 29 2 0"], "outputs": ["19\n18\n", "19\n21\n", "6\n12", "3\n12\n", "10\n12\n", "19\n12\n", "10\n-2\n", "10\n-3\n"]}
coding
703
Solve the programming task below in a Python markdown code block. You are given a positive integer L in base two. How many pairs of non-negative integers (a, b) satisfy the following conditions? - a + b \leq L - a + b = a \mbox{ XOR } b Since there can be extremely many such pairs, print the count modulo 10^9 + 7. W...
{"inputs": ["1\n", "10\n", "1111111111111111111\n", "11100000110100000010101101011111001100000\n", "110011111011111010101111000110101110110100001011011011111100101001110010\n", "10010011010011000011011110000011000000000011011110101001100000100101011101111111010001\n", "11000000000011110101111101010111101010011110011010...
coding
352
Solve the programming task below in a Python markdown code block. Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable. In total the table Arthur bought has n legs, the length of the i-th leg is l_{i}. Arthur decided to make the table stable and r...
{"inputs": ["1\n5\n4\n", "1\n5\n4\n", "1\n8\n4\n", "1\n8\n1\n", "1\n7\n1\n", "1\n5\n1\n", "1\n5\n2\n", "1\n8\n2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
coding
446
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times: Pick any nums[i] and delete it to earn nums[i] points. Afterwards, you...
{"functional": "def check(candidate):\n assert candidate(nums = [3,4,2]) == 6\n assert candidate(nums = [2,2,3,3,3,4]) == 9\n\n\ncheck(Solution().deleteAndEarn)"}
coding
138
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef once had a deep epiphany and ended up saying: Given a sequence of positive integers $a_{1}, a_{2}, \ldots, a_{N}$, if you take each of its $2^{N...
{"inputs": ["2\n2\n1 1\n3\n1 9 8"], "outputs": ["3\n27"]}
coding
334
Solve the programming task below in a Python markdown code block. Some large corporation where Polycarpus works has its own short message service center (SMSC). The center's task is to send all sorts of crucial information. Polycarpus decided to check the efficiency of the SMSC. For that, he asked to give him the sta...
{"inputs": ["1\n1 1\n", "1\n1 1\n", "2\n1 1\n2 1\n", "2\n1 1\n4 1\n", "2\n1 1\n4 2\n", "2\n1 1\n4 4\n", "2\n1 2\n4 6\n", "2\n2 3\n4 9\n"], "outputs": ["2 1\n", "2 1", "3 1\n", "5 1\n", "6 2\n", "8 4\n", "10 6\n", "14 10\n"]}
coding
759
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.   Please complete the following python code precisely: ```python class Solution: def threeC...
{"functional": "def check(candidate):\n assert candidate(arr = [2,6,4,1]) == False\n assert candidate(arr = [1,2,34,3,4,5,7,23,12]) == True\n\n\ncheck(Solution().threeConsecutiveOdds)"}
coding
77
Please solve the programming task below using a self-contained code snippet in a markdown code block. An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone. A number is valid if ea...
{"functional": "def check(candidate):\n assert candidate(n = 10) == 4\n assert candidate(n = 1) == 0\n assert candidate(n = 2) == 1\n\n\ncheck(Solution().rotatedDigits)"}
coding
197
Solve the programming task below in a Python markdown code block. Given a string A of length N consisting of lowercase English alphabet letters. You are allowed to perform the following operation on the string A any number of times: Select a non-empty [subsequence] S of the array [1,2,3,\ldots,N] and any lowercase ...
{"inputs": ["3\n2\nab\ncd\n3\naaa\nbab\n4\nabcd\naaab\n"], "outputs": ["2\n1\n2\n"]}
coding
517
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cell...
{"functional": "def check(candidate):\n assert candidate(n = 1) == 12\n assert candidate(n = 2) == 54\n assert candidate(n = 3) == 246\n assert candidate(n = 7) == 106494\n assert candidate(n = 5000) == 30228214\n\n\ncheck(Solution().numOfWays)"}
coding
154
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"]}
coding
149
Solve the programming task below in a Python markdown code block. You are given an array $a$ of $n$ non-negative integers. In one operation you can change any number in the array to any other non-negative integer. Let's define the cost of the array as $\operatorname{DIFF}(a) - \operatorname{MEX}(a)$, where $\operatorn...
{"inputs": ["1\n5 1\n5 4 3 1 2\n", "1\n5 1\n1 2 3 4 5\n", "1\n10 5\n0 1 2 3 100 101 102 102 102 102\n", "5\n5 1\n1 2 3 4 5\n5 1\n1 2 3 4 5\n5 1\n1 2 3 4 5\n5 1\n1 2 3 4 5\n5 1\n1 2 3 4 5\n", "4\n4 1\n3 0 1 2\n4 1\n0 2 4 5\n7 2\n4 13 0 0 13 1337 1000000000\n6 2\n1 2 8 0 0 0\n"], "outputs": ["0\n", "0\n", "1\n", "0\n0\n0...
coding
733
Solve the programming task below in a Python markdown code block. International Christmas Present Company (ICPC) is a company to employ Santa and deliver presents on Christmas. Many parents request ICPC to deliver presents to their children at specified time of December 24. Although same Santa can deliver two or more p...
{"inputs": ["4 2 3\n0 2 2\n1 2 10\n0 -1\n1 8\n2 0\n3 2 4\n1 1 0\n1 2 10\n0 0\n1 10\n2 20\n0 25\n18 10 10\n0 2 39\n2 3 81\n3 5 20\n4 8 24\n1 9 10\n7 9 40\n4 2 5\n5 7 20\n1 2 93\n1 4 13\n0 0\n1 100000000\n2 100\n3 941\n4 333\n5 235\n5 300\n7 166\n8 101\n9 100\n0 0 0", "3 2 3\n0 1 2\n1 2 10\n1 -1\n1 8\n2 0\n3 2 4\n1 1 10\...
coding
741
Solve the programming task below in a Python markdown code block. Kulyash has given you an array A of size N. He defines the *subsequence-number* of a non-empty [subsequence] S of array A as the number formed by the concatenation of all the elements of the subsequence S. Find the count of non-empty subsequences of...
{"inputs": ["3\n2\n1 2\n4\n1 2 3 4\n2\n7 7\n"], "outputs": ["0\n1\n3\n"]}
coding
621
Solve the programming task below in a Python markdown code block. Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS messages on candybar-shaped feature phones with 3x4 numeric keypads. ------- ------- ------- | | | ABC | | DEF | | 1 | | 2 | | 3 | ------- -------...
{"functional": "_inputs = [['LOL'], ['HOW R U'], ['WHERE DO U WANT 2 MEET L8R'], ['lol'], ['0'], ['ZER0'], ['1'], ['IS NE1 OUT THERE'], ['#'], ['#codewars #rocks']]\n_outputs = [[9], [13], [47], [9], [2], [11], [1], [31], [1], [36]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(...
coding
536
Solve the programming task below in a Python markdown code block. # Task "AL-AHLY" and "Zamalek" are the best teams in Egypt, but "AL-AHLY" always wins the matches between them. "Zamalek" managers want to know what is the best match they've played so far. The best match is the match they lost with the minimum goal ...
{"functional": "_inputs = [[[6, 4], [1, 2]], [[1], [0]], [[1, 2, 3, 4, 5], [0, 1, 2, 3, 4]], [[3, 4, 3], [1, 1, 2]], [[4, 3, 4], [1, 1, 1]]]\n_outputs = [[1], [0], [4], [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=...
coding
405
Solve the programming task below in a Python markdown code block. The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep". Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he ...
{"inputs": ["3\n5 2 1\n", "3\n4 3 1\n", "3\n4 2 1\n", "3\n3 2 1\n", "3\n2 3 1\n", "3\n2 7 11\n", "4\n7 8 3 1\n", "4\n1 5 0 4\n"], "outputs": ["1\n", "1\n", "1\n", "1", "0", "0", "2\n", "0\n"]}
coding
337
Solve the programming task below in a Python markdown code block. I love Fibonacci numbers in general, but I must admit I love some more than others. I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence. For example: ```python nth_fib(4) == 2...
{"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25]]\n_outputs = [[0], [1], [1], [2], [3], [5], [8], [13], [21], [34], [55], [89], [144], [233], [377], [610], [987], [1597], [2584], [4181], [6765], [10946]...
coding
146
Solve the programming task below in a Python markdown code block. Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white. Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it ...
{"inputs": ["2\n0\n1 0\n", "2\n0\n1 0\n", "3\n0 0\n0 1 1\n", "3\n0 0\n1 1 1\n", "3\n0 1\n0 1 1\n", "3\n0 0\n0 1 1\n", "5\n0 1 1 3\n0 0 0 1 1\n", "5\n0 1 1 3\n0 0 0 1 1\n"], "outputs": ["1\n", "1", "2\n", "1\n", "1\n", "2", "1\n", "1"]}
coding
467
Solve the programming task below in a Python markdown code block. Manager of HackerX company is having big trouble. Workers are very unhappy with the way salary is given to them. They want every worker to have the same salary, otherwise they will go on a strike. Their current salaries are denoted by a sequence of N in...
{"inputs": ["4 2\n9 12 3 6\n0\n3\n"], "outputs": ["3\n3\n"]}
coding
516
Solve the programming task below in a Python markdown code block. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back ...
{"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "3 1 2\n1 2 3\n", "3 1 2\n1 0 3\n", "3 1 3\n1 0 3\n", "3 1 3\n2 0 3\n", "3 1 4\n1 0 3\n", "3 1 2\n1 1 1\n"], "outputs": ["0 ", "0\n", "1 0 1 ", "1 0 1\n", "1 0 0\n", "2 0 0\n", "1 0 3\n", "1 1 1\n"]}
coding
412
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which means you can visit the cell (row, col) on...
{"functional": "def check(candidate):\n assert candidate(grid = [[0,1,3,2],[5,1,2,5],[4,3,8,6]]) == 7\n assert candidate(grid = [[0,2,4],[3,2,1],[1,0,4]]) == -1\n\n\ncheck(Solution().minimumTime)"}
coding
197
Solve the programming task below in a Python markdown code block. Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. -----Constraints----- - 2 \leq K \leq 10^5 - K is an integer. -----Input----- Input is given from Standard Input in the following format: K -----Output...
{"inputs": ["9", "8", "4", "3", "5", "2", "7", "6"], "outputs": ["9\n", "1\n", "1\n", "3\n", "1\n", "1\n", "2\n", "3"]}
coding
118
Solve the programming task below in a Python markdown code block. Given is a string S representing the day of the week today. S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)? ----...
{"inputs": ["SUN", "SAT", "SAT\n", "SUN\n", "FRI\n", "MON\n", "THU\n", "TUE\n"], "outputs": ["7", "1", "1\n", "7\n", "2\n", "6\n", "3\n", "5\n"]}
coding
156
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Time flies fast, Chef’s sons are getting older, stronger and higher. Chef has got two sons and they don’t go well with each other. Their relations are getting worse day by day. Concerned Chef h...
{"inputs": ["4 4\n0 1 1 \n1 2 2\n2 3 3\n3 0 4"], "outputs": ["1 2"]}
coding
704
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"]}
coding
521
Solve the programming task below in a Python markdown code block. Chef has been working in a restaurant which has N floors. He wants to minimize the time it takes him to go from the N-th floor to ground floor. He can either take the elevator or the stairs. The stairs are at an angle of 45 degrees and Chef's velocity...
{"inputs": ["3\n5 10 15\n2 10 14\n7 14 10"], "outputs": ["Elevator\nStairs\nStairs"]}
coding
362
Solve the programming task below in a Python markdown code block. ZCO is approaching, and you want to be well prepared! There are $N$ topics to cover and the $i^{th}$ topic takes $H_i$ hours to prepare (where $1 \le i \le N$). You have only $M$ days left to prepare, and you want to utilise this time wisely. You know ...
{"inputs": ["2\n5 4 10\n10 24 30 19 40\n5 4 16\n7 16 35 10 15"], "outputs": ["2\n4"]}
coding
594
Solve the programming task below in a Python markdown code block. A permutation of length N is an array of N integers A = [A_{1}, A_{2}, \dots, A_{N}] such that every integer from 1 to N appears in it exactly once. We define a function over a permutation as follows: F(A) = (A_{1} * A_{2}) + (A_{2} * A_{3}) + \cdots + ...
{"inputs": ["2\n2\n3"], "outputs": ["2\n333333343\n"]}
coding
600
Solve the programming task below in a Python markdown code block. Zurikela is creating a graph with a special graph maker. At the begining, it is empty and has no nodes or edges. He can perform $3$ types of operations: $\mbox{A}$ $\boldsymbol{x}$: Create a set of $\boldsymbol{x}$ new nodes and name it $\boldsymbol...
{"inputs": ["8\nA 1\nA 2\nB 1 2\nC 1\nA 2\nA 3\nB 3 4\nB 4 5\n"], "outputs": ["5\n"]}
coding
680
Solve the programming task below in a Python markdown code block. Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists. - Let s' be the concatenation of 10^{100} copies of s. t is a sub...
{"inputs": ["d\nd\n", "j\nw\n", "zv\nz\n", "jh\nh\n", "l\nll\n", "s\nsv\n", "csnteot\nson", "vtaletn\ntnn"], "outputs": ["1\n", "-1\n", "1\n", "2\n", "2\n", "-1\n", "10\n", "14\n"]}
coding
365
Solve the programming task below in a Python markdown code block. You are given an integer N. Can you find the least positive integer X made up of only 9's and 0's, such that, X is a multiple of N? Update X is made up of one or more occurences of 9 and zero or more occurences of 0. Input Format The first line c...
{"inputs": ["3\n5\n7\n1\n"], "outputs": ["90\n9009\n9\n"]}
coding
234
Solve the programming task below in a Python markdown code block. The Rumbling is a hypothetical cataclysmic event involving Karl Fritz's Wall Titans marching across the Earth, destroying all life upon it. Eren Yeager who possesses the Founding Titan has decided to begin The Rumbling to show the true power of the Eldia...
{"inputs": ["1\n5\nSENWS\n2 1"], "outputs": ["4"]}
coding
750
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.   Please complete the following python code precisely: ```python # Defin...
{"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,2,3,4,5])), list_node([3,4,5]))\n assert is_same_list(candidate(head = list_node([1,2,3,4,5,6])), list_node([4,5,6]))\n\n\ncheck(Solution().middleNode)"}
coding
122
Solve the programming task below in a Python markdown code block. One player came to a casino and found a slot machine where everything depends only on how he plays. The rules follow. A positive integer a is initially on the screen. The player can put a coin into the machine and then add 1 to or subtract 1 from any tw...
{"inputs": ["2\n28\n94\n", "2\n99\n11\n", "2\n37\n97\n", "2\n85\n96\n", "2\n64\n97\n", "2\n37\n94\n", "2\n19\n97\n", "2\n54\n96\n"], "outputs": ["-1\n", "8\n1 -1\n1 -1\n1 -1\n1 -1\n1 -1\n1 -1\n1 -1\n1 -1\n", "-1\n", "1\n1 1\n", "3\n1 1\n1 1\n1 1\n", "-1\n", "-1\n", "-1\n"]}
coding
629
Solve the programming task below in a Python markdown code block. For an array A of length N, let F(A) denote the sum of the product of all the subarrays of A. Formally, F(A) = \sum_{L=1}^N \sum_{R=L}^N (\prod_{i=L}^R A_{i}\right ) For example, let A = [1, 0, 1], then there are 6 possible subarrays: Subarray [1, 1]...
{"inputs": ["4\n3\n1 0 1\n1\n0\n2\n1 1\n4\n1 1 0 1\n"], "outputs": ["16\n0\n6\n120\n"]}
coding
641
Solve the programming task below in a Python markdown code block. Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team. At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and t. You need to transform word s into word t...
{"inputs": ["y\nu\n", "y\nu\n", "z\nu\n", "y\nt\n", "z\nt\n", "z\nzz\n", "z\nzz\n", "ba\naa\n"], "outputs": ["need tree\n", "need tree\n", "need tree\n", "need tree\n", "need tree\n", "need tree\n", "need tree\n", "need tree\n"]}
coding
557
Solve the programming task below in a Python markdown code block. Read problems statements in Russian. Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness ...
{"inputs": ["1\n3\n1 2 3", "1\n3\n-8 0 -2"], "outputs": ["18", "-10"]}
coding
455
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi]. The answer to the ith query is the maximum bitwise XOR value of xi and any element of n...
{"functional": "def check(candidate):\n assert candidate(nums = [0,1,2,3,4], queries = [[3,1],[1,3],[5,6]]) == [3,3,7]\n assert candidate(nums = [5,2,4,6,6,3], queries = [[12,4],[8,1],[6,3]]) == [15,-1,5]\n\n\ncheck(Solution().maximizeXor)"}
coding
176
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin chinese, Russian and Vietnamese as well. There are N minions who are competing in an election of the president of the ACM (Association of Cute Minions). They are standing in a line in the order from minion 1 to mini...
{"inputs": ["2\n4\n4 3 2 1\n5\n1 2 2 3 1"], "outputs": ["1 2 3 2\n2 3 2 3 1"]}
coding
526
Solve the programming task below in a Python markdown code block. This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the...
{"inputs": ["5\n1 1 1 1 1\n1\n+ 1\n", "5\n1 1 1 2 1\n1\n+ 1\n", "5\n1 1 1 4 1\n1\n+ 1\n", "5\n1 1 1 8 1\n1\n+ 1\n", "10\n1 1 1 1 1 1 1 1 1 1\n1\n+ 1\n", "10\n1 1 1 1 1 1 1 1 1 1\n1\n+ 1\n", "10\n1 1 1 1 0 1 1 1 1 1\n1\n+ 1\n", "10\n1 2 1 1 0 1 1 1 1 1\n1\n+ 1\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "Y...
coding
721
Solve the programming task below in a Python markdown code block. The objective is to disambiguate two given names: the original with another This kata is slightly more evolved than the previous one: [Author Disambiguation: to the point!](https://www.codewars.com/kata/580a429e1cb4028481000019). The function ```could_...
{"functional": "_inputs = [['Carlos Ray Norris', 'Carlos Ray Norris'], ['Carlos Ray Norris', 'Carlos Ray'], ['Carlos Ray Norris', 'Ray Norris'], ['Carlos Ray Norris', 'Carlos Norris'], ['Carlos Ray Norris', 'Norris'], ['Carlos Ray Norris', 'Carlos'], ['Carlos Ray Norris', 'Norris Carlos'], ['Carlos Ray Norris', 'carlos...
coding
536
Solve the programming task below in a Python markdown code block. Vanja and Miksi have already finished everything for this year at their university, so they decided to spend their free time playing a game with a binary sequence $A_1, A_2, \dots, A_N$ (i.e. a sequence containing only integers $0$ and $1$). At the begin...
{"inputs": ["2\n2 1\n1 0\n3 5\n0 1 0"], "outputs": ["1\n2"]}
coding
566
Solve the programming task below in a Python markdown code block. Dothraki are planning an attack to usurp King Robert's throne. King Robert learns of this conspiracy from Raven and plans to lock the single door through which the enemy can enter his kingdom. But, to lock the door he needs a key that is an anagram of a...
{"inputs": ["aaabbbb\n", "cdcdcdcdeeeef\n", "cdefghmnopqrstuvw\n"], "outputs": ["YES\n", "YES\n", "NO\n"]}
coding
388
Solve the programming task below in a Python markdown code block. Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem: Find k integers such that the sum of two to the power of each number equals to the number n a...
{"inputs": ["1 2\n", "1 1\n", "7 2\n", "7 3\n", "7 4\n", "1 4\n", "9 4\n", "3 4\n"], "outputs": ["Yes\n-1 -1 \n", "Yes\n0 \n", "No\n", "Yes\n2 1 0 \n", "Yes\n1 1 1 0 \n", "Yes\n-2 -2 -2 -2 \n", "Yes\n2 2 -1 -1 \n", "Yes\n0 0 -1 -1 \n"]}
coding
729
Solve the programming task below in a Python markdown code block. Alan's child can be annoying at times. When Alan comes home and tells his kid what he has accomplished today, his kid never believes him. Be that kid. Your function 'AlanAnnoyingKid' takes as input a sentence spoken by Alan (a string). The sentence c...
{"functional": "_inputs = [['Today I played football.'], [\"Today I didn't play football.\"], [\"Today I didn't attempt to hardcode this Kata.\"], ['Today I cleaned the kitchen.'], ['Today I learned to code like a pro.']]\n_outputs = [[\"I don't think you played football today, I think you didn't play at all!\"], [\"I ...
coding
450
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique path between each pair of ci...
{"functional": "def check(candidate):\n assert candidate(n = 4, edges = [[1,2],[2,3],[2,4]]) == [3,4,0]\n assert candidate(n = 2, edges = [[1,2]]) == [1]\n assert candidate(n = 3, edges = [[1,2],[2,3]]) == [2,1]\n\n\ncheck(Solution().countSubgraphsForEachDiameter)"}
coding
272
Solve the programming task below in a Python markdown code block. Introduction Mr. Safety loves numeric locks and his Nokia 3310. He locked almost everything in his house. He is so smart and he doesn't need to remember the combinations. He has an algorithm to generate new passcodes on his Nokia cell phone. Task ...
{"functional": "_inputs = [['Nokia'], ['Valut'], ['toilet'], ['waterheater'], ['birdhouse']]\n_outputs = [['66542'], ['82588'], ['864538'], ['92837432837'], ['247346873']]\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, ab...
coding
226
Solve the programming task below in a Python markdown code block. Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only s...
{"inputs": ["3 4 2\n2 2\n2 3\n", "2 2 2\n2 1\n1 2\n", "2 2 2\n2 1\n1 2\n", "3 4 2\n2 2\n1 3\n", "3 4 2\n2 2\n2 3\n", "100000 100000 2\n1 2\n2 1\n", "100000 100000 2\n1 2\n2 1\n", "100000 100000 2\n2 2\n2 1\n"], "outputs": ["2\n", "0\n", "0\n", "1\n", "2\n", "0\n", "0\n", "307833736\n"]}
coding
477