task_type
stringclasses
4 values
problem
stringlengths
14
5.23k
solution
stringlengths
1
8.29k
problem_tokens
int64
9
1.02k
solution_tokens
int64
1
1.98k
coding
Solve the programming task below in a Python markdown code block. Introduction to Disjunctions In logic and mathematics, a disjunction is an operation on 2 or more propositions. A disjunction is true if and only if 1 or more of its operands is true. In programming, we typically denote a disjunction using "||", but in...
{"functional": "_inputs = [[[False, True, True], False], [[False, True, False], False], [[False, True, True, True], True], [[True, True, True], False], [[True, True, True, True], False]]\n_outputs = [[True], [True], [True], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isin...
403
212
coding
Solve the programming task below in a Python markdown code block. Round any given number to the closest 0.5 step I.E. ``` solution(4.2) = 4 solution(4.3) = 4.5 solution(4.6) = 4.5 solution(4.8) = 5 ``` Round **up** if number is as close to previous and next 0.5 steps. ``` solution(4.75) == 5 ``` Also feel free to re...
{"functional": "_inputs = [[4.2], [4.25], [4.4], [4.6], [4.75], [4.8], [4.5], [4.55], [4.74], [4.74999999999], [4.74999999991]]\n_outputs = [[4], [4.5], [4.5], [4.5], [5], [5], [4.5], [4.5], [4.5], [4.5], [4.5]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n r...
131
275
coding
Solve the programming task below in a Python markdown code block. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya recently learned to determin...
{"inputs": ["1\n", "2\n", "7\n", "8\n", "6\n", "9\n", "4\n", "3\n"], "outputs": ["a", "ab", "abcdabc", "abcdabcd", "abcdab", "abcdabcda", "abcd", "abc"]}
492
67
coding
Solve the programming task below in a Python markdown code block. You can perform the following operations on the string, $a$: Capitalize zero or more of $a$'s lowercase letters. Delete all of the remaining lowercase letters in $a$. Given two strings, $a$ and $\boldsymbol{b}$, determine if it's possible to make $a$...
{"inputs": ["1\ndaBcd\nABC\n"], "outputs": ["YES\n"]}
551
20
coding
Solve the programming task below in a Python markdown code block. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. The player chooses a square as a starting point and places h...
{"inputs": ["3\n2 1 1", "3\n1 1 3", "3\n1 2 3", "3\n2 1 0", "3\n1 1 0", "3\n1 2 1", "3\n2 2 1", "3\n1 2 0"], "outputs": ["2\n", "1\n", "3\n", "1\n", "1\n", "2\n", "2\n", "3\n"]}
342
110
coding
Solve the programming task below in a Python markdown code block. You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. -----Constraints----- - 2 ≤ |S| ≤ 26, where |S| denotes the length of S. - S consists of lowercase English letters. -----Input-...
{"inputs": ["np", "mp", "pm", "pl", "ol", "lo", "nl", "ml"], "outputs": ["yes\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n"]}
120
62
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to x than an integer b if: |a - x| ...
{"functional": "def check(candidate):\n assert candidate(arr = [1,2,3,4,5], k = 4, x = 3) == [1,2,3,4]\n assert candidate(arr = [1,2,3,4,5], k = 4, x = -1) == [1,2,3,4]\n\n\ncheck(Solution().findClosestElements)"}
136
95
coding
Solve the programming task below in a Python markdown code block. Write the following function: ```python def area_of_polygon_inside_circle(circle_radius, number_of_sides): ``` It should calculate the area of a regular polygon of `numberOfSides`, `number-of-sides`, or `number_of_sides` sides inside a circle of radius...
{"functional": "_inputs = [[3, 3], [2, 4], [2.5, 5]]\n_outputs = [[11.691], [8], [14.86]]\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...
239
189
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes. If there is not any such r...
{"functional": "def check(candidate):\n assert candidate([[1,1],[1,3],[3,1],[3,3],[2,2]]) == 4\n assert candidate([[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]) == 2\n\n\ncheck(Solution().minAreaRect)"}
107
80
coding
Solve the programming task below in a Python markdown code block. There are N cats. We number them from 1 through N. Each of the cats wears a hat. Cat i says: "there are exactly a_i different colors among the N - 1 hats worn by the cats except me." Determine whether there exists a sequence of colors of the hats that ...
{"inputs": ["3\n1 1 3", "3\n0 2 2", "3\n4 2 2", "3\n1 0 3", "3\n0 2 4", "3\n4 0 2", "3\n0 2 8", "3\n0 0 2"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
260
110
coding
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"]}
759
144
coding
Solve the programming task below in a Python markdown code block. Chef has $K$ chocolates and he wants to distribute them to $N$ people (numbered $1$ through $N$). These people are standing in a line in such a way that for each $i$ ($1 \le i \le N-1$), person $i$ and person $i+1$ are adjacent. First, consider some way ...
{"inputs": ["1\n3\n2"], "outputs": ["2"]}
754
16
coding
Solve the programming task below in a Python markdown code block. Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and...
{"inputs": ["1\n1\nk\n", "1\n1\nk\n", "1\n1\nj\n", "1\n1\ni\n", "1\n1\nh\n", "1\n3\nraq\n", "1\n3\nraq\n", "1\n3\nbab\n"], "outputs": ["k\n1\n", "k\n1\n", "j\n1\n", "i\n1\n", "h\n1\n", "aqr\n2\n", "aqr\n2\n", "abb\n2\n"]}
748
120
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are playing a game with integers. You start with the integer 1 and you want to reach the integer target. In one move, you can either: Increment the current integer by one (i.e., x = x + 1). Double the current int...
{"functional": "def check(candidate):\n assert candidate(target = 5, maxDoubles = 0) == 4\n assert candidate(target = 19, maxDoubles = 2) == 7\n assert candidate(target = 10, maxDoubles = 4) == 4\n\n\ncheck(Solution().minMoves)"}
169
78
coding
Solve the programming task below in a Python markdown code block. # Convert number to reversed array of digits Given a random non-negative number, you have to return the digits of this number within an array in reverse order. ## Example: ``` 348597 => [7,9,5,8,4,3] ``` Also feel free to reuse/extend the following st...
{"functional": "_inputs = [[35231], [23582357], [984764738], [45762893920], [548702838394]]\n_outputs = [[[1, 3, 2, 5, 3]], [[7, 5, 3, 2, 8, 5, 3, 2]], [[8, 3, 7, 4, 6, 7, 4, 8, 9]], [[0, 2, 9, 3, 9, 8, 2, 6, 7, 5, 4]], [[4, 9, 3, 8, 3, 8, 2, 0, 7, 8, 4, 5]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstan...
93
339
coding
Solve the programming task below in a Python markdown code block. The only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version. Errichto gave Monogon the following challenge in order to intimidate him from taking his top contributor spot on Codeforces. ...
{"inputs": ["1\n6\nXXXXXX\nXXXXXX\nXX..XX\nXX..XX\nXXXXXX\nXXXXXX\n", "3\n3\n.O.\nOOO\n.O.\n6\nXXXOOO\nXXXOOO\nXX..OO\nOO..XX\nOOOXXX\nOOOXXX\n5\n.OOO.\nOXXXO\nOXXXO\nOXXXO\n.OOO.\n", "3\n3\n.X.\nXXX\n.X.\n6\nXX.XXX\nXXXXXX\nXXX.XX\nXXXXXX\nXX.X.X\nXXXXXX\n5\nXXX.X\n.X..X\nXXX.X\n..X..\n..X..\n"], "outputs": ["XXOXXO\n...
682
304
coding
Solve the programming task below in a Python markdown code block. As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2^{n} members and coincidentally Natalia Fan Club also has 2^{n} members. Each member of MDC is a...
{"inputs": ["1\n", "0\n", "0\n", "1\n", "11\n", "01\n", "10\n", "01\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "6\n", "2\n", "4\n", "2\n"]}
402
74
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given the head of a linked list, return the list after sorting it in ascending order.   Please complete the following python code precisely: ```python # Definition for singly-linked list. # class ListNode: # def _...
{"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([4,2,1,3])), list_node([1,2,3,4]))\n assert is_same_list(candidate(head = list_node([-1,5,3,4,0])), list_node([-1,0,3,4,5]))\n assert is_same_list(candidate(head = list_node([])), list_node([]))\n\n\ncheck(Solution().sortLis...
109
105
coding
Solve the programming task below in a Python markdown code block. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ....
{"inputs": ["2 2\n", "9 3\n", "1 2\n", "2 3\n", "4 4\n", "4 4\n", "1 2\n", "4 4\n"], "outputs": ["3\n", "13\n", "1\n", "2\n", "5\n", "5\n", "1\n", "5\n"]}
308
87
coding
Solve the programming task below in a Python markdown code block. One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of doll...
{"inputs": ["2 4\n6 7\n", "2 2\n6 7\n", "2 4\n3 7\n", "1 1472\n77\n", "1 1653\n77\n", "1 3232\n22\n", "1 2592\n31\n", "1 1653\n11\n"], "outputs": ["4\n", "2\n", "8\n", "1472\n", "1653\n", "3232\n", "2592\n", "1653\n"]}
267
143
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type. A valid IPv4 address is an IP in the form "x1.x2.x3.x4" whe...
{"functional": "def check(candidate):\n assert candidate(queryIP = \"172.16.254.1\") == \"IPv4\"\n assert candidate(queryIP = \"2001:0db8:85a3:0:0:8A2E:0370:7334\") == \"IPv6\"\n assert candidate(queryIP = \"256.256.256.256\") == \"Neither\"\n\n\ncheck(Solution().validIPAddress)"}
457
119
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes). The survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers ...
{"functional": "def check(candidate):\n assert candidate(students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]]) == 8\n assert candidate(students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]]) == 0\n\n\ncheck(Solution().maxCompatibilitySum)"}
320
108
coding
Solve the programming task below in a Python markdown code block. Chef defines a group of three friends as a *perfect* group if the age of one person is equal to the sum of the age of remaining two people. Given that, the ages of three people in a group are A, B, and C respectively, find whether the group is *perfect...
{"inputs": ["4\n10 20 30\n23 51 17\n44 21 23\n30 30 30\n"], "outputs": ["YES\nNO\nYES\nNO\n"]}
424
56
coding
Solve the programming task below in a Python markdown code block. HQ9+ is a joke programming language which has only four one-character instructions: * "H" prints "Hello, World!", * "Q" prints the source code of the program itself, * "9" prints the lyrics of "99 Bottles of Beer" song, * "+" increments the val...
{"inputs": ["Q\n", "~\n", "8\n", "H\n", "!\n", "9\n", "3\n", "+\n"], "outputs": ["YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "NO\n"]}
280
70
coding
Solve the programming task below in a Python markdown code block. You are given an array A of length N. Find the maximum length of any subarray of A, such that, the [bitwise OR] of all the elements of the subarray is equal to the [bitwise OR] of the remaining elements of the array. Report -1 if no such subarray exis...
{"inputs": ["3\n3\n1 2 4\n3\n1 3 2\n4\n2 3 4 7\n"], "outputs": ["-1\n1\n3\n"]}
597
45
coding
Solve the programming task below in a Python markdown code block. You are given an array $a$ of $n$ ($n \geq 2$) positive integers and an integer $p$. Consider an undirected weighted graph of $n$ vertices numbered from $1$ to $n$ for which the edges between the vertices $i$ and $j$ ($i<j$) are added in the following ma...
{"inputs": ["1\n2 1000000000\n1000000000 1000000000\n", "1\n2 1000000000\n1000000000 1000000000\n", "1\n2 1100000000\n1000000000 1000000000\n", "1\n2 1100000000\n1000000000 1100000000\n", "1\n2 1100000001\n1000000011 1001000000\n", "1\n2 1100000011\n1000000011 1001000000\n", "1\n2 1100100011\n1000000111 1001000000\n", ...
613
422
coding
Solve the programming task below in a Python markdown code block. G: Working Kou decided to do the same number of jobs every day for the next $ N $. $ A_i $ jobs are added on the $ i $ day of the $ N $ day. Mr. Kou has no work to do now, and he doesn't have to finish all the work by the $ N $ day. How many jobs can...
{"inputs": ["5\n4 2 5 3 0", "5\n4 2 3 3 0", "5\n6 2 3 3 0", "5\n6 3 0 3 0", "5\n6 3 0 2 0", "5\n8 3 0 2 0", "5\n9 3 0 2 0", "5\n9 3 0 4 0"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "3\n"]}
339
142
coding
Solve the programming task below in a Python markdown code block. This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2. Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly $\frac{n}{k}$ time...
{"inputs": ["1 1\n2\n", "1 1\n2\n", "1 1\n1\n", "2 1\n1 1\n", "2 2\n2 2\n", "2 1\n1 2\n", "2 2\n2 1\n", "2 2\n2 2\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "1\n", "0\n", "0"]}
575
110
coding
Solve the programming task below in a Python markdown code block. Henry and Derek are waiting on a room, eager to join the Snackdown 2016 Qualifier Round. They decide to pass the time by playing a game. In this game's setup, they write N positive integers on a blackboard. Then the players take turns, starting with He...
{"inputs": ["2\n2\n3 4\n3\n1 3 5"], "outputs": ["Henry\nDerek"]}
682
29
coding
Solve the programming task below in a Python markdown code block. The four bases found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T). In genetics, GC-content is the percentage of Guanine (G) and Cytosine (C) bases on a DNA molecule that are either guanine or cytosine. Given a DNA sequence (a stri...
{"functional": "_inputs = [[''], ['A'], ['C'], ['CA']]\n_outputs = [[0.0], [0.0], [100.0], [50.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) != le...
218
182
coding
Solve the programming task below in a Python markdown code block. You are given two binary strings A and B, each of length N. You can perform the following operation on string A any number of times: Select a [prime number] X. Choose any substring of string A having length X and reverse the substring. Determine whether...
{"inputs": ["4\n2\n00\n00\n4\n1001\n0111\n5\n11000\n10010\n5\n11000\n11010\n"], "outputs": ["YES\nNO\nYES\nNO\n"]}
533
68
coding
Solve the programming task below in a Python markdown code block. You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`. Constraints * 1 \leq K \leq 5 * All values in input are integers. Input Input is given from...
{"inputs": ["4", "6", "5", "8", "7", "9", "2", "1"], "outputs": ["ACLACLACLACL\n", "ACLACLACLACLACLACL\n", "ACLACLACLACLACL\n", "ACLACLACLACLACLACLACLACL\n", "ACLACLACLACLACLACLACL\n", "ACLACLACLACLACLACLACLACLACL\n", "ACLACL\n", "ACL\n"]}
122
96
coding
Solve the programming task below in a Python markdown code block. ### Tongues Gandalf's writings have long been available for study, but no one has yet figured out what language they are written in. Recently, due to programming work by a hacker known only by the code name ROT13, it has been discovered that Gandalf use...
{"functional": "_inputs = [['Ita dotf ni dyca nsaw ecc.'], ['Tim oh nsa nowa gid ecc fiir wat ni liwa ni nsa eor ig nsaod liytndu.'], ['Giydhlida etr hakat uaedh efi iyd gidagensadh pdiyfsn ytni nsoh'], ['litnotatn e tam tenoit.'], ['Nsa zyolv pdimt gij xywbar ikad nsa cequ rifh.'], ['Tywpadh (1234567890) etr bytlnyeno...
402
1,010
coding
Solve the programming task below in a Python markdown code block. Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q_1q_2... q_{k}. The algorithm consists of two steps: Find any continuous...
{"inputs": ["x\n1\n1 1\n", "x\n1\n1 1\n", "x\n1\n1 0\n", "zyxxxxxxyyz\n5\n5 5\n1 3\n1 6\n1 4\n3 6\n", "zyxxxxxxyyz\n5\n5 5\n1 3\n1 11\n1 4\n3 6\n", "zyxxxxxxyyz\n5\n5 5\n1 3\n1 11\n1 4\n3 1\n", "zyxxxxxxyyz\n5\n2 5\n1 3\n1 11\n1 4\n3 1\n", "zyxxxxxxyyz\n5\n5 5\n1 3\n1 11\n1 4\n3 2\n"], "outputs": ["YES\n", "YES\n", "YE...
576
262
coding
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...
520
572
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Write a recursive function to multiply two positive integers without using the * operator. You can use addition, subtraction, and bit shifting, but you should minimize the number of those operations. Please complete t...
{"functional": "def check(candidate):\n assert candidate(A = 1, B = 10) == 10\n assert candidate(A = 3, B = 4) == 12\n\n\ncheck(Solution().multiply)"}
85
55
coding
Solve the programming task below in a Python markdown code block. N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals. The preliminary stage consists of several rounds, which will take place as follows:...
{"inputs": ["2\n1 2\n9 0", "2\n2 3\n9 0", "2\n1 2\n9 1", "2\n2 2\n9 0", "2\n2 6\n9 0", "2\n2 6\n8 0", "2\n2 6\n8 1", "2\n2 6\n8 2"], "outputs": ["1\n", "2\n", "3\n", "1\n", "6\n", "6\n", "8\n", "10\n"]}
570
127
coding
Solve the programming task below in a Python markdown code block. Read problems statements in mandarin chinese, russian and vietnamese as well. Fehc is Chef's best friend. They grew up with each other, and often help each other with competitive programming. Chef is participating in a programming contest prepared b...
{"inputs": ["3\n7 2\n5 1\n6 1\n7 3\n2 1\n4 2\n6 1\n10 0"], "outputs": ["9\n12\n30"]}
671
51
coding
Solve the programming task below in a Python markdown code block. For a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$. * insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation. * find($x$): Report ...
{"inputs": ["10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n0 4\n3 1 4", "10\n0 1\n0 1\n0 2\n0 0\n2 2\n1 1\n1 2\n1 3\n0 4\n3 1 4", "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n1 4\n3 1 4", "10\n0 1\n0 1\n0 2\n0 5\n2 2\n1 1\n1 1\n1 3\n1 4\n3 1 4", "10\n0 1\n0 1\n0 2\n0 0\n2 2\n1 1\n1 1\n1 3\n1 4\n0 1 1", "10\n0 0\n0 1\n0 2...
448
550
coding
Solve the programming task below in a Python markdown code block. # Task Vanya gets bored one day and decides to enumerate a large pile of rocks. He first counts the rocks and finds out that he has `n` rocks in the pile, then he goes to the store to buy labels for enumeration. Each of the labels is a digit from 0 ...
{"functional": "_inputs = [[1], [10], [13], [100], [36123011]]\n_outputs = [[1], [11], [17], [192], [277872985]]\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 i...
319
201
coding
Solve the programming task below in a Python markdown code block. Mr. Suzuki has opened a new mobile sales shop for freshly squeezed milk in the Aizu area. It is assumed that all the customers who come to buy that day are already in the store with bottles to take home and will not increase any more. Customers only orde...
{"inputs": ["5\n2\n6\n4\n6\n9\n0", "5\n2\n6\n4\n7\n9\n0", "5\n1\n2\n6\n9\n0\n0", "5\n1\n2\n6\n9\n1\n0", "5\n1\n2\n6\n1\n1\n0", "5\n1\n2\n6\n1\n3\n0", "5\n1\n2\n4\n2\n4\n0", "5\n2\n2\n4\n2\n4\n0"], "outputs": ["38\n", "39\n", "13\n", "17\n", "11\n", "14\n", "18\n", "22\n"]}
610
166
coding
Solve the programming task below in a Python markdown code block. Convert a hash into an array. Nothing more, Nothing less. ``` {name: 'Jeremy', age: 24, role: 'Software Engineer'} ``` should be converted into ``` [["name", "Jeremy"], ["age", 24], ["role", "Software Engineer"]] ``` ```if:python,javascript,crystal **...
{"functional": "_inputs = [[{'name': 'Jeremy'}], [{'name': 'Jeremy', 'age': 24}], [{'name': 'Jeremy', 'age': 24, 'role': 'Software Engineer'}], [{'product': 'CodeWars', 'power_level_over': 9000}], [{}]]\n_outputs = [[[['name', 'Jeremy']]], [[['age', 24], ['name', 'Jeremy']]], [[['age', 24], ['name', 'Jeremy'], ['role',...
127
280
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
Please solve the programming task below using a self-contained code snippet in a markdown code block. A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself). Given a string s, return the longest happy prefix of s. Return an empty string "" if no such prefix exists.   Pleas...
{"functional": "def check(candidate):\n assert candidate(s = \"level\") == \"l\"\n assert candidate(s = \"ababab\") == \"abab\"\n\n\ncheck(Solution().longestPrefix)"}
93
49
coding
Solve the programming task below in a Python markdown code block. You have an array $a$ of length $n$. You can exactly once select an integer $len$ between $1$ and $n - 1$ inclusively, and then sort in non-decreasing order the prefix of the array of length $len$ and the suffix of the array of length $n - len$ independe...
{"inputs": ["1\n4\n1 3 2 4\n", "1\n7\n1 2 3 5 4 6 7\n", "3\n3\n2 2 1\n4\n3 1 2 1\n5\n1 2 2 4 4\n"], "outputs": ["YES\n", "YES\n", "YES\nYES\nNO\n"]}
552
90
coding
Solve the programming task below in a Python markdown code block. Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm. ........# ........# ........# ........# Constraints * 3 ≤ H ≤ 300 * 3 ≤ W ≤ 300 Input T...
{"inputs": ["3 4\n5 7\n3 3\n0 0", "3 6\n5 6\n3 3\n0 0", "3 4\n5 0\n3 3\n0 0", "3 4\n5 3\n3 3\n0 0", "3 4\n8 0\n3 3\n0 0", "5 4\n8 0\n3 3\n0 0", "5 4\n8 0\n3 6\n0 0", "3 4\n5 6\n5 3\n0 0"], "outputs": ["####\n#..#\n####\n\n#######\n#.....#\n#.....#\n#.....#\n#######\n\n###\n#.#\n###\n\n", "######\n#....#\n######\n\n####...
196
509
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words. Two strings s1 and s2 are said to be connected if the s...
{"functional": "def check(candidate):\n assert candidate(words = [\"a\",\"b\",\"ab\",\"cde\"]) == [2,3]\n assert candidate(words = [\"a\",\"ab\",\"abc\"]) == [1,3]\n\n\ncheck(Solution().groupStrings)"}
308
64
coding
Solve the programming task below in a Python markdown code block. Welcome young Jedi! In this Kata you must create a function that takes an amount of US currency in `cents`, and returns a dictionary/hash which shows the least amount of coins used to make up that amount. The only coin denominations considered in this ex...
{"functional": "_inputs = [[56], [0], [100], [-3], [7.9]]\n_outputs = [[{'Nickels': 1, 'Pennies': 1, 'Dimes': 0, 'Quarters': 2}], [{'Nickels': 0, 'Pennies': 0, 'Dimes': 0, 'Quarters': 0}], [{'Nickels': 0, 'Pennies': 0, 'Dimes': 0, 'Quarters': 4}], [{'Nickels': 0, 'Pennies': 0, 'Dimes': 0, 'Quarters': 0}], [{'Nickels': ...
315
311
coding
Solve the programming task below in a Python markdown code block. # Fourier transformations are hard. Fouriest transformations are harder. This Kata is based on the SMBC Comic on fourier transformations. A fourier transformation on a number is one that converts the number to a base in which it has more `4`s ( `10` in...
{"functional": "_inputs = [[30], [15], [9999], [35353], [100], [1000000243], [142042158218941532125212890], [2679388715912901287113185885289513476], [640614569414659959863091616350016384446719891887887380], [2579111107964987025047536361483312385374008248282655401675211033926782006920415224913494809688581314878892733564...
442
967
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, c, d < n a, b, c, and d are distinct. nums[a] + nums[b] + nums[c] + nums[d] ...
{"functional": "def check(candidate):\n assert candidate(nums = [1,0,-1,0,-2,2], target = 0) == [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]\n assert candidate(nums = [2,2,2,2,2], target = 8) == [[2,2,2,2]]\n\n\ncheck(Solution().fourSum)"}
139
104
coding
Solve the programming task below in a Python markdown code block. To help Lavanya learn all about binary numbers and binary sequences, her father has bought her a collection of square tiles, each of which has either a 0 or a 1 written on it. Her brother Nikhil has played a rather nasty prank. He has glued together pair...
{"inputs": ["4"], "outputs": ["5"]}
405
12
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\opl...
{"inputs": ["2\n1\n2"], "outputs": ["1\n2"]}
326
18
coding
Solve the programming task below in a Python markdown code block. There are $N$ cells numbered 1,2,….., N, and every cell has some positive value. you will be given an array $A_1$,$A_2$,…,$A_N$ where $A_i$ is the value of $ith$ cell and an integer $K$. There is a monkey who wants to reach the $right$ side of the last (...
{"inputs": ["1\n2 2\n3 4"], "outputs": ["2"]}
543
20
coding
Solve the programming task below in a Python markdown code block. Given is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order. -----Constraints----- - C is a lowercase English letter that is not z. -----Input----- Input is given from Standard Input in the following form...
{"inputs": ["z", "b", "x", "`", "w", "_", "{", "^"], "outputs": ["{\n", "c\n", "y\n", "a\n", "x\n", "`\n", "|\n", "_\n"]}
97
58
coding
Solve the programming task below in a Python markdown code block. Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question. Suppose you are given a positive integer $a$. You want to choose some integer $b$ from $1$ to $a - 1$ inclusive in such a way that the gr...
{"inputs": ["1\n4\n", "1\n7\n", "1\n2\n", "1\n9\n", "1\n8\n", "1\n6\n", "1\n3\n", "1\n5\n"], "outputs": ["7\n", "1\n", "3\n", "15\n", "15\n", "7\n", "1\n", "7\n"]}
574
88
coding
Solve the programming task below in a Python markdown code block. On a planet called RUIZ LAND, which is ruled by the queen, Erika Ruiz. Each person on that planet has a strength value (strength value >0). That planet has a special rule made by the queen that a boy and a girl will form a couple if their Hate value is a...
{"inputs": ["2\n10 16"], "outputs": ["8 18"]}
363
21
coding
Solve the programming task below in a Python markdown code block. Your program will receive an array of complex numbers represented as strings. Your task is to write the `complexSum` function which have to return the sum as a string. Complex numbers can be written in the form of `a+bi`, such as `2-3i` where `2` is th...
{"functional": "_inputs = [[['2+3i', '3-i']], [['2-3i', '3+i']], [['3', '-3+i']], [[]], [['3+4i']], [['123+456i']], [['0']], [['-i']], [['1', '1']], [['-5', '5']], [['1', '10', '100', '1000']], [['5+4i', '11+3i']], [['-2-4i', '-8+6i']], [['-1-i', '7+10i']], [['3+4i', '3-4i']], [['10+i', '10-i', '9']], [['2+3i', '0', '0...
272
616
coding
Solve the programming task below in a Python markdown code block. A [Mersenne prime](https://en.wikipedia.org/wiki/Mersenne_prime) is a prime number that can be represented as: Mn = 2^(n) - 1. Therefore, every Mersenne prime is one less than a power of two. Write a function that will return whether the given integer ...
{"functional": "_inputs = [[2], [3], [5], [7], [11], [13], [17], [19], [21], [23], [31], [49], [61], [89], [107], [127], [221], [521], [607], [1279]]\n_outputs = [[True], [True], [True], [True], [False], [True], [True], [True], [False], [False], [True], [False], [True], [True], [True], [True], [False], [True], [True], ...
130
293
coding
Solve the programming task below in a Python markdown code block. # Description "It's the end of trick-or-treating and we have a list/array representing how much candy each child in our group has made out with. We don't want the kids to start arguing, and using our parental intuition we know trouble is brewing as many ...
{"functional": "_inputs = [[[5, 8, 6, 4]], [[1, 2, 4, 6]], [[1, 2]], [[4, 2]], [[1, 3, 3, 7]], [[7, 7, 7, 7]], [[17, 20, 50, 61, 42, 44]], [[0]], [[]], [[4]], [[None]]]\n_outputs = [[9], [11], [1], [2], [14], [0], [132], [-1], [-1], [-1], [-1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or...
582
281
coding
Solve the programming task below in a Python markdown code block. ## Task Implement a function which finds the numbers less than `2`, and the indices of numbers greater than `1` in the given sequence, and returns them as a pair of sequences. Return a nested array or a tuple depending on the language: * The first se...
{"functional": "_inputs = [[[0, 1, 2, 1, 0, 2, 1, 1, 1, 0, 4, 5, 6, 2, 1, 1, 0]], [[0, 1, 1, 2, 0]], [[2, 2, 0]], [[0, 1, 2, 1, 0, 2, 1, 1]], [[1]], [[3, 0, 7, 0, 2, 0]]]\n_outputs = [[[[0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0], [2, 5, 10, 11, 12, 13]]], [[[0, 1, 1, 0], [3]]], [[[0], [0, 1]]], [[[0, 1, 1, 0, 1, 1], [2, 5]]], [...
208
401
coding
Solve the programming task below in a Python markdown code block. Monocarp wants to draw four line segments on a sheet of paper. He wants the $i$-th segment to have its length equal to $a_i$ ($1 \le i \le 4$). These segments can intersect with each other, and each segment should be either horizontal or vertical. Monoc...
{"inputs": ["4\n1 1 3 4\n2 8 5 5\n2 1 4 1\n101 21 0 111\n", "4\n1 1 3 4\n1 8 5 5\n2 1 4 1\n101 4 54 011\n", "4\n1 1 3 4\n2 8 5 5\n4 1 4 1\n101 21 0 011\n", "4\n1 1 3 4\n2 7 5 5\n2 1 4 1\n111 29 4 101\n", "4\n0 1 3 4\n2 5 1 5\n3 1 4 1\n101 8 20 101\n", "4\n1 1 3 4\n2 7 5 5\n2 0 4 1\n111 29 4 101\n", "4\n1 1 3 4\n2 8 4 5...
543
429
coding
Solve the programming task below in a Python markdown code block. Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return `true` if the string is valid, and `false` if it's invalid. ## Examples ``` "()" => true ")(()...
{"functional": "_inputs = [[')'], ['('], [''], ['hi)('], ['hi(hi)'], ['hi(hi)('], ['((())()())'], ['(c(b(a)))(d)'], ['hi(hi))('], ['())(()']]\n_outputs = [[False], [False], [True], [False], [True], [False], [True], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isi...
211
233
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer n, return true if and only if it is an Armstrong number. The k-digit number n is an Armstrong number if and only if the kth power of each digit sums to n.   Please complete the following python code p...
{"functional": "def check(candidate):\n assert candidate(n = 153) == True\n assert candidate(n = 123) == False\n\n\ncheck(Solution().isArmstrong)"}
89
46
coding
Solve the programming task below in a Python markdown code block. A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and c...
{"inputs": ["1 1 2 1 1\n2 1\n", "1 1 2 2 1\n2 1\n", "1 1 2 3 1\n2 1\n", "1 1 1 1 1\n2 1\n", "1 1 0 2 1\n2 1\n", "1 1 2 6 1\n2 1\n", "2 1 1 1 1\n2 1\n", "2 1 2 6 1\n2 1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
737
166
coding
Solve the programming task below in a Python markdown code block. problem AOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \ dots, and N $, ...
{"inputs": ["2 1 1 2\n1 2 9 011\n2 2 5 500", "2 2 1 2\n1 2 6 001\n1 2 2 893", "2 2 1 2\n1 2 8 111\n1 1 4 526", "2 1 1 2\n1 2 10 001\n1 2 5 58", "2 2 1 2\n1 2 6 101\n1 2 5 893", "2 1 1 2\n1 2 5 101\n1 2 5 500", "2 1 1 2\n1 2 10 001\n1 2 5 28", "2 2 1 2\n1 2 0 001\n2 2 5 500"], "outputs": ["9\n", "2\n", "8\n", "10\n", "5...
372
272
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Captain Dehatti from Bawanian village is making strategy to win the Fake Cricket World Cup organised in his village. He want his team to score runs only in 4's and 6's because he belie...
{"inputs": ["6\n10 2 9\n6 2 9\n6 1 9\n4 1 9\n5 1 9\n10 3 9"], "outputs": ["2\n4\n1\n1\n0\n12"]}
552
61
coding
Solve the programming task below in a Python markdown code block. Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees. -----Input----- The first line contains an integer T, the...
{"inputs": ["3 \n10 2 001\n0 8 5\n180 1 0", "3 \n10 2 001\n0 8 2\n180 1 0", "3 \n41 2 001\n0 8 15\n180 1 0", "3 \n10 2 001\n0 8 15\n180 1 0", "3 \n10 2 000\n0 8 15\n180 1 0", "3 \n10 2 000\n0 7 15\n180 1 0", "3 \n3 2 101\n0 45 15\n180 0 0", "3 \n41 2 101\n0 8 15\n180 1 0"], "outputs": ["NO\nNO\nNO\n", "NO\nNO\nNO\n", "...
202
292
coding
Solve the programming task below in a Python markdown code block. Implement a modified Fibonacci sequence using the following definition: Given terms $t\left[i\right]$ and $t[i+1]$ where $i\in(1,\infty)$, term $t[i+2]$ is computed as: $t_{i+2}=t_{i}+(t_{i+1})^{2}$ Given three integers, $\mbox{t1}$, $\mbox{t2}...
{"inputs": ["0 1 5\n"], "outputs": ["5\n"]}
504
18
coding
Solve the programming task below in a Python markdown code block. Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i. Constraints * 1 ≤ length of T ≤ 1000000 * 1 ≤ length of P_i ≤ 1000 * 1 ≤ Q ≤ 10000 * The input consists of alphabetical characters and digi...
{"inputs": ["aabaaa\n4\nab\nba\nbb\nxyz", "aabaaa\n4\nab\nba\nba\nxyz", "aabaaa\n4\nba\nbb\nac\nzyx", "aabaaa\n4\nca\nab\nba\nzyx", "aacaaa\n4\nba\nb`\nac\nzyx", "aacaaa\n4\nca\nb`\nac\nzyx", "aabaaa\n4\na`\nab\nca\nyzx", "aadaaa\n4\nca\nb`\nca\nzyx"], "outputs": ["1\n1\n0\n0\n", "1\n1\n1\n0\n", "1\n0\n0\n0\n", "0\n1\n...
185
209
coding
Solve the programming task below in a Python markdown code block. Scientists working internationally use metric units almost exclusively. Unless that is, they wish to crash multimillion dollars worth of equipment on Mars. Your task is to write a simple function that takes a number of meters, and outputs it using metri...
{"functional": "_inputs = [[1], [999], [123456], [12300000], [9000000000.0], [9000000000000.0], [9000000000000000.0], [9e+18], [9e+21], [9e+24]]\n_outputs = [['1m'], ['999m'], ['123.456km'], ['12.3Mm'], ['9Gm'], ['9Tm'], ['9Pm'], ['9Em'], ['9Zm'], ['9Ym']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(...
243
303
coding
Solve the programming task below in a Python markdown code block. The previous challenges covered Insertion Sort, which is a simple and intuitive sorting algorithm with a running time of $unrecognized$. In these next few challenges, we're covering a divide-and-conquer algorithm called Quicksort (also known as Partition...
{"inputs": ["5 \n4 5 3 7 2 \n"], "outputs": ["3 2 4 5 7\n"]}
726
36
coding
Solve the programming task below in a Python markdown code block. After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency. These were the great news for Alice, whose grand...
{"inputs": ["3\n13 7 6\n6 2\n", "3\n13 2 6\n6 2\n", "3\n23 2 2\n6 2\n", "3\n23 2 4\n6 6\n", "3\n13 2 2\n6 2\n", "3\n23 2 2\n6 3\n", "3\n23 2 4\n6 3\n", "3\n20 7 6\n6 2\n"], "outputs": ["4\n", "2\n", "6\n", "12\n", "2\n", "6\n", "6\n", "6\n"]}
490
159
coding
Solve the programming task below in a Python markdown code block. Consider the following operations on a triple of integers. In one operation, you should: - Choose an integer $d$ and an arithmetic operation ― either addition or multiplication. - Choose a subset of elements of the triple. - Apply the arithmetic operatio...
{"inputs": ["2\n3 5 7\n6 5 10\n8 6 3\n9 7 8\n"], "outputs": ["1\n2"]}
515
40
coding
Solve the programming task below in a Python markdown code block. As a treat, I'll let you read part of the script from a classic 'I'm Alan Partridge episode: ``` Lynn: Alan, there’s that teacher chap. Alan: Michael, if he hits me, will you hit him first? Michael: No, he’s a customer. I cannot hit customers. I’ve been ...
{"functional": "_inputs = [['50'], [4], ['12'], [60]]\n_outputs = [[\"It's hotter than the sun!!\"], ['Help yourself to a honeycomb Yorkie for the glovebox.'], ['Help yourself to a honeycomb Yorkie for the glovebox.'], [\"It's hotter than the sun!!\"]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, f...
361
214
coding
Solve the programming task below in a Python markdown code block. A penguin Rocher has $n$ sticks. He has exactly one stick with length $i$ for all $1 \le i \le n$. He can connect some sticks. If he connects two sticks that have lengths $a$ and $b$, he gets one stick with length $a + b$. Two sticks, that were used in ...
{"inputs": ["4\n1\n2\n3\n4\n", "4\n1\n2\n3\n8\n", "4\n1\n2\n1\n4\n", "4\n2\n2\n3\n5\n", "4\n1\n2\n4\n4\n", "4\n1\n3\n1\n4\n", "4\n1\n2\n5\n4\n", "4\n1\n3\n3\n5\n"], "outputs": ["1\n1\n2\n2\n", "1\n1\n2\n4\n", "1\n1\n1\n2\n", "1\n1\n2\n3\n", "1\n1\n2\n2\n", "1\n2\n1\n2\n", "1\n1\n3\n2\n", "1\n2\n2\n3\n"]}
399
182
coding
Solve the programming task below in a Python markdown code block. Given is an integer N. Find the number of digits that N has in base K. -----Notes----- For information on base-K representation, see Positional notation - Wikipedia. -----Constraints----- - All values in input are integers. - 1 \leq N \leq 10^9 - 2 ...
{"inputs": ["1 2", "1 3", "1 2\n", "22 2", "15 2", "11 4", "25 2", "20 2"], "outputs": ["1\n", "1\n", "1\n", "5\n", "4\n", "2\n", "5\n", "5\n"]}
151
84
coding
Solve the programming task below in a Python markdown code block. -----Input----- The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. -----Output----- Output "YES" or "NO". -----Examples----- Input NEAT Output YES Input WORD Output...
{"inputs": ["Q\n", "Q\n", "P\n", "O\n", "AI\n", "IS\n", "IS\n", "JS\n"], "outputs": ["YES\n", "YES", "YES\n", "YES\n", "YES\n", "NO\n", "NO", "YES\n"]}
124
68
coding
Solve the programming task below in a Python markdown code block. Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t to Vitaly. The...
{"inputs": ["y\nz\n", "a\nz\n", "q\nz\n", "x\nz\n", "a\nb\n", "w\nz\n", "p\nz\n", "b\nc\n"], "outputs": ["No such string", "b", "r", "y", "No such string", "x\n", "q\n", "No such string\n"]}
392
87
coding
Solve the programming task below in a Python markdown code block. There are $n$ computers in a row, all originally off, and Phoenix wants to turn all of them on. He will manually turn on computers one at a time. At any point, if computer $i-1$ and computer $i+1$ are both on, computer $i$ $(2 \le i \le n-1)$ will turn o...
{"inputs": ["3 100000007\n", "4 100000007\n", "5 999999937\n", "6 100000007\n", "7 100000007\n", "6 100000007\n", "5 999999937\n", "7 100000007\n"], "outputs": ["6\n", "20\n", "78\n", "344\n", "1680\n", "344\n", "78\n", "1680\n"]}
472
163
coding
Solve the programming task below in a Python markdown code block. The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops. If $x$ is the number of passengers in a bus just before the current bus stop and $y$ is t...
{"inputs": ["2 4\n0 1\n", "2 2\n0 1\n", "2 4\n0 0\n", "2 1\n0 0\n", "2 2\n0 0\n", "2 4\n1 0\n", "2 4\n-1 1\n", "2 4\n-1 0\n"], "outputs": ["4\n", "2\n", "5\n", "2\n", "3\n", "4\n", "4\n", "4\n"]}
545
120
coding
Solve the programming task below in a Python markdown code block. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600...
{"inputs": ["543", "609", "982", "554", "417", "979", "424", "470"], "outputs": ["8\n", "7\n", "6\n", "8\n", "8\n", "6\n", "8\n", "8\n"]}
328
78
coding
Solve the programming task below in a Python markdown code block. Born a misinterpretation of [this kata](https://www.codewars.com/kata/simple-fun-number-334-two-beggars-and-gold/), your task here is pretty simple: given an array of values and an amount of beggars, you are supposed to return an array with the sum of wh...
{"functional": "_inputs = [[[1, 2, 3, 4, 5], 1], [[1, 2, 3, 4, 5], 2], [[1, 2, 3, 4, 5], 3], [[1, 2, 3, 4, 5], 6], [[1, 2, 3, 4, 5], 0]]\n_outputs = [[[15]], [[9, 6]], [[5, 7, 3]], [[1, 2, 3, 4, 5, 0]], [[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retu...
325
278
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a string s and an integer k, rearrange s such that the same characters are at least distance k from each other. If it is not possible to rearrange the string, return an empty string "".   Please complete the fol...
{"functional": "def check(candidate):\n assert candidate(s = \"aabbcc\", k = 3) == \"abcabc\"\n assert candidate(s = \"aaabc\", k = 3) == \"\"\n assert candidate(s = \"aaadbbcc\", k = 2) == \"abacabcd\"\n\n\ncheck(Solution().rearrangeString)"}
95
83
coding
Solve the programming task below in a Python markdown code block. Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible b...
{"inputs": ["1\n4\n", "1\n6\n", "1\n0\n", "1\n7\n", "1\n2\n", "1\n4\n", "3\n0 1 0\n", "3\n0 1 0\n"], "outputs": ["4\n", "6\n", "0\n", "7\n", "2\n", "4\n", "1\n", "1\n"]}
449
94
coding
Solve the programming task below in a Python markdown code block. You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value. The returned value must be a string, and have `"***"` between each of its letters. You ...
{"functional": "_inputs = [[['bitcoin', 'take', 'over', 'the', 'world', 'maybe', 'who', 'knows', 'perhaps']], [['turns', 'out', 'random', 'test', 'cases', 'are', 'easier', 'than', 'writing', 'out', 'basic', 'ones']], [['lets', 'talk', 'about', 'javascript', 'the', 'best', 'language']], [['i', 'want', 'to', 'travel', 't...
101
344
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", "-1\n", "-1\n"]}
367
76
coding
Solve the programming task below in a Python markdown code block. There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. Constra...
{"inputs": ["8 2 4", "3 3 1", "3 8 7", "1 2 4", "4 3 1", "6 8 7", "1 0 4", "4 2 1"], "outputs": ["Yes\n", "No\n", "Yes\n", "No\n", "No\n", "Yes\n", "No\n", "No\n"]}
219
94
coding
Solve the programming task below in a Python markdown code block. You are given two strings of equal length $s$ and $t$ consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings. During each operation you choose two adjacent characters in any string and assign the v...
{"inputs": ["3\nxabb\naabx\ntechnocup\ntechnocup\na\nz\n", "3\nxabb\naabx\nteohnccup\ntechnocup\na\nz\n", "3\nbcbw\nxaaa\ntdohncbup\npvconhcet\nb\nz\n", "3\nxabb\naabx\ntdohnccup\ntechnocup\na\nz\n", "3\nxabb\nxbaa\ntdohnccup\ntechnocup\na\nz\n", "3\nxacb\nxbaa\ntdohnccup\ntechnocup\na\nz\n", "3\nxabb\naabx\ntechnncup\...
577
261
coding
Solve the programming task below in a Python markdown code block. Petya has n positive integers a_1, a_2, ..., a_{n}. His friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replaced all digits 0 with one lette...
{"inputs": ["1\nh\n", "1\na\n", "1\na\n", "1\nh\n", "1\nb\n", "1\ni\n", "1\nc\n", "2\na\na\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "2\n"]}
556
88
coding
Solve the programming task below in a Python markdown code block. Problem Statement Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her ...
{"inputs": ["6\nUZI@ 4\nLINER 3\nKGNE 1\nBLL 2\nAS 1\nCHEL 10\nBSKA\nILIC\nNRZI\nUELE\n21", "6\nUZIA 2\nLINER 12\nLGNE 9\nALL 2\nSA 1\nCIEL 9\nBSLA\nCJLI\nIRZN\nUELE\n21", "6\nUZI@ 4\nLINER 12\nLGOE 9\nALL 2\nAS 0\nCIEL 5\nBSLA\nCILI\nINZR\nUELE\n21", "6\nAIZU 4\nLINER 6\nLGNE 3\nLLA 2\nAS 1\nCIEL 10\nBSLA\nCILI\nIRZN\...
724
437
coding
Solve the programming task below in a Python markdown code block. Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and second...
{"inputs": ["10\n3\n8 11\n12 19\n18 9\n8\n2\n6 6\n5 6\n0", "10\n3\n8 11\n12 19\n18 9\n8\n2\n4 6\n5 6\n0", "10\n3\n6 11\n12 19\n18 9\n8\n2\n4 6\n5 6\n0", "10\n3\n6 11\n12 19\n18 9\n8\n2\n3 6\n5 6\n0", "10\n3\n6 11\n12 19\n18 9\n8\n2\n3 6\n5 9\n0", "10\n3\n8 11\n12 19\n18 38\n8\n2\n6 6\n5 6\n0", "10\n3\n8 8\n12 19\n18 8\...
530
346
coding
Solve the programming task below in a Python markdown code block. A list of names is taken as input, in which a particular name can occur multiple times. You need to arrange these names as they will appear in the dictionary and also print the number of times the arranged names appear in the list taken as input. Input:...
{"inputs": ["3\nritesh\nsahil\nritesh", "5\nritesh\nritesh\nritesh\nsahil\nsahil"], "outputs": ["ritesh 2\nsahil 1", "ritesh 3\nsahil 2"]}
252
63
coding
Solve the programming task below in a Python markdown code block. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: - Take 2i ston...
{"inputs": ["1 0", "6 0", "2 0", "1 8", "4 0", "1 5", "3 0", "0 7"], "outputs": ["Brown\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n"]}
281
78
coding
Solve the programming task below in a Python markdown code block. -----Problem----- Suppose there is a circle. There are N Juice shops on that circle. Juice shops are numbered 0 to N-1 (both inclusive). You have two pieces of information corresponding to each of the juice shop: (1) the amount of Juice that a particula...
{"inputs": ["3\n1 5\n10 3\n3 4"], "outputs": ["1"]}
328
25
coding
Solve the programming task below in a Python markdown code block. Mario was going to gift Princess Peach a string S of even length N. Mario was clumsy and thus, broke the string in the middle. He now has two strings A and B such that A = S[1, \frac{N}{2}] and B = S[\frac{N}{2} + 1, N]. Mario is not sure about the o...
{"inputs": ["4\n6\nabcabc\n6\nabcdef\n4\naaaa\n4\nbaab"], "outputs": ["YES\nNO\nYES\nNO\n"]}
601
37
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array books where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book. You are also given an integer shelfWidth. We want to place these books in order onto bookcase she...
{"functional": "def check(candidate):\n assert candidate(books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelfWidth = 4) == 6\n\n\ncheck(Solution().minHeightShelves)"}
279
66
coding
Solve the programming task below in a Python markdown code block. Chef is taking a tough examination. The question paper consists of N objective problems and each problem has 4 options A, B, C, and D, out of which, exactly one option is correct. Since Chef did not study for the exam, he does not know the answer to any...
{"inputs": ["2\n5\n0 0 5 0\n10\n7 1 1 1\n"], "outputs": ["5\n7\n"]}
539
37
coding
Solve the programming task below in a Python markdown code block. There were $n$ types of swords in the theater basement which had been used during the plays. Moreover there were exactly $x$ swords of each type. $y$ people have broken into the theater basement and each of them has taken exactly $z$ swords of some singl...
{"inputs": ["2\n2 9\n", "2\n1 9\n", "2\n2 9\n", "2\n1 15\n", "2\n0 15\n", "2\n0 13\n", "3\n3 8 6\n", "3\n3 8 0\n"], "outputs": ["1 7\n", "1 8\n", "1 7\n", "1 14\n", "1 15\n", "1 13\n", "7 1\n", "13 1\n"]}
717
129
coding
Solve the programming task below in a Python markdown code block. Chef is hosting a party at his house and N people are invited to it. Everyone has arrived and they are eager to make a group and chit-chat. The i^{th} person prefers to be in a group of exactly P_{i} people (including himself). A person who is not in a ...
{"inputs": ["4\n5\n2 3 2 3 3\n5\n5 5 5 5 5\n5\n3 2 2 3 2\n4\n4 4 4 3\n"], "outputs": ["YES\nYES\nNO\nNO\n"]}
563
66
coding
Solve the programming task below in a Python markdown code block. For two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies the following: * The p_i-th element (1 \leq i \leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q. You...
{"inputs": ["3 1\n1 2 3\n3 2 1", "3 6\n1 2 3\n3 2 1", "3 9\n2 1 3\n3 2 1", "3 4\n1 2 3\n3 2 1", "3 2\n1 2 3\n3 2 1", "3 9\n1 2 3\n3 2 1", "3 8\n1 2 3\n3 2 1", "3 7\n1 2 3\n3 2 1"], "outputs": ["1 2 3", "3 2 1", "2 3 1", "1 2 3", "3 2 1", "3 2 1", "3 2 1", "1 2 3"]}
433
198