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.
*Mario has reached Bowser's Castle and is inches away from rescuing Princess Peach. He has to answer the following problem at the gate to be allowed to enter. Can you help him?*
Let S(M) denote the set of all [prime] [factors] of M.
Given two positive... | {"inputs": ["3\n21 63\n72 72\n25 20"], "outputs": ["YES\nYES\nNO"]} | 451 | 34 |
coding | Solve the programming task below in a Python markdown code block.
Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine if the columns are also in ascending alphabetical order, top to bottom. Return YES if they are or NO if they are not.
Exampl... | {"inputs": ["1\n5\nebacd\nfghij\nolmkn\ntrpqs\nxywuv\n"], "outputs": ["YES\n"]} | 519 | 36 |
coding | Solve the programming task below in a Python markdown code block.
One of the most important skills a programmer needs to learn early on is the ability to pose a problem in an abstract way. This skill is important not just for researchers but also in applied fields like software engineering and web development.
You a... | {"inputs": ["4\n10 -5 5 20\n", "5\n7 12 24 6 5\n"], "outputs": ["50\n", "144\n"]} | 529 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Is the number even?
If the numbers is even return `true`. If it's odd, return `false`.
Oh yeah... the following symbols/commands have been disabled!
use of ```%```
use of ```.even?``` in Ruby
use of ```mod``` in Python
Also feel free to reuse/ext... | {"functional": "_inputs = [[2], [3], [14], [15], [26], [27]]\n_outputs = [[True], [False], [True], [False], [True], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple))... | 94 | 188 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.
A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,2,3],[4,5,6],[7,8,9]]) == 13\n assert candidate(grid = [[7]]) == 7\n\n\ncheck(Solution().minFallingPathSum)"} | 108 | 63 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Captain Dehatti from Bawanian village is making strategy to win the Fake Cricket World Cup organised in his village.
He want his team to score runs only in 4's and 6's because he belie... | {"inputs": ["6\n10 2 9\n6 2 9\n6 1 9\n4 1 9\n5 1 9\n10 3 9"], "outputs": ["2\n4\n1\n1\n0\n12"]} | 552 | 61 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.
Return all lonely numbers in nums. You may return the answer in ... | {"functional": "def check(candidate):\n assert candidate(nums = [10,6,5,8]) == [10,8]\n assert candidate(nums = [1,3,5,3]) == [1,5]\n\n\ncheck(Solution().findLonely)"} | 108 | 64 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return whether s is a valid number.
For example, all the following are valid numbers: "2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789", while th... | {"functional": "def check(candidate):\n assert candidate(s = \"0\") == True\n assert candidate(s = \"e\") == False\n assert candidate(s = \".\") == False\n\n\ncheck(Solution().isNumber)"} | 316 | 52 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a binary array nums containing only the integers 0 and 1. Return the number of subarrays in nums that have more 1's than 0's. Since the answer may be very large, return it modulo 109 + 7.
A subarray is a... | {"functional": "def check(candidate):\n assert candidate(nums = [0,1,1,0,1]) == 9\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [1]) == 1\n\n\ncheck(Solution().subarraysWithMoreZerosThanOnes)"} | 123 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Valera has array a, consisting of n integers a_0, a_1, ..., a_{n} - 1, and function f(x), taking an integer from 0 to 2^{n} - 1 as its single argument. Value f(x) is calculated by formula $f(x) = \sum_{i = 0}^{n - 1} a_{i} \cdot b i t(i)$, where value bi... | {"inputs": ["1\n0\n1\n", "1\n1\n0\n", "1\n1\n1\n", "1\n0\n0\n", "1\n1\n1\n", "1\n0\n1\n", "1\n1\n0\n", "1\n0\n0\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "1\n", "0\n", "0\n", "0\n"]} | 515 | 102 |
coding | Solve the programming task below in a Python markdown code block.
You have an integer variable x.
Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the valu... | {"inputs": ["5\nDIDII", "5\nDIIID", "5\nIDIID", "5\nIIDDI", "5\nDIIDI", "5\nIIIDD", "5\nDDIII", "5\nIDDII"], "outputs": ["1\n", "2\n", "2\n", "2\n", "1\n", "3\n", "1\n", "1\n"]} | 225 | 88 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
There are $N$ workers; each worker is of one of the following three types:
A *translator* translates some text from Chef's language to another langague.
An *author* writes so... | {"inputs": ["5\n1 3 4 6 8\n1 2 1 2 3"], "outputs": ["4"]} | 551 | 32 |
coding | Solve the programming task below in a Python markdown code block.
If we alternate the vowels and consonants in the string `"have"`, we get the following list, arranged alphabetically:
`['ahev', 'aveh', 'ehav', 'evah', 'vahe', 'veha']`. These are the only possibilities in which vowels and consonants are alternated. The ... | {"functional": "_inputs = [['java'], ['oruder'], ['zodiac'], ['apple'], ['acidity'], ['codewars'], ['orudere']]\n_outputs = [['ajav'], ['edorur'], ['acidoz'], ['lapep'], ['caditiy'], ['failed'], ['ederoru']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retur... | 389 | 206 |
coding | Solve the programming task below in a Python markdown code block.
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are n types of geometric f... | {"inputs": ["1\n1 1000\n1\n2\n", "1\n1 1000\n1\n1\n", "1\n1 1100\n1\n2\n", "1\n4 10\n2\n3 6\n", "1\n9 10\n2\n3 6\n", "1\n4 10\n2\n1 6\n", "1\n9 10\n2\n2 6\n", "1\n4 10\n2\n2 6\n"], "outputs": ["1000\n", "1000\n", "1100\n", "50\n", "180\n", "70\n", "190\n", "60\n"]} | 596 | 174 |
coding | Solve the programming task below in a Python markdown code block.
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written... | {"inputs": ["a\n0\n", "a\n1\n", "a\n2\n", "a\n4\n", "aa\n2\n", "aa\n1\n", "ab\n1\n", "ba\n1\n"], "outputs": ["1\na\n", "0\n\n", "0\n", "0\n", "0\n\n", "1\naa\n", "1\nb\n", "1\nb\n"]} | 524 | 96 |
coding | Solve the programming task below in a Python markdown code block.
On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.
Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.
Similarly, among the lines parallel to the y... | {"inputs": ["3 3\n1 3 4\n1 3 9", "3 3\n1 3 4\n0 3 9", "3 3\n1 3 4\n1 3 7", "3 3\n1 3 8\n0 3 9", "3 3\n0 3 4\n1 3 6", "3 3\n1 3 4\n0 3 3", "3 3\n1 3 3\n0 3 3", "3 3\n1 1 5\n0 2 3"], "outputs": ["96\n", "108\n", "72\n", "252\n", "80\n", "36\n", "24\n", "48\n"]} | 394 | 184 |
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 value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.
You are allowed to select any subarray of the given array and reverse it.... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,1,5,4]) == 10\n assert candidate(nums = [2,4,9,24,2,1,10]) == 68\n\n\ncheck(Solution().maxValueAfterReverse)"} | 125 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a binary string S of length N. Chef wants to find two substrings of equal length, such that their [bitwise XOR] is maximised.
Formally, Chef wants to find L_{1}, R_{1}, L_{2}, and R_{2} such that:
1 ≤ L_{1} ≤ R_{1} ≤ N and 1 ≤ L_{2} ≤ R_{2} ≤ N... | {"inputs": ["3\n4\n1010\n5\n11111\n3\n011\n"], "outputs": ["7\n0\n2\n"]} | 715 | 39 |
coding | Solve the programming task below in a Python markdown code block.
There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left... | {"inputs": ["1 1\n", "2 1\n", "6 8\n", "2 2\n", "1 2\n", "3 4\n", "1 4\n", "1 6\n"], "outputs": ["0", "0\n", "2\n", "1\n", "0\n", "1\n", "0\n", "0\n"]} | 440 | 85 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
-First-line will contain $T$, the number of test cases. Then th... | {"inputs": ["2\n2\n4"], "outputs": ["A\n12\nA\n12\nABC\n1234"]} | 186 | 31 |
coding | Solve the programming task below in a Python markdown code block.
Johnny, like every mathematician, has his favorite sequence of distinct natural numbers. Let’s call this sequence $\mbox{M}$. Johnny was very bored, so he wrote down $N$ copies of the sequence $\mbox{M}$ in his big notebook. One day, when Johnny was out... | {"inputs": ["2\n2\n1 3\n3\n2 3 4\n"], "outputs": [" 1 2 3 4\n"]} | 575 | 35 |
coding | Solve the programming task below in a Python markdown code block.
The customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how many... | {"inputs": ["3 300\n100 46 150\n110 50 150\n001 97 261\n3 300\n100 50 150\n100 50 267\n168 50 88\n9 18\n2 1 1\n3 2 1\n3 0 2\n4 010 1\n5 100 1\n5 100 1\n10 5 3\n10 5 3\n1 7 1000\n10 18\n1 3 3\n2 3 4\n3 3 5\n3 5 6\n5 6 7\n6 7 8\n7 8 9\n8 9 10\n9 10 6\n17 11 12\n0 0", "3 300\n100 46 150\n100 50 150\n101 50 150\n3 300\n100... | 767 | 1,876 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata you are to implement a function that parses a string which is composed from tokens of the form 'n1-n2,n3,n4-n5:n6' where 'nX' is a positive integer. Each token represent a different range:
'n1-n2' represents the range n1 to n2 (inclusive in... | {"functional": "_inputs = [['1-10,14, 20-25:2'], ['5-10'], ['2'], ['1-10,3'], ['1-10:5']]\n_outputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 20, 22, 24]], [[5, 6, 7, 8, 9, 10]], [[2]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3]], [[1, 6]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b... | 302 | 300 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns.
The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph.
The mouse starts at no... | {"functional": "def check(candidate):\n assert candidate(graph = [[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]]) == 0\n assert candidate(graph = [[1,3],[0],[3],[0,2]]) == 1\n\n\ncheck(Solution().catMouseGame)"} | 317 | 80 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer $n$. You have to calculate the number of binary (consisting of characters 0 and/or 1) strings $s$ meeting the following constraints.
For every pair of integers $(i, j)$ such that $1 \le i \le j \le n$, an integer $a_{i,j}$ is gi... | {"inputs": ["2\n0 0\n2\n", "2\n1 0\n2\n", "2\n1 2\n2\n", "3\n1 0 2\n1 0\n1\n", "3\n1 1 2\n1 0\n1\n", "3\n1 2 1\n1 0\n1\n", "3\n2 0 2\n0 1\n1\n", "3\n0 0 0\n2 0\n2\n"], "outputs": ["0\n", "0\n", "0\n", "6\n", "2\n", "0\n", "0\n", "0\n"]} | 543 | 148 |
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 servers and tasks of lengths n and m respectively. servers[i] is the weight of the ith server, and tasks[j] is the time needed to process the jth... | {"functional": "def check(candidate):\n assert candidate(servers = [3,3,2], tasks = [1,2,3,2,1,2]) == [2,2,0,2,1,2]\n assert candidate(servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1]) == [1,4,1,4,1,3,2]\n\n\ncheck(Solution().assignTasks)"} | 342 | 113 |
coding | Solve the programming task below in a Python markdown code block.
There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.
When Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happines... | {"inputs": ["3\n28 0\n2 40\n8 7", "3\n28 0\n3 40\n8 7", "3\n2 0\n3 40\n8 11", "3\n4 0\n0 0\n53 12", "3\n4 0\n0 0\n86 12", "3\n0 17\n5 4\n2 53", "3\n0 17\n5 4\n3 53", "3\n0 34\n5 4\n3 53"], "outputs": ["10\n", "11\n", "-6\n", "53\n", "86\n", "-10\n", "-9\n", "-26\n"]} | 456 | 180 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
Please complete the following python code precisely:
```python
# Definition for a b... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,9,20,None,None,15,7])) == [[3],[9,20],[15,7]]\n assert candidate(root = tree_node([1])) == [[1]]\n assert candidate(root = tree_node([])) == []\n\n\ncheck(Solution().levelOrder)"} | 134 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Burger Town is a city that consists of $N$ special junctions and $N-1$ pathways. There is exactly one shortest path between each pair of junctions. Junction $\boldsymbol{i}$ is located at $(x_i,y_i)$ and the distance between two junctions $i,j$ is define... | {"inputs": ["3 2 1\n0 0\n1 1\n2 0\n1 2\n2 3\n"], "outputs": ["1\n"]} | 630 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A train line going through a city has two routes, the regular route and the express route. Both routes go through the same n + 1 stops labeled from 0 to n. Initially, you start on the regular route at stop 0.
You are ... | {"functional": "def check(candidate):\n assert candidate(regular = [1,6,9,5], express = [5,2,3,10], expressCost = 8) == [1,7,14,19]\n assert candidate(regular = [11,5,13], express = [7,10,6], expressCost = 3) == [10,15,24]\n\n\ncheck(Solution().minimumCosts)"} | 291 | 109 |
coding | Solve the programming task below in a Python markdown code block.
There is a grid of squares with H+1 horizontal rows and W vertical columns.
You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-t... | {"inputs": ["4 7\n2 4\n1 1\n2 3\n2 4", "4 4\n2 4\n1 1\n2 0\n2 4", "4 4\n3 4\n1 1\n2 3\n2 4", "4 4\n2 4\n1 1\n2 0\n3 4", "4 4\n1 4\n1 1\n2 0\n3 4", "4 5\n0 4\n0 1\n4 5\n3 4", "4 7\n2 4\n0 1\n2 3\n5 7", "4 7\n1 3\n0 1\n4 1\n3 7"], "outputs": ["1\n2\n3\n4\n", "1\n3\n4\n-1\n", "1\n2\n5\n-1\n", "1\n3\n4\n5\n", "-1\n-1\n-1\n... | 315 | 262 |
coding | Solve the programming task below in a Python markdown code block.
Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without reveali... | {"inputs": ["2 1\n4 5 6 7\n4 7\n", "2 1\n1 2 1 3\n1 2\n", "2 1\n3 5 6 7\n4 7\n", "2 1\n1 2 2 3\n1 2\n", "2 2\n1 2 1 3\n1 2 1 3\n", "2 2\n1 2 2 4\n1 2 1 3\n", "2 2\n1 2 2 3\n2 3 3 4\n", "2 2\n1 2 3 4\n1 5 3 4\n"], "outputs": ["-1", "1", "7\n", "2\n", "1", "0", "0", "1"]} | 719 | 193 |
coding | Solve the programming task below in a Python markdown code block.
Hakone Ekiden is one of the Japanese New Year's traditions. In Hakone Ekiden, 10 runners from each team aim for the goal while connecting the sashes at each relay station. In the TV broadcast, the ranking change from the previous relay station is display... | {"inputs": ["2\nD\nT", "2\nE\nU", "2\nF\nU", "2\nD\nS", "2\nC\nU", "2\nB\nU", "2\nD\nV", "2\nD\nR"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 375 | 94 |
coding | Solve the programming task below in a Python markdown code block.
The land of Programmers Army is surrounded by many islands. A unique number is associated with each island. The king of the islands is a very generous person, he donates a certain amount of gold coins to travelers for visiting each island that they visit... | {"inputs": ["1\n4\n10 2 5 50\n2\n1 3\n2 4"], "outputs": ["17\n57"]} | 584 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowe... | {"inputs": ["2\n1\n3\n", "2\n1\n4\n", "2\n0\n4\n", "2\n1\n1\n", "2\n1\n8\n", "2\n1\n9\n", "2\n1\n2\n", "2\n1\n6\n"], "outputs": ["6\n", "8\n", "0\n", "2\n", "16\n", "18\n", "4\n", "12\n"]} | 478 | 105 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.
Please complete the following python code precisely:
```python
class Solution:
def findMaximumXOR(self, nums:... | {"functional": "def check(candidate):\n assert candidate(nums = [3,10,5,25,2,8]) == 28\n assert candidate(nums = [14,70,53,83,49,91,36,80,92,51,66,70]) == 127\n\n\ncheck(Solution().findMaximumXOR)"} | 78 | 94 |
coding | Solve the programming task below in a Python markdown code block.
"The Shell Game" involves cups upturned on a playing surface, with a ball placed underneath one of them. The index of the cups are swapped around multiple times. After that the players will try to find which cup contains the ball.
Your task is as follo... | {"functional": "_inputs = [[5, []], [0, []], [9, []], [0, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], ... | 272 | 1,775 |
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 absolute sum of a subarray [numsl, numsl+1, ..., numsr-1, numsr] is abs(numsl + numsl+1 + ... + numsr-1 + numsr).
Return the maximum absolute sum of any (possibly empty) subarr... | {"functional": "def check(candidate):\n assert candidate(nums = [1,-3,2,3,-4]) == 5\n assert candidate(nums = [2,-5,1,-4,3,-2]) == 8\n\n\ncheck(Solution().maxAbsoluteSum)"} | 158 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Given is a positive integer N.
How many tuples (A,B,C) of positive integers satisfy A \times B + C = N?
-----Constraints-----
- 2 \leq N \leq 10^6
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the followin... | {"inputs": ["4", "5", "8", "6", "2", "9", "7", "3"], "outputs": ["5\n", "8\n", "16\n", "10\n", "1\n", "20\n", "14\n", "3"]} | 158 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any... | {"functional": "def check(candidate):\n assert candidate(n = 4, connections = [[0,1],[0,2],[1,2]]) == 1\n assert candidate(n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]) == 2\n assert candidate(n = 6, connections = [[0,1],[0,2],[0,3],[1,2]]) == -1\n assert candidate(n = 5, connections = [[0,1],[0,2],... | 172 | 143 |
coding | Solve the programming task below in a Python markdown code block.
Nim is the most famous two-player algorithm game. The basic rules for this game are as follows:
The game starts with a number of piles of stones. The number of stones in each pile may not be equal.
The players alternately pick up $\mbox{1}$ or more sto... | {"inputs": ["2\n2\n1 1\n3\n2 1 4\n"], "outputs": ["Second\nFirst\n"]} | 658 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi wi... | {"inputs": ["2 3\n2 1 3\n2 1 3\n2 1 3", "1 3\n2 1 3\n2 1 3\n2 1 3", "1 3\n2 1 3\n2 1 4\n2 1 3", "3 3\n2 1 3\n2 1 3\n2 1 3", "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 4 3 1", "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 5\n2 5 4 3 1", "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 7\n2 5 4 3 1", "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 0 1 4 5\n2 5 ... | 426 | 309 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, find the length of the longest substring without repeating characters.
Please complete the following python code precisely:
```python
class Solution:
def lengthOfLongestSubstring(self, s: str) ... | {"functional": "def check(candidate):\n assert candidate(s = \"abcabcbb\") == 3\n assert candidate(s = \"bbbbb\") == 1\n assert candidate(s = \"pwwkew\") == 3\n\n\ncheck(Solution().lengthOfLongestSubstring)"} | 66 | 64 |
coding | Solve the programming task below in a Python markdown code block.
Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \ge i$).
Iva... | {"inputs": ["1\n1\n", "1\n1\n", "4\n1 2 4 4\n", "4\n1 2 4 4\n", "4\n2 2 4 4\n", "4\n2 4 4 4\n", "9\n1 3 3 6 7 6 8 8 9\n", "9\n1 3 3 6 7 6 8 8 9\n"], "outputs": ["1\n", "1\n", "3\n", "3\n", "2\n", "1\n", "4\n", "4\n"]} | 393 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Calculate the power of an army of numbers from 1 to $N$, both included.
-----Input:-----
- First line will contain a single integer $N$.
-----Output:-----
For each testcase, output in a single line containing the answer.
-----Constraints-----
- $1 \le... | {"inputs": ["24"], "outputs": ["5"]} | 97 | 13 |
coding | Solve the programming task below in a Python markdown code block.
Given a tree T with n nodes, how many subtrees (T') of T have at most K edges connected to (T - T')?
Input Format
The first line contains two integers n and K followed by n-1 lines each containing two integers a & b denoting that there's an edge betwe... | {"inputs": ["3 1\n2 1\n2 3\n"], "outputs": ["6\n"]} | 272 | 24 |
coding | Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.
Its most important components are a button and a line ... | {"inputs": ["1\n0\n", "1\n0\n", "2\n1 0\n", "2\n0 0\n", "2\n0 1\n", "2\n1 0\n", "2\n1 1\n", "2\n1 1\n"], "outputs": ["Yes\n", "Yes\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n"]} | 503 | 98 |
coding | Solve the programming task below in a Python markdown code block.
Jack stays in a n-storey hostel. His dorm room is on the jth floor. Every morning, he is in so much hurry for classes that he cannot not decide whether to take Lift or Stairs to reach ground-floor. He asks you to help him choose either Stairs or Lift bas... | {"inputs": ["32\n10 5 5 U\n10 5 5 D\n10 3 3 D\n10 9 9 U\n10 10 10 U\n10 10 10 D\n100 80 20 U\n100 80 45 U\n100 80 46 U\n100 80 40 D\n100 80 0 D\n100 80 79 D\n100 100 3 U\n100 100 4 U\n100 100 5 U\n100 100 2 U\n100 100 1 D\n100 53 100 U\n100 52 100 U\n100 51 100 U\n100 54 100 U\n100 51 99 U\n100 53 99 U\n100 54 99 U\n10... | 743 | 1,420 |
coding | Solve the programming task below in a Python markdown code block.
A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.
Let $f(x)$ be the number of distinct integers the frog can reach if it never jump... | {"inputs": ["7 5 3\n", "6 4 5\n", "7 5 3\n", "6 4 5\n", "26 92701 7\n", "26 92701 7\n", "3 998 99486\n", "3 998 99486\n"], "outputs": ["19\n", "10\n", "19\n", "10\n", "27\n", "27\n", "4\n", "4\n"]} | 488 | 130 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a litt... | {"inputs": ["5\n1 1\n2 2\n2 3\n2 4\n2 5"], "outputs": ["1 5 6 9 10 12 13 14 15 "]} | 599 | 54 |
coding | Solve the programming task below in a Python markdown code block.
International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbrevi... | {"inputs": ["1\nIAO'001\n", "1\nIAO'089\n", "1\nIAO'099\n", "1\nIAO'990\n", "1\nIAO'2015\n", "1\nIAO'2000\n", "1\nIAO'11378\n", "1\nIAO'11111\n"], "outputs": ["3001\n", "3089\n", "2099\n", "2990\n", "12015\n", "12000\n", "111378\n", "111111\n"]} | 395 | 162 |
coding | Solve the programming task below in a Python markdown code block.
There is a sequence of words in CamelCase as a string of letters, $\boldsymbol{\mathrm{~S~}}$, having the following properties:
It is a concatenation of one or more words consisting of English letters.
All letters in the first word are lowercase.
For e... | {"inputs": ["saveChangesInTheEditor\n"], "outputs": ["5\n"]} | 297 | 17 |
coding | Solve the programming task below in a Python markdown code block.
King loves to go on tours with his friends.
King has N cars that can seat 5 people each and M cars that can seat 7 people each. Determine the maximum number of people that can travel together in these cars.
------ Input Format ------
- The first line... | {"inputs": ["4\n4 8\n2 13\n14 5\n8 8"], "outputs": ["76\n101\n105\n96"]} | 442 | 42 |
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.
Ada has two matrices $A$ and $B$, each with $N$ rows (numbered $1$ through $N$) and $N$ columns (numbered $1$ through $N$).
Ada may perform the foll... | {"inputs": ["1\n3\n1 2 3\n4 5 6\n7 8 9\n1 2 7\n4 5 8\n3 6 9"], "outputs": ["Yes"]} | 571 | 50 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings s and t, transform string s into string t using the following operation any number of times:
Choose a non-empty substring in s and sort it in place so the characters are in ascending order.
For e... | {"functional": "def check(candidate):\n assert candidate(s = \"84532\", t = \"34852\") == True\n assert candidate(s = \"34521\", t = \"23415\") == True\n assert candidate(s = \"12345\", t = \"12435\") == False\n assert candidate(s = \"1\", t = \"2\") == False\n\n\ncheck(Solution().isTransformable)"} | 152 | 108 |
coding | Solve the programming task below in a Python markdown code block.
Introduction
It's been more than 20 minutes since the negligent waiter has taken your order for the house special prime tofu steak with a side of chili fries.
Out of boredom, you start fiddling around with the condiments tray. To be efficient, you want... | {"functional": "_inputs = [[0], [3], [16], [32], [49], [89], [327], [363], [366], [512], [656], [1038], [1052], [1222], [1235], [1302], [1735], [1757], [1974], [2048]]\n_outputs = [[0], [7], [171], [683], [1215], [3715], [52239], [60195], [62063], [174763], [209095], [699451], [700379], [757295], [762019], [832559], [1... | 385 | 391 |
coding | Solve the programming task below in a Python markdown code block.
Spoonerize... with numbers... numberize?... numboonerize?... noonerize? ...anyway! If you don't yet know what a spoonerism is and haven't yet tried my spoonerism kata, please do [check it out](http://www.codewars.com/kata/spoonerize-me) first.
You will... | {"functional": "_inputs = [[[12, 34]], [[55, 63]], [[357, 579]], [[1000000, 9999999]], [[1000000, 'hello']], [['pippi', 9999999]], [['pippi', 'hello']], [[1, 1]], [[1, 0]], [[0, 1]]]\n_outputs = [[18], [12], [178], [7000001], ['invalid array'], ['invalid array'], ['invalid array'], [0], [1], [1]]\nimport math\ndef _dee... | 259 | 287 |
coding | Solve the programming task below in a Python markdown code block.
You're given an array A of N integers. You need to find the minimum cost of creating another array B of N integers with the following properties
B_{i} ≥ 0 for each 1 ≤ i ≤ N
The GCD of adjacent elements of B is equal to 1, i.e, \gcd(B_{i}, B_{i+1}) = 1 ... | {"inputs": ["3\n3\n15 16 19\n2\n5 10\n7\n9 15 7 19 10 7 1\n"], "outputs": ["3\n3\n8"]} | 603 | 54 |
coding | Solve the programming task below in a Python markdown code block.
There are $N$ sabotages available in the game Among Us, initially all at level $0$.
$N$ imposters are allotted the task to upgrade the level of the sabotages.
The $i^{th}$ imposter $(1 \leq i \leq N)$ increases the level of $x^{th}$ sabotage $(1 \leq x... | {"inputs": ["1\n6"], "outputs": ["0"]} | 335 | 14 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Tic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are:
Players take turns placing characters into empty squares ' '.
The first player A always places 'X' characters, while the sec... | {"functional": "def check(candidate):\n assert candidate(moves = [[0,0],[2,0],[1,1],[2,1],[2,2]]) == \"A\"\n assert candidate(moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]]) == \"B\"\n assert candidate(moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]]) == \"Draw\"\n assert candidate(moves = [[0... | 290 | 157 |
coding | Solve the programming task below in a Python markdown code block.
A and B are preparing themselves for programming contests.
The University where A and B study is a set of rooms connected by corridors. Overall, the University has n rooms connected by n - 1 corridors so that you can get from any room to any other one b... | {"inputs": ["4\n1 2\n1 3\n2 4\n1\n2 3\n", "5\n1 2\n1 3\n2 5\n2 4\n1\n5 4\n", "4\n1 2\n2 3\n2 4\n2\n1 2\n1 2\n", "4\n1 3\n2 3\n2 4\n2\n1 2\n1 2\n", "4\n1 3\n2 3\n2 4\n2\n1 1\n1 2\n", "4\n1 4\n2 3\n2 4\n2\n1 1\n1 3\n", "5\n1 2\n1 3\n2 5\n2 4\n1\n5 3\n", "4\n1 4\n4 3\n2 4\n2\n1 1\n1 3\n"], "outputs": ["1\n", "3\n", "0\n0\... | 482 | 252 |
coding | Solve the programming task below in a Python markdown code block.
If you can't sleep, just count sheep!!
## Task:
Given a non-negative integer, `3` for example, return a string with a murmur: `"1 sheep...2 sheep...3 sheep..."`. Input will always be valid, i.e. no negative integers.
Also feel free to reuse/extend the ... | {"functional": "_inputs = [[3]]\n_outputs = [['1 sheep...2 sheep...3 sheep...']]\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... | 94 | 164 |
coding | Solve the programming task below in a Python markdown code block.
The Chef has prepared the appetizers in the shapes of letters to spell a special message for the guests. There are n appetizers numbered from 0 to n-1 such that if the appetizers are arrayed in this order, they will display the message. The Chef plans to... | {"inputs": ["2\n2 chef\n4 enjoyourapplepie", "2\n2 chef\n4 eipelpparuoyojne", "2\n2 chef\n4 enjoyourappmepie", "2\n2 cief\n4 enjoyourappmepie", "2\n2 cgef\n4 enjoyourapplepie", "2\n2 chef\n4 eipempparuoyojne", "2\n2 cief\n4 enjoyourpapmepie", "2\n2 cgef\n4 enjoyourapqlepie"], "outputs": ["cehf\neayejpuinpopolre", "cehf... | 568 | 233 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi, who is A years old, is riding a Ferris wheel.
It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who a... | {"inputs": ["6 111", "9 100", "9 010", "1 100", "2 100", "2 101", "0 000", "3 101"], "outputs": ["55\n", "50\n", "5\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 228 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to return the sum of Triangular Numbers up-to-and-including the `nth` Triangular Number.
Triangular Number: "any of the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc."
`... | {"functional": "_inputs = [[6], [34], [-291], [943], [-971]]\n_outputs = [[56], [7140], [0], [140205240], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if ... | 228 | 199 |
coding | Solve the programming task below in a Python markdown code block.
Chef is given two binary strings A and B, each having length N.
Chef wants to find the number of binary strings C, of length N, such that H(A, C) = H(B, C), where H(X, Y) denotes the *hamming distance* between the strings X and Y.
Since the answer can ... | {"inputs": ["3\n2\n11\n00\n5\n10101\n10101\n3\n101\n011\n"], "outputs": ["2\n32\n4\n"]} | 736 | 51 |
coding | Solve the programming task below in a Python markdown code block.
JJ has an array A. He can perform the following operation on A:
Divide A into two subsequences P and Q such that each A_{i} belongs to either P or Q.
Set A := P\ \texttt{concat}\ Q
Here \texttt{concat} denotes the concatenation operation. For e.g. [2,... | {"inputs": ["3\n6\n4 5 6 1 2 3\n5\n1 3 5 2 4\n5\n5 10 7 11 9\n"], "outputs": ["YES\nNO\nYES\n"]} | 605 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Chef gives an integer $K$ in the input. If the given number is beautiful binary number, print it, Else find its previous beautiful binary number. A beautiful binary number is a number whose binary representation does not contain any consecutive 1s.
Note... | {"inputs": ["3\n3\n6\n8"], "outputs": ["2\n5\n8"]} | 272 | 22 |
coding | Solve the programming task below in a Python markdown code block.
Jeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence p_1, p_2, ..., p_{n} for his birthday.
Jeff hates inversions in sequences. An inversion in sequence a_1, a_2, ..., a_{n} is a pair of ... | {"inputs": ["1\n0\n", "1\n0\n", "1\n1\n", "1\n-1\n", "1\n-2\n", "1\n-3\n", "1\n-4\n", "2\n2 1\n"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 281 | 91 |
coding | Solve the programming task below in a Python markdown code block.
You are given two positive integers $a$ and $b$. In one move you can increase $a$ by $1$ (replace $a$ with $a+1$). Your task is to find the minimum number of moves you need to do in order to make $a$ divisible by $b$. It is possible, that you have to mak... | {"inputs": ["1\n9 3\n", "1\n8 4\n", "1\n3 4\n", "1\n3 6\n", "1\n3 3\n", "1\n29 4\n", "1\n9 75\n", "1\n9 95\n"], "outputs": ["0\n", "0\n", "1\n", "3\n", "0\n", "3\n", "66\n", "86\n"]} | 274 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Appy and Chef are participating in a contest. There are $N$ problems in this contest; each problem has a unique problem code between $1$ and $N$ inclusive. Appy and Chef decided to split the problems to solve between them ― Appy should solve the problems... | {"inputs": ["1\n6 2 3 3"], "outputs": ["Win"]} | 469 | 20 |
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 grid grid where:
'.' is an empty cell.
'#' is a wall.
'@' is the starting point.
Lowercase letters represent keys.
Uppercase letters represent locks.
You start at the starting point and one mo... | {"functional": "def check(candidate):\n assert candidate(grid = [\"@.a..\",\"###.#\",\"b.A.B\"]) == 8\n assert candidate(grid = [\"@..aA\",\"..B#.\",\"....b\"]) == 6\n\n\ncheck(Solution().shortestPathAllKeys)"} | 251 | 72 |
coding | Solve the programming task below in a Python markdown code block.
You are given $n$ words of equal length $m$, consisting of lowercase Latin alphabet letters. The $i$-th word is denoted $s_i$.
In one move you can choose any position in any single word and change the letter at that position to the previous or next lett... | {"inputs": ["1\n2 7\nabcdefg\naaaaaaa\n", "6\n2 4\nbest\ncost\n6 3\nabb\nzba\nbef\ncdu\nooo\nzzz\n2 7\naaabbbc\nbbaezfe\n3 2\nab\nab\nab\n2 8\naaaaaaaa\nzzzzzzzz\n3 1\na\nu\ny\n"], "outputs": ["21\n", "11\n8\n35\n0\n200\n4\n"]} | 627 | 119 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of integers nums (0-indexed) and an integer k.
The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.
... | {"functional": "def check(candidate):\n assert candidate(nums = [1,4,3,7,4,5], k = 3) == 15\n assert candidate(nums = [5,5,4,5,4,1,1,1], k = 0) == 20\n\n\ncheck(Solution().maximumScore)"} | 132 | 79 |
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 beans, where each integer represents the number of magic beans found in a particular magic bag.
Remove any number of beans (possibly none) from each bag such that the number... | {"functional": "def check(candidate):\n assert candidate(beans = [4,1,6,5]) == 4\n assert candidate(beans = [2,10,3,2]) == 7\n\n\ncheck(Solution().minimumRemoval)"} | 146 | 59 |
coding | Solve the programming task below in a Python markdown code block.
C: Canisal cryptography
problem
Ebi-chan was given the string C obtained by encrypting a non-negative integer D with "canisal cipher". This cipher replaces each number in decimal notation with a fixed number (not necessarily different from the original... | {"inputs": ["2\n8", "2\n5", "2\n0", "2\n38", "2\n44", "2\n40", "2\n10", "2\n30"], "outputs": ["2", "2", "2", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 564 | 80 |
coding | Solve the programming task below in a Python markdown code block.
The restaurant AtCoder serves the following five dishes:
- ABC Don (rice bowl): takes A minutes to serve.
- ARC Curry: takes B minutes to serve.
- AGC Pasta: takes C minutes to serve.
- APC Ramen: takes D minutes to serve.
- ATC Hanbagu (hamburger p... | {"inputs": ["1\n1\n1\n1\n1\n", "29\n0\n8\n5\n22", "29\n0\n8\n5\n11", "29\n1\n8\n9\n11", "29\n0\n8\n10\n2", "29\n0\n8\n17\n2", "29\n-1\n8\n0\n3", "29\n0\n2\n-1\n3"], "outputs": ["41\n", "72\n", "61\n", "71\n", "52\n", "62\n", "43\n", "42\n"]} | 527 | 149 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is instructor of the famous course "Introduction to Algorithms" in a famous univerisity. There are n students in his class. There is not enough space in the class room, ... | {"inputs": ["4\n><\n*><*\n><><\n*><><><*"], "outputs": ["0\n0\n1\n2"]} | 562 | 35 |
coding | Solve the programming task below in a Python markdown code block.
You are standing near a very strange machine. If you put C cents in the machine, the remaining money in your purse will transform in an unusual way. If you have A dollars and B cents remaining in your purse after depositing the C cents, then after the tr... | {"inputs": ["2\n0 12 1\n1 1 6", "2\n0 12 0\n1 1 6", "2\n0 12 0\n2 1 6", "2\n0 56 0\n1 1 21", "2\n0 56 0\n1 0 21", "2\n0 56 1\n0 0 21", "2\n0 56 2\n0 0 21", "2\n1 33 1\n15 2 5"], "outputs": ["23\n33\n", "1\n33\n", "1\n34\n", "1\n37\n", "1\n38\n", "2\n0\n", "100\n0\n", "65\n6\n"]} | 568 | 196 |
coding | Solve the programming task below in a Python markdown code block.
Bob and Alice are having a lockout match between them. There are three problems in the contest worth A, B, and C points respectively. Only the first player to solve a problem gets points for that problem. It is impossible for Bob and Alice to solve a pro... | {"inputs": ["3\n2 5 2\n4 2 2\n3 5 5"], "outputs": ["NO\nYES\nNO"]} | 390 | 34 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are o... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,0],[0,1]]) == 0\n assert candidate(grid = [[1,0],[1,1]]) == 3\n assert candidate(grid = [[1,1,0,0],[0,0,1,0],[0,0,1,0],[0,0,0,1]]) == 4\n\n\ncheck(Solution().countServers)"} | 124 | 97 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string of length N. Calculate the number of distinct substrings of S.
Constraints
* 1 \leq N \leq 500,000
* S consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
Print... | {"inputs": ["baaaa", "baaba", "bbba`", "`babb", "`ca`b", "`_adb", "ababa", "aaabb"], "outputs": ["9\n", "11\n", "12\n", "13\n", "14\n", "15\n", "9\n", "11\n"]} | 125 | 78 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maxi... | {"functional": "def check(candidate):\n assert candidate(nums = [10,20], k = 0) == 10\n assert candidate(nums = [10,20,30], k = 1) == 10\n assert candidate(nums = [10,20,15,30,20], k = 2) == 15\n\n\ncheck(Solution().minSpaceWastedKResizing)"} | 236 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
You are given an array of strings sentences, where each sentences[i] represents a single sentence.
Return the maxi... | {"functional": "def check(candidate):\n assert candidate(sentences = [\"alice and bob love leetcode\", \"i think so too\", \"this is great thanks very much\"]) == 6\n assert candidate(sentences = [\"please wait\", \"continue to fight\", \"continue to win\"]) == 3\n\n\ncheck(Solution().mostWordsFound)"} | 103 | 80 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other inters... | {"functional": "def check(candidate):\n assert candidate(n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]) == 4\n assert candidate(n = 2, roads = [[1,0,10]]) == 1\n\n\ncheck(Solution().countPaths)"} | 219 | 116 |
coding | Solve the programming task below in a Python markdown code block.
There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters ca... | {"inputs": ["3 0\n", "1 0\n", "3 0\n", "100000 0\n", "100000 0\n", "9 2\n1 2 0\n2 3 0\n", "9 2\n1 2 0\n2 3 0\n", "9 2\n1 2 0\n2 3 1\n"], "outputs": ["4\n", "1\n", " 4\n", "303861760\n", " 303861760\n", "6... | 631 | 157 |
coding | Solve the programming task below in a Python markdown code block.
Welcome.
In this kata you are required to, given a string, replace every letter with its position in the alphabet.
If anything in the text isn't a letter, ignore it and don't return it.
`"a" = 1`, `"b" = 2`, etc.
## Example
```python
alphabet_positi... | {"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(_d... | 193 | 157 |
coding | Solve the programming task below in a Python markdown code block.
Chef recently opened a big e-commerce website where her recipes can be bought online. It's Chef's birthday month and so she has decided to organize a big sale in which grand discounts will be provided.
In this sale, suppose a recipe should have a discoun... | {"inputs": ["2\n2\n100 5 10\n100 1 50\n3\n10 10 0\n79 79 79\n100 1 100"], "outputs": ["30.000000000\n3995.0081000"]} | 739 | 85 |
coding | Solve the programming task below in a Python markdown code block.
ABCXYZ company has up to 100 employees.
The company decides to create a unique identification number (UID) for each of its employees.
The company has assigned you the task of validating all the randomly generated UIDs.
A valid UID must follow the ru... | {"inputs": ["2\nB1CD102354\nB1CDEF2354\n"], "outputs": ["Invalid\nValid\n"]} | 312 | 35 |
coding | Solve the programming task below in a Python markdown code block.
Character recognition software is widely used to digitise printed texts. Thus the texts can be edited, searched and stored on a computer.
When documents (especially pretty old ones written with a typewriter), are digitised character recognition software... | {"functional": "_inputs = [['1F-RUDYARD K1PL1NG'], ['R0BERT MERLE - THE DAY 0F THE D0LPH1N'], ['R1CHARD P. FEYNMAN - THE FEYNMAN LECTURE5 0N PHY51C5'], ['R1CHARD P. FEYNMAN - 5TAT15T1CAL MECHAN1C5'], ['5TEPHEN HAWK1NG - A BR1EF H15T0RY 0F T1ME'], ['5TEPHEN HAWK1NG - THE UN1VER5E 1N A NUT5HELL'], ['ERNE5T HEM1NGWAY - A ... | 147 | 1,124 |
coding | Solve the programming task below in a Python markdown code block.
You've came to visit your grandma and she straight away found you a job - her Christmas tree needs decorating!
She first shows you a tree with an identified number of branches, and then hands you a some baubles (or loads of them!).
You know your grandm... | {"functional": "_inputs = [[5, 5], [5, 0], [6, 5], [50, 9], [0, 10]]\n_outputs = [[[1, 1, 1, 1, 1]], ['Grandma, we will have to buy a Christmas tree first!'], [[2, 1, 1, 1, 1]], [[6, 6, 6, 6, 6, 5, 5, 5, 5]], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or i... | 308 | 285 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n matrix mat where every row is sorted in strictly increasing order, return the smallest common element in all rows.
If there is no common element, return -1.
Please complete the following python code p... | {"functional": "def check(candidate):\n assert candidate(mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]]) == 5\n assert candidate(mat = [[1,2,3],[2,3,4],[2,3,5]]) == 2\n\n\ncheck(Solution().smallestCommonElement)"} | 87 | 101 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length N.
Your task is to delete a [subsequence] of maximum length from the string, such that, after concatenating the remaining parts of the string, it becomes a [palindrome] of length greater than 1.
If this is possible, p... | {"inputs": ["3\n6\nbabkhj\n3 \nabc \n4 \nqtoo"], "outputs": ["4\n-1\n2 \n"]} | 469 | 37 |
coding | Solve the programming task below in a Python markdown code block.
# Back-Story
Every day I travel on the freeway.
When I am more bored than usual I sometimes like to play the following counting game I made up:
* As I join the freeway my count is ```0```
* Add ```1``` for every car that I overtake
* Subtract ```1``` ... | {"functional": "_inputs = [[50.0, 130.0, [[-1.0, 120.0], [-1.5, 120.0]]], [50.0, 110.0, [[1.0, 120.0], [1.5, 125.0]]], [50.0, 120.0, [[-1.0, 115.0], [-1.5, 110.0], [1.0, 130.0], [1.5, 130.0]]], [30.0, 100.0, [[-1.0, 110.0], [-0.7, 102.0], [-1.5, 108.0]]], [30.0, 130.0, [[1.0, 120.0], [0.7, 125.0], [1.5, 110.0]]], [50.0... | 323 | 519 |
coding | Solve the programming task below in a Python markdown code block.
Construct an N \times M matrix with entries having positive integers such that:
If M > 1, i^{th} row is strictly increasing from left to right with a fixed common difference d_{i} for all 1≤ i ≤ N.
If N > 1, j^{th} column is strictly increasing from top... | {"inputs": ["3\n3 3\n1 2\n1 1\n"], "outputs": ["1 2 3\n3 6 9\n5 10 15\n1 2\n1\n"]} | 488 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them by -1... | {"inputs": ["2\n-1 -1 1\n", "2\n-1 -1 1\n", "2\n-1 -1 0\n", "2\n50 50 50\n", "2\n50 50 63\n", "2\n-1 -1 -1\n", "2\n50 98 63\n", "2\n50 50 50\n"], "outputs": ["3\n", "3\n", "2\n", "150\n", "163\n", "1\n", "211\n", "150\n"]} | 291 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef had a hard day and want to play little bit. The game is called "Chain". Chef has the sequence of symbols. Each symbol is either '-' or '+'. The sequence is called Chain if each two neighbo... | {"inputs": ["2\n---+-+-+++\n-------", "2\n+++-+-+---\n-------", "2\n-+--+++--+\n-------", "2\n-+-+-+-+-+\n-------", "2\n--++---+++\n-----+-", "2\n---+-+-+++\n-----+-", "2\n+-+-+-+--+\n-------", "2\n---+++-+-+\n-------"], "outputs": ["2\n3", "2\n3\n", "4\n3\n", "0\n3\n", "4\n2\n", "2\n2\n", "2\n3\n", "2\n3\n"]} | 401 | 139 |
coding | Solve the programming task below in a Python markdown code block.
Snuke signed up for a new website which holds programming competitions.
He worried that he might forget his password, and he took notes of it.
Since directly recording his password would cause him trouble if stolen,
he took two notes: one contains the ch... | {"inputs": ["xyz\nacc", "xyz\nadc", "xyy\nadc", "xyy\nacd", "yyx\nacd", "xyy\ncad", "xyz\ncad", "zyx\ncad"], "outputs": ["xayczc\n", "xaydzc\n", "xaydyc\n", "xaycyd\n", "yaycxd\n", "xcyayd\n", "xcyazd\n", "zcyaxd\n"]} | 262 | 110 |
coding | Solve the programming task below in a Python markdown code block.
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same numbe... | {"inputs": ["3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>(======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#==~>=", "3\n>'======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=", "3\n>(==... | 331 | 373 |
coding | Solve the programming task below in a Python markdown code block.
There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may sho... | {"inputs": ["2\nFA\n", "2\nFF\n", "2\nIF\n", "2\nFA\n", "2\nFF\n", "2\nFA\n", "2\nIF\n", "2\nAF\n"], "outputs": ["1\n", "0\n", "1\n", "1\n", "0", "1", "1", "1\n"]} | 336 | 83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.