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. You are given a string $t$ consisting of $n$ lowercase Latin letters and an integer number $k$. Let's define a substring of some string $s$ with indices from $l$ to $r$ as $s[l \dots r]$. Your task is to construct such string $s$ of minimum possible le...
{"inputs": ["1 1\na\n", "1 1\na\n", "1 50\nq\n", "2 4\naa\n", "2 2\noo\n", "2 2\naa\n", "2 1\naa\n", "2 2\nab\n"], "outputs": ["a\n", "a\n", "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n", "aaaaa\n", "ooo\n", "aaa\n", "aa\n", "abab\n"]}
299
129
coding
Solve the programming task below in a Python markdown code block. You wrote down all integers from $0$ to $10^n - 1$, padding them with leading zeroes so their lengths are exactly $n$. For example, if $n = 3$ then you wrote out 000, 001, ..., 998, 999. A block in an integer $x$ is a consecutive segment of equal digits...
{"inputs": ["1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["10\n", "180 10\n", "2610 180 10\n", "34200 2610 180 10\n", "423000 34200 2610 180 10\n", "5040000 423000 34200 2610 180 10\n", "58500000 5040000 423000 34200 2610 180 10\n", "666000000 58500000 5040000 423000 34200 2610 180 10\n"]}
313
246
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three charac...
{"functional": "def check(candidate):\n assert candidate(s = \"PPALLP\") == True\n assert candidate(s = \"PPALLL\") == False\n\n\ncheck(Solution().checkRecord)"}
166
45
coding
Solve the programming task below in a Python markdown code block. Programmer Deepak has created a program which calculates magical number as 2^n * 3^n * 5^n where "n" is an integer. Now he wants to find the magical number which is just greater than the input. Help him in finding it. NOTE : a^b denotes a raised to po...
{"inputs": ["456"], "outputs": ["900"]}
139
16
coding
Solve the programming task below in a Python markdown code block. Chef considers an array *good* if it has no subarray of size less than N such that the [GCD] of all the elements of the subarray is equal to 1. Chef has an array A of size N with him. He wants to convert it into a *good* array by applying a specific op...
{"inputs": ["3\n3\n3 2 6\n4\n3 2 4 8\n4\n6 15 9 18\n "], "outputs": ["1\n2 3\n-1\n0\n"]}
661
54
coding
Solve the programming task below in a Python markdown code block. You are given two integers $N$ and ${L}}$. Compute the number of unrooted labelled trees with exactly $N$ nodes and exactly ${L}$ leafs. This number can be huge, so please output it's modulo $10^9+7$. Input Format The first line of input consists of tw...
{"inputs": ["5 2"], "outputs": ["60"]}
138
15
coding
Solve the programming task below in a Python markdown code block. The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per s...
{"inputs": ["6 3\n1\n6\n201449\n16\n7\n60700\n7", "6 3\n1\n6\n201449\n18\n7\n60700\n7", "7 3\n1\n34\n966369\n7\n9\n40177\n11", "7 3\n1\n62\n334284\n16\n7\n60700\n7", "6 3\n1\n62\n201449\n16\n7\n60700\n7", "6 1\n1\n62\n190402\n16\n6\n60700\n7", "6 3\n1\n62\n334284\n16\n7\n60700\n7", "6 3\n1\n62\n201449\n16\n6\n60700\n7"...
171
276
coding
Solve the programming task below in a Python markdown code block. As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters "(" and ")" (without quotes)). O...
{"inputs": ["(\n", ")\n", "(\n", ")\n", "((\n", "))\n", "()\n", ")(\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "0\n"]}
665
72
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a broken calculator that has the integer startValue on its display initially. In one operation, you can: multiply the number on display by 2, or subtract 1 from the number on display. Given two integers sta...
{"functional": "def check(candidate):\n assert candidate(startValue = 2, target = 3) == 2\n assert candidate(startValue = 5, target = 8) == 2\n assert candidate(startValue = 3, target = 10) == 3\n\n\ncheck(Solution().brokenCalc)"}
117
74
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. A subarray s of length m is called alternating if: m is greater than 1. s1 = s0 + 1. The 0-indexed subarray s looks like [s0, s1, s0, s1,...,s(m-1) % 2]. In other words, ...
{"functional": "def check(candidate):\n assert candidate(nums = [2,3,4,3,4]) == 4\n assert candidate(nums = [4,5,6]) == 2\n\n\ncheck(Solution().alternatingSubarray)"}
222
57
coding
Solve the programming task below in a Python markdown code block. zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor. Initially, the text editor...
{"inputs": ["8 1 1\n", "1 1 1\n", "1 1 1\n", "1 1 0\n", "8 1 2\n", "2 1 0\n", "8 1 0\n", "4 1 0\n"], "outputs": ["4\n", "1\n", "1", "1", "6", "1", "1", "1"]}
249
96
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Sergey recently learned about country codes - two letter strings, denoting countries. For example, BY stands for Belarus and IN stands for India. Mesmerized by this new disc...
{"inputs": ["2\nINBY\nBYBY"], "outputs": ["3\n2"]}
320
20
coding
Solve the programming task below in a Python markdown code block. In input string ```word```(1 word): * replace the vowel with the nearest left consonant. * replace the consonant with the nearest right vowel. P.S. To complete this task imagine the alphabet is a circle (connect the first and last element of the array i...
{"functional": "_inputs = [['cat'], ['codewars'], ['abcdtuvwxyz']]\n_outputs = [['ezu'], ['enedazuu'], ['zeeeutaaaaa']]\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 ...
292
178
coding
Solve the programming task below in a Python markdown code block. Petya works as a PR manager for a successful Berland company BerSoft. He needs to prepare a presentation on the company income growth since 2001 (the year of its founding) till now. Petya knows that in 2001 the company income amounted to a1 billion bourl...
{"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n4\n", "1\n-1\n", "1\n-2\n", "1\n-3\n"], "outputs": ["0\n", "1\n2001 ", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n"]}
533
99
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character. Return the minimum number of steps to make t an anagram of s. An Anagram of a ...
{"functional": "def check(candidate):\n assert candidate(s = \"bab\", t = \"aba\") == 1\n assert candidate(s = \"leetcode\", t = \"practice\") == 5\n assert candidate(s = \"anagram\", t = \"mangaar\") == 0\n\n\ncheck(Solution().minSteps)"}
120
73
coding
Solve the programming task below in a Python markdown code block. A carpet shop sells carpets in different varieties. Each carpet can come in a different roll width and can have a different price per square meter. Write a function `cost_of_carpet` which calculates the cost (rounded to 2 decimal places) of carpeting a...
{"functional": "_inputs = [[3, 5, 4, 10], [4, 5, 4, 10], [0, 0, 4, 10], [3, 2, 4, 10], [3.9, 2, 4, 10], [5, 6, 4, 10], [3, 2, 4, 0], [3, 2, 2, 10]]\n_outputs = [[200], [200], ['error'], [80], [80], ['error'], [0], [60]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ...
252
286
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Recently, Chef hosted a strange competition at the Byteland annual fair. There were $N$ participants in the competition (numbered $1$ through $N$); a...
{"inputs": ["1\n5\n5 2 4 6 7"], "outputs": ["5 5"]}
732
26
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a binary tree rooted at 0 consisting of n nodes. The nodes are labeled from 0 to n - 1. You are given a 0-indexed integer array parents representing the tree, where parents[i] is the parent of node i. Since n...
{"functional": "def check(candidate):\n assert candidate(parents = [-1,2,0,2,0]) == 3\n assert candidate(parents = [-1,2,0]) == 2\n\n\ncheck(Solution().countHighestScoreNodes)"}
200
59
coding
Solve the programming task below in a Python markdown code block. A number is called 2050-number if it is $2050$, $20500$, ..., ($2050 \cdot 10^k$ for integer $k \ge 0$). Given a number $n$, you are asked to represent $n$ as the sum of some (not necessarily distinct) 2050-numbers. Compute the minimum number of 2050-nu...
{"inputs": ["1\n1\n", "1\n1\n", "1\n62\n", "1\n57\n", "1\n68\n", "1\n12\n", "1\n10\n", "1\n22\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
347
93
coding
Solve the programming task below in a Python markdown code block. Three Best Friends $AMAN$ , $AKBAR$ , $ANTHONY$ are planning to go to “GOA” , but just like every other goa trip plan there is a problem to their plan too. Their parents will only give permission if they can solve this problem for them They are a given ...
{"inputs": ["3"], "outputs": ["3"]}
286
12
coding
Solve the programming task below in a Python markdown code block. # Task: We define the "self reversed power sequence" as one shown below: Implement a function that takes 2 arguments (`ord max` and `num dig`), and finds the smallest term of the sequence whose index is less than or equal to `ord max`, and has exactl...
{"functional": "_inputs = [[5, 10], [7, 11], [7, 14], [8, 16], [10, 20]]\n_outputs = [[[True, 10]], [[False, -1]], [[True, 13]], [[True, 15]], [[True, 17]]]\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 ...
406
219
coding
Solve the programming task below in a Python markdown code block. The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ... Given is a string S representing the weather in the town today. Predict the weather tomorrow. Constraints * S is `Sunny`, `Clou...
{"inputs": ["Rainy", "Sunny"], "outputs": ["Sunny", "Cloudy"]}
141
22
coding
Solve the programming task below in a Python markdown code block. Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The comput...
{"inputs": ["3 0 3\n0\n", "1 1 1\n0\n", "1 1 1\n0\n", "3 0 3\n0\n", "1 2 1\n0\n", "2 0 3\n0\n", "1 2 0\n0\n", "2 1 3\n0\n"], "outputs": ["0 0\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n"]}
519
134
coding
Solve the programming task below in a Python markdown code block. prison There are an infinite number of prisoners. Initially, the prisoners are numbered 0, 1, 2, .... Do the following N times: * Release the 0th prisoner and execute the k, 2k, 3k, ... th prisoners. * Then renumber the remaining prisoners. At this ti...
{"inputs": ["5 2", "7 2", "2 2", "1 2", "4 3", "8 2", "6 2", "7 4"], "outputs": ["15\n", "63\n", "1\n", "0\n", "4\n", "127\n", "31\n", "10\n"]}
263
84
coding
Solve the programming task below in a Python markdown code block. Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook. Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclu...
{"inputs": ["1 1\n5\n", "1 2\n57\n", "1 2\n74\n", "1 2\n49\n", "1 2\n68\n", "1 2\n84\n", "1 2\n59\n", "2 1\n4\n6\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
354
110
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a very large integer n, represented as a string,​​​​​​ and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number. You want to maximi...
{"functional": "def check(candidate):\n assert candidate(n = \"99\", x = 9) == \"999\"\n assert candidate(n = \"-13\", x = 2) == \"-123\"\n\n\ncheck(Solution().maxValue)"}
220
63
coding
Solve the programming task below in a Python markdown code block. Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him. Before the very beginning of the game several cards are lain ...
{"inputs": ["11\n", "??\n", "00\n", "10?\n", "01?\n", "1?1\n", "0101\n", "000?\n"], "outputs": ["11\n", "00\n01\n10\n11\n", "00\n", "00\n01\n", "00\n01\n", "01\n11\n", "01\n", "00\n"]}
735
111
coding
Solve the programming task below in a Python markdown code block. Simple, remove the spaces from the string, then return the resultant string. ~~~if:c For C, you must return a new dynamically allocated string. ~~~ Also feel free to reuse/extend the following starter code: ```python def no_space(x): ```
{"functional": "_inputs = [['8 j 8 mBliB8g imjB8B8 jl B'], ['8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd'], ['8aaaaa dddd r '], ['jfBm gk lf8hg 88lbe8 '], ['8j aam']]\n_outputs = [['8j8mBliB8gimjB8B8jlB'], ['88Bifk8hB8BB8BBBB888chl8BhBfd'], ['8aaaaaddddr'], ['jfBmgklf8hg88lbe8'], ['8jaam']]\nimport math\ndef...
68
303
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an integer array nums and an integer goal. You want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is...
{"functional": "def check(candidate):\n assert candidate(nums = [5,-7,3,5], goal = 6) == 0\n assert candidate(nums = [7,-9,15,-2], goal = -5) == 1\n assert candidate(nums = [1,2,3], goal = -7) == 7\n\n\ncheck(Solution().minAbsDifference)"}
154
88
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s. Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the a...
{"functional": "def check(candidate):\n assert candidate(s = \"10101\") == 4\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"100100010100110\") == 12\n\n\ncheck(Solution().numWays)"}
133
93
coding
Solve the programming task below in a Python markdown code block. You are given an HTML code snippet of $N$ lines. Your task is to detect and print all the HTML tags, attributes and attribute values. Print the detected items in the following format: Tag1 Tag2 -> Attribute2[0] > Attribute_value2[0] -> Attribute2[1] >...
{"inputs": ["9\n<head>\n<title>HTML</title>\n</head>\n<object type=\"application/x-flash\" \n data=\"your-file.swf\" \n width=\"0\" height=\"0\">\n <!-- <param name=\"movie\" value=\"your-file.swf\" /> -->\n <param name=\"quality\" value=\"high\"/>\n</object>\n"], "outputs": ["head\ntitle\nobject\n-> type > applica...
522
137
coding
Solve the programming task below in a Python markdown code block. Tanya wants to go on a journey across the cities of Berland. There are n cities situated along the main railroad line of Berland, and these cities are numbered from 1 to n. Tanya plans her journey as follows. First of all, she will choose some city c_1...
{"inputs": ["2\n2 2\n", "2\n1 2\n", "2\n2 1\n", "2\n1 1\n", "2\n3 1\n", "2\n1 0\n", "2\n2 0\n", "2\n1 -1\n"], "outputs": ["2\n", "3\n", "2\n", "1\n", "3\n", "1\n", "2\n", "1\n"]}
655
102
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 wonders eagerly what minimum...
{"inputs": ["8\n", "4\n", "2\n", "1\n", "5\n", "6\n", "3\n", "9\n"], "outputs": ["44\n", "4\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
185
71
coding
Solve the programming task below in a Python markdown code block. “Jesse, you asked me if I was in the meth business, or the money business… Neither. I’m in the empire business.” Walter’s sold his stack in Gray Matter Technologies, a company which he deserved half a credit, for peanuts. Now this company is worth a bill...
{"inputs": ["2\n5\n6 5 5 5 2\n5\n1 2 3 4 5"], "outputs": ["6 5 4 3 2\n1 2 3 4 5"]}
592
54
coding
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ integers. In one move, you can jump from the position $i$ to the position $i - a_i$ (if $1 \le i - a_i$) or to the position $i + a_i$ (if $i + a_i \le n$). For each position $i$ from $1$ to $n$ you want to kn...
{"inputs": ["10\n4 5 7 6 7 5 4 4 6 4\n", "10\n4 9 7 6 7 5 4 4 6 4\n", "10\n4 9 7 6 7 5 4 4 6 0\n", "10\n4 9 7 6 7 5 4 4 6 1\n", "10\n4 5 7 6 7 5 4 4 6 4\n", "10\n4 17 7 6 7 5 4 4 6 1\n", "10\n4 17 7 6 7 5 4 4 12 1\n", "10\n4 17 1 6 7 5 4 4 12 1\n"], "outputs": ["1 1 1 2 -1 1 1 3 1 1 \n", "1 -1 1 2 -1 1 1 3 1 1\n", "1 -...
397
389
coding
Solve the programming task below in a Python markdown code block. You are given two strings $s$ and $t$ both of length $n$ and both consisting of lowercase Latin letters. In one move, you can choose any length $len$ from $1$ to $n$ and perform the following operation: Choose any contiguous substring of the string $s...
{"inputs": ["4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "4\n4\nabcd\nabdc\n5\naaabc\nbabaa\n4\nfdsa\nasdg\n4\nabdd\nbadc\n", "4\n4\ndabb\nabdb\n5\nababa\naba...
569
361
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithm...
{"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == 3\n assert candidate(nums = [1]) == 0\n\n\ncheck(Solution().numberOfArithmeticSlices)"}
143
52
coding
Solve the programming task below in a Python markdown code block. Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know th...
{"inputs": ["1 1 1 0\n0\n", "2 2 1 0\n00\n", "1 1 1 -1\n0\n", "1 1 1 -2\n0\n", "1 1 1 -3\n0\n", "2 2 1 -1\n00\n", "5 4 1 0\n00000\n", "5 1 2 1\n00100\n"], "outputs": ["1\n1 ", "1\n1 ", "1\n1\n", "1\n1\n", "1\n1\n", "1\n1\n", "2\n1 2 ", "2\n2 5 "]}
524
161
coding
Solve the programming task below in a Python markdown code block. Mario transforms each time he eats a mushroom as follows: If he is currently small, he turns normal. If he is currently normal, he turns huge. If he is currently huge, he turns small. Given that Mario was initially normal, find his size after eating X m...
{"inputs": ["3\n2\n4\n12"], "outputs": ["SMALL\nHUGE\nNORMAL"]}
384
25
coding
Solve the programming task below in a Python markdown code block. You are given an axis-aligned rectangle in a 2D Cartesian plane. The bottom left corner of this rectangle has coordinates (0,0)$(0, 0)$ and the top right corner has coordinates (N−1,N−1)$(N-1, N-1)$. You are also given K$K$ light sources; each light sour...
{"inputs": ["2\n2 10\n0 0\n1 0\n2 10\n1 2\n1 1"], "outputs": ["yes\nno"]}
493
40
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array target that consists of distinct integers and another integer array arr that can have duplicates. In one operation, you can insert any integer at any position in arr. For example, if arr = [1,4,...
{"functional": "def check(candidate):\n assert candidate(target = [5,1,3], arr = [9,4,2,3,4]) == 2\n assert candidate(target = [6,4,8,1,3,2], arr = [4,7,6,2,3,8,6,1]) == 3\n\n\ncheck(Solution().minOperations)"}
238
89
coding
Solve the programming task below in a Python markdown code block. You are given a binary string $s$ of length $n$. Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum\limits_{...
{"inputs": ["1\n2 1000000000\n01\n", "3\n4 0\n1010\n7 1\n0010100\n5 2\n00110\n"], "outputs": ["1\n", "21\n22\n12\n"]}
565
76
coding
Solve the programming task below in a Python markdown code block. Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the ...
{"inputs": ["2\n", "9\n", "3\n", "1\n", "4\n", "5\n", "8\n", "6\n"], "outputs": ["1\n1 ", "0\n", "0\n", "0\n", "1\n2\n", "0\n\n", "1\n4\n", "1\n3\n"]}
294
78
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no tw...
{"functional": "def check(candidate):\n assert candidate(costs = [[17,2,17],[16,16,5],[14,3,19]]) == 10\n assert candidate(costs = [[7,6,2]]) == 2\n\n\ncheck(Solution().minCost)"}
181
72
coding
Solve the programming task below in a Python markdown code block. You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions: - The initial character of S is an uppercase A. - There is exactly one occurrence of C between the third c...
{"inputs": ["AaCa\n", "AtBoCo", "ACodes", "AtBnCo", "ACodds", "@tBnCo", "sddoCA", "oCnBt@"], "outputs": ["AC\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n"]}
206
84
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order. Return the area of the largest submatrix within matrix where every element of the submatrix ...
{"functional": "def check(candidate):\n assert candidate(matrix = [[0,0,1],[1,1,1],[1,0,1]]) == 4\n assert candidate(matrix = [[1,0,1,0,1]]) == 3\n assert candidate(matrix = [[1,1,0],[1,0,1]]) == 2\n assert candidate(matrix = [[0,0],[0,0]]) == 0\n\n\ncheck(Solution().largestSubmatrix)"}
107
109
coding
Solve the programming task below in a Python markdown code block. Write a function that takes one or more arrays and returns a new array of unique values in the order of the original provided arrays. In other words, all values present from all arrays should be included in their original order, but with no duplicates i...
{"functional": "_inputs = [[[1, 2], [3, 4]], [[1, 3, 2], [5, 2, 1, 4], [2, 1]], [[4, 3, 2, 2]], [[4, 'a', 2], []], [[], [4, 'a', 2]], [[], [4, 'a', 2], []], [[]], [[], []], [[], [1, 2]], [[], [1, 2, 1, 2], [2, 1, 1, 2, 1]]]\n_outputs = [[[1, 2, 3, 4]], [[1, 3, 2, 5, 4]], [[4, 3, 2]], [[4, 'a', 2]], [[4, 'a', 2]], [[4, ...
173
357
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a positive integer num, return true if num is a perfect square or false otherwise. A perfect square is an integer that is the square of an integer. In other words, it is the product of some integer with itself. ...
{"functional": "def check(candidate):\n assert candidate(num = 16) == True\n assert candidate(num = 14) == False\n\n\ncheck(Solution().isPerfectSquare)"}
108
44
coding
Solve the programming task below in a Python markdown code block. Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type: 1. + ai — add non-negative integer ai to the mul...
{"inputs": ["4\n+ 200\n+ 15\n- 200\n? 0\n", "4\n+ 200\n+ 200\n- 200\n? 0\n", "10\n+ 2\n- 2\n+ 778\n+ 3\n+ 4\n- 4\n+ 1\n+ 617\n? 011\n? 011\n", "10\n+ 2\n- 2\n+ 778\n+ 2\n+ 4\n- 4\n+ 1\n+ 617\n? 011\n? 011\n", "10\n+ 2\n- 2\n+ 778\n+ 0\n+ 4\n- 4\n+ 0\n+ 617\n? 001\n? 011\n", "10\n+ 2\n- 2\n+ 778\n+ 1\n+ 4\n- 4\n+ 1\n+ 6...
756
419
coding
Solve the programming task below in a Python markdown code block. Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. About every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can't pass any ex...
{"inputs": ["1 1\n1\n1\n", "1 1\n1\n1\n", "1 1\n0\n1\n", "1 1\n0\n2\n", "1 1\n0\n3\n", "1 1\n1\n2\n", "1 1\n1\n4\n", "1 1\n1\n3\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]}
693
119
coding
Solve the programming task below in a Python markdown code block. You are given a spreadsheet that contains a list of $N$ athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the $K^{th}$ attribute and print the final resulting table. Follow the example given be...
{"inputs": ["5 3\n10 2 5\n7 1 0\n9 9 9\n1 23 12\n6 5 9\n1\n"], "outputs": ["7 1 0\n10 2 5\n6 5 9\n9 9 9\n1 23 12\n"]}
375
82
coding
Solve the programming task below in a Python markdown code block. Given the integer $n$ — the number of available blocks. You must use all blocks to build a pedestal. The pedestal consists of $3$ platforms for $2$-nd, $1$-st and $3$-rd places respectively. The platform for the $1$-st place must be strictly higher than...
{"inputs": ["1\n3777\n", "1\n3234\n", "1\n5234\n", "1\n14377\n", "6\n11\n6\n10\n100000\n7\n8\n", "17\n58512\n46568\n77983\n60262\n48767\n75002\n79520\n52911\n42089\n38692\n71175\n51960\n33754\n36367\n67108\n79100\n78009\n"], "outputs": ["1259 1260 1258\n", "1078 1079 1077\n", "1745 1746 1743\n", "4793 4794 4790\n", "4 ...
632
599
coding
Solve the programming task below in a Python markdown code block. This is an easy version of the problem. The only difference between an easy and a hard version is in the number of queries. Polycarp grew a tree from $n$ vertices. We remind you that a tree of $n$ vertices is an undirected connected graph of $n$ vertice...
{"inputs": ["1\n1\n1\n1\n", "1\n2\n1\n1\n1\n1\n", "3\n3 1\n2 1\n1\n2\n1 2\n", "5\n4 2\n5 4\n1 4\n3 5\n1\n4\n1 3 5 2\n", "2\n1 2\n5\n1\n2\n1\n1\n1\n1\n2\n2 1\n2\n1 2\n", "6\n1 6\n6 5\n1 2\n2 3\n2 4\n1\n4\n5 2 4 3\n", "6\n1 2\n2 3\n1 4\n4 5\n4 6\n1\n4\n3 4 5 6\n", "7\n1 2\n2 3\n3 4\n1 5\n5 6\n5 7\n1\n3\n4 6 7\n"], "outpu...
730
268
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Sereja have an array that consist of n integers a[1], a[2], ..., a[n]. Now Sereja want to delete some(possible none, but not all) elements from the array, such that arithmetical mean of all rema...
{"inputs": ["2\n1\n1\n4\n1 2 1 2"], "outputs": ["1\n3"]}
291
28
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second. Return an array of all the ...
{"functional": "def check(candidate):\n assert candidate(text = \"alice is a good girl she is a good student\", first = \"a\", second = \"good\") == [\"girl\",\"student\"]\n assert candidate(text = \"we will we will rock you\", first = \"we\", second = \"will\") == [\"we\",\"rock\"]\n\n\ncheck(Solution().findOcur...
109
89
coding
Solve the programming task below in a Python markdown code block. In Japan, people make offerings called hina arare, colorful crackers, on March 3. We have a bag that contains N hina arare. (From here, we call them arare.) It is known that the bag either contains arare in three colors: pink, white and green, or contain...
{"inputs": ["6\nG W Y Q Y W", "6\nG X X O X X", "6\nF W Y P Y W", "6\nF W Y O Y W", "6\nG W Y O Y W", "6\nE W Y O Y W", "6\nF W Y Q Y W", "6\nE W Y P Y W"], "outputs": ["Four\n", "Three\n", "Four\n", "Four\n", "Four\n", "Four\n", "Four\n", "Four\n"]}
315
118
coding
Solve the programming task below in a Python markdown code block. Polycarp has n dice d_1, d_2, ..., d_{n}. The i-th dice shows numbers from 1 to d_{i}. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values d_1, ...
{"inputs": ["1 3\n5\n", "1 1\n3\n", "1 2\n3\n", "1 5\n5\n", "1 1\n3\n", "1 2\n3\n", "1 5\n5\n", "1 1\n1\n"], "outputs": ["4 ", "2 ", "2 ", "4 ", "2\n", "2\n", "4\n", "0"]}
565
97
coding
Solve the programming task below in a Python markdown code block. Polycarp started working at a bank. He was assigned to monitor the ATM. The ATM initially contains $s$ rubles. A queue of $n$ students lined up to him. Each student wants to either withdraw a certain amount of money or deposit it into an account. If $a_...
{"inputs": ["3\n4 10\n-16 2 -6 8\n3 1000\n-100000 -100000 -100000\n6 0\n2 6 -164 1 -1 -6543\n"], "outputs": ["2 4\n-1\n1 2\n"]}
748
88
coding
Solve the programming task below in a Python markdown code block. Serval is fighting with a monster. The health of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the nu...
{"inputs": ["4 3", "1 1\n", "14 4", "14 3", "11 2", "14 5", "26 4", "20 2"], "outputs": ["2\n", "1\n", "4\n", "5\n", "6\n", "3\n", "7\n", "10\n"]}
228
86
coding
Solve the programming task below in a Python markdown code block. Indian National Olympiad in Informatics 2012 You are given a table with 2 rows and N columns. Each cell has an integer in it. The score of such a table is defined as follows: for each column, consider the sum of the two numbers in the column; the maximum...
{"inputs": ["and output corresponding to the example above.\nSample input\n4\n7 1 6 2\nSample output\n9 10 10 11\nNote: Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print statements before making your final submission. A program with extraneous ...
620
89
coding
Solve the programming task below in a Python markdown code block. Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibl...
{"inputs": ["3 1\n0", "6 1\n0", "5 1\n0", "4 1\n1", "8 1\n0", "2 1\n0", "7 1\n1", "1 1\n0"], "outputs": ["3\n", "6\n", "5\n", "4\n", "8\n", "2\n", "7\n", "1\n"]}
324
94
coding
Solve the programming task below in a Python markdown code block. Chef bought car insurance. The policy of the insurance is: The maximum rebatable amount for any damage is Rs X lakhs. If the amount required for repairing the damage is ≤ X lakhs, that amount is rebated in full. Chef's car meets an accident and require...
{"inputs": ["4\n5 3\n5 8\n4 4\n15 12\n"], "outputs": ["3\n5\n4\n12\n"]}
373
39
coding
Solve the programming task below in a Python markdown code block. Like any unknown mathematician, Yuri has favourite numbers: $A$, $B$, $C$, and $D$, where $A \leq B \leq C \leq D$. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides $x$, $y$, and $z$ exist, such that $A ...
{"inputs": ["1 2 3 4\n", "1 2 2 5\n", "1 2 2 3\n", "1 0 2 5\n", "1 2 2 5\n", "1 2 3 4\n", "32 89 451 476\n", "32 89 451 476\n"], "outputs": ["4\n", "3\n", "3\n", "0\n", "3", "4", "72384\n", "72384"]}
471
135
coding
Solve the programming task below in a Python markdown code block. =====Problem Statement===== For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be correct u...
{"inputs": ["2 1\n5 6", "5.9 6\n9 10"], "outputs": ["7.00+7.00i\n-3.00-5.00i\n4.00+17.00i\n0.26-0.11i\n2.24+0.00i\n7.81+0.00i", "14.90+16.00i\n-3.10-4.00i\n-6.90+113.00i\n0.62-0.03i\n8.41+0.00i\n13.45+0.00i"]}
528
170
coding
Solve the programming task below in a Python markdown code block. Every character in the string “IITMANDI” is given a certain number of points. You are given a scrabble board with only one row. The input contains the positions of score modifiers such as: Double Letter, Triple Letter, Double Word and Triple Word. You ne...
{"inputs": ["2\n10\n..d.t.D..d\n10 11 12 9 8 10 11 15\n22\ndtDtTD..ddT.TtTdDT..TD\n12297 5077 28888 17998 12125 27400 31219 21536"], "outputs": ["270\n35629632"]}
636
119
coding
Solve the programming task below in a Python markdown code block. A professor invented Cookie Breeding Machine for his students who like cookies very much. When one cookie with the taste of x is put into the machine and a non-negative integer y less than or equal to 127 is input on the machine, it consumes the cookie ...
{"inputs": ["3\n3 1\n4 4\n1 2", "3\n3 1\n4 50\n1 2", "3\n3 1\n4 75\n1 2", "3\n3 2\n2 98\n1 9", "3\n3 1\n4 75\n1 0", "3\n3 1\n4 64\n1 2", "3\n3 1\n4 37\n1 2", "3\n3 1\n4 89\n1 2"], "outputs": ["255\n504\n2\n", "255\n458\n2\n", "255\n433\n2\n", "256\n156\n9\n", "255\n433\n0\n", "255\n444\n2\n", "255\n471\n2\n", "255\n419...
410
229
coding
Solve the programming task below in a Python markdown code block. Oliver and Nova are true lovers. Inspite of knowing that Nova will die Oliver married her at the lake where they met. But they had a conflict about even and odd numbers. Nova likes the odd numbers and Oliver prefers even. One day they went to a fair wher...
{"inputs": ["1\n111"], "outputs": ["YESS(sunglass emo)"]}
422
22
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For each letter in word, that letter is in puzzle. For example, if th...
{"functional": "def check(candidate):\n assert candidate(\nwords = [\"aaaa\",\"asas\",\"able\",\"ability\",\"actt\",\"actor\",\"access\"], \npuzzles = [\"aboveyz\",\"abrodyz\",\"abslute\",\"absoryz\",\"actresz\",\"gaswxyz\"]) == [1,1,3,2,4,0]\n\n\ncheck(Solution().findNumOfValidWords)"}
190
95
coding
Solve the programming task below in a Python markdown code block. -----Input----- The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid"). -----Output----- Output a single integer. -----E...
{"inputs": ["A221033\n", "A223635\n", "A232726\n", "A102210\n", "A231010\n", "A222222\n", "A555555\n", "A102222\n"], "outputs": ["21\n", "22\n", "23\n", "25\n", "26\n", "13\n", "31\n", "19\n"]}
114
126
coding
Solve the programming task below in a Python markdown code block. Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now that the exams are approaching fast, he is doing book exercises day and night. He writes down and keeps updating the remaining number of exercises...
{"inputs": ["6\n9 english\n6 mathematics\n8 geography\n-1\n3 graphics\n-1", "6\n9 english\n6 mathematics\n6 geography\n-1\n3 grcphias\n-1", "6\n9 english\n6 mathematics\n0 geography\n-1\n3 grcphias\n-1", "6\n9 english\n6 mathematics\n0 geography\n-1\n3 gscphias\n-1", "6\n9 english\n6 mathematics\n8 geography\n-1\n3 hra...
608
283
coding
Solve the programming task below in a Python markdown code block. The next "Data Structures and Algorithms" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson. Nam created a sequence a consisting of n (1 ≤ n ...
{"inputs": ["1\n4\n", "1\n7\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n11\n", "2\n5 4\n", "2\n5 4\n"], "outputs": ["3\n", "3", "3", "3", "3", "3", "22\n", "22"]}
667
87
coding
Solve the programming task below in a Python markdown code block. Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off. You...
{"inputs": ["1\n1\n", "1\n1\n", "1\n5\n", "1\n9\n", "1\n3\n", "1\n4\n", "1\n8\n", "1\n6\n"], "outputs": ["16\n", "16\n", "20\n", "24\n", "18\n", "19\n", "23\n", "21\n"]}
383
94
coding
Solve the programming task below in a Python markdown code block. Roger the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam. You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Eac...
{"inputs": ["#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4", "#.##.##.\n7\n1 8\n2 6\n2 6\n6 8\n3 5\n2 4\n2 5"], "outputs": ["1\n1\n2\n2\n0", "2\n1\n1\n1\n1\n1\n1"]}
354
97
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only cha...
{"inputs": ["4\n1 3\n4 5\n1031 93714\n1000000000123 1000000123456"], "outputs": ["3\n5\n131071\n1000000192511"]}
306
82
coding
Solve the programming task below in a Python markdown code block. There is an infinitely large pond, which we consider as a number line. In this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1. On the lotus at coordinate i, an integer s_i is written. You are standing on the lotus at coordina...
{"inputs": ["5\n0 2 5 0 0", "5\n0 2 5 1 0", "5\n0 2 5 1 0\n", "6\n0 7 -7 -4 0 0", "6\n0 2 -7 -1 -5 0", "6\n0 4 -7 -1 -3 0", "6\n0 4 -7 -1 -1 0", "6\n0 5 -7 -2 -1 0"], "outputs": ["2\n", "3", "3\n", "7\n", "0\n", "1\n", "3\n", "4\n"]}
634
152
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane...
{"functional": "def check(candidate):\n assert candidate(towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2) == [2,1]\n assert candidate(towers = [[23,11,21]], radius = 9) == [23,11]\n assert candidate(towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2) == [1,2]\n\n\ncheck(Solution().bestCoordinate)"}
332
124
coding
Solve the programming task below in a Python markdown code block. You are given a sequence of N$N$ powers of an integer k$k$; let's denote the i$i$-th of these powers by kAi$k^{A_i}$. You should partition this sequence into two non-empty contiguous subsequences; each element of the original sequence should appear in ex...
{"inputs": ["1\n5 2\n1 1 3 3 5"], "outputs": ["4"]}
627
26
coding
Solve the programming task below in a Python markdown code block. Problem Here is a list of strings. Let's take a break and play with shiritori. Shiritori is performed according to the following rules. 1. First of all, select one of your favorite strings from the list and exclude that string from the list. 2. Next, s...
{"inputs": ["5\nuoy\nate\nmy\nhum\ntoast", "5\nuoy\nate\nmy\nhum\ntoasu", "5\nuoy\natf\nmy\nhum\ntoasu", "5\nuyp\natf\nmy\nhum\ntoasu", "5\npyu\nauf\nmy\nhum\ntoasu", "5\npyu\nauf\nmy\nmuh\ntoasu", "5\npyu\nfua\nmy\nmuh\ntoasu", "5\npyu\nfua\nmy\nmui\ntoasu"], "outputs": ["e\nt\ny\n", "e\ny\n", "f\ny\n", "f\np\ny\n", "...
377
206
coding
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Roman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. During a turn the maximal value over a...
{"inputs": ["4 1\n5 0 7 0", "4 1\n5 0 7 1", "4 2\n5 0 7 1", "4 2\n5 0 7 0", "4 0\n2 0 5 0", "4 1\n4 0 0 1", "4 1\n4 0 1 1", "4 1\n4 1 1 1"], "outputs": ["2 7 0 7\n", "2 7 0 6\n", "5 0 7 1\n", "5 0 7 0\n", "2 0 5 0\n", "0 4 4 3\n", "0 4 3 3\n", "0 3 3 3\n"]}
263
190
coding
Solve the programming task below in a Python markdown code block. You are given an unordered array of unique integers incrementing from $\mbox{1}$. You can swap any two elements a limited number of times. Determine the largest lexicographical value array that can be created by executing no more than the limited numbe...
{"inputs": ["2 1\n2 1\n", "3 1\n2 1 3\n"], "outputs": ["2 1\n", "3 1 2\n"]}
640
42
coding
Solve the programming task below in a Python markdown code block. Each floating-point number should be formatted that only the first two decimal places are returned. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Don't round the numbers! Just cut them af...
{"functional": "_inputs = [[10.1289767789], [-7488.83485834983], [4.653725356]]\n_outputs = [[10.12], [-7488.83], [4.65]]\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...
171
218
coding
Solve the programming task below in a Python markdown code block. Alice has a grid with $2$ rows and $n$ columns. She fully covers the grid using $n$ dominoes of size $1 \times 2$ — Alice may place them vertically or horizontally, and each cell should be covered by exactly one domino. Now, she decided to show one row ...
{"inputs": ["4\n1\nU\n2\nLR\n5\nLRDLR\n6\nUUUUUU\n"], "outputs": ["D\nLR\nLRULR\nDDDDDD\n"]}
432
44
coding
Solve the programming task below in a Python markdown code block. Akshat has X rupees to spend in the current month. His daily expenditure is Y rupees, i.e., he spends Y rupees each day. Given that the current month has 30 days, find out if Akshat has enough money to meet his daily expenditures for this month. -----...
{"inputs": ["3\n1000 10\n250 50\n1500 50\n"], "outputs": ["YES\nNO\nYES\n"]}
445
41
coding
Solve the programming task below in a Python markdown code block. You are given an array $a$ that contains $n$ integers. You can choose any proper subsegment $a_l, a_{l + 1}, \ldots, a_r$ of this array, meaning you can choose any two integers $1 \le l \le r \le n$, where $r - l + 1 < n$. We define the beauty of a given...
{"inputs": ["1\n4\n1000000000 1000000000 1000000000 1000000000\n", "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8\n"], "outputs": ["0\n", "9\n297\n0\n14\n"]}
587
135
coding
Solve the programming task below in a Python markdown code block. Taro had his own personal computer and set a password for login. However, Taro inadvertently forgot the password. Then, remembering that there was a piece of paper with the password written down, Taro found the paper and was surprised to see it. The pape...
{"inputs": ["AI[U\n_A", "U[IA\n_A", "U[IA\n^A", "U[HA\n^A", "U[H@\n^A", "U[H@\n^B", "U[H@\nB^", "@H[U\nB^"], "outputs": ["No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]}
226
98
coding
Solve the programming task below in a Python markdown code block. In some ranking people collects points. The challenge is sort by points and calulate position for every person. But remember if two or more persons have same number of points, they should have same position number and sorted by name (name is unique). Fo...
{"functional": "_inputs = [[[]]]\n_outputs = [[[]]]\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_eq...
93
154
coding
Solve the programming task below in a Python markdown code block. The first input array is the key to the correct answers to an exam, like ["a", "a", "b", "d"]. The second one contains a student's submitted answers. The two arrays are not empty and are the same length. Return the score for this array of answers, givi...
{"functional": "_inputs = [[['a', 'a', 'b', 'b'], ['a', 'c', 'b', 'd']], [['a', 'a', 'c', 'b'], ['a', 'a', 'b', '']], [['a', 'a', 'b', 'c'], ['a', 'a', 'b', 'c']], [['b', 'c', 'b', 'a'], ['', 'a', 'a', 'c']]]\n_outputs = [[6], [7], [16], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or i...
273
256
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. Write a function `count_vowels` to count the number of vowels in a given string. ### Notes: - Return `nil` or `None` for non-string inputs. - Return `0` if the parameter is omitted. ### Examples: ```python count_vowels("abcdefg") => 2 count_vowels("a...
{"functional": "_inputs = [['abcdefg'], ['asdfdsafdsafds'], [''], ['asdfdsaf asdfsdaf 13243242 dsafdsafds'], ['aeiouAEIOU'], ['1213'], ['12 3'], ['ewqriwetruituofdsajflsd23423r5043'], ['asdfviosdfopsiewrwwer asdf asdfdsaf)(asdflkajdsf '], ['asdfdsaf asdfsasdfdsafgjlsdjf asdfdsf daf 13243242 dsafdsafds...
133
375
coding
Solve the programming task below in a Python markdown code block. Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another o...
{"inputs": ["2\n1 1\n", "2\n1 0\n", "2\n0 2\n", "2\n2 2\n", "2\n2 0\n", "2\n0 0\n", "2\n1 2\n", "3\n2 2 8\n"], "outputs": ["2\n", "1\n", "2\n", "4\n", "2\n", "0\n", "3\n", "4\n"]}
548
104
coding
Solve the programming task below in a Python markdown code block. You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a_1, a_2, ..., a_{k}, that their sum is equal to n and greatest common divisor is maximal. Greatest common divisor of sequence is maximum ...
{"inputs": ["6 3\n", "8 2\n", "5 3\n", "1 1\n", "1 2\n", "2 1\n", "5 1\n", "6 2\n"], "outputs": ["1 2 3\n", "2 6\n", "-1\n", "1\n", "-1\n", "2\n", "5\n", "2 4\n"]}
188
94
coding
Solve the programming task below in a Python markdown code block. Consider a pyramid made up of blocks. Each layer of the pyramid is a rectangle of blocks, and the dimensions of these rectangles increment as you descend the pyramid. So, if a layer is a `3x6` rectangle of blocks, then the next layer will be a `4x7` rect...
{"functional": "_inputs = [[1, 1, 2], [2, 4, 3], [1, 10, 10], [20, 30, 40]]\n_outputs = [[5], [47], [880], [83540]]\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 ...
385
208
coding
Solve the programming task below in a Python markdown code block. Takahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc. A Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\leq i\leq N-1) connects Vertex a_i and b_i. He would like to make ...
{"inputs": ["7\n1 2\n2 3\n2 4\n2 5\n4 6\n6 7", "7\n1 4\n2 3\n2 4\n4 5\n4 6\n6 7", "7\n1 4\n2 3\n2 4\n4 5\n7 6\n6 7", "7\n1 4\n2 3\n2 4\n1 5\n7 6\n6 7", "7\n1 4\n2 3\n2 4\n1 5\n7 6\n6 5", "7\n1 4\n2 3\n2 4\n4 5\n7 3\n6 3", "7\n1 2\n2 3\n4 4\n1 5\n7 6\n6 7", "7\n1 4\n2 3\n2 4\n1 5\n5 6\n7 7"], "outputs": ["2 4\n", "2 3\n...
522
270
coding
Solve the programming task below in a Python markdown code block. A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall start...
{"inputs": ["8\n1 1 2\n344 3 0\n696 5 0\n73 9 5\n998 8 7\n344 2 19\n696 4 19\n999 10 20", "8\n1 1 2\n344 3 0\n696 5 0\n73 9 5\n998 8 7\n344 2 10\n696 4 19\n999 10 20", "8\n1 1 3\n344 3 0\n696 5 0\n73 9 5\n998 8 7\n344 2 10\n696 4 19\n999 10 20", "8\n1 2 3\n344 3 0\n696 5 0\n73 9 5\n998 8 7\n344 2 10\n696 4 19\n999 10 2...
707
942
coding
Solve the programming task below in a Python markdown code block. Given a number, return a string with dash``` '-' ```marks before and after each odd integer, but do not begin or end the string with a dash mark. Ex: Also feel free to reuse/extend the following starter code: ```python def dashatize(num): ```
{"functional": "_inputs = [[274], [5311], [86320], [974302]]\n_outputs = [['2-7-4'], ['5-3-1-1'], ['86-3-20'], ['9-7-4-3-02']]\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...
71
213
coding
Solve the programming task below in a Python markdown code block. There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate i...
{"inputs": ["1 1\n0\n0\n", "1 1\n1\n1\n", "1 1\n0\n1\n", "1 1\n5\n5\n", "1 1\n0\n-1\n", "2 2\n0 2\n0 1\n", "1 5\n1\n1 2 3 4 5\n", "3 3\n0 0 0\n0 0 0\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "4\n", "3\n", "6\n"]}
582
139
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and 1's, where 0 means empty an...
{"functional": "def check(candidate):\n assert candidate(flowerbed = [1,0,0,0,1], n = 1) == True\n assert candidate(flowerbed = [1,0,0,0,1], n = 2) == False\n\n\ncheck(Solution().canPlaceFlowers)"}
145
73
coding
Solve the programming task below in a Python markdown code block. Fibonacci numbers are generated by setting F0 = 0, F1 = 1, and then using the formula: # Fn = Fn-1 + Fn-2 Your task is to efficiently calculate the **n**th element in the Fibonacci sequence and then count the occurrence of each digit in the number. Ret...
{"functional": "_inputs = [[10]]\n_outputs = [[[[2, 5]]]]\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(_d...
334
161
coding
Solve the programming task below in a Python markdown code block. One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole there are...
{"inputs": ["1\nABB\n", "1\nAAB\n", "1\nBAB\n", "1\nBAC\n", "1\nACB\n", "1\nCAB\n", "1\nC@B\n", "1\nB@C\n"], "outputs": ["ABB\n", "AAB\n", "BAB\n", "BAC\n", "ACB\n", "CAB\n", "C@B\n", "B@C\n"]}
272
102
coding
Solve the programming task below in a Python markdown code block. This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following: * he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing the rest...
{"inputs": ["1 1\n100000\n1 1\n", "6 3\n1 4 5 5 4 3\n1 6\n4 4\n3 3\n", "6 3\n1 2 3 5 4 2\n1 2\n4 4\n3 6\n", "6 3\n1 6 3 4 4 1\n1 6\n2 6\n3 6\n", "6 3\n1 2 3 5 2 2\n1 6\n4 4\n3 6\n", "6 3\n1 2 3 5 4 2\n1 6\n4 4\n3 6\n", "6 3\n1 2 3 5 4 2\n1 6\n4 4\n3 5\n", "6 3\n1 4 3 5 4 2\n1 6\n4 4\n3 5\n"], "outputs": ["1\n", "2\n1\n...
533
293