problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Solve the programming task below in a Python markdown code block.
Alice, the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of p players playing in p different positions. She also recognizes the importance of audience support, so she wants to select k people as p... | {"inputs": ["2 1 1\n30 9\n46\n73\n", "2 1 1\n30 9\n46\n87\n", "2 1 1\n76 91\n34\n77\n", "2 1 1\n76 146\n34\n77\n", "2 1 1\n76 291\n34\n77\n", "2 1 1\n76 291\n35\n77\n", "2 1 1\n131 291\n35\n77\n", "4 1 2\n2 4 10 3\n18\n19\n23\n3\n"], "outputs": ["103", "117\n", "153", "180\n", "325\n", "326\n", "326\n", "32\n"]} | coding | 617 |
Solve the programming task below in a Python markdown code block.
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (`HH:MM:SS`)
* `HH` = hours, padded to 2 digits, range: 00 - 99
* `MM` = minutes, padded to 2 digits, range: 00 - 59
* `SS` = seconds... | {"functional": "_inputs = [[0], [59], [60], [3599], [3600], [86399], [86400], [359999]]\n_outputs = [['00:00:00'], ['00:00:59'], ['00:01:00'], ['00:59:59'], ['01:00:00'], ['23:59:59'], ['24:00:00'], ['99:59:59']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ... | coding | 168 |
Solve the programming task below in a Python markdown code block.
# Task
Smartphones software security has become a growing concern related to mobile telephony. It is particularly important as it relates to the security of available personal information.
For this reason, Ahmed decided to encrypt phone numbers of co... | {"functional": "_inputs = [['353'], ['444'], ['123456'], ['147'], ['4334']]\n_outputs = [['123'], ['404'], ['738496'], ['377'], ['impossible']]\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 isinstanc... | coding | 554 |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is the constraints.
Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of $n$ consecutive pictures (with kittens, of course). Vova likes all the... | {"inputs": ["1 1 1\n7082632\n", "1 1 1\n7082632\n", "1 1 1\n7647119\n", "1 1 1\n99996055\n", "1 1 1\n99996055\n", "1 1 1\n37049130\n", "1 1 1\n50273182\n", "1 1 1\n14314026\n"], "outputs": ["7082632\n", "7082632\n", "7647119\n", "99996055\n", "99996055\n", "37049130\n", "50273182\n", "14314026\n"]} | coding | 500 |
Solve the programming task below in a Python markdown code block.
**This Kata is intended as a small challenge for my students**
All Star Code Challenge #19
You work for an ad agency and your boss, Bob, loves a catchy slogan. He's always jumbling together "buzz" words until he gets one he likes. You're looking to imp... | {"functional": "_inputs = [[['super']], [['super', 'hot']], [['super', 'hot', 'guacamole']], [['super', 'guacamole', 'super', 'super', 'hot', 'guacamole']], [['testing', 'testing', 'testing']]]\n_outputs = [[['super']], [['super hot', 'hot super']], [['super hot guacamole', 'super guacamole hot', 'hot super guacamole',... | coding | 397 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two arrays of unique digits nums1 and nums2, return the smallest number that contains at least one digit from each array.
Please complete the following python code precisely:
```python
class Solution:
def ... | {"functional": "def check(candidate):\n assert candidate(nums1 = [4,1,3], nums2 = [5,7]) == 15\n assert candidate(nums1 = [3,5,2,6], nums2 = [3,1,7]) == 3\n\n\ncheck(Solution().minNumber)"} | coding | 81 |
Solve the programming task below in a Python markdown code block.
Finding your seat on a plane is never fun, particularly for a long haul flight... You arrive, realise again just how little leg room you get, and sort of climb into the seat covered in a pile of your own stuff.
To help confuse matters (although they cla... | {"functional": "_inputs = [['2B'], ['20B'], ['58I'], ['60D'], ['17K']]\n_outputs = [['Front-Left'], ['Front-Left'], ['No Seat!!'], ['Back-Middle'], ['Front-Right']]\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=t... | coding | 255 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
A football competition has just finished. The players have been given points for scoring goals and points for committing fouls. Now, it is up to Alex... | {"inputs": ["2\n3\n40 30 50\n2 4 20\n1\n0\n10"], "outputs": ["800\n0"]} | coding | 605 |
Solve the programming task below in a Python markdown code block.
N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.
The preliminary stage consists of several rounds, which will take place as follows:... | {"inputs": ["2\n1 2\n9 0", "2\n2 3\n9 0", "2\n1 2\n9 1", "2\n2 2\n9 0", "2\n2 6\n9 0", "2\n2 6\n8 0", "2\n2 6\n8 1", "2\n2 6\n8 2"], "outputs": ["1\n", "2\n", "3\n", "1\n", "6\n", "6\n", "8\n", "10\n"]} | coding | 570 |
Solve the programming task below in a Python markdown code block.
MoEngage helps the Chef send email reminders about rated contests to the participants.
There are a total of N participants on Chef’s platform, and U of them have told Chef not to send emails to them.
If so, how many participants should MoEngage send th... | {"inputs": ["100 7", "4456 342"], "outputs": ["93", "4114"]} | coding | 298 |
Solve the programming task below in a Python markdown code block.
Shefin gives you a string S and you have to find a non-empty string P such that:
P is a substring of S.
No non-empty substring of P is a prefix of S.
No non-empty substring of P is a suffix of S.
For all such possible strings, find the length of the l... | {"inputs": ["2\nabcdab\naaa\n"], "outputs": ["2\n-1\n"]} | coding | 484 |
Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.
You are given a string $S$ with length $N$. You may perform the following operation any number of times: choose a non-empty substring of $S$ (possib... | {"inputs": ["4\n6\ncabbac\n7\nacabbad\n18\nfbedfcbdaebaaceeba\n21\nyourcrushlovesyouback"], "outputs": ["YES\nNO\nYES\nNO"]} | coding | 483 |
Solve the programming task below in a Python markdown code block.
Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to go out from each flat. Also, each flat is connected with t... | {"inputs": ["1\nA\n", "1\ng\n", "1\nA\n", "1\ng\n", "1\nh\n", "1\ni\n", "1\nf\n", "1\ne\n"], "outputs": ["1\n", "1\n", "1", "1", "1\n", "1\n", "1\n", "1\n"]} | coding | 480 |
Solve the programming task below in a Python markdown code block.
Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.
Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1... | {"inputs": ["4\n4\n0\n3\n1", "4\n3\n0\n3\n1", "4\n0\n0\n3\n1", "4\n0\n0\n0\n1", "4\n0\n0\n1\n1", "4\n0\n0\n6\n1", "4\n0\n1\n6\n1", "4\n0\n1\n6\n0"], "outputs": ["4\n", "3\n", "2\n", "0\n", "1\n", "3\n", "4\n", "3\n"]} | coding | 240 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
A pangram is a sentence where every letter of the English alphabet appears at least once.
Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.
... | {"functional": "def check(candidate):\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"leetcode\") == False\n\n\ncheck(Solution().checkIfPangram)"} | coding | 91 |
Solve the programming task below in a Python markdown code block.
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $... | {"inputs": ["1 1\n119\n395\n", "1 1\n511\n511\n", "1 1\n119\n395\n", "1 1\n511\n511\n", "4 2\n2 6 4 0\n2 4\n", "4 2\n2 6 4 0\n2 4\n", "3 2\n5 7 99\n23 162\n", "3 2\n3 7 227\n23 137\n"], "outputs": ["3", "511", "3", "511", "2", "2", "3\n", "3\n"]} | coding | 518 |
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.
For example, "Hello World", "HELLO", "hello world hello world" are all sentences.
Words consist of only uppercas... | {"functional": "def check(candidate):\n assert candidate(sentence = \"leetcode exercises sound delightful\") == True\n assert candidate(sentence = \"eetcode\") == True\n assert candidate(sentence = \"Leetcode is cool\") == False\n\n\ncheck(Solution().isCircularSentence)"} | coding | 222 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1:
Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by ... | {"functional": "def check(candidate):\n assert candidate(nums1 = [4,3,1,4], nums2 = [1,3,7,1], k = 3) == 2\n assert candidate(nums1 = [3,8,5,2], nums2 = [2,4,1,6], k = 1) == -1\n\n\ncheck(Solution().minOperations)"} | coding | 202 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Today is Devu's birthday. He has obtained few colored balloons from his friends. You are given this information by a string s consisting of lower case English Latin letters. Each letter ... | {"inputs": ["3\naab\nab\naa"], "outputs": ["aba\nab\n-1"]} | coding | 430 |
Solve the programming task below in a Python markdown code block.
Chef went shopping and bought items worth X rupees (1 ≤ X ≤ 100). Unfortunately, Chef only has a single 100 rupees note.
Since Chef is weak at maths, can you help Chef in calculating what money he should get back after paying 100 rupees for those items?... | {"inputs": ["3\n1\n25\n100\n"], "outputs": ["99\n75\n0\n"]} | coding | 282 |
Solve the programming task below in a Python markdown code block.
There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all.
There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.
Eating the same type of cake two days in a row would be n... | {"inputs": ["7 3\n4 2 2", "6 2\n1 4 1", "100 2\n100", "110 2\n110", "7 3\n2 2 2", "7 3\n2 1 2", "7 3\n0 1 2", "7 3\n0 1 1"], "outputs": ["0\n", "1\n", "99\n", "109\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 299 |
Solve the programming task below in a Python markdown code block.
A school has to decide on its team for an international quiz. There are $n$ students in the school. We can describe the students using an array $a$ where $a_i$ is the smartness of the $i$-th ($1 \le i \le n$) student.
There are $m$ topics $1, 2, 3, \ldo... | {"inputs": ["3\n2 4\n3 7\n4 2\n3 7 2 9\n5 7\n6 4 3 5 7\n"], "outputs": ["-1\n0\n3\n"]} | coding | 606 |
Solve the programming task below in a Python markdown code block.
After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».
The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1... | {"inputs": ["1 1 1\n1\n1\n", "1 1 1\n1\n1\n", "1 1 2\n1\n1\n", "4 2 2\n5\n6\n7\n", "2 2 1\n2\n1\n1\n", "2 2 1\n2\n1\n1\n", "4 2 2\n5\n6\n7\n", "4 2 3\n5\n6\n7\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "1\n", "1\n", "2\n", "2\n"]} | coding | 390 |
Solve the programming task below in a Python markdown code block.
Riley is a very bad boy, but at the same time, he is a yo-yo master. So, he decided to use his yo-yo skills to annoy his friend Anton.
Anton's room can be represented as a grid with $n$ rows and $m$ columns. Let $(i, j)$ denote the cell in row $i$ and c... | {"inputs": ["7\n2 3 1 1\n4 4 1 2\n3 5 2 2\n5 1 2 1\n3 1 3 1\n1 1 1 1\n1000000000 1000000000 1000000000 50\n"], "outputs": ["1 1 2 3\n1 1 4 4\n1 1 3 5\n1 1 5 1\n1 1 3 1\n1 1 1 1\n1 1 1000000000 1000000000\n"]} | coding | 709 |
Solve the programming task below in a Python markdown code block.
There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.
First, Snuke will arrange the N balls in a row from left to right.
Then, Takahashi will collect only the K bl... | {"inputs": ["7 3", "7 5", "5 5", "7 4", "7 2", "5 2", "3 3", "2 3"], "outputs": ["5\n20\n10\n", "3\n12\n6\n0\n0\n", "1\n0\n0\n0\n0\n", "4\n18\n12\n1\n", "6\n15\n", "4\n6\n", "1\n0\n0\n", "0\n0\n0\n"]} | coding | 465 |
Solve the programming task below in a Python markdown code block.
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array st... | {"inputs": ["1\n1\n", "1\n0\n", "1\n2\n", "1\n4\n", "1\n5\n", "1\n1000\n", "1\n1001\n", "1\n0001\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 346 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Write an algorithm to print all ways of arranging n queens on an n x n chess board so that none of them share the same row, column, or diagonal. In this case, "diagonal" means all diagonals, not just the two that bise... | {"functional": "def check(candidate):\n assert candidate(4) == [[\".Q..\",\"...Q\",\"Q...\",\"..Q.\"],[\"..Q.\",\"Q...\",\"...Q\",\".Q..\"]]\n\n\ncheck(Solution().solveNQueens)"} | coding | 125 |
Solve the programming task below in a Python markdown code block.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another stri... | {"inputs": ["1\nz\n", "2\naz\n", "2\naa\n", "2\nba\n", "2\nbb\n", "2\nbc\n", "2\nca\n", "2\nab\n"], "outputs": ["z", "az", "aa", "ab\n", "bb\n", "bc\n", "ac\n", "ab\n"]} | coding | 517 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
It's the soccer match finals in Chefland and as always it has reached the penalty shotouts.
Each team is given 5 shots to make and the team scoring a goal on... | {"inputs": ["4\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 1\n1 0 1 0 0 0 0 0 0 0 \n1 1 1 1 1 1 1 1 1 0"], "outputs": ["0\n2\n1\n1"]} | coding | 610 |
Solve the programming task below in a Python markdown code block.
You are given a binary string of length $n$ (i. e. a string consisting of $n$ characters '0' and '1').
In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given on... | {"inputs": ["1\n2 1\n00\n", "1\n2 1\n00\n", "2\n8 5\n11011010\n7 9\n1111100\n", "2\n8 5\n11011010\n7 9\n1111100\n", "2\n8 5\n11011010\n7 9\n1011100\n", "2\n8 5\n01011010\n7 9\n1011100\n", "2\n8 1\n01011010\n7 9\n1011100\n", "2\n8 5\n11011010\n7 9\n1111101\n"], "outputs": ["00\n", "00\n", "01011110\n0101111\n", "0101111... | coding | 540 |
Solve the programming task below in a Python markdown code block.
# Task
The `hamming distance` between a pair of numbers is the number of binary bits that differ in their binary notation.
# Example
For `a = 25, b= 87`, the result should be `4`
```
25: 00011001
87: 01010111
```
The `hamming distance` between thes... | {"functional": "_inputs = [[25, 87], [256, 302], [543, 634], [34013, 702]]\n_outputs = [[4], [4], [4], [7]]\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... | coding | 221 |
Solve the programming task below in a Python markdown code block.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and they are connec... | {"inputs": ["3\n1 2\n2 3\n3\n", "3\n1 2\n1 3\n2 3\n", "3\n1 2\n1 3\n3 2\n", "4\n1 2\n1 3\n1 4\n4 3 2\n", "5\n1 2\n4 3\n1 4\n4 5\n5 2 3\n", "6\n1 2\n1 3\n2 4\n4 5\n4 6\n5 6 3\n", "6\n1 2\n1 3\n2 4\n4 5\n4 6\n5 3 6\n", "8\n4 3\n1 4\n8 5\n7 6\n3 5\n7 3\n4 2\n2 6 8\n"], "outputs": ["1 2 3 2 1 ", "1 2 1 3 1 ", "1 3 1 2 1 ",... | coding | 434 |
Solve the programming task below in a Python markdown code block.
You are given a set of all integers from $l$ to $r$ inclusive, $l < r$, $(r - l + 1) \le 3 \cdot 10^5$ and $(r - l)$ is always odd.
You want to split these numbers into exactly $\frac{r - l + 1}{2}$ pairs in such a way that for each pair $(i, j)$ the gr... | {"inputs": ["1 8\n", "1 2\n", "2 3\n", "4 9\n", "3 6\n", "2 7\n", "2 7\n", "1 2\n"], "outputs": ["YES\n1 2\n3 4\n5 6\n7 8\n", "YES\n1 2\n", "YES\n2 3\n", "YES\n4 5\n6 7\n8 9\n", "YES\n3 4\n5 6\n", "YES\n2 3\n4 5\n6 7\n", "YES\n2 3\n4 5\n6 7\n", "YES\n1 2\n"]} | coding | 344 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Consider a very long K-digit number N with digits d_{0}, d_{1}, ..., d_{K-1} (in decimal notation; d_{0} is the most significant and d_{K-1} the least significant digit). Thi... | {"inputs": ["3\n5 3 4\n13 8 1\n760399384224 5 1"], "outputs": ["NO\nYES\nYES"]} | coding | 455 |
Solve the programming task below in a Python markdown code block.
An array is called `centered-N` if some `consecutive sequence` of elements of the array sum to `N` and this sequence is preceded and followed by the same number of elements.
Example:
```
[3,2,10,4,1,6,9] is centered-15
because the sequence 10,4,1 sums ... | {"functional": "_inputs = [[[0, 0, 0], 0], [[3, 2, 10, 4, 1, 6, 9], 15], [[2, 10, 4, 1, 6, 9], 15], [[3, 2, 10, 4, 1, 6], 15], [[1, 1, 8, 3, 1, 1], 15], [[1, 1, 8, 3, 1, 1], 11], [[1, 1, 8, 3, 1, 1], 13], [[9, 0, 6], 0], [[], 25], [[25], 25], [[25, 26, 23, 24], 0], [[2, 1, 2], 0], [[1, 1, 15, -1, -1], 15], [[1, 1, 15, ... | coding | 189 |
Solve the programming task below in a Python markdown code block.
```if:python
Note: Python may currently have some performance issues. If you find them, please let me know and provide suggestions to improve the Python version! It's my weakest language... any help is much appreciated :)
```
Artlessly stolen and adapt... | {"functional": "_inputs = [[[100, 90, 90, 80], [70, 80, 105]], [[982, 490, 339, 180], [180, 250, 721, 2500]], [[1982, 490, 339, 180], [180, 250, 721, 880]], [[1079, 490, 339, 180], [180, 250, 1200, 1980]]]\n_outputs = [[[4, 3, 1]], [[4, 4, 2, 1]], [[4, 4, 2, 2]], [[4, 4, 1, 1]]]\nimport math\ndef _deep_eq(a, b, tol=1e-... | coding | 505 |
Solve the programming task below in a Python markdown code block.
Luca has a cypher made up of a sequence of $n$ wheels, each with a digit $a_i$ written on it. On the $i$-th wheel, he made $b_i$ moves. Each move is one of two types:
up move (denoted by ${U}$): it increases the $i$-th digit by $1$. After applying the u... | {"inputs": ["3\n3\n9 3 1\n3 DDD\n4 UDUU\n2 DU\n2\n0 9\n9 DDDDDDDDD\n9 UUUUUUUUU\n5\n0 5 9 8 3\n10 UUUUUUUUUU\n3 UUD\n8 UUDUUDDD\n10 UUDUUDUDDU\n4 UUUU\n", "1\n45\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1 D\n1... | coding | 696 |
Solve the programming task below in a Python markdown code block.
There are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are n... | {"inputs": ["1\nB\n", "1\nB\n", "1\nC\n", "2\nBG\n", "2\nBB\n", "2\nBB\n", "2\nBG\n", "2\nGB\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "0\n", "0\n"]} | coding | 218 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
An array is monotonic if it is either monotone increasing or monotone decreasing.
An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, num... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,2,3]) == True\n assert candidate(nums = [6,5,4,4]) == True\n assert candidate(nums = [1,3,2]) == False\n\n\ncheck(Solution().isMonotonic)"} | coding | 129 |
Solve the programming task below in a Python markdown code block.
You are given an array A containing N integers. Find if it is possible to choose exactly M elements from the array such that the MEX of the chosen elements is exactly K.
Recall that the *MEX* of an array is the smallest non-negative integer that does no... | {"inputs": ["6\n5 4 2\n0 1 3 0 3\n2 1 2\n0 1\n3 3 3\n0 1 2\n4 3 3\n2 0 4 3\n5 4 2\n0 2 1 2 5\n6 5 2\n0 1 0 2 0 3\n"], "outputs": ["YES\nNO\nYES\nNO\nNO\nYES\n"]} | coding | 635 |
Solve the programming task below in a Python markdown code block.
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves eac... | {"inputs": ["3 0\n", "4 0\n", "3 0\n", "999 0\n", "999 0\n", "540 0\n", "428 0\n", "1000 0\n"], "outputs": ["1\n", "4\n", "1\n", "1993\n", "1993\n", "1076\n", "852\n", "1996\n"]} | coding | 523 |
Solve the programming task below in a Python markdown code block.
You are given a permutation $p_1, p_2, \ldots, p_n$ of length $n$. You have to choose two integers $l,r$ ($1 \le l \le r \le n$) and reverse the subsegment $[l,r]$ of the permutation. The permutation will become $p_1,p_2, \dots, p_{l-1},p_r,p_{r-1}, \dot... | {"inputs": ["4\n1\n1\n3\n2 1 3\n4\n1 4 2 3\n5\n1 2 3 4 5\n"], "outputs": ["1 \n1 2 3 \n1 2 4 3 \n1 2 3 4 5 \n"]} | coding | 658 |
Solve the programming task below in a Python markdown code block.
Now that you have won Code Monk and been hired by HackerEarth as a software engineer, you have been assigned to work on their wildly popular programming contest website.
HackerEarth is expecting a lot of participants (P) in Code Monk next year, and they... | {"inputs": ["2\n19 57 3\n24 97 2", "4\n50 700 2\n19 57 3\n1 1000 2\n24 97 2"], "outputs": ["Case #1: 0\nCase #2: 2", "Case #1: 2\nCase #2: 0\nCase #3: 4\nCase #4: 2"]} | coding | 559 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer matrix isWater of size m x n that represents a map of land and water cells.
If isWater[i][j] == 0, cell (i, j) is a land cell.
If isWater[i][j] == 1, cell (i, j) is a water cell.
You must as... | {"functional": "def check(candidate):\n assert candidate(isWater = [[0,1],[0,0]]) == [[1,0],[2,1]]\n assert candidate(isWater = [[0,0,1],[1,0,0],[0,0,0]]) == [[1,1,0],[0,1,1],[1,2,2]]\n\n\ncheck(Solution().highestPeak)"} | coding | 261 |
Solve the programming task below in a Python markdown code block.
The entire network is under the inspection and direct control of the Decepticons. They have learned our language through the World Wide Web and can easily understand the messages which are being sent. Sam is trying to send the information to Autobots to ... | {"inputs": ["techtrishna online event\nonlin"], "outputs": ["Y"]} | coding | 272 |
Solve the programming task below in a Python markdown code block.
You are given a string S consisting of lowercase English letters.
Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S.
If every lowercase English letter occurs in S, print None instead.
-----Constraints... | {"inputs": ["atcoderregularcontest\n", "abcdefghijklmnopqrstuvwxyz\n", "fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg\n"], "outputs": ["b\n", "None\n", "d\n"]} | coding | 175 |
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 0 1\n", "2\n-1 -1 1\n", "2\n50 54 50\n", "2\n50 50 50\n", "3\n-1 1 1 1 1\n", "3\n-2 3 4 5 6\n", "3\n-2 3 0 5 6\n", "2\n-1 -112 -1\n"], "outputs": ["2\n", "3\n", "154\n", "150\n", "5\n", "20\n", "16\n", "112\n"]} | coding | 287 |
Solve the programming task below in a Python markdown code block.
Error Handling is very important in coding and seems to be overlooked or not implemented properly.
#Task
Your task is to implement a function which takes a string as input and return an object containing the properties
vowels and consonants. The vowels... | {"functional": "_inputs = [['Test'], ['Here is some text'], ['To be a Codewarrior or not to be'], ['To Kata or not to Kata'], ['aeiou'], ['TEst'], ['HEre Is sOme text'], [['To Kata or not to Kata']], [None], ['Test '], ['Here is some text '], [' '], [{'jjjjj': 'jjjjj'}]]\n_outputs... | coding | 350 |
Solve the programming task below in a Python markdown code block.
The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the f... | {"inputs": ["1\n5\n", "1\n5\n", "1\n2\n", "2\n0 1\n", "2\n0 5\n", "2\n0 5\n", "2\n0 1\n", "3\n1 1 1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 351 |
Solve the programming task below in a Python markdown code block.
A programming contest is held every year at White Tiger University. When the total number of teams is N, each team is assigned a team ID from 1 to N. The contest starts with all teams scoring 0 and runs continuously for L seconds.
This year's contest wi... | {"inputs": ["3 0 340\n3 110 5\n0 4 11\n2 483 0\n3 249 8", "3 0 340\n3 110 5\n0 4 11\n2 942 0\n3 249 8", "3 0 340\n3 110 5\n0 4 11\n2 132 0\n3 249 8", "3 0 445\n3 110 5\n0 4 11\n2 132 0\n3 249 8", "3 0 445\n3 110 5\n0 4 21\n2 132 0\n3 249 8", "3 0 445\n3 110 5\n0 4 38\n2 132 0\n3 249 8", "3 0 445\n3 110 5\n0 5 38\n2 132... | coding | 518 |
Solve the programming task below in a Python markdown code block.
Write a function `sumTimesTables` which sums the result of the sums of the elements specified in `tables` multiplied by all the numbers in between `min` and `max` including themselves.
For example, for `sumTimesTables([2,5],1,3)` the result should be th... | {"functional": "_inputs = [[[2, 3], 1, 3], [[1, 3, 5], 1, 1], [[1, 3, 5], 1, 10], [[], 1, 10], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 1, 10], [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 1, 10], [[5, 4, 7, 8, 9, 6, 3, 2, 10, 1], 1, 10], [[-2], -1, 3], [[-2, 2], -1, 3], [[-2, 3], -1, 3], [[2, -3], -1, 3], [[2, 4, 7], -100, 100], [[2, 4... | coding | 196 |
Solve the programming task below in a Python markdown code block.
*This kata is based on [Project Euler Problem 539](https://projecteuler.net/problem=539)*
##Object
Find the last number between 1 and `n` (inclusive) that survives the elimination process
####How It Works
Start with the first number on the left then ... | {"functional": "_inputs = [[9], [10], [100], [1000], [50000]]\n_outputs = [[6], [8], [54], [510], [22358]]\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(... | coding | 324 |
Solve the programming task below in a Python markdown code block.
The number ```12``` is the first number in having six divisors, they are: ```1, 2, 3, 4, 6 and 12.```
Your challenge for this kata is to find the minimum number that has a certain number of divisors.
For this purpose we have to create the function
```f... | {"functional": "_inputs = [[6], [10], [12], [13]]\n_outputs = [[12], [48], [60], [4096]]\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): retu... | coding | 300 |
Solve the programming task below in a Python markdown code block.
A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to compl... | {"inputs": ["1\n0 0 0\n", "1\n1 -2 0\n", "2\n5 -23 12\n0 0 0\n", "2\n5 -23 19\n0 0 0\n", "2\n3 -23 21\n0 0 0\n", "2\n6 -23 21\n0 0 0\n", "2\n6 -33 21\n0 0 0\n", "2\n6 -33 11\n0 0 0\n"], "outputs": ["YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | coding | 390 |
Solve the programming task below in a Python markdown code block.
Write a program to obtain a number $(N)$ from the user and display whether the number is a one digit number, 2 digit number, 3 digit number or more than 3 digit number
-----Input:-----
- First line will contain the number $N$,
-----Output:-----
Print "... | {"inputs": ["9"], "outputs": ["1"]} | coding | 164 |
Solve the programming task below in a Python markdown code block.
Monocarp has just learned a new card trick, and can't wait to present it to you. He shows you the entire deck of $n$ cards. You see that the values of cards from the topmost to the bottommost are integers $a_1, a_2, \dots, a_n$, and all values are differ... | {"inputs": ["3\n2\n1 2\n3\n1 1 1\n4\n3 1 4 2\n2\n3 1\n5\n2 1 5 4 3\n5\n3 2 1 2 1\n"], "outputs": ["2\n3\n3\n"]} | coding | 638 |
Solve the programming task below in a Python markdown code block.
Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table).
At the beginning of the game Alice puts k ships on the field without telling their positions ... | {"inputs": ["5 1 3\n1\n3\n", "1 1 1\n1\n1\n", "1 1 1\n1\n1\n", "2 1 1\n1\n1\n", "2 1 2\n1\n1\n", "3 1 2\n1\n1\n", "5 1 3\n1\n2\n", "5 1 2\n1\n1\n"], "outputs": ["1\n", "1\n", "1\n", "-1\n", "1\n", "-1\n", "-1\n", "-1\n"]} | coding | 484 |
Solve the programming task below in a Python markdown code block.
Your algorithms have become so good at predicting the market that you now know what the share price of Wooden Orange Toothpicks Inc. (WOT) will be for the next number of days.
Each day, you can either buy one share of WOT, sell any number of shares of W... | {"inputs": ["3\n3\n5 3 2\n3\n1 2 100\n4\n1 3 1 2"], "outputs": ["0\n197\n3\n"]} | coding | 568 |
Solve the programming task below in a Python markdown code block.
Our friendly friend Pete is really a nice person, but he tends to be rather... Inappropriate.
And possibly loud, if given enough ethanol and free rein, so we ask you to write a function that should take its not always "clean" speech and cover as much as... | {"functional": "_inputs = [['I want to punch someone in the face'], ['uh!'], ['What the hell am I doing here? And where is my wallet? PETE SMASH!'], ['I want to punch someone in the face', ['someone', 'face']], ['I want to punch someone in the face', ['drink', 'job', 'girls']]]\n_outputs = [['I w**t to p***h s*****e in... | coding | 413 |
Solve the programming task below in a Python markdown code block.
There are N rabbits, numbered 1 through N.
The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.
For a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.
* ... | {"inputs": ["3\n3 3 1", "3\n2 0 1", "3\n3 0 1", "3\n2 0 0", "3\n2 1 1", "3\n3 3 2", "3\n3 0 0", "3\n2 3 1"], "outputs": ["1\n", "0\n", "1\n", "0\n", "1\n", "1\n", "0\n", "0"]} | coding | 222 |
Solve the programming task below in a Python markdown code block.
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.
Given an integer N, determine whether it is a Harshad number.
-----Constraints-----
- 1?N?10^8
- N is an integer.
---... | {"inputs": ["1", "2", "3", "6", "8", "5", "4", "9"], "outputs": ["Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]} | coding | 164 |
Solve the programming task below in a Python markdown code block.
Vasya likes to solve equations. Today he wants to solve $(x~\mathrm{div}~k) \cdot (x \bmod k) = n$, where $\mathrm{div}$ and $\mathrm{mod}$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation... | {"inputs": ["6 3\n", "1 2\n", "4 6\n", "2 2\n", "5 5\n", "9 8\n", "2 2\n", "5 5\n"], "outputs": ["11\n", "3\n", "10\n", "5\n", "26\n", "27\n", "5", "26"]} | coding | 460 |
Solve the programming task below in a Python markdown code block.
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junc... | {"inputs": ["1\n\n", "1\n\n", "2\n1\n", "2\n1\n", "3\n1 1\n", "3\n1 2\n", "3\n1 1\n", "5\n1 1 3 3\n"], "outputs": ["1 \n", "1 \n", "1 1 \n", "1 1 \n", "1 1 2 \n", "1 1 1\n", "1 1 2 \n", "1 1 1 2 3 \n"]} | coding | 582 |
Solve the programming task below in a Python markdown code block.
Alice likes to shop online. The main reason is that she gets a lot of discounts! There are M online shops from where she purchases her items. The prices of the same item vary in both the shops. She needs to buy N items in all. And each she can buy each i... | {"inputs": ["2\n2 2\n3 4\n1 2\n1 0\n0 1\n2 4\n1 2 3 4\n4 3 2 1\n2 3 2 1\n1 2 1 1"], "outputs": ["3\n2"]} | coding | 699 |
Solve the programming task below in a Python markdown code block.
You are given an integer, $N$. Write a program to determine if $N$ is an element of the Fibonacci sequence.
The first few elements of the Fibonacci sequence are $0,1,1,2,3,5,8,13,\cdots$. A Fibonacci sequence is one where every element is a sum of the... | {"inputs": ["3\n5\n7\n8\n"], "outputs": ["IsFibo\nIsNotFibo\nIsFibo\n"]} | coding | 401 |
Solve the programming task below in a Python markdown code block.
To celebrate the start of the Rio Olympics (and the return of 'the Last Leg' on C4 tonight) this is an Olympic inspired kata.
Given a string of random letters, you need to examine each. Some letters naturally have 'rings' in them. 'O' is an obvious exam... | {"functional": "_inputs = [['wHjMudLwtoPGocnJ'], ['eCEHWEPwwnvzMicyaRjk'], ['JKniLfLW'], ['EWlZlDFsEIBufsalqof'], ['IMBAWejlGRTDWetPS']]\n_outputs = [['Bronze!'], ['Bronze!'], ['Not even a medal!'], ['Silver!'], ['Gold!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):... | coding | 242 |
Solve the programming task below in a Python markdown code block.
A monster is attacking the Cyberland!
Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).
During the battle, every second the monster's HP de... | {"inputs": ["1 1 1\n1 1 1\n1 1 1\n", "1 0 1\n1 1 1\n1 1 1\n", "1 0 2\n1 1 1\n1 1 1\n", "1 100 1\n1 1 1\n1 1 1\n", "79 1 1\n1 1 10\n1 1 100\n", "79 1 1\n2 1 10\n1 1 100\n", "79 1 0\n2 1 10\n1 1 100\n", "1 10 29\n1 1 43\n1 1 100\n"], "outputs": ["1", "2\n", "2\n", "0", "10", "10\n", "10\n", "34"]} | coding | 456 |
Solve the programming task below in a Python markdown code block.
Lord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!
A password is an array $a$ of $n$ positive integers. You apply the following operation to the array: pick any t... | {"inputs": ["1\n1\n1\n", "1\n1\n1\n", "1\n3\n3 4 7\n", "1\n3\n3 1 2\n", "1\n3\n1 2 3\n", "1\n3\n1 3 4\n", "1\n3\n3 2 1\n", "1\n3\n4 3 1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 581 |
Solve the programming task below in a Python markdown code block.
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter... | {"inputs": ["1\n9671\n", "1\n24061\n", "1\n24095\n", "1\n32871\n", "1\n62298\n", "1\n91044\n", "1\n94177\n", "1\n36654\n"], "outputs": ["6\n", "6\n", "6\n", "6\n", "6\n", "6\n", "6\n", "6\n"]} | coding | 441 |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ of size $n$. Each element in this array is an integer between $1$ and $10^9$.
You can perform several operations to this array. During an operation, you can replace an element in the array with any integer between $1$ and $10^... | {"inputs": ["5\n3\n2 1 2\n4\n1 2 3 1\n5\n1 2 1 2 1\n9\n1 2 1 3 2 3 1 2 1\n9\n2 1 3 1 3 1 3 1 3\n"], "outputs": ["0\n2 1 2 \n1\n1 2 3 3 \n1\n1 2 2 2 1 \n2\n1 2 3 3 2 3 3 2 1 \n2\n2 1 3 3 3 1 3 3 3 \n"]} | coding | 627 |
Solve the programming task below in a Python markdown code block.
Alice and Bob have participated to a Rock Off with their bands. A jury of true metalheads rates the two challenges, awarding points to the bands on a scale from 1 to 50 for three categories: Song Heaviness, Originality, and Members' outfits.
For each on... | {"functional": "_inputs = [[[47, 7, 2], [47, 7, 2]], [[47, 50, 22], [26, 47, 12]], [[25, 50, 22], [34, 49, 50]], [[8, 8, 11], [3, 8, 10]], [[20, 32, 18], [48, 25, 40]], [[5, 6, 7], [3, 6, 10]], [[21, 39, 15], [50, 1, 12]], [[0, 1, 2], [1, 2, 0]]]\n_outputs = [['0, 0: that looks like a \"draw\"! Rock on!'], ['3, 0: Alic... | coding | 357 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.
The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.
For example, a... | {"functional": "def check(candidate):\n assert candidate(arr = [5,4,3,2,1], k = 1) == 4\n assert candidate(arr = [4,1,5,2,6,2], k = 2) == 0\n assert candidate(arr = [4,1,5,2,6,2], k = 3) == 2\n\n\ncheck(Solution().kIncreasing)"} | coding | 283 |
Solve the programming task below in a Python markdown code block.
A new task for you!
You have to create a method, that corrects a given time string.
There was a problem in addition, so many of the time strings are broken.
Time-Format is european. So from "00:00:00" to "23:59:59".
Some examples:
"09:10:01" -> "09:1... | {"functional": "_inputs = [[None], [''], ['001122'], ['00;11;22'], ['0a:1c:22'], ['09:10:01'], ['11:70:10'], ['19:99:99'], ['24:01:01'], ['52:01:01'], ['14:59:94']]\n_outputs = [[None], [''], [None], [None], [None], ['09:10:01'], ['12:10:10'], ['20:40:39'], ['00:01:01'], ['04:01:01'], ['15:00:34']]\nimport math\ndef _d... | coding | 260 |
Solve the programming task below in a Python markdown code block.
Given an array A consisting of N non-negative integers.
You need to perform the following operation (N - 1) times:
Sort the array A in ascending order.
Let M be the current size of the array A. Replace the array A by [(A_{2} - A_{1}), (A_{3} - A_{2}), ... | {"inputs": ["2\n4\n29 19 0 3\n1\n777"], "outputs": ["1\n777"]} | coding | 578 |
Solve the programming task below in a Python markdown code block.
You have a binary string S of length N. In one operation you can select a substring of S and reverse it. For example, on reversing the substring S[2,4] for S=11000, we change 1 \textcolor{red}{100} 0 \rightarrow 1 \textcolor{red}{001} 0.
Find the minimu... | {"inputs": ["4\n3\n000\n4\n1001\n4\n1010\n6\n010101"], "outputs": ["0\n1\n2\n2"]} | coding | 577 |
Solve the programming task below in a Python markdown code block.
There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and... | {"inputs": ["1\n1\n", "1\n1\n", "2\n1 2\n", "2\n2 1\n", "2\n1 2\n", "2\n2 1\n", "6\n1 2 3 4 5 6\n", "6\n6 5 4 3 2 1\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "0\n", "1\n", "0\n", "1\n"]} | coding | 326 |
Solve the programming task below in a Python markdown code block.
Ayoub had an array $a$ of integers of size $n$ and this array had two interesting properties: All the integers in the array were between $l$ and $r$ (inclusive). The sum of all the elements was divisible by $3$.
Unfortunately, Ayoub has lost his arr... | {"inputs": ["2 1 3\n", "3 2 2\n", "1 1 1\n", "3 1 1\n", "3 1 1\n", "1 1 1\n", "6 1 1\n", "2 1 2\n"], "outputs": ["3\n", "1\n", "0\n", "1\n", "1", "0", "1\n", "2\n"]} | coding | 373 |
Solve the programming task below in a Python markdown code block.
In the city of Saint Petersburg, a day lasts for $2^{100}$ minutes. From the main station of Saint Petersburg, a train departs after $1$ minute, $4$ minutes, $16$ minutes, and so on; in other words, the train departs at time $4^k$ for each integer $k \ge... | {"inputs": ["0\n", "1\n", "1\n", "0\n", "11\n", "11\n", "101\n", "110\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "2\n", "2\n"]} | coding | 385 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a binary string $S$. Chef defines $\mathrm{MEX}(S)$ as the smallest non-negative integer such that its binary representation (without leading '0... | {"inputs": ["2\n1001011\n1111"], "outputs": ["1100\n0"]} | coding | 525 |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ of lowercase Latin letters.
The following operation can be used:
select one character (from 'a' to 'z') that occurs at least once in the string. And replace all such characters in the string with the previous one in alphabeti... | {"inputs": ["1\n15 1\nwaterwaterwater\n", "4\n3 2\ncba\n4 5\nfgde\n7 5\ngndcafb\n4 19\nekyv\n"], "outputs": ["vatervatervater\n", "aaa\nagaa\nbnbbabb\naapp\n"]} | coding | 497 |
Solve the programming task below in a Python markdown code block.
Valera is a collector. Once he wanted to expand his collection with exactly one antique item.
Valera knows n sellers of antiques, the i-th of them auctioned k_{i} items. Currently the auction price of the j-th object of the i-th seller is s_{ij}. Valera... | {"inputs": ["1 50001\n1 50000\n", "1 50001\n1 50000\n", "1 1000000\n1 561774\n", "1 1000000\n1 561774\n", "1 1000000\n1 672641\n", "1 1000000\n1 1000000\n", "1 1000000\n1 1000000\n", "1 1100000\n1 1000000\n"], "outputs": ["1\n1\n", "1\n1\n", "1\n1\n", "1\n1\n", "1\n1 \n", "0\n\n", "0\n", "1\n1 \n"]} | coding | 634 |
Solve the programming task below in a Python markdown code block.
A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.
Given a string S, determine whether it is coffee-like.
-----Co... | {"inputs": ["cofgee", "sjppvv", "uuppis", "ephoni", "cofgef", "uvppis", "eohoni", "fegfoc"], "outputs": ["No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | coding | 169 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are two types of persons:
The good person: The person who always tells the truth.
The bad person: The person who might tell the truth and might lie.
You are given a 0-indexed 2D integer array statements of siz... | {"functional": "def check(candidate):\n assert candidate(statements = [[2,1,2],[1,2,2],[2,0,2]]) == 2\n assert candidate(statements = [[2,0],[0,2]]) == 1\n\n\ncheck(Solution().maximumGood)"} | coding | 231 |
Solve the programming task below in a Python markdown code block.
Meera bought a house on Mars, and plans to decorate it with chains of alien flowers. Each flower is either red ($\mbox{R}$) or blue ($\mbox{B}$), and Meera knows how many occurrences of RR, RB, BB, and BR she wants to see in a chain.
The diagram be... | {"inputs": ["1 1 2 1\n"], "outputs": ["5\n"]} | coding | 502 |
Solve the programming task below in a Python markdown code block.
You are given a binary string S of length N (i.e. every character of S is either 0 or 1).
You can perform the following operation on S:
select any two indices i, j of the same parity, i.e. either both i, j are odd or both i, j are even
swap S_{i} and S_... | {"inputs": ["3\n5\n00100\n5\n01010\n5\n10001"], "outputs": ["1\n2\n2"]} | coding | 666 |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ that contains $n$ integers. You can choose any proper subsegment $a_l, a_{l + 1}, \ldots, a_r$ of this array, meaning you can choose any two integers $1 \le l \le r \le n$, where $r - l + 1 < n$. We define the beauty of a given... | {"inputs": ["1\n4\n1000000000 1000000000 1000000000 1000000000\n", "4\n8\n1 2 2 3 1 5 6 1\n5\n1 2 3 100 200\n4\n3 3 3 3\n6\n7 8 3 1 1 8\n"], "outputs": ["0\n", "9\n297\n0\n14\n"]} | coding | 587 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to s... | {"functional": "def check(candidate):\n assert candidate(n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [False,False,True,False,True,True,False]) == 8 \n assert candidate(n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [False,False,True,False,False,True,False]) == 6\n assert ... | coding | 200 |
Solve the programming task below in a Python markdown code block.
Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are $N$ atoms numbered from $1$ to $N$. These atoms are especially quirky. Initially, each atom is in n... | {"inputs": ["4 2\n1 2 4 8\n1 5 3 5\n", "4 2\n1 2 4 8\n5 1 3 5\n", "4 2\n1 2 4 8\n5 3 1 5\n", "4 2\n1 2 4 8\n6 5 3 1\n", "4 3\n1 2 4 8\n1 5 3 5\n", "4 3\n1 2 4 8\n5 1 3 5\n", "4 3\n1 2 4 8\n5 3 1 5\n", "4 3\n1 2 4 8\n6 5 3 1\n"], "outputs": ["14\n", "14\n", "14\n", "12\n", "14\n", "14\n", "14\n", "12\n"]} | coding | 680 |
Solve the programming task below in a Python markdown code block.
Compute A \times B.
-----Constraints-----
- 1 \leq A \leq 100
- 1 \leq B \leq 100
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
Print the value A \times B as an ... | {"inputs": ["4 5", "1 1", "1 2", "1 3", "4 2", "6 2", "2 5", "2 5\n"], "outputs": ["20\n", "1\n", "2\n", "3\n", "8\n", "12\n", "10", "10\n"]} | coding | 119 |
Solve the programming task below in a Python markdown code block.
"Don't Drink and Drive, but when you do, Better Call Saul."
Once Jesse and Walter were fighting over extra cash, and Saul decided to settle it with a game of stone piles whose winner gets the extra money. The game is described as follows :
There are N$N$... | {"inputs": ["2\n5 3\n4 4 4 3 4\n7 4\n3 3 1 1 1 2 4"], "outputs": ["Jesse\nWalter"]} | coding | 618 |
Solve the programming task below in a Python markdown code block.
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds.... | {"inputs": ["1 7\n7\n", "1 7\n5\n", "1 1\n1\n", "1 1\n1\n", "1 7\n5\n", "1 7\n9\n", "1 3\n9\n", "1 7\n7\n"], "outputs": ["0 0\n", "1 6\n", "0 0\n", "0 0", "1 6", "0 0\n", "0 0\n", "0 0"]} | coding | 550 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith tree produces.
You want to co... | {"functional": "def check(candidate):\n assert candidate(fruits = [1,2,1]) == 3\n assert candidate(fruits = [0,1,2,2]) == 3\n assert candidate(fruits = [1,2,3,2,2]) == 4\n assert candidate(fruits = [3,3,3,1,2,1,1,2,3,3,4]) == 5\n\n\ncheck(Solution().totalFruit)"} | coding | 220 |
Solve the programming task below in a Python markdown code block.
Once upon a time, a CodeWarrior, after reading a [discussion on what can be the plural](http://www.codewars.com/kata/plural/discuss/javascript), took a look at [this page](http://en.wikipedia.org/wiki/Grammatical_number#Types_of_number
) and discovered t... | {"functional": "_inputs = [['1 tomato'], ['0 tomato'], ['1 ananas'], ['2 bananas'], ['3 bananas'], ['10 bananas'], ['111 bananas'], ['6 birds with 2 wings each = 12 legs'], ['\\n3 pigs\\nmet 1 wolf\\n2 days ago']]\n_outputs = [['1 tomato'], ['0 tomato'], ['1 ananas'], ['2 bubanana'], ['3 bananazo'], ['10 gabananaga'], ... | coding | 598 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a graph $G$ with $N$ vertices (numbered $1$ through $N$) and $M$ edges. You should partition the vertices of $G$ into two sets $A$ and $B$ such ... | {"inputs": ["1\n5 7\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4"], "outputs": ["1\n11000"]} | coding | 705 |
Solve the programming task below in a Python markdown code block.
For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.
You are given a positive integer D. How many positive integers N satisfy r... | {"inputs": ["9", "8", "3", "6", "5", "7", "1", "2"], "outputs": ["8\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 181 |
Solve the programming task below in a Python markdown code block.
Let us begin with an example:
A man has a rather old car being worth $2000.
He saw a secondhand car being worth $8000. He wants to keep his old car until he can buy the secondhand one.
He thinks he can save $1000 each month but the prices of his old
... | {"functional": "_inputs = [[2000, 8000, 1000, 1.5], [8000, 12000, 500, 1], [18000, 32000, 1500, 1.25], [7500, 32000, 300, 1.55]]\n_outputs = [[[6, 766]], [[8, 597]], [[8, 332]], [[25, 122]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a,... | coding | 725 |
Solve the programming task below in a Python markdown code block.
There are $n$ variables and $m$ requirements. Requirements are represented as $\left(x\leq y\right)$, meaning that the $x^{th}$ variable must be less than or equal to the $y^{th}$ variable.
Your task is to assign non-negative numbers smaller than $10$ ... | {"inputs": ["6 7\n1 3\n0 1\n2 4\n0 4\n2 5\n3 4\n0 2\n"], "outputs": ["1000\n"]} | coding | 444 |
Solve the programming task below in a Python markdown code block.
Given a string, return a new string that has transformed based on the input:
* Change case of every character, ie. lower case to upper case, upper case to lower case.
* Reverse the order of words from the input.
**Note:** You will have to handle multip... | {"functional": "_inputs = [['Example string'], ['Example Input'], ['To be OR not to be That is the Question'], [''], ['You Know When THAT Hotline Bling'], [' A b C d E f G ']]\n_outputs = [['STRING eXAMPLE'], ['iNPUT eXAMPLE'], ['qUESTION THE IS tHAT BE TO NOT or BE tO'], [''], ['bLING hOTLINE that wHEN kNOW yOU'],... | coding | 131 |
Solve the programming task below in a Python markdown code block.
Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.
When Vasya has some free time, he goes to... | {"inputs": ["2 1\n", "4 6\n", "1 2\n", "4 7\n", "1 3\n", "7 3\n", "5 7\n", "7 1\n"], "outputs": ["Equal\n", "Equal\n", "Equal\n", "Dasha\n", "Dasha\n", "Masha\n", "Dasha\n", "Masha\n"]} | coding | 615 |
Solve the programming task below in a Python markdown code block.
Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!
This contest consists of n problems, and Pasha solves ith problem in a_{i} time units (his solutions are... | {"inputs": ["1\n1\n0\n", "1\n2\n0\n", "1\n4\n0\n", "1\n5\n0\n", "1\n1\n0\n", "1\n2\n0\n", "1\n4\n0\n", "1\n5\n0\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | coding | 684 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.