task_type stringclasses 1
value | problem stringlengths 261 3.34k | answer stringlengths 35 6.15k | problem_tokens int64 62 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character... | {"inputs": ["1 1 1\n1\n", "1 1 1\n1\n", "1 1 2\n1\n", "2 1 1\n1\n2\n", "2 1 2\n1\n2\n", "2 1 2\n1\n4\n", "2 1 1\n1\n1\n", "2 1 1\n1\n2\n"], "outputs": ["Both\n", "Both\n", "Vova\n", "Both\nBoth\n", "Vova\nBoth\n", "Vova\nVova\n", "Both\nBoth\n", "Both\nBoth\n"]} | 449 | 142 |
coding | Solve the programming task below in a Python markdown code block.
# Story
You and a group of friends are earning some extra money in the school holidays by re-painting the numbers on people's letterboxes for a small fee.
Since there are 10 of you in the group each person just concentrates on painting one digit! For e... | {"functional": "_inputs = [[125, 132], [1001, 1001]]\n_outputs = [[[1, 9, 6, 3, 0, 1, 1, 1, 1, 1]], [[2, 2, 0, 0, 0, 0, 0, 0, 0, 0]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list... | 445 | 232 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s consisting of words and spaces, return the length of the last word in the string.
A word is a maximal substring consisting of non-space characters only.
Please complete the following python code pre... | {"functional": "def check(candidate):\n assert candidate(s = \"Hello World\") == 5\n assert candidate(s = \" fly me to the moon \") == 4\n assert candidate(s = \"luffy is still joyboy\") == 6\n\n\ncheck(Solution().lengthOfLastWord)"} | 83 | 72 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially positioned in the top-left r... | {"functional": "def check(candidate):\n assert candidate(dungeon = [[-2,-3,3],[-5,-10,1],[10,30,-5]]) == 7\n assert candidate(dungeon = [[0]]) == 1\n\n\ncheck(Solution().calculateMinimumHP)"} | 258 | 66 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of `n+1` integers `1` through `n`. In addition there is a single duplicate integer.
The array is unsorted.
An example valid array would be `[3, 2, 5, 1, 3, 4]`. It has the integers `1` through `5` and `3` is duplicated. `[1, 2, 4... | {"functional": "_inputs = [[[1, 1, 2, 3]], [[1, 2, 2, 3]], [[5, 4, 3, 2, 1, 1]], [[1, 3, 2, 5, 4, 5, 7, 6]], [[8, 2, 6, 3, 7, 2, 5, 1, 4]]]\n_outputs = [[1], [2], [1], [5], [2]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=t... | 149 | 256 |
coding | Solve the programming task below in a Python markdown code block.
Chef has two piles of stones with him, one has n1 stones and the other has n2 stones. Fired up by boredom, he invented a game with the two piles.
Before the start of the game Chef chooses an integer m.
In the j-th move:
- He chooses a number xj such... | {"inputs": ["3\n1 1 1\n1 2 1\n4 5 2"], "outputs": ["0\n1\n3"]} | 622 | 34 |
coding | Solve the programming task below in a Python markdown code block.
A permutation $p_1,p_2...p_N$ of $\{1, 2, ..., N\}$ is beautiful if $p_i \& p_{i+1}$ is greater than 0 for every $1 \leq i < N$ . You are given an integer $N$, and your task is toconstruct a beautiful permutation of length $N$ or determine that it's impo... | {"inputs": ["3\n4\n3\n5"], "outputs": ["-1\n1 3 2\n2 3 1 5 4"]} | 314 | 35 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diago... | {"functional": "def check(candidate):\n assert candidate(mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]) == [[1,1,1,1],[1,2,2,2],[1,2,3,3]]\n assert candidate(mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]) == [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[... | 157 | 258 |
coding | Solve the programming task below in a Python markdown code block.
Like any good boss, the Chef has delegated all cooking jobs to his employees so he can take care of other tasks. Occasionally, one of the cooks needs a tool that is out of reach. In some of these cases, the cook cannot leave their workstation to get the ... | {"inputs": ["3\n2\n1 0 0 1\n0 0 1 1\n3\n0 3 0 1\n0 4 0 2\n0 5 0 3\n3\n0 1 0 2\n0 1 0 2\n0 1 0 2"], "outputs": ["4\n10\n6"]} | 683 | 87 |
coding | Solve the programming task below in a Python markdown code block.
Vishal Wants to buy 2 gifts for his best friend whose name is Annabelle(her age is 20), So they both went for shopping in a store. But Annabelle gave, Vishal a condition that she will accept this gifts only when the total price of the gifts is the same a... | {"inputs": ["1\n5\n10 2 1000 50 1000"], "outputs": ["Accepted"]} | 420 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.
Each plant needs a specific amount of ... | {"functional": "def check(candidate):\n assert candidate(plants = [2,2,3,3], capacityA = 5, capacityB = 5) == 1\n assert candidate(plants = [2,2,3,3], capacityA = 3, capacityB = 4) == 2\n assert candidate(plants = [5], capacityA = 10, capacityB = 8) == 0\n\n\ncheck(Solution().minimumRefill)"} | 343 | 108 |
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. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.
Return the sum of all subarray ranges of nums.
A subarray is a contiguou... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3]) == 4\n assert candidate(nums = [1,3,3]) == 4\n assert candidate(nums = [4,-2,-3,4,1]) == 59\n\n\ncheck(Solution().subArrayRanges)"} | 105 | 73 |
coding | Solve the programming task below in a Python markdown code block.
CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB).
Specifications of HEX Color Code
■ It must start with a '#' symbol.
■ It can have $3$ or $\boldsymbol{6}$ digits.
■ Each digit i... | {"inputs": ["11\n#BED\n{\n color: #FfFdF8; background-color:#aef;\n font-size: 123px;\n background: -webkit-linear-gradient(top, #f9f9f9, #fff);\n}\n#Cab\n{\n background-color: #ABC;\n border: 2px dashed #fff;\n} \n"], "outputs": ["#FfFdF8\n#aef\n#f9f9f9\n#fff\n#ABC\n#fff\n"]} | 489 | 124 |
coding | Solve the programming task below in a Python markdown code block.
You are given $n$ lengths of segments that need to be placed on an infinite axis with coordinates.
The first segment is placed on the axis so that one of its endpoints lies at the point with coordinate $0$. Let's call this endpoint the "start" of the fi... | {"inputs": ["6\n2\n1 3\n3\n1 2 3\n4\n6 2 3 9\n4\n6 8 4 5\n7\n1 2 4 6 7 7 3\n8\n8 6 5 1 2 2 3 6\n", "6\n2\n1 3\n3\n1 2 3\n4\n2 2 3 9\n4\n6 8 4 5\n7\n1 2 4 6 7 7 3\n8\n8 6 5 1 2 2 3 6\n", "6\n2\n1 3\n3\n1 2 6\n4\n6 2 3 9\n4\n6 8 4 5\n7\n1 2 4 6 7 7 3\n8\n8 6 5 1 2 2 3 6\n", "6\n2\n1 3\n3\n1 2 3\n4\n2 2 3 9\n4\n6 8 4 5\n7... | 702 | 695 |
coding | Solve the programming task below in a Python markdown code block.
problem
AOR Ika is studying to pass the test.
AOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure.
1. Check the correctness of the answer.
2. If the answer is correct, write a circle mark, ... | {"inputs": ["3\nnxx", "3\nnwx", "3\nxxo", "3\nxwn", "3\nowx", "3\npxx", "3\npyx", "3\npzx"], "outputs": ["2\n", "3\n", "1\n", "3\n", "3\n", "2\n", "3\n", "3\n"]} | 306 | 85 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points. Answers within 10-5 of the actual answer will be a... | {"functional": "def check(candidate):\n assert candidate(points = [[0,0],[0,1],[1,0],[0,2],[2,0]]) == 2.00000\n assert candidate(points = [[1,0],[0,0],[0,1]]) == 0.50000\n\n\ncheck(Solution().largestTriangleArea)"} | 103 | 85 |
coding | Solve the programming task below in a Python markdown code block.
You are given four points $A,B,C$ and $\mbox{D}$ in a 3-dimensional Cartesian coordinate system. You are required to print the angle between the plane made by the points $A,B,C$ and $B,C,D$ in degrees(not radians). Let the angle be $\textit{PHI}$.
$\te... | {"inputs": ["0 4 5\n1 7 6\n0 5 9\n1 7 2\n"], "outputs": ["8.19\n"]} | 290 | 39 |
coding | Solve the programming task below in a Python markdown code block.
John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3.
A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that ... | {"inputs": ["5\n", "7\n", "4\n", "9\n", "6\n", "2\n", "8\n", "3\n"], "outputs": ["5\n01111\n10111\n11010\n11100\n11000\n", "5\n01111\n10111\n11011\n11100\n11100\n", "4\n0111\n1011\n1101\n1110\n", "7\n0111111\n1011111\n1101100\n1110000\n1110000\n1100000\n1100000\n", "6\n011111\n101111\n110100\n111000\n110000\n110000\n",... | 356 | 340 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
We define the string base to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so base will look like this:
"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".
Given a string s, retu... | {"functional": "def check(candidate):\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"cac\") == 2\n assert candidate(s = \"zab\") == 6\n\n\ncheck(Solution().findSubstringInWraproundString)"} | 102 | 60 |
coding | Solve the programming task below in a Python markdown code block.
You are given a permutation P of length N. You can perform the following operation on P:
Choose any i and j such that i < j and P_{i} < P_{j}, and remove exactly one of them from the array. After removing, the remaining parts of the array are concatenate... | {"inputs": ["3\n4\n3 1 2 4\n3\n2 3 1\n6\n5 2 3 6 1 4\n"], "outputs": ["YES\nNO\nYES\n"]} | 675 | 50 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.
The ith item... | {"functional": "def check(candidate):\n assert candidate(items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"color\", ruleValue = \"silver\") == 1\n assert candidate(items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[... | 179 | 112 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Recently Chef bought a bunch of robot-waiters. And now he needs to know how much to pay for the electricity that robots use for their work. All waiters serve food from the kitchen (which is in ... | {"inputs": ["2\n3 3\n3 4", "2\n3 3\n3 0", "2\n5 3\n3 0", "2\n5 3\n6 0", "2\n5 3\n6 1", "2\n5 2\n6 1", "2\n3 2\n6 1", "2\n1 2\n6 1"], "outputs": ["6\n7", "6\n7\n", "10\n7\n", "10\n12\n", "10\n13\n", "11\n13\n", "7\n13\n", "3\n13\n"]} | 321 | 150 |
coding | Solve the programming task below in a Python markdown code block.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the ave... | {"inputs": ["0 0\n0 1\n0 2\n1 0\n1 2\n2 0\n2 1\n2 2\n", "0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n", "1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n", "0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "0 0\n1 0\n0 1\n1 1\n0 2\n1 2\n0 3\n1 3\n", "0 0\n2 1\n1 0\n0 2\n2 2\n1 0\n2 1\n0 2\n", "0 0\n2 1\n1 0\n0 2\n2 2\n1 0\n2 1\n0 2\n", ... | 388 | 318 |
coding | Solve the programming task below in a Python markdown code block.
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.
There are M kinds of regular boat services between these islands. Each service connects two islan... | {"inputs": ["3 2\n1 2\n0 3", "3 2\n1 2\n2 3", "4 3\n1 3\n2 3\n3 4", "4 3\n1 3\n3 3\n3 4", "4 3\n1 1\n2 3\n3 4", "4 2\n1 3\n2 3\n3 4", "4 3\n1 1\n2 5\n3 4", "4 2\n1 3\n2 3\n0 4"], "outputs": ["IMPOSSIBLE\n", "POSSIBLE", "POSSIBLE\n", "POSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n"]} | 403 | 186 |
coding | Solve the programming task below in a Python markdown code block.
Chef is playing a game on the non-negative x-axis. It takes him $1$ second to reach from $i^{th}$ position to $(i-1)^{th}$ position or $(i+1)^{th}$ position. The chef never goes to the negative x-axis. Also, Chef doesn't stop at any moment of time.
The ... | {"inputs": ["5\n0 1\n1 1\n2 1\n1 3\n4 6"], "outputs": ["0\n1\n4\n5\n46"]} | 748 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Sunita has lots of tasks pending and she has no time to complete. She needs your help and wants you complete the task.
You are given a list of integers and two values $N$ and $K$ $-$ the size of array of integers and the numbers of partitions to be made... | {"inputs": ["1\n4 2\n5 6 3 2"], "outputs": ["6"]} | 340 | 24 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
There is a haunted town called HauntedLand. The structure of HauntedLand can be thought of as a grid of size n * m. There is a house in each cell of the grid. Some people hav... | {"inputs": ["2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*..", "2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*.."], "outputs": ["1\n2", "1\n2"]} | 581 | 66 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off.
You are given a 2D array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[ro... | {"functional": "def check(candidate):\n assert candidate(n = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]) == [1,0]\n assert candidate(n = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,1]]) == [1,1]\n assert candidate(n = 5, lamps = [[0,0],[0,4]], queries = [[0,4],[0,1],[1,4]]) == [1,1,0]\n\n\ncheck(Solut... | 298 | 138 |
coding | Solve the programming task below in a Python markdown code block.
problem
Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could ... | {"inputs": ["3\n2 3\n7\n0\n37\n110", "3\n2 1\n7\n0\n37\n110", "3\n2 1\n7\n0\n37\n010", "3\n2 1\n2\n0\n35\n010", "3\n2 2\n2\n0\n35\n000", "3\n5 2\n1\n0\n45\n101", "3\n1 2\n1\n0\n45\n101", "3\n2 1\n8\n0\n37\n010"], "outputs": ["23\n", "39\n", "14\n", "12\n", "9\n", "16\n", "34\n", "15\n"]} | 737 | 189 |
coding | Solve the programming task below in a Python markdown code block.
Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is v_{i}. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: She wi... | {"inputs": ["1\n1\n2\n1 1 1\n2 1 1\n", "1\n1\n2\n1 1 1\n2 1 1\n", "6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6\n", "6\n6 6 3 8 5 4\n3\n2 2 3\n2 1 5\n1 1 5\n", "6\n6 6 3 8 5 4\n3\n2 2 3\n2 1 5\n1 1 5\n", "6\n6 6 3 8 5 6\n3\n2 2 3\n2 1 5\n1 1 5\n", "6\n1 6 3 8 5 6\n3\n2 2 3\n2 1 5\n1 1 5\n", "6\n1 1 3 8 5 6\n3\n2 2 3\n2 1 5\n... | 603 | 335 |
coding | Solve the programming task below in a Python markdown code block.
Given a string `s` of uppercase letters, your task is to determine how many strings `t` (also uppercase) with length equal to that of `s` satisfy the followng conditions:
* `t` is lexicographical larger than `s`, and
* when you write both `s` and `t` in... | {"functional": "_inputs = [['XYZ'], ['ABC'], ['ABCD'], ['ZAZ'], ['XYZA']]\n_outputs = [[5], [16174], [402230], [25], [34480]]\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)... | 200 | 195 |
coding | Solve the programming task below in a Python markdown code block.
Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it.
There is integer n and array a, consisting of ten integers, indexed by n... | {"inputs": ["6\n2 2 2 0 0 0 0 0 0 0\n", "4\n1 1 2 0 0 0 0 0 0 0\n", "8\n1 0 1 0 1 1 2 2 0 0\n", "6\n0 1 0 1 1 0 0 0 1 0\n", "6\n1 1 0 1 2 1 0 0 0 0\n", "7\n0 0 2 2 1 0 1 0 0 0\n", "6\n1 1 1 1 1 1 0 0 0 0\n", "4\n0 0 1 0 1 0 0 0 1 1\n"], "outputs": ["60\n", "9\n", "8820\n", "23160\n", "300\n", "9660\n", "600\n", "24\n"]... | 399 | 246 |
coding | Solve the programming task below in a Python markdown code block.
Demodogs from the Upside-down have attacked Hawkins again. El wants to reach Mike and also kill as many Demodogs in the way as possible.
Hawkins can be represented as an $n \times n$ grid. The number of Demodogs in a cell at the $i$-th row and the $j$-t... | {"inputs": ["4\n2\n3\n50\n1000000000\n"], "outputs": ["14154\n44484\n171010650\n999589541\n"]} | 545 | 62 |
coding | Solve the programming task below in a Python markdown code block.
To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:
- 1 yen (the currency of Japan)
- 6 yen, 6^2(=36) yen, 6^3(=216) yen, ...
- 9 yen, 9^2(=81) yen, 9^3(=729) yen,... | {"inputs": ["1", "0", "8", "2", "5", "6", "4", "9"], "outputs": ["1\n", "0\n", "3\n", "2\n", "5\n", "1\n", "4\n", "1\n"]} | 257 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:
The value of the first element in arr must be 1.
The absolute difference between ... | {"functional": "def check(candidate):\n assert candidate(arr = [2,2,1,2,1]) == 2\n assert candidate(arr = [100,1,1000]) == 3\n assert candidate(arr = [1,2,3,4,5]) == 5\n\n\ncheck(Solution().maximumElementAfterDecrementingAndRearranging)"} | 222 | 89 |
coding | Solve the programming task below in a Python markdown code block.
A sequence of $n$ numbers is called a permutation if it contains all integers from $1$ to $n$ exactly once. For example, the sequences [$3, 1, 4, 2$], [$1$] and [$2,1$] are permutations, but [$1,2,1$], [$0,1$] and [$1,3,4$] — are not.
Polycarp lost his ... | {"inputs": ["1\n1 2\n4\n", "1\n2 4\n5 1\n", "1\n3 13\n4 1 3\n", "1\n7 489\n5 29 12 16 25 36 18\n", "2\n1 9\n2\n9 9\n11 6 5 13 7 10 2 3 12\n", "5\n3 13\n3 1 4\n1 1\n1\n3 3\n1 4 2\n2 1\n4 3\n5 6\n1 2 3 4 5\n", "1\n50 870\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3... | 695 | 352 |
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 | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.
Please complete the following python... | {"functional": "def check(candidate):\n assert candidate(matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]) == True\n assert candidate(matrix = [[1,2],[2,2]]) == False\n\n\ncheck(Solution().isToeplitzMatrix)"} | 96 | 72 |
coding | Solve the programming task below in a Python markdown code block.
Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permuta... | {"inputs": ["1 0\n", "2 1\n", "3 2\n", "4 1\n", "7 4\n", "7 7\n", "8 4\n", "8 5\n"], "outputs": ["1\n", "0\n", "4\n", "6\n", "328\n", "0\n", "2658\n", "688\n"]} | 425 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number b_{i}. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. Sh... | {"inputs": ["2\n1 2\n", "2\n1 1\n", "2\n5 6\n", "2\n3 2\n", "2\n1 1\n", "2\n3 2\n", "2\n5 6\n", "2\n0 1\n"], "outputs": ["1 1", "0 1", "1 1", "1 1", "0 1\n", "1 1\n", "1 1\n", "1 1\n"]} | 363 | 114 |
coding | Solve the programming task below in a Python markdown code block.
You are given a binary string S.
In one second, the following scenario happens simultaneously and independently for all the bits which are set to 1 in the string:
Change the bit from 1 to 0.
If the left neighbour exists and is 0, change it to 1.
If the... | {"inputs": ["3\n3 1\n101\n5 2\n10001\n14 3\n10011010111000"], "outputs": ["010\n10101\n01100101010101"]} | 532 | 73 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from nums1 of length k.
For chosen indices i0, i1, ..., ik - 1, your scor... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,3,3,2], nums2 = [2,1,3,4], k = 3) == 12\n assert candidate(nums1 = [4,2,3,1,1], nums2 = [7,5,10,9,6], k = 1) == 30\n\n\ncheck(Solution().maxScore)"} | 236 | 98 |
coding | Solve the programming task below in a Python markdown code block.
Cirno_9baka has a paper tape with $n$ cells in a row on it. As he thinks that the blank paper tape is too dull, he wants to paint these cells with $m$ kinds of colors. For some aesthetic reasons, he thinks that the $i$-th color must be used exactly $a_i$... | {"inputs": ["1\n7 3 3\n3 3 1\n", "1\n12 5 5\n3 3 3 2 1\n", "2\n12 6 2\n1 1 1 1 1 7\n12 6 2\n2 2 2 2 2 2\n", "10\n2 1 1\n2\n2 1 1\n2\n1 1 1\n1\n1 1 1\n1\n1 1 1\n1\n2 1 1\n2\n1 1 1\n1\n1 1 1\n1\n2 1 1\n2\n2 1 1\n2\n", "10\n1 1 1\n1\n1 1 1\n1\n2 1 1\n2\n2 1 1\n2\n2 1 1\n2\n2 1 1\n2\n2 1 1\n2\n2 1 1\n2\n1 1 1\n1\n2 1 1\n2\... | 569 | 313 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Bitsetbaba Ashiq works in a power grid, which consists of $2^{K}$ power stations (numbered $0$ through $2^{K}-1$). Initially, there are no connection... | {"inputs": ["2\n2 1\n0\n2 1\n2"], "outputs": ["4\n2"]} | 574 | 26 |
coding | Solve the programming task below in a Python markdown code block.
Watson gives four 3-dimensional points to Sherlock and asks him if they all lie in the same plane. Your task here is to help Sherlock.
Input Format
First line contains T, the number of testcases.
Each test case consists of four lines. Each line c... | {"inputs": ["1\n1 2 0\n2 3 0\n4 0 0\n0 0 0\n"], "outputs": ["YES\n"]} | 213 | 38 |
coding | Solve the programming task below in a Python markdown code block.
*This section assumes that you understand the basics discussed in HTML Parser - Part 1
.handle_comment(data)
This method is called when a comment is encountered (e.g. <!--comment-->).
The data argument is the content inside the comment tag:
from HT... | {"inputs": ["4\n<!--[if IE 9]>IE9-specific content\n<![endif]-->\n<div> Welcome to HackerRank</div>\n<!--[if IE 9]>IE9-specific content<![endif]-->\n"], "outputs": [">>> Multi-line Comment\n[if IE 9]>IE9-specific content\n<![endif]\n>>> Data\n Welcome to HackerRank\n>>> Single-line Comment\n[if IE 9]>IE9-specific conte... | 440 | 103 |
coding | Solve the programming task below in a Python markdown code block.
>
**Note**: This kata is a translation of this (Java) one: http://www.codewars.com/kata/rotate-array. I have not translated this first one as usual because I did not solved it, and I fear not being able to solve it (Java is **not** my cup of... tea). @c... | {"functional": "_inputs = [[['a', 'b', 'c'], 1], [[1.0, 2.0, 3.0], 1], [[True, True, False], 1]]\n_outputs = [[['c', 'a', 'b']], [[3.0, 1.0, 2.0]], [[False, True, True]]]\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... | 703 | 221 |
coding | Solve the programming task below in a Python markdown code block.
Given is a permutation P_1, \ldots, P_N of 1, \ldots, N.
Find the number of integers i (1 \leq i \leq N) that satisfy the following condition:
- For any integer j (1 \leq j \leq i), P_i \leq P_j.
-----Constraints-----
- 1 \leq N \leq 2 \times 10^5
... | {"inputs": ["1\n0", "1\n1", "1\n1\n", "1\n-1", "1\n-2", "1\n-4", "4\n4 3 2 1", "4\n4 3 2 1\n"], "outputs": ["1\n", "1", "1\n", "1\n", "1\n", "1\n", "4", "4\n"]} | 260 | 93 |
coding | Solve the programming task below in a Python markdown code block.
## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto n number of rows.
* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.
### Rules/Note:
* The pattern should be create... | {"functional": "_inputs = [[1], [2], [3], [7], [17], [27], [0], [-89]]\n_outputs = [['1'], ['22\\n21'], ['333\\n322\\n321'], ['7777777\\n7666666\\n7655555\\n7654444\\n7654333\\n7654322\\n7654321'], ['77777777777777777\\n76666666666666666\\n76555555555555555\\n76544444444444444\\n76543333333333333\\n76543222222222222\\n... | 637 | 1,373 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n matrix grid consisting of positive integers.
Perform the following operation until grid becomes empty:
Delete the element with the greatest value from each row. If multiple such elements exist,... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,2,4],[3,3,1]]) == 8\n assert candidate(grid = [[10]]) == 10\n\n\ncheck(Solution().deleteGreatestValue)"} | 129 | 57 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.
Please complete the following python code pr... | {"functional": "def check(candidate):\n assert candidate(nums = [10,5,2,6], k = 100) == 8\n assert candidate(nums = [1,2,3], k = 0) == 0\n\n\ncheck(Solution().numSubarrayProductLessThanK)"} | 92 | 71 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
Constraints
* The length of S is 2 or 3.
* S consists of lower... | {"inputs": ["bc", "cb", "cc", "dc", "cd", "ec", "fc", "cf"], "outputs": ["bc\n", "cb\n", "cc\n", "dc\n", "cd\n", "ec\n", "fc\n", "cf\n"]} | 144 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == [24,12,8,6]\n assert candidate(nums = [-1,1,0,-3,3]) == [0,0,9,0,0]\n\n\ncheck(Solution().productExceptSelf)"} | 122 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Every day we can send from the server a certain limit of e-mails.
Task:
Write a function that will return the integer number of e-mails sent in the percentage of the limit.
Example:
```
limit - 1000;
emails sent - 101;
return - 10%; // becou... | {"functional": "_inputs = [[101, 1000], [256, 500], [259], [0], [1000, 1000]]\n_outputs = [['10%'], ['51%'], ['25%'], ['No e-mails sent'], ['Daily limit is reached']]\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... | 209 | 216 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob are decorating a Christmas Tree.
Alice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.
In Bob's opinion, a Christmas Tree... | {"inputs": ["1 2 3\n", "9 5 5\n", "1 3 4\n", "6 5 7\n", "1 5 4\n", "3 2 4\n", "3 3 5\n", "3 2 3\n"], "outputs": ["6", "12", "6", "15", "6", "6", "9", "6"]} | 513 | 96 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ students standing in a circle in some order. The index of the $i$-th student is $p_i$. It is guaranteed that all indices of students are distinct integers from $1$ to $n$ (i. e. they form a permutation).
Students want to start a round danc... | {"inputs": ["1\n11\n11 2 3 4 5 6 7 8 9 10 1\n", "1\n11\n11 2 1 4 5 6 7 8 9 10 1\n", "1\n11\n11 2 1 4 5 6 7 9 9 10 1\n", "1\n11\n11 2 3 4 5 6 7 4 9 10 1\n", "1\n11\n11 2 3 4 5 6 7 13 9 10 1\n", "1\n11\n11 2 3 4 5 6 7 13 5 10 1\n", "1\n11\n11 2 3 6 5 6 7 13 5 10 1\n", "1\n11\n11 2 6 6 5 6 7 13 5 10 1\n"], "outputs": ["NO... | 605 | 290 |
coding | Solve the programming task below in a Python markdown code block.
Given is a positive integer N.
Find the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:
- When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit o... | {"inputs": ["0", "6", "9", "2", "3", "7", "5", "8"], "outputs": ["0\n", "6\n", "9\n", "2\n", "3\n", "7\n", "5\n", "8\n"]} | 262 | 62 |
coding | Solve the programming task below in a Python markdown code block.
There are N sweets in the store. The cost of the i^{th} sweet is A_{i} rupees. Chef is a regular customer, so after buying the i^{th} sweet, he gets a cashback of B_{i} rupees.
Chef has R rupees. He is fond of all the sweets, so he wants you to calculat... | {"inputs": ["3\n3 3\n2 3 4\n1 1 1\n2 4\n5 4\n1 2\n4 10\n4 4 5 5\n1 2 4 2"], "outputs": ["2\n1\n7\n"]} | 526 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a binary tree. The binary tree consists of 1 or more nodes. Each node has a unique integer id. Each node has up to 2 children, which are identified by their ids, and each node is the child of at most 1 other node. A node X is considered to be an... | {"inputs": ["2\n1\n4 0\n6\n1 5\n2 0\n3 0\n4 0\n5 5\n6 5", "2\n1\n4 0\n6\n1 8\n2 0\n3 0\n4 0\n5 5\n6 5", "2\n1\n4 0\n6\n0 8\n2 0\n3 0\n4 0\n5 5\n6 5", "2\n1\n4 0\n6\n1 8\n2 0\n3 0\n4 0\n5 5\n6 4", "2\n1\n4 0\n6\n1 8\n2 0\n3 0\n4 0\n5 5\n6 7", "2\n1\n0 0\n6\n1 8\n2 0\n3 0\n4 0\n5 5\n6 4", "2\n1\n4 0\n6\n1 5\n2 1\n3 0\n4 ... | 497 | 333 |
coding | Solve the programming task below in a Python markdown code block.
On an $8 \times 8$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the cells through whi... | {"inputs": ["4\n\n....B...\n....B...\n....B...\nRRRRRRRR\n....B...\n....B...\n....B...\n....B...\n\nRRRRRRRB\nB......B\nB......B\nB......B\nB......B\nB......B\nB......B\nRRRRRRRB\n\nRRRRRRBB\n.B.B..BB\nRRRRRRBB\n.B.B..BB\n.B.B..BB\nRRRRRRBB\n.B.B..BB\n.B.B..BB\n\n........\n........\n........\nRRRRRRRR\n........\n......... | 459 | 157 |
coding | Solve the programming task below in a Python markdown code block.
There are N slimes standing on a number line. The i-th slime from the left is at position x_i.
It is guaruanteed that 1 \leq x_1 < x_2 < \ldots < x_N \leq 10^{9}.
Niwango will perform N-1 operations. The i-th operation consists of the following procedu... | {"inputs": ["3\n1 2 5", "3\n1 3 5", "3\n1 3 3", "3\n1 0 3", "3\n1 2 3", "3\n1 2 10", "3\n1 3 10", "3\n0 2 10"], "outputs": ["11\n", "10\n", "4\n", "7\n", "5", "26\n", "25\n", "28\n"]} | 442 | 117 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food: on Mondays, Thursdays and Sundays he eats fish food; on Tuesdays and Saturdays he eats rabbit stew; on other days of week he eats chicken st... | {"inputs": ["2 1 1\n", "3 2 2\n", "4 1 2\n", "2 8 9\n", "3 1 4\n", "3 2 1\n", "5 4 3\n", "1 1 2\n"], "outputs": ["4\n", "7\n", "6\n", "6\n", "6\n", "6\n", "12\n", "4\n"]} | 525 | 103 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ positive integers $a_1, a_2, \dots, a_n$. For the one move you can choose any even value $c$ and divide by two all elements that equal $c$.
For example, if $a=[6,8,12,6,3,12]$ and you choose $c=6$, and $a$ is transformed into $a=[3,8,12,3,... | {"inputs": ["4\n6\n40 6 40 3 20 1\n1\n1024\n4\n2 4 8 16\n3\n3 1 7\n"], "outputs": ["4\n10\n4\n0\n"]} | 633 | 64 |
coding | Solve the programming task below in a Python markdown code block.
When Mr. Kay was browsing a certain SNS as usual, the problem that "there are people who can solve IQ150 or more" came to the timeline. Mr. Kay has an IQ of over 150, so he solved the problem in an instant without even looking at it. For him, he doesn't ... | {"inputs": ["5", "2", "7", "1", "4", "8", "3", "6"], "outputs": ["0\n", "1\n", "0\n", "0\n", "1\n", "1\n", "0\n", "1\n"]} | 549 | 62 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Write a function that accepts `msg` string and returns local tops of string from the highest to the lowest.
The string's tops are from displaying the string in the below way:
```
7891012
... | {"functional": "_inputs = [[''], ['abcde'], ['123456789abcdefghijklmnopqrstuwyxvzABCDEFGHIJKLMNOPQRSTU'], ['123456789abcdefghijklmnopqrstuwyxvzABCDEFGHIJKLMNOPQRSTUWvXYZ123456789012345678910123']]\n_outputs = [[''], ['cd'], ['TUABCDElmnoabc34'], ['7891012TUWvXYABCDElmnoabc34']]\nimport math\ndef _deep_eq(a, b, tol=1e-5... | 433 | 256 |
coding | Solve the programming task below in a Python markdown code block.
$Riggi$ is a spy of $KBI$ and he is on a secret mission, he is spying an Underworld Don $Anit$.
$Riggi$ is spying him since 5 years and he is not able to find any evidence against $Anit$.
$KBI$ told $Riggi$ they will send him a code string in a spe... | {"inputs": ["3+xy-bb3+yx-", "3+xy-bb3+xy-"], "outputs": ["Return", "Continue"]} | 467 | 33 |
coding | Solve the programming task below in a Python markdown code block.
Rupsa really loves triangles. One day she came across an equilateral triangle having length of each side as an integer N. She started wondering if it was possible to transform the triangle keeping two sides fixed and alter the third side such that it sti... | {"inputs": ["2\n5\n3"], "outputs": ["YES\nNO"]} | 342 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.
To obfuscate the code, Kostya ... | {"inputs": ["a\n", "z\n", "b\n", "x\n", "c\n", "z\n", "c\n", "b\n"], "outputs": ["YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 408 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
Please complete the following python code precisely:
```python
class So... | {"functional": "def check(candidate):\n assert candidate(grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]) == 8\n assert candidate(grid = [[3,2],[1,0]]) == 0\n\n\ncheck(Solution().countNegatives)"} | 81 | 80 |
coding | Solve the programming task below in a Python markdown code block.
problem
Once upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to the locati... | {"inputs": ["10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n2 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0", "10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 1\n5 3\n0 5\n5 2\n10\n2 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0", "10\n9 4\n4 4\n1 1\n4 2\n2 5\n5 8\n4 1\n5 3\n0 5\n5 2\n10\n2 4\n4 3\n1 1\n4 2\n2 4... | 535 | 774 |
coding | Solve the programming task below in a Python markdown code block.
Sakuzyo - Imprinting
A.R.C. Markland-N is a tall building with $n$ floors numbered from $1$ to $n$. Between each two adjacent floors in the building, there is a staircase connecting them.
It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he'... | {"inputs": ["1\n10 1 1\n1\n", "1\n10 1 1\n1\n", "1\n10 9 2\n8 2\n", "1\n10 9 2\n8 2\n", "1\n110 8 1\n32\n", "1\n100 32 1\n32\n", "1\n100 32 1\n32\n", "1\n100 55 1\n32\n"], "outputs": ["1\n", "1\n", "0\n", "0\n", "0\n", "1\n", "1\n", "0\n"]} | 660 | 157 |
coding | Solve the programming task below in a Python markdown code block.
##Background - the Collatz Conjecture:
Imagine you are given a positive integer, `n`, then:
* if `n` is even, calculate: `n / 2`
* if `n` is odd, calculate: `3 * n + 1`
Repeat until your answer is `1`. The Collatz conjecture states that performing thi... | {"functional": "_inputs = [[[1, 5, 27, 4]], [[64, 64, 27, 64]], [[75, 226, 113, 340]], [[340, 113, 226, 75]], [[75, 113, 226, 75]]]\n_outputs = [[27], [27], [75], [75], [75]]\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,... | 436 | 255 |
coding | Solve the programming task below in a Python markdown code block.
The following problem is well-known: given integers n and m, calculate $2^{n} \operatorname{mod} m$,
where 2^{n} = 2·2·...·2 (n factors), and $x \operatorname{mod} y$ denotes the remainder of division of x by y.
You are asked to solve the "reverse" pr... | {"inputs": ["1\n1\n", "1\n2\n", "2\n1\n", "2\n2\n", "2\n3\n", "2\n4\n", "2\n5\n", "3\n8\n"], "outputs": ["1\n", "0\n", "1\n", "2\n", "3\n", "0\n", "1\n", "0\n"]} | 298 | 86 |
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.
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.
He has N pa... | {"inputs": ["2\n1 5\n2 4\n3 6\n", "3\n1 1 1\n2 2 2\n3 3 3\n", "6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n"], "outputs": ["3\n", "27\n", "87\n"]} | 470 | 116 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a new customer and he wants to prepare his order as soon as possible. While preparing, he sees that the mint sauce is finished. He has to run upstairs to get it from other kitchen. Chef is currently on the X^{th} stair. He has to climb all the w... | {"inputs": ["4\n2 10\n5 12\n34 43\n57 63"], "outputs": ["6\n5\n6\n4"]} | 611 | 40 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.
A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to ... | {"functional": "def check(candidate):\n assert candidate(root1 = tree_node([1,2,3,4,5,6,None,None,None,7,8]), root2 = tree_node([1,3,2,None,6,4,5,None,None,None,None,8,7])) == True\n\n\ncheck(Solution().flipEquiv)"} | 195 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has array A consisting of N integers. He calls a sub-array of the array good if the bitwise OR of all the elements in it is greater or equal than number K. Please help h... | {"inputs": ["2\n3 3\n1 2 3\n3 6\n3 4 5"], "outputs": ["4\n2"]} | 267 | 34 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules.
Email address:
An email address is:
A name consisti... | {"functional": "def check(candidate):\n assert candidate(s = \"LeetCode@LeetCode.com\") == \"l*****e@leetcode.com\"\n assert candidate(s = \"AB@qq.com\") == \"a*****b@qq.com\"\n assert candidate(s = \"1(234)567-890\") == \"***-***-7890\"\n\n\ncheck(Solution().maskPII)"} | 360 | 94 |
coding | Solve the programming task below in a Python markdown code block.
There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains a_{i} balls, all of which have color i. You have to write a program that will divide all balls into sets such that: each ball belongs to exactly one of... | {"inputs": ["1\n1\n", "1\n1\n", "2\n2 7\n", "2\n9 6\n", "2\n9 6\n", "2\n9 1\n", "2\n2 3\n", "2\n3 5\n"], "outputs": ["1\n", "1\n", "4\n", "5\n", "5\n", "6\n", "2\n", "3\n"]} | 294 | 98 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Write a method to compute all permutations of a string whose characters are not necessarily unique. The list of permutations should not have duplicates.
Please complete the following python code precisely:
```python
c... | {"functional": "def check(candidate):\n assert candidate(S = \"qqe\") == [\"eqq\",\"qeq\",\"qqe\"]\n assert candidate(S = \"ab\") == [\"ab\", \"ba\"]\n\n\ncheck(Solution().permutation)"} | 72 | 60 |
coding | Solve the programming task below in a Python markdown code block.
You love array, don't you?
You are given two integer N and M, along with an array B of length N containing pairwise distinct integers. You have to find the number of array A of length N satisfying the follow conditions:
1. 1 ≤ A_{i} ≤ M.
2. A_{i} \neq ... | {"inputs": ["2 2\n1 3", "3 4\n5 1 2"], "outputs": ["1", "14"]} | 594 | 33 |
coding | Solve the programming task below in a Python markdown code block.
The professor is conducting a course on Discrete Mathematics to a class of N students. He is angry at the lack of their discipline, and he decides to cancel the class if there are fewer than K students present after the class starts.
Given the arrival t... | {"inputs": ["2\n4 3\n-1 -3 4 2\n4 2\n0 -1 2 1", "10\n10 4\n-93 -86 49 -62 -90 -63 40 72 11 67\n10 10\n23 -35 -2 58 -67 -56 -42 -73 -19 37\n10 9\n13 91 56 -62 96 -5 -84 -36 -46 -13\n10 8\n45 67 64 -50 -8 78 84 -51 99 60\n10 7\n26 94 -95 34 67 -97 17 52 1 86\n10 2\n19 29 -17 -71 -75 -27 -56 -53 65 83\n10 10\n-32 -3 -70 8... | 440 | 412 |
coding | Solve the programming task below in a Python markdown code block.
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.
He is famous across the country for his ability to foresee... | {"inputs": ["2\n1 2", "2\n2 3", "2\n2 5", "2\n4 5", "2\n2 7", "2\n7 8", "2\n2 6", "2\n3 5"], "outputs": ["2000\n", "1500\n", "2500\n", "1250\n", "3500\n", "1142\n", "3000\n", "1666\n"]} | 398 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v_1 milliseconds and has ping t_1 milliseconds. The second parti... | {"inputs": ["5 1 2 1 2\n", "3 3 1 1 1\n", "4 5 3 1 5\n", "1 1 1 1 1\n", "8 8 1 1 1\n", "1 2 8 8 5\n", "1 2 8 9 8\n", "2 9 8 8 9\n"], "outputs": ["First\n", "Second\n", "Friendship\n", "Friendship\n", "Second\n", "Friendship\n", "First\n", "Friendship\n"]} | 506 | 138 |
coding | Solve the programming task below in a Python markdown code block.
This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one ... | {"inputs": ["2\nSHILPA\nAAMIR\nMATT\nDENISE\n\n\n"], "outputs": ["ENEMIES\nLOVE"]} | 376 | 34 |
coding | Solve the programming task below in a Python markdown code block.
The *fuel economy* of a car is the distance which it can travel on one litre of fuel.
The base fuel economy (i.e, its fuel economy when there is only one person - the driver - in the car) of a certain car is M kilometres per litre. It was also observed ... | {"inputs": ["3\n5 10 20\n1 6 10\n4 6 1"], "outputs": ["120\n60\n3"]} | 542 | 40 |
coding | Solve the programming task below in a Python markdown code block.
You have been appointed as the designer for your school's computer network.
In total, there are N computers in the class, and M computer-to-computer connections need to be made. Also, there are three mandatory conditions the design should fulfill.
The fi... | {"inputs": ["2\n10 1\n5 5"], "outputs": ["-1 -1\n1 2\n2 3\n3 4\n4 5\n5 1"]} | 528 | 44 |
coding | Solve the programming task below in a Python markdown code block.
For a given polygon g, print "1" if g is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.
g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and... | {"inputs": ["4\n0 0\n3 0\n2 1\n0 3", "4\n0 0\n3 1\n2 1\n0 3", "4\n0 0\n3 0\n2 0\n0 3", "4\n0 0\n3 1\n2 0\n0 3", "4\n0 0\n3 1\n2 1\n0 2", "4\n0 0\n3 1\n2 3\n0 3", "4\n0 0\n3 1\n2 1\n-1 2", "4\n0 0\n3 1\n2 1\n-1 4"], "outputs": ["1\n", "0\n", "0\n", "0\n", "0\n", "1", "0\n", "0\n"]} | 316 | 191 |
coding | Solve the programming task below in a Python markdown code block.
You will be given a string (x) featuring a cat 'C' and a mouse 'm'. The rest of the string will be made up of '.'.
You need to find out if the cat can catch the mouse from it's current position. The cat can jump over three characters. So:
C.....m retu... | {"functional": "_inputs = [['C....m'], ['C..m'], ['C.....m'], ['C.m'], ['m...C']]\n_outputs = [['Escaped!'], ['Caught!'], ['Escaped!'], ['Caught!'], ['Caught!']]\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)... | 135 | 194 |
coding | Solve the programming task below in a Python markdown code block.
A country has coins with denominations
```python
coins_list = d1 < d2 < · · · < dn.
```
You want to make change for n cents, using the smallest number of coins.
```python
# Example 1: U.S. coins
d1 = 1 d2 = 5 d3 = 10 d4 = 25
## Optimal change for 37 ce... | {"functional": "_inputs = [[[1, 5, 10, 25], 37], [[1, 3, 4], 6], [[25, 5, 10, 1, 21], 63], [[1, 4, 5, 10], 8], [[1, 2, 5, 10, 20, 50, 100, 200], 93]]\n_outputs = [[4], [2], [3], [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,... | 215 | 267 |
coding | Solve the programming task below in a Python markdown code block.
Your goal is to implement the method **meanVsMedian** which accepts an *odd-length* array of integers and returns one of the following:
* 'mean' - in case **mean** value is **larger than** median value
* 'median' - in case **median** value is **larger t... | {"functional": "_inputs = [[[1, 1, 1]], [[1, 2, 37]], [[7, 14, -70]], [[-10, 20, 5]]]\n_outputs = [['same'], ['mean'], ['median'], ['same']]\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... | 147 | 203 |
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 |
coding | Solve the programming task below in a Python markdown code block.
You are given a number $k$ and a string $s$ of length $n$, consisting of the characters '.' and '*'. You want to replace some of the '*' characters with 'x' characters so that the following conditions are met:
The first character '*' in the original str... | {"inputs": ["5\n7 3\n.**.***\n5 1\n..*..\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*\n", "5\n7 3\n.**.***\n5 2\n..*..\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*\n", "5\n7 5\n.**.***\n5 1\n..*..\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*\n", "5\n7 3\n***..**\n5 1\n*....\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*\n", "5\n7 4\n.****.*\n5 2\n..*..\n5 4\n*.*.*\n3 2\n*.*\n1 2\... | 531 | 456 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.
The cost of the connection between any two points are given in an size1 x size2 matrix ... | {"functional": "def check(candidate):\n assert candidate(cost = [[15, 96], [36, 2]]) == 17\n assert candidate(cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]) == 4\n assert candidate(cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]) == 10\n\n\ncheck(Solution().connectTwoGroups)"} | 202 | 136 |
coding | Solve the programming task below in a Python markdown code block.
JJ has three integers A, B, and N. He can apply the following operation on A:
Select an integer X such that 1 ≤ X < N and set A := A \oplus X. (Here, \oplus denotes the [bitwise XOR operation].)
JJ wants to make A equal to B.
Determine the minimum nu... | {"inputs": ["2\n24 27 3\n4 5 1000\n", "3\n5 5 2\n3 7 8\n8 11 1\n"], "outputs": ["2\n1", "0\n1\n-1\n"]} | 592 | 64 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array A of length N.
An index i is called *strong* if we can change the [gcd] of the whole array just by changing the value of A_{i}.
Determine the number of *strong* indices in the array.
------ Input Format ------
- First line will con... | {"inputs": ["3\n3\n5 10 20\n4\n3 5 7 11\n4\n2 2 2 2\n"], "outputs": ["3\n0\n4\n"]} | 444 | 49 |
coding | Solve the programming task below in a Python markdown code block.
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he... | {"inputs": ["1\n1\n", "2\n1 2\n", "2\n2 1\n", "3\n3 2 1\n", "3\n1 2 3\n", "3\n3 1 2\n", "3\n1 3 2\n", "3\n2 3 1\n"], "outputs": ["0", "0", "1", "2", "0", "1", "1", "1"]} | 276 | 102 |
coding | Solve the programming task below in a Python markdown code block.
You are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \le x < m$ and $\gcd(a, m) = \gcd(a + x, m)$.
Note: $\gcd(a, b)$ is the greatest common divisor of $a$ and $b$.
-----Input-----
The first line contains the sing... | {"inputs": ["3\n4 9\n5 10\n42 9999999967\n", "3\n4 5\n5 10\n42 9999999967\n", "3\n4 5\n8 10\n42 9999999967\n", "3\n4 9\n5 10\n42 9999999967\n", "3\n4 14\n5 10\n42 9999999967\n", "3\n4 27\n5 10\n42 9999999967\n", "3\n4 45\n5 10\n42 9999999967\n", "3\n4 75\n5 10\n42 9999999967\n"], "outputs": ["6\n1\n9999999966\n", "4\n1... | 282 | 365 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Vietnamese],
[Bengali], [Mandarin Chinese], and [Russian] as well.
Chef is planning a heist in the reserve bank of Chefland. They are planning to hijack the bank for $D$ days and print the money. The initial rate of printing... | {"inputs": ["3\n2 1 1 1\n3 2 1 1\n5 2 1 2"], "outputs": ["3\n4\n13"]} | 718 | 41 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.