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. For his birthday, Kevin received the set of pairwise distinct numbers $1, 2, 3, \ldots, n$ as a gift. He is going to arrange these numbers in a way such that the minimum absolute difference between two consecutive numbers be maximum possible. More forma...
{"inputs": ["1\n2\n", "2\n4\n3\n"], "outputs": ["2 1 \n", "3 1 4 2 \n2 1 3 \n"]}
504
45
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 representing the score of students in an exam. The teacher would like to form one non-empty group of students with maximal strength, where the strength of a group of studen...
{"functional": "def check(candidate):\n assert candidate(nums = [3,-1,-5,2,5,-9]) == 1350\n assert candidate(nums = [-4,-5,-4]) == 20\n\n\ncheck(Solution().maxStrength)"}
143
61
coding
Solve the programming task below in a Python markdown code block. Kolya is going to make fresh orange juice. He has n oranges of sizes a_1, a_2, ..., a_{n}. Kolya will put them in the juicer in the fixed order, starting with orange of size a_1, then orange of size a_2 and so on. To be put in the juicer the orange must ...
{"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 5 10\n7\n", "1 5 6\n10\n", "1 5 6\n10\n", "1 5 10\n9\n", "1 5 10\n7\n", "2 6 8\n2 1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
476
125
coding
Solve the programming task below in a Python markdown code block. Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it: * deletes all the vow...
{"inputs": ["g\n", "D\n", "h\n", "Ba\n", "ab\n", "aB\n", "bA\n", "Ab\n"], "outputs": [".g\n", ".d\n", ".h\n", ".b\n", ".b\n", ".b\n", ".b\n", ".b\n"]}
257
73
coding
Solve the programming task below in a Python markdown code block. Contest T-shirts Segtree has $ M $ contest T-shirts. He decided to spend $ N $ days on the contest T-shirt alone, and told $ i = 1, 2, 3, \ dots, N $ "$ A_i $ T-shirt on the $ i $ day." I made a plan for $ N $ to wear. However, if you keep the current...
{"inputs": ["2 0\n2 2 1", "2 0\n2 0 1", "2 0\n2 0 0", "2 0\n1 0 0", "4 0\n1 0 0", "0 0\n2 2 1", "2 1\n2 0 1", "3 0\n2 0 0"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
350
126
coding
Solve the programming task below in a Python markdown code block. In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages . Assume that you happen to hear the above words and you want to give a try in finding the square root...
{"inputs": ["3\n1\n5\n10000", "3\n1\n2\n10000", "3\n2\n6\n11100", "3\n4\n4\n10001", "3\n2\n1\n11101", "3\n4\n6\n11100", "3\n2\n9\n00011", "3\n2\n1\n00001"], "outputs": ["1\n2\n100\n", "1\n1\n100\n", "1\n2\n105\n", "2\n2\n100\n", "1\n1\n105\n", "2\n2\n105\n", "1\n3\n3\n", "1\n1\n1\n"]}
205
186
coding
Solve the programming task below in a Python markdown code block. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free time, he goes to...
{"inputs": ["2 1\n", "4 6\n", "1 2\n", "4 7\n", "1 3\n", "7 3\n", "5 7\n", "7 1\n"], "outputs": ["Equal\n", "Equal\n", "Equal\n", "Dasha\n", "Dasha\n", "Masha\n", "Dasha\n", "Masha\n"]}
615
91
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting...
{"functional": "def check(candidate):\n assert candidate(n = 3, edges = [[0,1],[0,2],[1,2]]) == 0\n assert candidate(n = 7, edges = [[0,2],[0,5],[2,4],[1,6],[5,4]]) == 14\n\n\ncheck(Solution().countPairs)"}
129
82
coding
Solve the programming task below in a Python markdown code block. This is the easy version of Problem F. The only difference between the easy version and the hard version is the constraints. We will call a non-empty string balanced if it contains the same number of plus and minus signs. For example: strings "+--+" and...
{"inputs": ["5\n3\n+-+\n5\n-+---\n4\n----\n7\n--+---+\n6\n+++---\n"], "outputs": ["2\n4\n2\n7\n4\n"]}
631
51
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. An n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An integer appears no more than once in the sequence, The binary representa...
{"functional": "def check(candidate):\n assert candidate(n = 2) == [0,1,3,2]\n assert candidate(n = 1) == [0,1]\n\n\ncheck(Solution().grayCode)"}
145
53
coding
Solve the programming task below in a Python markdown code block. JOI has a stove in your room. JOI himself is resistant to the cold, so he doesn't need to put on the stove when he is alone in the room, but he needs to put on the stove when there are visitors. On this day, there are N guests under JOI. The ith (1 \ le...
{"inputs": ["3 2\n0\n4\n1", "3 2\n0\n6\n1", "3 2\n1\n4\n3", "3 2\n4\n0\n6", "3 2\n0\n3\n6", "3 2\n0\n4\n6", "3 2\n1\n5\n6", "3 2\n0\n3\n7"], "outputs": ["-1\n", "-3\n", "1\n", "-2\n", "5\n", "4\n", "3\n", "5\n"]}
228
127
coding
Solve the programming task below in a Python markdown code block. — Do you have a wish? — I want people to stop gifting each other arrays. O_o and Another Young Boy An array of $n$ positive integers $a_1,a_2,\ldots,a_n$ fell down on you from the skies, along with a positive integer $k \le n$. You can apply the foll...
{"inputs": ["6\n3 1\n2 4 1\n3 2\n1 9 84\n3 1\n10 2 6\n3 2\n179 17 1000000000\n2 1\n5 9\n2 2\n4 2\n"], "outputs": ["4\n168\n10\n1000000000\n9\n1000000000\n"]}
670
115
coding
Solve the programming task below in a Python markdown code block. An avid hiker keeps meticulous records of their hikes. During the last hike that took exactly $\textit{steps}$ steps, for every step it was noted if it was an uphill, $\mbox{U}$, or a downhill, $\mbox{D}$ step. Hikes always start and end at sea level, an...
{"inputs": ["8\nUDDDUDUU\n"], "outputs": ["1\n"]}
449
19
coding
Solve the programming task below in a Python markdown code block. Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a lo...
{"inputs": ["#\n", "(#(\n", ")#)\n", "*#)\n", ")#*\n", ")*#\n", "#*)\n", "(#)\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
363
78
coding
Solve the programming task below in a Python markdown code block. You are given two arrays $a$ and $b$ of $n$ elements, each element is either $0$ or $1$. You can make operations of $2$ kinds. Pick an index $i$ and change $a_i$ to $1-a_i$. Rearrange the array $a$ however you want. Find the minimum number of operati...
{"inputs": ["5\n3\n1 0 1\n0 0 1\n4\n1 1 0 0\n0 1 1 1\n2\n1 1\n1 1\n4\n1 0 0 1\n0 1 1 0\n1\n0\n1\n"], "outputs": ["1\n2\n0\n1\n1\n"]}
571
88
coding
Solve the programming task below in a Python markdown code block. Taro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for easy understanding, but the mover ...
{"inputs": ["4\n2 4 2 2", "4\n1 4 3 2", "4\n3 4 1 2", "4\n2 4 1 3", "4\n2 4 3 1", "4\n2 1 4 3", "4\n2 4 1 3", "4\n1 2 4 3"], "outputs": ["4\n", "5\n", "3\n", "4\n", "4\n", "4\n", "4\n", "3\n"]}
420
126
coding
Solve the programming task below in a Python markdown code block. Create a function that takes a Number as its argument and returns a Chinese numeral string. You don't need to validate the input argument, it will always be a Number in the range `[-99999.999, 99999.999]`, rounded to 8 decimal places. Simplified Chinese...
{"functional": "_inputs = [[0], [9], [99], [999], [9999], [99999], [-5], [-54], [-543], [-5432], [-54321], [0.5], [0.25], [0.125], [0.0625], [0.03125], [10], [14], [18], [20], [24], [50], [100], [110], [111], [-10], [-14], [-18], [-20], [-100], [-110], [-111], [1000], [10000], [10306], [10006], [10006.005], [-10306.005...
605
1,507
coding
Solve the programming task below in a Python markdown code block. Ringo is giving a present to Snuke. Ringo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other th...
{"inputs": ["KAY", "JAY", "JAZ", "ZAJ", "[AJ", "[AK", "KA[", "LA["], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
209
68
coding
Solve the programming task below in a Python markdown code block. Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not thre...
{"inputs": ["1\n3\n", "1\n2\n", "1\n3\n", "1\n2\n", "1\n1\n", "2\n1\n2\n", "2\n3\n3\n", "2\n2\n1\n"], "outputs": ["NO\n", "YES\n", "NO\n", "YES\n", "YES\n", "NO\n", "NO\n", "NO\n"]}
441
92
coding
Solve the programming task below in a Python markdown code block. Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point w...
{"inputs": ["4\n1\n0\n4\n3", "4\n0\n0\n4\n3", "4\n0\n1\n4\n3", "4\n0\n0\n8\n3", "4\n0\n0\n8\n1", "4\n1\n0\n8\n1", "4\n1\n0\n0\n1", "4\n1\n0\n3\n3"], "outputs": ["1\n", "0\n", "1\n", "0\n", "0\n", "1\n", "1\n", "1\n"]}
422
126
coding
Solve the programming task below in a Python markdown code block. Your company, [Congo Pizza](http://interesting-africa-facts.com/Africa-Landforms/Congo-Rainforest-Facts.html), is the second-largest online frozen pizza retailer. You own a number of international warehouses that you use to store your frozen pizzas, and ...
{"functional": "_inputs = [[32, 64, 16], [20, 20, 20], [80, 40, 20], [70, 60, 15], [90, 7, 5], [53, 21, 13]]\n_outputs = [[13824], [3375], [27000], [25740], [1005], [5265]]\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, a...
294
257
coding
Solve the programming task below in a Python markdown code block. Your friend recently came up with a card game called UT-Rummy. The cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards i...
{"inputs": ["5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 6\nR R B G G G R R R\n2 2 2 3 3 3 1 1 2\nR G B R G B R G B", "5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R ...
570
1,246
coding
Solve the programming task below in a Python markdown code block. Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied: * a12 + a22 + ... + an2 ≥ x * a1 + a2 + ... + an ≤ y Input The first line contains three space-separated integ...
{"inputs": ["1 1 1\n", "5 1 4\n", "2 1 1\n", "2 3 2\n", "10 3 8\n", "1 5 10\n", "5 37 10\n", "100 1 1\n"], "outputs": ["1\n", "-1", "-1", "-1\n", "-1", "10\n", "1\n1\n1\n1\n6\n", "-1"]}
255
113
coding
Solve the programming task below in a Python markdown code block. Every positive integer number, that is not prime, may be decomposed in prime factors. For example the prime factors of 20, are: ``` 2, 2, and 5, because: 20 = 2 . 2 . 5 ``` The first prime factor (the smallest one) of ```20``` is ```2``` and the last on...
{"functional": "_inputs = [[10, 100], [10, 200], [15, 150], [501, 1000], [501, 5000]]\n_outputs = [[[21, 25, 63]], [[21, 25, 63, 105, 125, 147, 189]], [[26, 52, 78, 104, 130]], [[998]], [[998, 1996, 2994, 3992, 4990]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ...
604
299
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome. Return the number of...
{"functional": "def check(candidate):\n assert candidate(root = tree_node([2,3,1,3,1,None,1])) == 2 \n assert candidate(root = tree_node([2,1,1,1,3,None,None,None,None,None,1])) == 1 \n assert candidate(root = tree_node([9])) == 1\n\n\ncheck(Solution().pseudoPalindromicPaths)"}
173
93
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has a sequence A containing N integers A_{1}, A_{2}, ..., A_{N}. Chef is playing a game with this sequence. In this game, he may perform the following operation any num...
{"inputs": ["2\n2\n1 2\n5\n7 4 3 2 6"], "outputs": ["2\n1"]}
337
32
coding
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)"}
154
100
coding
Solve the programming task below in a Python markdown code block. You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2... s|s|. Strin...
{"inputs": ["b\n", "z\n", "y\n", "a\n", "c\n", "x\n", "d\n", "w\n"], "outputs": ["b\n", "z\n", "y\n", "a\n", "c\n", "x\n", "d\n", "w\n"]}
334
70
coding
Solve the programming task below in a Python markdown code block. Consider the following series: `0,1,2,3,4,5,6,7,8,9,10,22,11,20,13,24...`There is nothing special between numbers `0` and `10`. Let's start with the number `10` and derive the sequence. `10` has digits `1` and `0`. The next possible number that does n...
{"functional": "_inputs = [[1], [5], [11], [100], [500]]\n_outputs = [[1], [5], [22], [103], [476]]\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) != l...
454
188
coding
Solve the programming task below in a Python markdown code block. Uh oh, Someone at the office has dropped all these sequences on the floor and forgotten to label them with their correct bases. We have to fix this before the boss gets back or we're all going to be fired! This is what your years of coding have been l...
{"functional": "_inputs = [[['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']], [['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']], [['1', '2', '3', '4', '5', '6', '10', '11', '12', '13']], [['301', '302', '303', '304', '305', '310', '311', '312', '313', '314']], [['50', '51', '61', '53', '54', '60', '52', '62', '5...
357
352
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every house can be warmed, as long as the house is within the heater's warm radius r...
{"functional": "def check(candidate):\n assert candidate(houses = [1,5], heaters = [2]) == 3\n\n\ncheck(Solution().findRadius)"}
150
39
coding
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...
179
279
coding
Solve the programming task below in a Python markdown code block. You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message i...
{"inputs": ["0\n", "_\n", "a\n", "D\n", "_\n", "?\n", "?\n", "R\n"], "outputs": ["Too weak\n", "Too weak\n", "Too weak\n", "Too weak\n", "Too weak\n", "Too weak\n", "Too weak\n", "Too weak\n"]}
283
78
coding
Solve the programming task below in a Python markdown code block. Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to pla...
{"inputs": ["1 4\n", "2 2\n", "3 2\n", "2 1\n", "5 3\n", "5 2\n", "8 5\n", "1 3\n"], "outputs": ["3B\n", "Impossible\n", "1A1B\n", "1A\n", "1A1B1A\n", "2A1B\n", "1A1B1A1B\n", "2B\n"]}
671
107
coding
Solve the programming task below in a Python markdown code block. The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than...
{"inputs": ["5 2 7 4\n0 1\n1 2\n0 4\n1 2\n", "5 2 10 4\n0 1\n1 1\n0 4\n1 2\n", "5 2 10 4\n0 1\n1 1\n1 4\n1 2\n", "5 2 10 4\n0 1\n1 1\n1 4\n0 2\n", "5 2 10 4\n1 1\n1 1\n1 4\n0 2\n", "5 2 10 4\n1 1\n1 1\n1 4\n0 1\n", "7 2 10 4\n1 1\n1 1\n1 4\n0 1\n", "7 3 17 4\n1 1\n1 1\n1 4\n0 1\n"], "outputs": ["4 1\n5 1\n4 1\n5 1\n", ...
699
367
coding
Solve the programming task below in a Python markdown code block. Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations. Fangy takes some positive integer x and wants to get a number one from it. While x is not equal to 1, Fangy repeats the following ac...
{"inputs": ["1\n", "11\n", "101010\n", "111010\n", "111110\n", "110010\n", "110011\n", "111011\n"], "outputs": ["0\n", "3\n", "9\n", "8\n", "7\n", "9\n", "9\n", "8\n"]}
334
101
coding
Solve the programming task below in a Python markdown code block. You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer. Constraints * 2 \leq N \leq 200\,000 * 0 < A_i < 10^4 * A_i is given with at most 9 digits after ...
{"inputs": ["5\n7.5\n2.4\n17.000000001\n22\n16.000000000", "5\n7.5\n2.4\n17.000000001\n17\n16.000000000", "5\n7.5\n2.4\n17.000000001\n22\n16.47557284807662", "5\n7.5\n2.4\n17.000000001\n17\n16.487690532545415", "5\n7.950925288494011\n2.4\n17.000000001\n17\n16.487690532545415", "5\n8.205736028631307\n2.4\n17.000000001\n...
297
448
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'. Return the lexicographically smallest string that starts at a leaf of this tree and ends at...
{"functional": "def check(candidate):\n assert candidate(root = tree_node([0,1,2,3,4,3,4])) == \"dba\"\n assert candidate(root = tree_node([25,1,3,1,3,0,2])) == \"adz\"\n assert candidate(root = tree_node([2,2,1,None,1,0,None,0])) == \"abc\"\n\n\ncheck(Solution().smallestFromLeaf)"}
201
104
coding
Solve the programming task below in a Python markdown code block. Vlad and Nastya live in a city consisting of $n$ houses and $n-1$ road. From each house, you can get to the other by moving only along the roads. That is, the city is a tree. Vlad lives in a house with index $x$, and Nastya lives in a house with index $...
{"inputs": ["3\n\n3 1\n1 3\n2\n1 3\n1 2\n\n6 4\n3 5\n1 6 2 1\n1 3\n3 4\n3 5\n5 6\n5 2\n\n6 2\n3 2\n5 3\n1 3\n3 4\n3 5\n5 6\n5 2\n"], "outputs": ["3\n7\n2\n"]}
757
107
coding
Solve the programming task below in a Python markdown code block. In this kata, we will check is an array is (hyper)rectangular. A rectangular array is an N-dimensional array with fixed sized within one dimension. Its sizes can be repsented like A1xA2xA3...xAN. That means a N-dimensional array has N sizes. The 'As' a...
{"functional": "_inputs = [[[]]]\n_outputs = [[[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 isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_deep_e...
614
158
coding
Solve the programming task below in a Python markdown code block. The Story: Aliens from Kepler 27b have immigrated to Earth! They have learned English and go to our stores, eat our food, dress like us, ride Ubers, use Google, etc. However, they speak English a little differently. Can you write a program that converts ...
{"functional": "_inputs = [['codewars'], ['hello']]\n_outputs = [['cudewors'], ['hellu']]\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): ret...
160
165
coding
Solve the programming task below in a Python markdown code block. Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team ...
{"inputs": ["2 2 2 2 4 4\n", "5 5 1 5 5 5\n", "5 5 1 3 5 5\n", "3 3 1 3 9 9\n", "1 1 1 1 1 1\n", "5 5 0 5 5 5\n", "1 1 1 2 1 1\n", "5 5 0 3 5 5\n"], "outputs": ["2 2 \n", "1 1 1 1 1 \n", "1 1 1 1 1 \n", "3 3 3 \n", "1 \n", "1 1 1 1 1 \n", "1 \n", "1 1 1 1 1 \n"]}
416
196
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. A string is represented by an array if the array elements concatenated in order forms the string. ...
{"functional": "def check(candidate):\n assert candidate(word1 = [\"ab\", \"c\"], word2 = [\"a\", \"bc\"]) == True\n assert candidate(word1 = [\"a\", \"cb\"], word2 = [\"ab\", \"c\"]) == False\n assert candidate(word1 = [\"abc\", \"d\", \"defg\"], word2 = [\"abcddefg\"]) == True\n\n\ncheck(Solution().arrayStr...
100
109
coding
Solve the programming task below in a Python markdown code block. Chef has recently learned about number bases and is becoming fascinated. Chef learned that for bases greater than ten, new digit symbols need to be introduced, and that the convention is to use the first few letters of the English alphabet. For example, ...
{"inputs": ["4\n6\n9\n11\n24"], "outputs": ["4\n7\n8\n14"]}
501
29
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.   Please complete the following python code precisely: ```python class Solution: def minimumDeleteSum(self,...
{"functional": "def check(candidate):\n assert candidate(s1 = \"sea\", s2 = \"eat\") == 231\n assert candidate(s1 = \"delete\", s2 = \"leet\") == 403\n\n\ncheck(Solution().minimumDeleteSum)"}
78
62
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. This problem has no story, so we at least wish you good luck solving it. Consider a multiset $S$ which contains $A$ copies of the integer $1$, $B$ ...
{"inputs": ["5\n3 3 3\n3 2 3\n1 1 2\n1 0 1\n1 1 1"], "outputs": ["YES\nYES\nNO\nNO\nYES"]}
477
50
coding
Solve the programming task below in a Python markdown code block. Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day a...
{"inputs": ["1 1\n1\n", "1 1\n0\n", "1 1\n0\n", "1 1\n1\n", "2 1\n0\n", "4 1\n0100\n", "2 1\n0100\n", "8 1\n0100\n"], "outputs": ["0\n", "1\n", "1", "0", "1\n", "1\n", "1\n", "1\n"]}
431
109
coding
Solve the programming task below in a Python markdown code block. Bankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office. The crossroads are connected with m oriented bicycle lanes (the i-th lane goes fro...
{"inputs": ["1 1\n0\n", "0 2\n0\n", "4 3\n4\n2 1 2\n2 3 2\n3 4 2\n4 1 1\n", "4 3\n4\n2 0 2\n2 3 2\n3 4 1\n4 1 1\n", "4 3\n4\n2 1 2\n2 3 2\n3 4 4\n4 1 1\n", "4 3\n4\n2 0 2\n2 3 2\n3 4 2\n4 1 1\n", "7 4\n4\n1 6 2\n6 2 2\n3 4 2\n2 7 1\n", "4 5\n4\n2 1 2\n1 3 2\n3 4 2\n4 1 1\n"], "outputs": ["0\n", "-1\n", "4\n", "3\n", "6...
598
246
coding
Solve the programming task below in a Python markdown code block. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: - In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at m...
{"inputs": ["8", "2", "9", "3", "5", "6", "4", "7"], "outputs": ["8\n", "2\n", "9\n", "3\n", "5\n", "6\n", "4\n", "7\n"]}
259
62
coding
Solve the programming task below in a Python markdown code block. Write a function that returns the count of characters that have to be removed in order to get a string with no consecutive repeats. *Note:* This includes any characters ## Examples ```python 'abbbbc' => 'abc' # answer: 3 'abbcca' => 'abca' # ...
{"functional": "_inputs = [['abcdefg'], ['aabbccddeeffgg'], ['abcdeefee'], ['122453124'], ['@*$##^^^*)*'], ['abmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
132
390
coding
Solve the programming task below in a Python markdown code block. Note that the memory limit is unusual. You are given a multiset consisting of n integers. You have to process queries of two types: * add integer k into the multiset; * find the k-th order statistics in the multiset and remove it. k-th order s...
{"inputs": ["2 2\n1 2\n1 -1\n", "6 2\n1 1 1 2 3 4\n5 6\n", "6 2\n1 1 1 1 3 4\n5 6\n", "6 2\n1 1 1 2 3 4\n5 2\n", "6 2\n1 1 2 1 3 4\n5 6\n", "6 2\n1 1 2 2 3 4\n5 6\n", "6 2\n1 1 2 1 3 4\n5 5\n", "6 2\n1 1 2 1 3 4\n5 8\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
580
206
coding
Solve the programming task below in a Python markdown code block. N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." As...
{"inputs": ["3\n0 0 0", "6\n0 1 2 0 3 4", "6\n0 1 1 3 4 5", "6\n0 1 0 3 4 5", "6\n0 1 0 1 4 5", "6\n0 1 0 1 2 5", "6\n0 1 1 1 2 5", "6\n0 1 1 1 2 6"], "outputs": ["6", "6\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
411
151
coding
Solve the programming task below in a Python markdown code block. # Task Mr.Odd is my friend. Some of his common dialogues are “Am I looking odd?” , “It’s looking very odd” etc. Actually “odd” is his favorite word. In this valentine when he went to meet his girlfriend. But he forgot to take gift. Because of this he ...
{"functional": "_inputs = [['oudddbo'], ['ouddddbo'], ['ooudddbd'], ['qoddoldfoodgodnooofostorodrnvdmddddeidfoi']]\n_outputs = [[1], [1], [2], [6]]\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...
271
198
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a binary array nums, return the maximum number of consecutive 1's in the array.   Please complete the following python code precisely: ```python class Solution: def findMaxConsecutiveOnes(self, nums: List[in...
{"functional": "def check(candidate):\n assert candidate(nums = [1,1,0,1,1,1]) == 3\n assert candidate(nums = [1,0,1,1,0,1]) == 2\n\n\ncheck(Solution().findMaxConsecutiveOnes)"}
71
67
coding
Solve the programming task below in a Python markdown code block. A programming contest will be held at White Tiger University this year as well. There are several questions in the contest, each of which is assigned a score according to the difficulty level. The executive committee decided to calculate the score for e...
{"inputs": ["3\n1 0 100", "3\n2 0 100", "3\n1 1 100", "4\n11 15 58 1", "7\n2 0 4 2 2 0 0", "7\n2 1 4 2 2 0 0", "7\n2 1 4 2 4 0 0", "7\n2 1 2 2 4 0 0"], "outputs": ["1\n", "2\n", "1", "3", "2\n", "2\n", "2\n", "2\n"]}
281
151
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​ A string is said to be palindrome if it the same string when reversed.  ...
{"functional": "def check(candidate):\n assert candidate(s = \"abcbdd\") == True\n assert candidate(s = \"bcbddxy\") == False\n\n\ncheck(Solution().checkPartitioning)"}
99
47
coding
Solve the programming task below in a Python markdown code block. Casimir has a string $s$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions: he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the s...
{"inputs": ["6\nABACAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCBCBCBC\n", "6\nABACAB\nABBA\nAC\nABC\nCABCBB\nCBCBCBCBCBCBCBCB\n", "6\nABACAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCACBCBC\n", "6\nABACAB\nABBA\nBC\nABB\nCABCBB\nCBCBCBCBCBCBCBCB\n", "6\nABBCAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCACBCBC\n", "6\nABACAC\nABBA\nAC\nACB\nC...
489
342
coding
Solve the programming task below in a Python markdown code block. Given an array (or list or vector) of arrays (or, guess what, lists or vectors) of integers, your goal is to return the sum of a specific set of numbers, starting with elements whose position is equal to the main array length and going down by one at eac...
{"functional": "_inputs = [[[[3, 2, 1, 0], [4, 6, 5, 3, 2], [9, 8, 7, 4]]], [[[3], [4, 6, 5, 3, 2], [9, 8, 7, 4]]], [[[3, 2, 1, 0], [4, 6, 5, 3, 2], []]], [[[3, 2, 1, 0], [4, 6, 5, 3, 2], []], 5], [[[3, 2], [4], []]]]\n_outputs = [[16], [15], [7], [12], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstanc...
297
310
coding
Solve the programming task below in a Python markdown code block. Chef wants to teach a lesson of sharing to the students. There are $N$ students (numbered from $1$ to $N$ from left to right) who are asked to stand in a row. Initially Chef gave $A$$i$ candies to the $i$$th$ child. In one operation any child can give an...
{"inputs": ["2\n5\n1 2 3 4 5\n5\n5 4 3 2 1"], "outputs": ["3\n5"]}
559
38
coding
Solve the programming task below in a Python markdown code block. The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of the prisoners to a prison located in another city. For this reason, he made the n prisoners to stand in a line, with a numb...
{"inputs": ["1 1 1\n2\n", "1 0 1\n2\n", "1 1 1\n2\n", "1 -1 1\n2\n", "1 -2 1\n2\n", "1 228 1\n1\n", "1 228 1\n1\n", "1 230 1\n1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "1\n"]}
391
124
coding
Solve the programming task below in a Python markdown code block. Your friend has n cards. You know that each card has a lowercase English letter on one side and a digit on the other. Currently, your friend has laid out the cards on a table so only one side of each card is visible. You would like to know if the foll...
{"inputs": ["z\n", "1\n", "0\n", "a\n", "y\n", "w\n", "w\n", "0\n"], "outputs": ["0\n", "1\n", "0\n", "1\n", "0\n", "0\n", "0\n", "0\n"]}
506
70
coding
Solve the programming task below in a Python markdown code block. One day, Chef found a cube which has each of its sides painted in some color out of black, blue, red, green, yellow and orange. Now he asks you to check if he can choose three sides such that they are pairwise adjacent and painted in the same color. ---...
{"inputs": ["2\nblue yellow green orange black green\ngreen yellow green orange black green", "2\nblue yellow green orange black green\ngreen yellow green orange black green"], "outputs": ["NO\nYES", "NO\nYES\n"]}
328
53
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. An array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutations of nums that are squareful. Two permutations perm1 and perm2 are ...
{"functional": "def check(candidate):\n assert candidate([1,17,8]) == 2\n assert candidate([2,2,2]) == 1\n\n\ncheck(Solution().numSquarefulPerms)"}
114
51
coding
Solve the programming task below in a Python markdown code block. Tejas has invited the Clash Team for a Dinner Party. He places V empty plates (numbered from 1 to V inclusive) in a straight line on a table. He has prepared 2 kinds of Delicious Dishes named dish A and dish B. He has exactly V servings of Dish A and W ...
{"inputs": ["1\n3 3"], "outputs": ["4"]}
280
16
coding
Solve the programming task below in a Python markdown code block. Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? Constraints * 1 \leq a, b, c \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: a \ b \ c Output If \sqrt{a} + \sqrt{b} < \sqrt{c}, print `Yes...
{"inputs": ["2 1 9", "4 1 9", "4 0 9", "3 3 0", "1 0 9", "0 0 9", "2 5 0", "2 7 0"], "outputs": ["Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n"]}
138
94
coding
Solve the programming task below in a Python markdown code block. Kenkoooo found a simple connected graph. The vertices are numbered 1 through n. The i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i. Kenkoooo is trying to write a positive integer in each vertex so that the following condition is sati...
{"inputs": ["4 3\n1 2 6\n2 3 7\n3 4 7", "3 3\n1 2 3\n2 3 0\n1 3 4", "4 3\n1 2 6\n2 3 7\n3 4 3", "4 3\n1 2 4\n2 3 7\n3 4 7", "4 3\n1 2 6\n2 3 7\n3 4 6", "4 3\n1 2 4\n2 3 1\n3 4 7", "4 3\n1 2 6\n2 3 7\n3 4 2", "4 3\n1 2 2\n2 3 7\n3 4 7"], "outputs": ["5\n", "0\n", "1\n", "3\n", "4\n", "0\n", "0\n", "1\n"]}
419
222
coding
Solve the programming task below in a Python markdown code block. Do you have in mind the good old TicTacToe? Assuming that you get all the data in one array, you put a space around each value, `|` as a columns separator and multiple `-` as rows separator, with something like `["O", "X", " ", " ", "X", " ", "X", "O", ...
{"functional": "_inputs = [[['O', 'X', 'X', 'O'], 2], [['O', 'X', ' ', ' ', 'X', ' ', 'X', 'O', ' '], 3], [['O', 'X', ' ', ' ', 'X', ' ', 'X', 'O', ' ', 'O'], 5], [['O', 'X', ' ', ' ', 'X', ' ', 'X', 'O', ' ', 'O'], 2], [['1', '2', '3', '4', '5', '1', '2', '3', '4', '5', '1', '2', '3', '4', '5', '1', '2', '3', '4', '5'...
299
602
coding
Solve the programming task below in a Python markdown code block. Chef is stuck on the minute hand of a giant clock. To escape from this clock he needs to get onto the hour hand which has an exit door. Since the minute hand and and hour hand are not connected at any point, chef will surely need to make a jump. Since h...
{"inputs": ["3\n14:20\n02:10\n09:30"], "outputs": ["50 degree\n5 degree\n105 degree"]}
430
40
coding
Solve the programming task below in a Python markdown code block. Suppose you are given a string $s$ of length $n$ consisting of lowercase English letters. You need to compress it using the smallest possible number of coins. To compress the string, you have to represent $s$ as a concatenation of several non-empty stri...
{"inputs": ["3 3 1\naba\n", "3 3 0\naba\n", "3 3 1\naba\n", "4 1 1\nabcd\n", "4 1 2\nabcd\n", "4 2 3\nabdd\n", "4 1 3\nabcd\n", "4 1 3\nabdd\n"], "outputs": ["7\n", "6\n", "7\n", "4\n", "4\n", "8\n", "4\n", "4\n"]}
599
120
coding
Solve the programming task below in a Python markdown code block. At the legendary times of Nonsenso wars in ISM Dhanbad, there was a neck to neck competition between Barney Stinson and Sheldon Cooper. They both were on level 19. After trying too hard both of them could not decipher the nonsense, so they decided to pla...
{"inputs": ["2\n721011081081113287111114108100\n871011089911110910132116111327311010010597"], "outputs": ["Hello World\nWelcome to India"]}
258
91
coding
Solve the programming task below in a Python markdown code block. Given a string $s$. You can perform the following operation on given string any number of time. Delete two successive elements of the string if they are same. After performing the above operation you have to return the least possible length of the string...
{"inputs": ["3\nabccd\nabbac\naaaa"], "outputs": ["3\n1\n0"]}
230
24
coding
Solve the programming task below in a Python markdown code block. Chef wants to serve mankind by making people immortal by preparing a dish, a dish of life - a dish with the best taste in the universe, one with the smell and splash of fresh water flowing down the springs of the mountain, one with the smell of the best ...
{"inputs": ["3\n3 4\n3 1 2 3\n2 1 3\n2 1 2\n2 3\n3 1 2 3\n2 1 3\n2 3\n2 1 2\n2 1 3"], "outputs": ["sad\nsome\nall"]}
636
74
coding
Solve the programming task below in a Python markdown code block. Han Solo and Chewbacca start a space journey to planet Naboo on the Millennium Falcon. During the journey they land at a mysterious planet with high gravity where they find n diamond stones scattered all around. All the stones are of same weight. Each st...
{"inputs": ["7\n1 2 3 4 5 6 7"], "outputs": ["1 2 4 7\n3 5 6"]}
431
38
coding
Solve the programming task below in a Python markdown code block. When a contiguous block of text is selected in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example: There is a list of $26$ character heights aligned by index to thei...
{"inputs": ["1 3 1 3 1 4 1 3 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5\nabc\n", "1 3 1 3 1 4 1 3 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7\nzaba\n"], "outputs": ["9\n", "28\n"]}
676
128
coding
Solve the programming task below in a Python markdown code block. A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01"...
{"inputs": ["1\n0\n", "2\n1\n", "1\n1\n", "0\n1\n", "2\n0\n", "0\n0\n", "0\n00\n", "1\n00\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "0\n", "1\n", "3\n", "0\n"]}
376
88
coding
Solve the programming task below in a Python markdown code block. Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Example ...
{"inputs": ["1 2 3 4 5\n"], "outputs": ["10 14\n"]}
447
26
coding
Solve the programming task below in a Python markdown code block. Find the number of positive integral solutions for the equations $\dfrac{1}{x}+\dfrac{1}{y}=\dfrac{1}{N!}$ Input Format An integer N  Output Format The number of positive integral solutions for the above equation modulo 1000007 Constraints ...
{"inputs": ["1 \n", "32327\n", "40921\n"], "outputs": ["1\n", "656502 \n", "686720\n"]}
157
52
coding
Solve the programming task below in a Python markdown code block. Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert. On the day of the party, the Chef was over-seeing all the food arrange...
{"inputs": ["4\n6\n4\n1\n1", "4\n2\n8\n2\n3", "4\n40\n1\n1\n3", "4\n40\n1\n2\n3", "4\n40\n1\n1\n5", "4\n40\n2\n1\n5", "4\n2\n16\n2\n3", "4\n40\n4\n1\n4"], "outputs": ["1\n0\n0\n0\n", "1\n2\n1\n2\n", "3\n0\n0\n2\n", "3\n0\n1\n2\n", "3\n0\n0\n4\n", "3\n1\n0\n4\n", "1\n0\n1\n2\n", "3\n0\n0\n0\n"]}
641
180
coding
Solve the programming task below in a Python markdown code block. A positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two positive integers n and k, you should count the number of ways to express n as a sum of k different primes. Here, two ways are considered t...
{"inputs": ["6 3\n24 2\n2 1\n1 1\n4 2\n18 3\n17 1\n17 3\n9 4\n110 5\n1000 1\n980 3\n0 0", "24 6\n15 2\n2 2\n1 1\n6 2\n5 1\n17 2\n24 2\n5 4\n100 2\n1000 3\n680 4\n0 0", "34 3\n24 2\n2 1\n1 1\n4 2\n18 3\n17 1\n17 3\n9 4\n110 5\n1000 1\n980 3\n0 0", "34 6\n24 2\n2 2\n1 1\n4 2\n18 3\n17 1\n17 3\n5 4\n110 5\n1000 1\n715 3\n...
561
766
coding
Solve the programming task below in a Python markdown code block. Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from $1$, starting from the topmost one. The columns are numbered from $1$, starting from the leftmost one. Initially, the table hasn't been filled and Polyc...
{"inputs": ["1\n8\n", "1\n7\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n48\n", "1\n38\n", "1\n33\n"], "outputs": ["3 2\n", "3 3\n", "1 1\n", "1 2\n", "2 1\n", "7 2\n", "2 7\n", "6 4\n"]}
543
105
coding
Solve the programming task below in a Python markdown code block. Given is a three-digit integer N. Does N contain the digit 7? If so, print Yes; otherwise, print No. -----Constraints----- - 100 \leq N \leq 999 -----Input----- Input is given from Standard Input in the following format: N -----Output----- If N conta...
{"inputs": ["3", "6", "8", "9", "4", "1", "5", "2"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
120
62
coding
Solve the programming task below in a Python markdown code block. Reducing Problems - Bug Fixing #8 Oh no! Timmy's reduce is causing problems, Timmy's goal is to calculate the two teams scores and return the winner but timmy has gotten confused and sometimes teams don't enter their scores, total the scores out of 3! H...
{"functional": "_inputs = [[[1, 2, 2], [1, 0, 0]], [[6, 45, 1], [1, 55, 0]], [[57, 2, 1], []], [[], [3, 4, 3]], [[], []]]\n_outputs = [[True], [False], [True], [False], [False]]\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=t...
119
229
coding
Solve the programming task below in a Python markdown code block. The snail crawls up the column. During the day it crawls up some distance. During the night she sleeps, so she slides down for some distance (less than crawls up during the day). Your function takes three arguments: 1. The height of the column (meters) ...
{"functional": "_inputs = [[3, 2, 1], [10, 3, 1], [10, 3, 2], [100, 20, 5], [5, 10, 3]]\n_outputs = [[2], [5], [8], [7], [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)...
147
214
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer n, your task is to count how many strings of length n can be formed under the following rules: Each character is a lower case vowel ('a', 'e', 'i', 'o', 'u') Each vowel 'a' may only be followed by an...
{"functional": "def check(candidate):\n assert candidate(n = 1) == 5\n assert candidate(n = 2) == 10\n assert candidate(n = 5) == 68\n\n\ncheck(Solution().countVowelPermutation)"}
200
60
coding
Solve the programming task below in a Python markdown code block. In the city of Saint Petersburg, a day lasts for $2^{100}$ minutes. From the main station of Saint Petersburg, a train departs after $1$ minute, $4$ minutes, $16$ minutes, and so on; in other words, the train departs at time $4^k$ for each integer $k \ge...
{"inputs": ["0\n", "1\n", "1\n", "0\n", "11\n", "11\n", "101\n", "110\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "2\n", "2\n"]}
385
76
coding
Solve the programming task below in a Python markdown code block. Two players are playing a game. The game is played on a sequence of positive integer pairs. The players make their moves alternatively. During his move the player chooses a pair and decreases the larger integer in the pair by a positive multiple of the s...
{"inputs": ["3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n3 5", "3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n1 5", "3\n1\n2 3\n2\n4 5\n5 6\n1\n2 3\n3 5", "3\n1\n1 3\n2\n6 5\n5 6\n1\n2 6\n5 5", "3\n1\n2 3\n2\n4 5\n5 3\n1\n2 3\n3 5", "3\n1\n2 3\n2\n6 2\n5 6\n1\n2 6\n3 5", "3\n1\n2 1\n2\n6 5\n5 6\n1\n2 3\n1 5", "3\n1\n2 1\n2\n6 5\n5 3\n1\n2 3\n1 ...
513
301
coding
Solve the programming task below in a Python markdown code block. Polycarp is going to participate in the contest. It starts at $h_1:m_1$ and ends at $h_2:m_2$. It is guaranteed that the contest lasts an even number of minutes (i.e. $m_1 \% 2 = m_2 \% 2$, where $x \% y$ is $x$ modulo $y$). It is also guaranteed that th...
{"inputs": ["10:00\n11:00\n", "11:10\n11:12\n", "01:02\n03:02\n", "00:00\n23:58\n", "00:01\n23:59\n", "00:00\n00:02\n", "23:57\n23:59\n", "11:40\n12:22\n"], "outputs": ["10:30\n", "11:11\n", "02:02\n", "11:59\n", "12:00\n", "00:01\n", "23:58\n", "12:01\n"]}
521
182
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 representing the contents of a pile, where nums[0] is the topmost element of the pile. In one move, you can perform either of the following: If the pile is not empty, remo...
{"functional": "def check(candidate):\n assert candidate(nums = [5,2,2,4,0,6], k = 4) == 5\n assert candidate(nums = [2], k = 1) == -1\n\n\ncheck(Solution().maximumTop)"}
197
63
coding
Solve the programming task below in a Python markdown code block. X and A are integers between 0 and 9 (inclusive). If X is less than A, print 0; if X is not less than A, print 10. -----Constraints----- - 0 \leq X, A \leq 9 - All values in input are integers. -----Input----- Input is given from Standard Input in th...
{"inputs": ["0 6", "7 0", "3 0", "0 8", "0 0", "0 3", "9 0", "6 0"], "outputs": ["0\n", "10\n", "10\n", "0\n", "10\n", "0\n", "10\n", "10\n"]}
149
83
coding
Solve the programming task below in a Python markdown code block. Your task it to return ```true``` if the fractional part (rounded to 1 digit) of the result (```a``` / ```b```) exists, more than ```0``` and is multiple of ```n```. Otherwise return ```false```. (For Python return True or False) All arguments are posit...
{"functional": "_inputs = [[5, 2, 3], [5, 3, 4], [5, 4, 3], [666, 665, 2], [3691401, 1892272, 5]]\n_outputs = [[False], [False], [True], [False], [False]]\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 i...
244
224
coding
Solve the programming task below in a Python markdown code block. You have decided to give an allowance to your child depending on the outcome of the game that he will play now. The game is played as follows: - There are three "integer panels", each with a digit between 1 and 9 (inclusive) printed on it, and one "oper...
{"inputs": ["9 9 8", "1 8 2", "6 6 5", "0 9 8", "1 1 2", "6 7 5", "1 2 2", "6 9 5"], "outputs": ["107\n", "83\n", "71\n", "98\n", "22\n", "81\n", "23\n", "101\n"]}
271
104
coding
Solve the programming task below in a Python markdown code block. A fraction whose numerator is 1 and whose denominator is a positive integer is called a unit fraction. A representation of a positive rational number p/q as the sum of finitely many unit fractions is called a partition of p/q into unit fractions. For exa...
{"inputs": ["2 6 120 5\n2 3 300 3\n3 3 299 3\n2 3 7 2\n2 0 12000 7\n54 795 22620 7\n2 4 300 1\n2 1 8 5\n2 4 54 2\n0 0 0 0", "2 6 120 5\n2 3 300 3\n3 3 299 3\n2 3 7 2\n2 0 12000 7\n54 781 35092 7\n2 4 300 1\n2 1 8 5\n2 4 54 2\n0 0 0 0", "2 6 120 8\n2 3 300 3\n3 3 299 3\n3 3 7 2\n2 0 12000 7\n54 781 35092 7\n2 4 300 1\n2...
595
975
coding
Solve the programming task below in a Python markdown code block. You are playing euchre and you want to know the new score after finishing a hand. There are two teams and each hand consists of 5 tricks. The team who wins the majority of the tricks will win points but the number of points varies. To determine the numbe...
{"functional": "_inputs = [[[4, 0], 1, False, [2, 2, 2, 2, 2]], [[4, 2], 1, True, [2, 2, 2, 2, 2]], [[4, 4], 2, False, [2, 2, 2, 2, 2]], [[4, 6], 2, True, [2, 2, 2, 2, 2]], [[7, 2], 1, False, [1, 2, 2, 2, 2]], [[7, 4], 1, True, [1, 2, 2, 2, 2]], [[7, 6], 2, False, [1, 2, 2, 2, 2]], [[7, 7], 2, True, [1, 2, 2, 2, 2]], [...
278
918
coding
Solve the programming task below in a Python markdown code block. A binary string is a string consisting only of the characters 0 and 1. You are given a binary string $s_1 s_2 \ldots s_n$. It is necessary to make this string non-decreasing in the least number of operations. In other words, each character should be not ...
{"inputs": ["8\n1\n1\n2\n10\n3\n101\n4\n1100\n5\n11001\n6\n100010\n10\n0000110000\n7\n0101010\n"], "outputs": ["0\n1\n2\n1\n2\n3\n1\n5\n"]}
624
91
coding
Solve the programming task below in a Python markdown code block. Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job. During all his career Hideo has produced n games. Some of them were successful, so...
{"inputs": ["1\n0\n", "1\n1\n", "1\n1\n", "1\n0\n", "2\n0 1\n", "2\n0 1\n", "2\n0 0\n", "3\n1 0 0\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "2\n", "2\n"]}
384
96
coding
Solve the programming task below in a Python markdown code block. A company conducted a coding test to hire candidates. $N$ candidates appeared for the test, and each of them faced $M$ problems. Each problem was either unsolved by a candidate (denoted by 'U'), solved partially (denoted by 'P'), or solved completely (de...
{"inputs": ["3\n4 5\n3 2\nFUFFP\nPFPFU\nUPFFU\nPPPFP\n3 4\n1 3\nPUPP\nUUUU\nUFUU\n1 3\n2 2\nPPP"], "outputs": ["1100\n101\n0"]}
677
72
coding
Solve the programming task below in a Python markdown code block. Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants! Vlad built up his own pl...
{"inputs": ["3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n2", "3\n4\n1 3 7 2\n1\n5\n1 2 0 9 4\n5\n5\n1 2 3 9 4 \n2", "3\n4\n1 3 4 2\n1\n5\n1 2 0 2 4\n5\n5\n1 2 3 9 4 \n2", "3\n4\n1 3 4 2\n2\n5\n1 2 3 9 8\n5\n5\n1 2 3 9 4 \n1", "3\n4\n1 3 4 2\n1\n5\n1 2 0 9 4\n5\n5\n1 2 3 1 4 \n2", "3\n4\n1 3 4 2\n0\n5\n1 2 3 9 4\n...
761
422
coding
Solve the programming task below in a Python markdown code block. In mathematics, a matrix (plural matrices) is a rectangular array of numbers. Matrices have many applications in programming, from performing transformations in 2D space to machine learning. One of the most useful operations to perform on matrices is m...
{"functional": "_inputs = [[[[2, -2], [5, 3]], [[-1, 4], [7, -6]]], [[[1]], [[3]]], [[[1, 2], [3, 4]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]]], [[[7, 3], [2, 5], [6, 8], [9, 0]], [[7, 4, 9], [8, 1, 5]]], [[[1, 0.5], [-0.5, 1]], [[5, 0.25], [2, 0.5]]]]\n_outputs = [[[[-16, 20], [16, 2]]], [[[3]]], [-1], [[[73, 31, 78], [54, ...
405
397
coding
Solve the programming task below in a Python markdown code block. You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal...
{"inputs": ["1 4\n1", "1 2\n0", "1 6\n1", "1 2\n1", "3 5\n7\n5\n7", "3 6\n7\n5\n7", "3 6\n7\n5\n10", "3 6\n7\n5\n12"], "outputs": ["0\n", "0\n", "0\n", "0", "6\n", "5", "5\n", "5\n"]}
265
110
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese . Given an array of n non-negative integers: A_{1}, A_{2}, …, A_{N}. Your mission is finding a pair of integers A_{u}, A_{v} (1 ≤ u < v ≤ N) such that (A_{u} and A_{v}) is as large as possible. And is a bit...
{"inputs": ["4\n2\n4\n0\n8", "4\n2\n4\n2\n7", "4\n1\n8\n7\n5", "4\n2\n3\n3\n7", "4\n7\n7\n3\n1", "4\n2\n4\n2\n8", "4\n2\n4\n0\n3", "4\n2\n4\n0\n0"], "outputs": ["0\n", "4\n", "5\n", "3\n", "7\n", "2\n", "2\n", "0\n"]}
321
126