task_type stringclasses 4
values | problem stringlengths 14 5.23k | solution stringlengths 1 8.29k | problem_tokens int64 9 1.02k | solution_tokens int64 1 1.98k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=... | {"inputs": ["6 2\n3 4", "5 3\n1 2 4"], "outputs": ["4", "3"]} | 381 | 32 |
coding | Solve the programming task below in a Python markdown code block.
# Sort an array by value and index
Your task is to sort an array of integer numbers by the product of the value and the index of the positions.
For sorting the index starts at 1, NOT at 0!
The sorting has to be ascending.
The array will never be null a... | {"functional": "_inputs = [[[1, 2, 3, 4, 5]], [[23, 2, 3, 4, 5]], [[26, 2, 3, 4, 5]], [[9, 5, 1, 4, 3]]]\n_outputs = [[[1, 2, 3, 4, 5]], [[2, 3, 4, 23, 5]], [[2, 3, 4, 5, 26]], [[1, 9, 5, 3, 4]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclo... | 288 | 275 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $s$ of length $n$ consisting of characters a and/or b.
Let $\operatorname{AB}(s)$ be the number of occurrences of string ab in $s$ as a substring. Analogically, $\operatorname{BA}(s)$ is the number of occurrences of ba in $s$ as a... | {"inputs": ["4\nb\naabbbabaa\nabbb\nabbaab\n", "4\nb\naabbbabaa\nabbb\nabbaab\n", "4\na\naabbbabaa\nabbb\nabbaab\n", "4\nb\naabbbabaa\nabbb\nabbabb\n", "4\na\naabababaa\nabbb\nabbaab\n", "4\nb\naabbbacaa\nabbb\nabbabb\n", "4\nc\naabbbacaa\nabbb\nabbabb\n", "4\nc\naacabbbaa\nabbb\nabbabb\n"], "outputs": ["b\naabbbabaa\n... | 656 | 262 |
coding | Solve the programming task below in a Python markdown code block.
Let N be a positive integer.
There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).
Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.
Here,... | {"inputs": ["1\n1 0 5", "1\n0 0 5", "1\n1 3 5", "1\n1 2 5", "1\n0 0 8", "1\n0 0 0", "1\n0 1 0", "1\n1 2 3"], "outputs": ["1\n", "0\n", "-2\n", "-1\n", "0\n", "0\n", "1\n", "-1"]} | 299 | 109 |
coding | Solve the programming task below in a Python markdown code block.
Pak Chanek has a grid that has $N$ rows and $M$ columns. Each row is numbered from $1$ to $N$ from top to bottom. Each column is numbered from $1$ to $M$ from left to right.
Each tile in the grid contains a number. The numbers are arranged as follows:
... | {"inputs": ["3 4\n", "2 1\n", "1 1\n", "1 2\n", "2 2\n", "1 999999997\n", "1 589284012\n", "999999999 1\n"], "outputs": ["9\n", "1\n", "0\n", "1\n", "2\n", "999999996\n", "589284011\n", "999999998\n"]} | 371 | 134 |
coding | Solve the programming task below in a Python markdown code block.
This is the harder version of the problem. In this version, $1 \le n \le 10^6$ and $0 \leq a_i \leq 10^6$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems
Christmas is coming, and our pr... | {"inputs": ["1\n1\n", "1\n1\n", "1\n25\n", "1\n835\n", "1\n2103\n", "1\n2103\n", "1\n2140\n", "3\n4 8 5\n"], "outputs": ["-1\n", "-1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "9\n"]} | 678 | 103 |
coding | Solve the programming task below in a Python markdown code block.
You are given a matrix consisting of digits zero and one, its size is n × m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described operations?... | {"inputs": ["1 1\n0\n", "1 1\n1\n", "2 2\n10\n11\n", "4 3\n101\n011\n000\n101\n", "4 3\n101\n011\n101\n101\n", "4 3\n101\n011\n100\n101\n", "4 3\n100\n111\n000\n101\n", "4 3\n100\n011\n000\n101\n"], "outputs": ["0\n", "1\n", "2\n", "3\n", "4\n", "3\n", "3\n", "2\n"]} | 357 | 176 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which calculates the area and perimeter of a given rectangle.
Constraints
* 1 ≤ a, b ≤ 100
Input
The length a and breadth b of the rectangle are given in a line separated by a single space.
Output
Print the area and perimeter of the... | {"inputs": ["0 5", "1 5", "1 3", "0 3", "0 1", "0 2", "0 4", "1 4"], "outputs": ["0 10\n", "5 12\n", "3 8\n", "0 6\n", "0 2\n", "0 4\n", "0 8\n", "4 10\n"]} | 104 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Ty... | {"inputs": ["3 3\nbyg\ndwg\nl\nx\n", "3 3\nbzg\ndwg\nl\nx\n", "4 4\nlocw\na\nr\nba\nxuv\n", "4 4\nlocw\na\ns\nba\nxuv\n", "4 4\nlocw\na\ns\nba\nwuv\n", "4 4\nlocw\na\ns\nba\nwtv\n", "4 4\nlodw\na\nr\nba\nxuv\n", "5 5\nvpjjx\njj\ne\nnor\nuthm\nbf\n"], "outputs": ["6\n1\n1\n", "6\n1\n1\n", "1\n1\n4\n9\n", "1\n1\n4\n9\n",... | 682 | 228 |
coding | Solve the programming task below in a Python markdown code block.
Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it.
At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words an... | {"inputs": ["1 1 1\nv\n", "1 1 1\nn\n", "1 1 1\nz\n", "1 1 1\nd\n", "1 1 1\nb\n", "1 1 1\ny\n", "1 1 1\nc\n", "1 1 1\nx\n"], "outputs": ["v\n", "n\n", "z\n", "d\n", "b\n", "y\n", "c\n", "x\n"]} | 306 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue sm... | {"functional": "def check(candidate):\n assert candidate(img = [[1,1,1],[1,0,1],[1,1,1]]) == [[0, 0, 0],[0, 0, 0], [0, 0, 0]]\n assert candidate(img = [[100,200,100],[200,50,200],[100,200,100]]) == [[137,141,137],[141,138,141],[137,141,137]]\n\n\ncheck(Solution().imageSmoother)"} | 171 | 155 |
coding | Solve the programming task below in a Python markdown code block.
After completing some serious investigation, Watson and Holmes are now chilling themselves in the Shimla hills. Very soon Holmes became bored. Holmes lived entirely for his profession. We know he is a workaholic. So Holmes wants to stop his vacation and ... | {"inputs": ["2\n12\n3 1 2 3 2 0 2 2 2 0 2 3\n11\n3 9 9 6 4 3 6 4 9 6 0"], "outputs": ["33322222200\n999666330"]} | 578 | 84 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array consisting of $n$ integers $a_1, a_2, \dots , a_n$ and an integer $x$. It is guaranteed that for every $i$, $1 \le a_i \le x$.
Let's denote a function $f(l, r)$ which erases all values such that $l \le a_i \le r$ from the array $a... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "2 3\n1 1\n", "2 3\n3 2\n", "2 3\n3 2\n", "2 3\n1 1\n", "2 4\n3 2\n", "2 20\n1 8\n"], "outputs": ["1\n", "1\n", "6\n", "5\n", "5\n", "6\n", "8\n", "210\n"]} | 461 | 117 |
coding | Solve the programming task below in a Python markdown code block.
Freddy has a really fat left pinky finger, and every time Freddy tries to type an ```A```, he accidentally hits the CapsLock key!
Given a string that Freddy wants to type, emulate the keyboard misses where each ```A``` supposedly pressed is replaced wit... | {"functional": "_inputs = [['aAaaaaAaaaAAaAa'], ['The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the bl... | 554 | 405 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp is a great fan of television.
He wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment l_{i} and ends at moment r_{i}.
Polycarp owns two TVs. He can watch two different shows sim... | {"inputs": ["2\n0 1\n0 1\n", "2\n0 4\n0 4\n", "2\n0 2\n0 6\n", "2\n2 5\n0 5\n", "2\n0 2\n0 6\n", "2\n0 1\n0 1\n", "2\n0 4\n0 4\n", "2\n2 5\n0 5\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES"]} | 298 | 133 |
coding | Solve the programming task below in a Python markdown code block.
You are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'.
The period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$ won't always divide $a+b = |s|$.
... | {"inputs": ["2 4\n", "5 3\n", "1 1\n", "1 2\n", "2 1\n", "1 3\n", "3 1\n", "2 2\n"], "outputs": ["4\n", "5\n", "1\n", "2\n", "2\n", "2\n", "2\n", "3\n"]} | 378 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once.
He serves them in the form of a stack.
A pancake can be treated as a circular disk with some radius.
Chef needs to take care that when he places a pancake on the to... | {"inputs": ["2\n1\n2", "2\n0\n2", "2\n0\n4", "2\n0\n5", "2\n0\n6", "2\n0\n8", "2\n1\n8", "2\n2\n8"], "outputs": ["1\n2", "0\n2\n", "0\n15\n", "0\n52\n", "0\n203\n", "0\n4140\n", "1\n4140\n", "2\n4140\n"]} | 272 | 122 |
coding | Solve the programming task below in a Python markdown code block.
You receive the name of a city as a string, and you need to return a string that shows how many times each letter shows up in the string by using an asterisk (`*`).
For example:
```
"Chicago" --> "c:**,h:*,i:*,a:*,g:*,o:*"
```
As you can see, the le... | {"functional": "_inputs = [['Chicago'], ['Bangkok'], ['Las Vegas'], ['Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch']]\n_outputs = [['c:**,h:*,i:*,a:*,g:*,o:*'], ['b:*,a:*,n:*,g:*,k:**,o:*'], ['l:*,a:**,s:**,v:*,e:*,g:*'], ['l:***********,a:***,n:****,f:*,i:***,r:****,p:*,w:****,g:*******,y:*****,o:******,... | 263 | 309 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.
Here, a correct bracket sequence is defined as follows:
- () is a correct bracket sequence.
- If X... | {"inputs": ["3\n)()", "3\n)))", "3\n))(", "3\n(()", "3\n())", "3\n())\n", "6\n)())))", "6\n())())"], "outputs": ["()()\n", "((()))\n", "(())()\n", "(())\n", "(())", "(())\n", "(((()())))\n", "((())())\n"]} | 254 | 93 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).
For example, "2582" is good because the digits (2 and 8) at even positions are even a... | {"functional": "def check(candidate):\n assert candidate(n = 1) == 5\n assert candidate(n = 4) == 400\n assert candidate(n = 50) == 564908303\n\n\ncheck(Solution().countGoodNumbers)"} | 206 | 67 |
coding | Solve the programming task below in a Python markdown code block.
Since I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer L, how many pairs of positive integers a, b (a ≤ b) such that LCM(a, b) = L are there? Here, LCM(a, b) stands for the least com... | {"inputs": ["12\n9\n3\n0", "12\n8\n2\n0", "12\n9\n0\n0", "12\n0\n3\n0", "12\n9\n1\n0", "12\n8\n1\n0", "12\n9\n4\n0", "12\n8\n0\n0"], "outputs": ["8\n3\n2\n", "8\n4\n2\n", "8\n3\n", "8\n", "8\n3\n1\n", "8\n4\n1\n", "8\n3\n3\n", "8\n4\n"]} | 157 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Chef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinary fractions are sometimes used to represent this number approximately. For example, 22/7, 355/113 or even 103993/33102.
Soon, by calculating the ... | {"inputs": ["3\n1\n0\n0", "3\n1\n1\n0", "3\n2\n1\n0", "3\n2\n1\n1", "3\n0\n1\n1", "3\n1\n1\n1", "3\n1\n1\n2", "3\n1\n0\n1"], "outputs": ["3.1\n3\n3\n", "3.1\n3.1\n3\n", "3.14\n3.1\n3\n", "3.14\n3.1\n3.1\n", "3\n3.1\n3.1\n", "3.1\n3.1\n3.1\n", "3.1\n3.1\n3.14\n", "3.1\n3\n3.1\n"]} | 566 | 181 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. Let's denote monotonic renumeration of array $a$ as an array $b$ consisting of $n$ integers such that all of the following conditions are met:
$b_1 = 0$; for every pair of indices $i$ and $j$ suc... | {"inputs": ["2\n100 1\n", "2\n000 1\n", "2\n000 2\n", "2\n010 2\n", "2\n011 2\n", "2\n100 1\n", "4\n1 3 3 7\n", "4\n1 3 1 7\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "4\n", "2\n"]} | 461 | 122 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Write a function `deNico`/`de_nico()` that accepts two parameters:
- `key`/`$key` - string consists of unique letters and digits
- `message`/`$message` - string with encoded message
and decodes the `message` using the `key`.
First create a n... | {"functional": "_inputs = [['crazy', 'cseerntiofarmit on '], ['crazy', 'cseerntiofarmit on'], ['abc', 'abcd'], ['ba', '2143658709'], ['a', 'message'], ['key', 'eky']]\n_outputs = [['secretinformation'], ['secretinformation'], ['abcd'], ['1234567890'], ['message'], ['key']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n... | 359 | 242 |
coding | Solve the programming task below in a Python markdown code block.
A product-sum number is a natural number N which can be expressed as both the product and the sum of the same set of numbers.
N = a1 × a2 × ... × ak = a1 + a2 + ... + ak
For example, 6 = 1 × 2 × 3 = 1 + 2 + 3.
For a given set of size, k, we shall call... | {"functional": "_inputs = [[3], [6], [12], [2]]\n_outputs = [[10], [30], [61], [4]]\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 Fa... | 401 | 176 |
coding | Solve the programming task below in a Python markdown code block.
DNA sequencing data can be stored in many different formats. In this Kata, we will be looking at SAM formatting. It is a plain text file where every line (excluding the first header lines) contains data about a "read" from whatever sample the file comes ... | {"functional": "_inputs = [[['36M', 'CATAATACTTTACCTACTCTCAACAAATGCGGGAGA']], [['10M6H', 'GAGCGAGTGCGCCTTAC']], [['12S', 'TGTTTCTCCAAG']]]\n_outputs = [[True], ['Invalid cigar'], [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,... | 440 | 217 |
coding | Solve the programming task below in a Python markdown code block.
Consider a table of size $n \times m$, initially fully white. Rows are numbered $1$ through $n$ from top to bottom, columns $1$ through $m$ from left to right. Some square inside the table with odd side length was painted black. Find the center of this s... | {"inputs": ["1 1\nB\n", "1 1\nB\n", "1 1\nB\n", "1 4\nWWBW\n", "1 4\nWWBW\n", "1 4\nWWWB\n", "1 4\nBWWW\n", "1 4\nWBWW\n"], "outputs": ["1 1\n", "1 1\n", "1 1\n", "1 3\n", "1 3\n", "1 4\n", "1 1\n", "1 2\n"]} | 295 | 123 |
coding | Solve the programming task below in a Python markdown code block.
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beauti... | {"inputs": ["7\n", "3\n", "5\n", "4\n", "2\n", "1\n", "74\n", "88\n"], "outputs": ["-1\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 361 | 73 |
coding | Solve the programming task below in a Python markdown code block.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up $q$ questions about this song. Each question is about a subsegment of the song starting from the $l$-th letter to the $r$... | {"inputs": ["7 3\nabacaba\n1 3\n2 5\n1 7\n", "7 3\nabacaba\n2 3\n2 5\n1 7\n", "7 3\nabacaba\n2 6\n2 5\n1 7\n", "7 3\nabacaba\n2 6\n2 6\n1 7\n", "7 3\nabacaba\n2 3\n4 5\n1 7\n", "7 1\nabacaba\n2 6\n2 5\n1 7\n", "7 2\nabacaba\n2 6\n2 6\n1 7\n", "7 3\nabacaba\n2 3\n4 5\n2 7\n"], "outputs": ["4\n7\n11\n", "3\n7\n11\n", "9\... | 613 | 246 |
coding | Solve the programming task below in a Python markdown code block.
Find the intersection of two sets $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$.
Constraints
* $1 \leq n, m \leq 200,000$
* $0 \leq a_0 < a_1 < ... < a_{n-1} \leq 10^9$
* $0 \leq b_0 < b_1 < ... < b_{m-1} \leq 10^9$
Input
... | {"inputs": ["4\n1 3 5 8\n5\n1 3 5 9 7", "4\n1 2 5 8\n5\n2 3 5 9 7", "4\n1 2 5 8\n7\n0 3 5 9 9", "4\n1 2 0 8\n9\n1 3 5 9 6", "4\n1 2 5 8\n5\n4 3 5 9 11", "4\n1 2 5 8\n9\n2 3 5 9 11", "4\n1 2 9 8\n5\n4 3 5 9 11", "4\n1 2 5 8\n9\n1 3 5 9 11"], "outputs": ["1\n3\n5\n", "2\n5\n", "5\n", "1\n", "5\n", "2\n5\n", "9\n", "1\n5\... | 278 | 236 |
coding | Solve the programming task below in a Python markdown code block.
# Write Number in Expanded Form - Part 2
This is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form).
You will be given a number and you will need to return it as a string in [Expanded Form... | {"functional": "_inputs = [[1.24], [7.304], [0.04], [1.04], [7.3004], [0.004], [693.230459]]\n_outputs = [['1 + 2/10 + 4/100'], ['7 + 3/10 + 4/1000'], ['4/100'], ['1 + 4/100'], ['7 + 3/10 + 4/10000'], ['4/1000'], ['600 + 90 + 3 + 2/10 + 3/100 + 4/10000 + 5/100000 + 9/1000000']]\nimport math\ndef _deep_eq(a, b, tol=1e-5... | 202 | 332 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer N and an array A of size N. There are N lists L_{1}, L_{2} \ldots L_{N}. Initially, L_{i} = [A_{i}].
You can perform the following operation any number of times as long as there are at least 2 lists:
Select 2 (non-empty... | {"inputs": ["3\n1\n1\n2\n1 2\n3\n1 1 2\n"], "outputs": ["0\n-1\n2\n"]} | 678 | 37 |
coding | Solve the programming task below in a Python markdown code block.
*Shamelessly stolen from Here :)*
Your server has sixteen memory banks; each memory bank can hold any number of blocks. You must write a routine to balance the blocks between the memory banks.
The reallocation routine operates in cycles. In each cycle,... | {"functional": "_inputs = [[[5, 1, 10, 0, 1, 7, 13, 14, 3, 12, 8, 10, 7, 12, 0, 600]], [[53, 21, 10, 0, 1, 7, 13, 14, 3, 12, 8, 10, 7, 12, 0, 60]], [[14, 21, 10, 0, 1, 7, 0, 14, 3, 12, 8, 10, 17, 12, 0, 19]], [[5, 1, 10, 0, 1, 7, 13, 14, 3, 12, 8, 10, 7, 12, 0, 6]], [[17, 17, 3, 5, 1, 10, 6, 2, 0, 12, 8, 11, 16, 2, 1, ... | 668 | 454 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.
Return a list answer of size 2 where:
answer[0] is a list of all player... | {"functional": "def check(candidate):\n assert candidate(matches = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]) == [[1,2,10],[4,5,7,8]]\n assert candidate(matches = [[2,3],[1,3],[5,4],[6,4]]) == [[1,2,5,6],[]]\n\n\ncheck(Solution().findWinners)"} | 175 | 122 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integer arrays startTime and endTime and given an integer queryTime.
The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].
Return the number of students do... | {"functional": "def check(candidate):\n assert candidate(startTime = [1,2,3], endTime = [3,2,7], queryTime = 4) == 1\n assert candidate(startTime = [4], endTime = [4], queryTime = 4) == 1\n assert candidate(startTime = [4], endTime = [4], queryTime = 5) == 0\n assert candidate(startTime = [1,1,1,1], endTime... | 130 | 195 |
coding | Solve the programming task below in a Python markdown code block.
Chef Zidane likes the number 9. He has a number N, and he wants to turn it into a multiple of 9. He cannot add or remove digits, and he can only change one digit at a time. The only allowed operation is to increment or decrement a digit by one, and doing... | {"inputs": ["4\n1989\n86236\n90210\n99999999999999999999999999999999999999988"], "outputs": ["0\n2\n3\n2"]} | 456 | 77 |
coding | Solve the programming task below in a Python markdown code block.
This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.
There are two binary strings a and b of length ... | {"inputs": ["5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1\n", "5\n2\n01\n10\n5\n01011\n11110\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1\n", "5\n2\n01\n10\n5\n01001\n11100\n2\n01\n01\n10\n0110011011\n1000110100\n1\n0\n1\n", "5\n2\n01\n10\n5\n01011\n11100\n2\n01\n01\n10\n0110011011\n... | 605 | 904 |
coding | Solve the programming task below in a Python markdown code block.
# Your Task
You have a Petri dish with bacteria, and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them.
You know that you have `n` bacteria in the Petri dish and size ... | {"functional": "_inputs = [[[101, 53, 42, 102, 101, 55, 54], 1], [[20, 15, 10, 15, 20, 25], 5], [[5, 3, 1, 5], 1]]\n_outputs = [[3], [1], [4]]\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... | 564 | 234 |
coding | Solve the programming task below in a Python markdown code block.
A permutation of size $n$ is an array of size $n$ such that each integer from $1$ to $n$ occurs exactly once in this array. An inversion in a permutation $p$ is a pair of indices $(i, j)$ such that $i > j$ and $a_i < a_j$. For example, a permutation $[4,... | {"inputs": ["1\n1\n", "1\n1\n", "1\n-1\n", "1\n-1\n", "2\n1 2\n", "2\n2 1\n", "2\n1 2\n", "2\n-1 2\n"], "outputs": ["0\n", " 0", "0\n", " 0", "0\n", "1\n", " ... | 688 | 100 |
coding | Solve the programming task below in a Python markdown code block.
There is an easy way to obtain a new task from an old one called "Inverse the problem": we give an output of the original task, and ask to generate an input, such that solution to the original problem will produce the output we provided. The hard task of... | {"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n6\n", "1\n5\n", "1\n7\n", "1\n3\n"], "outputs": ["YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 458 | 86 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).
Please complete the following python code precisely:
```python
clas... | {"functional": "def check(candidate):\n assert candidate(nums = [3,4,5,2]) == 12 \n assert candidate(nums = [1,5,4,5]) == 16\n assert candidate(nums = [3,7]) == 12\n\n\ncheck(Solution().maxProduct)"} | 84 | 73 |
coding | Solve the programming task below in a Python markdown code block.
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor o... | {"inputs": ["9\n", "5\n", "2\n", "8\n", "3\n", "4\n", "7\n", "1\n"], "outputs": ["2\n", "1\n0\n", "1\n0\n", "1\n4\n", "1\n0\n", "2\n", "1\n0\n", "1\n0\n"]} | 418 | 82 |
coding | Solve the programming task below in a Python markdown code block.
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr c... | {"inputs": ["9 4 3\n", "1 0 0\n", "6 5 5\n", "5 4 0\n", "9 4 4\n", "6 0 5\n", "3 0 1\n", "9 3 4\n"], "outputs": ["4", "1", "1", "1", "5\n", "6\n", "2\n", "5\n"]} | 178 | 98 |
coding | Solve the programming task below in a Python markdown code block.
Given are three positive integers A, B, and C. Compute the following value modulo 998244353:
\sum_{a=1}^{A} \sum_{b=1}^{B} \sum_{c=1}^{C} abc
-----Constraints-----
- 1 \leq A, B, C \leq 10^9
-----Input-----
Input is given from standard input in the fo... | {"inputs": ["1 2 3\n", "88 395 518\n", "693 299 737\n", "198 235 277\n", "682152024 451794315 2028038\n", "192279221 156648747 154396385\n", "264704198 120999147 136987925\n", "1000000000 987654321 123456789\n"], "outputs": ["18\n", "572699487\n", "373149185\n", "518269127\n", "579633067\n", "152138957\n", "24444247\n"... | 246 | 270 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique.
The athletes are placed based on their scores, where the 1st... | {"functional": "def check(candidate):\n assert candidate(score = [5,4,3,2,1]) == [\"Gold Medal\",\"Silver Medal\",\"Bronze Medal\",\"4\",\"5\"]\n assert candidate(score = [10,3,8,9,4]) == [\"Gold Medal\",\"5\",\"Bronze Medal\",\"Silver Medal\",\"4\"]\n\n\ncheck(Solution().findRelativeRanks)"} | 226 | 92 |
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.
Alice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a present to Bob. However, she wants to find the set of photos with maximum beauty and she needs your help.
There are $n$ bui... | {"inputs": ["2\n2 1\n-2 -3\n", "1\n1\n1000000000\n", "1\n1\n-1000000000\n", "5\n1 2 3 5 4\n1 5 3 2 4\n", "5\n1 4 3 2 5\n-3 4 -10 2 7\n", "8\n8 7 3 2 6 4 1 5\n4 -1 4 -1 -1 2 2 3\n", "10\n5 1 6 2 8 3 4 10 9 7\n1 1 -1 -1 -1 1 -1 1 -1 1\n", "10\n4 7 3 2 5 1 9 10 6 8\n-4 40 -46 -8 -16 4 -10 41 12 3\n"], "outputs": ["-3\n", ... | 754 | 294 |
coding | Solve the programming task below in a Python markdown code block.
Give me Chocolate
Anushka wants to buy chocolates.there are many chocolates in front of her, tagged with their prices.
Anushka has only a certain amount to spend, and she wants to maximize the number of chocolates she buys with this money.
Given a lis... | {"inputs": ["7 50\n1 12 5 111 200 1000 10"], "outputs": ["4"]} | 326 | 38 |
coding | Solve the programming task below in a Python markdown code block.
# The die is cast!
Your task in this kata is to write a "dice roller" that interprets a subset of [dice notation](http://en.wikipedia.org/wiki/Dice_notation).
# Description
In most role-playing games, die rolls required by the system are given in the ... | {"functional": "_inputs = [[''], [{}], ['abc'], ['2d6+3 abc'], ['abc 2d6+3'], ['2d6++4']]\n_outputs = [[False], [False], [False], [False], [False], [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 ... | 370 | 198 |
coding | Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has two strings a and b of... | {"inputs": ["7\n4\n", "7\n7\n", "4\n7\n", "4\n4\n", "4\n46\n", "47\n77\n", "47\n47\n", "47\n44\n"], "outputs": ["1\n", "0\n", "1\n", "0\n", "0\n", "1\n", "0\n", "1\n"]} | 342 | 93 |
coding | Solve the programming task below in a Python markdown code block.
Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how man... | {"inputs": ["3\nabcxyx\ncyx\nabb", "3\nabxxyc\ncyx\nabb", "6\nb\na\nabb\nc\nd\nab", "6\nb\na\nabb\nc\nd\nba", "3\naxxbyc\ncyx\nabb", "3\naxxbyc\ncyx\naab", "3\naxxbyc\ncyw\naab", "3\naxxbyc\ncyw\nbaa"], "outputs": ["1\n", "0\n", "5\n", "4\n", "0\n", "0\n", "0\n", "0\n"]} | 289 | 145 |
coding | Solve the programming task below in a Python markdown code block.
A binary string is called *alternating* if no two adjacent characters of the string are equal. Formally, a binary string T of length M is called alternating if T_{i} \neq T_{i +1} for each 1 ≤ i < M.
For example, 0, 1, 01, 10, 101, 010, 1010 are altern... | {"inputs": ["4\n3\n110\n4\n1010\n4\n0000\n7\n1101101\n"], "outputs": ["3\n4\n1\n5\n"]} | 590 | 50 |
coding | Solve the programming task below in a Python markdown code block.
For a collection of integers $S$, define $\operatorname{mex}(S)$ as the smallest non-negative integer that does not appear in $S$.
NIT, the cleaver, decides to destroy the universe. He is not so powerful as Thanos, so he can only destroy the universe by... | {"inputs": ["4\n4\n0 0 0 0\n5\n0 1 2 3 4\n7\n0 2 3 0 1 2 0\n1\n1000000000\n"], "outputs": ["0\n1\n2\n1\n"]} | 613 | 71 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums.
You are given a 2D integer array adjacentPairs of size n ... | {"functional": "def check(candidate):\n assert candidate(adjacentPairs = [[2,1],[3,4],[3,2]]) == [1,2,3,4]\n assert candidate(adjacentPairs = [[4,-2],[1,4],[-3,1]]) == [-2,4,1,-3]\n assert candidate(adjacentPairs = [[100000,-100000]]) == [100000,-100000]\n\n\ncheck(Solution().restoreArray)"} | 194 | 120 |
coding | Solve the programming task below in a Python markdown code block.
You have two arrays A and B of size N and M respectively. You have to merge both the arrays to form a new array C of size N + M (the relative order of elements in the original arrays A and B should not change in the array C).
For e.g. if A = [{\color{bl... | {"inputs": ["2\n3 2\n6 4 5\n1 3\n2 3\n1 3\n2 2 4\n"], "outputs": ["4\n5\n"]} | 715 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nights in the garden and guard the fr... | {"inputs": ["1 1\n1\n1 1\n", "1 1\n0\n1 1\n", "2 2\n1 1\n1 1\n1 1\n", "2 2\n1 0\n1 1\n1 1\n", "2 3\n1 0 1\n0 1 0\n3 2\n", "3 2\n1 1\n1 1\n1 0\n2 1\n", "2 3\n0 0 1\n0 1 0\n3 2\n", "2 3\n0 0 1\n1 1 0\n3 2\n"], "outputs": ["1", "0", "1\n", "0", "3", "1", "2\n", "3\n"]} | 606 | 181 |
coding | Solve the programming task below in a Python markdown code block.
A and B are preparing themselves for programming contests.
To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.
For each chess piece we know its weight: t... | {"inputs": ["...QK...\n........\n........\n........\n........\n........\n........\n...rk...\n", "rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR\n", "rppppppr\n...k....\n........\n........\n........\n........\nK...Q...\n........\n", "....bQ.K\n.B......\n.....P..\n........\n........\n........ | 596 | 315 |
coding | Solve the programming task below in a Python markdown code block.
Following on from [Part 1](http://www.codewars.com/kata/filling-an-array-part-1/), part 2 looks at some more complicated array contents.
So let's try filling an array with...
## ...square numbers
The numbers from `1` to `n*n`
## ...a range of numbers
... | {"functional": "_inputs = [[5]]\n_outputs = [[[1, 4, 9, 16, 25]]]\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 retur... | 176 | 168 |
coding | Solve the programming task below in a Python markdown code block.
Given is a md5 hash of a five digits long PIN. It is given as string.
Md5 is a function to hash your password:
"password123" ===> "482c811da5d5b4bc6d497ffa98491e38"
Why is this useful?
Hash functions like md5 can create a hash from string in a short tim... | {"functional": "_inputs = [['827ccb0eea8a706c4c34a16891f84e7b'], ['86aa400b65433b608a9db30070ec60cd']]\n_outputs = [['12345'], ['00078']]\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, (... | 425 | 222 |
coding | Solve the programming task below in a Python markdown code block.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the f... | {"inputs": ["2 4 2", "0 0 0", "3 4 2", "2 6 2", "3 4 1", "2 7 2", "3 0 1", "1 7 2"], "outputs": ["No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 141 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Remember the movie with David Bowie: 'The Labyrinth'?
You can remember your childhood here: https://www.youtube.com/watch?v=2dgmgub8mHw
In this scene the girl is faced with two 'Knights" and two doors. One door leads the castle where the Goblin King an... | {"functional": "_inputs = [[True], [False], ['4+2==5'], ['2+2==4'], ['not True and False or False or False'], ['3 is 3'], ['True'], ['not True'], ['2+2==5'], ['4+1==5'], ['4 is 3'], ['9+2==3'], ['105+30076==30181'], ['3 is 3 is 3 is 9'], ['False'], ['\"orange\" is not \"red\"'], ['4 is \"blue\"'], ['True is not False']... | 376 | 399 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.
The shop sells N kinds of cakes.
Each kind of cake has three parameters "beauty", "tastiness" and "popularity". The i-th kind of cake has the... | {"inputs": ["5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 6 9", "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 1\n7 7 9", "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9", "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n", "5 3\n3 0 4\n1 5 18\n2 6 5\n3 5 8\n7 7 9", "5 3\n3 0 4\n1 5 18\n2 6 5\n3 5 4\n7 7 9", "5 5\n1 -2 4\n0 5 -6\n7 -8 -16\n-10 7 -12\n13 -3 15"... | 611 | 341 |
coding | Solve the programming task below in a Python markdown code block.
It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bought two cakes and cut them into pieces: the first cake has been cut into a pieces, and the second one — into b pieces.
Ivan knows that there will be n peo... | {"inputs": ["5 2 3\n", "5 5 6\n", "2 4 3\n", "2 1 1\n", "5 6 7\n", "5 2 8\n", "3 2 3\n", "5 7 8\n"], "outputs": ["1\n", "2\n", "3\n", "1\n", "2\n", "2\n", "1\n", "2\n"]} | 419 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Switch/Case - Bug Fixing #6
Oh no! Timmy's evalObject function doesn't work. He uses Switch/Cases to evaluate the given properties of an object, can you fix timmy's function?
Also feel free to reuse/extend the following starter code:
```python
def eval_... | {"functional": "_inputs = [[{'a': 1, 'b': 1, 'operation': '+'}], [{'a': 1, 'b': 1, 'operation': '-'}], [{'a': 1, 'b': 1, 'operation': '/'}], [{'a': 1, 'b': 1, 'operation': '*'}], [{'a': 1, 'b': 1, 'operation': '%'}], [{'a': 1, 'b': 1, 'operation': '**'}]]\n_outputs = [[2], [0], [1], [1], [0], [1]]\nimport math\ndef _de... | 79 | 274 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array A of size N and an integer K. He can perform the following operation on A any number of times:
Select any K distinct indices i_{1}, i_{2}, \ldots, i_{K} and increment the array elements at these K indices by 1.
Formally, set A_{i_{j}}... | {"inputs": ["4\n5 3\n2 4 5 4 2\n6 1\n4 5 5 4 6 4\n6 2\n4 5 5 4 6 4\n4 2\n1 2 3 3\n"], "outputs": ["YES\nYES\nYES\nNO\n"]} | 728 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Berland annual chess tournament is coming!
Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers sho... | {"inputs": ["1\n3 3\n", "1\n2 3\n", "1\n2 1\n", "1\n8 6\n", "1\n2 3\n", "1\n2 1\n", "1\n8 6\n", "1\n2 5\n"], "outputs": ["NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 378 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Mislove had an array $a_1$, $a_2$, $\cdots$, $a_n$ of $n$ positive integers, but he has lost it. He only remembers the following facts about it:
The number of different numbers in the array is not less than $l$ and is not greater than $r$;
For each... | {"inputs": ["4 2 2\n", "5 1 5\n", "1 1 1\n", "1 1 1\n", "2 1 1\n", "2 1 2\n", "2 2 2\n", "3 1 2\n"], "outputs": ["5 7\n", "5 31\n", "1 1\n", "1 1\n", "2 2\n", "2 3\n", "3 3\n", "3 5\n"]} | 561 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Alice has quarreled with Berta recently. Now she doesn't want to have anything in common with her!
Recently, they've received two collections of positive integers. The Alice'... | {"inputs": ["2\n3 4\n1 2 3\n3 4 5 6\n3 3\n1 2 3\n4 5 6"], "outputs": ["1\n0"]} | 545 | 48 |
coding | Solve the programming task below in a Python markdown code block.
Chef's current score is X. Each second, Chef will find the smallest [prime factor] of his score and add it to his score.
Determine the minimum time in seconds, after which his score becomes ≥ Y.
------ Input Format ------
- The first line of input wi... | {"inputs": ["4\n2 23\n9 20\n5 100\n6 89\n"], "outputs": ["11\n5\n46\n42\n"]} | 546 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Coders is about to start and Ram has not done dinner yet. So, he quickly goes to hostel mess and finds a long queue in front of food counter. But somehow he manages to take the food plate and reaches in front of the queue. The plates are divided into se... | {"inputs": ["19\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19"], "outputs": ["4\n9\n25\n64\n169\n441\n1156\n3025\n7921\n20736\n54289\n142129\n372100\n974169\n2550409\n6677056\n17480761\n45765225\n119814916"]} | 367 | 169 |
coding | Solve the programming task below in a Python markdown code block.
Pushkar is very good in Number Theory. He takes two numbers $A\ and\ B$ and declares them a Pushkar Pair. Pushkar Pair has a property that $A$ has a $Modular\ Inverse$ modulo $B$.
He asks you to tell him the largest number $L$ that divides both of them... | {"inputs": ["1\n3 4"], "outputs": ["1"]} | 199 | 16 |
coding | Solve the programming task below in a Python markdown code block.
John is very good in shooting. We wants to get admitted in HackerEarth Shooting Academy (HESA). But HESA take very hard interview process to select the candidates. In the Interview process, an assignment is given to John.
In this assignment, some amount... | {"inputs": ["5\n27 3\n64 4\n23 5\n10 2\n12 4"], "outputs": ["3 0\n3 0\n0 23\n1 5\n1 3"]} | 244 | 56 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $s$, consisting only of Latin letters 'a', and a string $t$, consisting of lowercase Latin letters.
In one move, you can replace any letter 'a' in the string $s$ with a string $t$. Note that after the replacement string $s$ might ... | {"inputs": ["3\naaaa\na\naa\nabc\na\nb\n"], "outputs": ["1\n-1\n2\n"]} | 469 | 31 |
coding | Solve the programming task below in a Python markdown code block.
Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by $i \operatorname{mod} j$. A Modular Equation, as Hamed's teacher described, ... | {"inputs": ["1 0\n", "0 0\n", "5 2\n", "2 0\n", "2 0\n", "5 2\n", "1 0\n", "0 0\n"], "outputs": ["1\n", "infinity\n", "1\n", "2\n", "2", "1", "1", "infinity"]} | 407 | 82 |
coding | Solve the programming task below in a Python markdown code block.
Define a "prime prime" number to be a rational number written as one prime number over another prime number: `primeA / primeB` (e.g. `7/31`)
Given a whole number `N`, generate the number of "prime prime" rational numbers less than 1, using only prime nu... | {"functional": "_inputs = [[6], [4], [10], [65], [0], [1000], [666]]\n_outputs = [[[3, 1]], [[1, 0]], [[6, 3]], [[153, 63]], [[0, 0]], [[14028, 6266]], [[7260, 3213]]]\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_to... | 217 | 236 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed array of strings details. Each element of details provides information about a given passenger compressed into a string of length 15. The system is such that:
The first ten characters consis... | {"functional": "def check(candidate):\n assert candidate(details = [\"7868190130M7522\",\"5303914400F9211\",\"9273338290F4010\"]) == 2\n assert candidate(details = [\"1313579440F2036\",\"2921522980M5644\"]) == 0\n\n\ncheck(Solution().countSeniors)"} | 152 | 124 |
coding | Solve the programming task below in a Python markdown code block.
KISS stands for Keep It Simple Stupid.
It is a design principle for keeping things simple rather than complex.
You are the boss of Joe.
Joe is submitting words to you to publish to a blog. He likes to complicate things.
Define a function that determin... | {"functional": "_inputs = [['Joe had a bad day'], ['Joe had some bad days'], ['Joe is having no fun'], ['Sometimes joe cries for hours'], ['Joe is having lots of fun'], ['Joe is working hard a lot'], ['Joe listened to the noise and it was an onamonapia'], ['Joe listened to the noises and there were some onamonapias']]\... | 218 | 274 |
coding | Solve the programming task below in a Python markdown code block.
Chef found N magical cards in his drawer. Each card has a number written on each of its faces. He places all the cards on the table in a front face-up manner.
Chef denotes the numbers on the front face by A_{1}, A_{2},..., A_{N} and on the back face by ... | {"inputs": ["3\n3\n4 6 8\n2 1 2\n3\n0 2 0\n2 0 8\n3\n1 2 1\n2 3 6"], "outputs": ["2 2\n0 0\n2 2"]} | 568 | 64 |
coding | Solve the programming task below in a Python markdown code block.
You are parking at a parking lot. You can choose from the following two fee plans:
- Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
- Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee wh... | {"inputs": ["7 17 120\n", "5 20 100\n", "6 18 100\n"], "outputs": ["119\n", "100\n", "100\n"]} | 234 | 57 |
coding | Solve the programming task below in a Python markdown code block.
In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the l... | {"inputs": ["5 5 3\n", "5 7 2\n", "2 2 1\n", "3 5 1\n", "3 6 1\n", "1 5 3\n", "5 4 2\n", "2 2 2\n"], "outputs": ["0\n", "15\n", "0\n", "6\n", "10\n", "0\n", "0\n", "0\n"]} | 401 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Problem
One day, mo3tthi and tubuann decided to play a game with magic pockets and biscuits.
Now there are $ K $ pockets, numbered $ 1,2, \ ldots, K $.
The capacity of the $ i $ th pocket is $ M_i $, which initially contains $ N_i $ biscuits.
mo3tthi an... | {"inputs": ["1\n2 5", "1\n2 6", "1\n2 7", "1\n1 6", "1\n4 5", "1\n4 6", "1\n3 5", "1\n2 3"], "outputs": ["mo3tthi\n", "mo3tthi\n", "mo3tthi\n", "tubuann\n", "mo3tthi\n", "tubuann\n", "tubuann\n", "mo3tthi\n"]} | 528 | 123 |
coding | Solve the programming task below in a Python markdown code block.
The Robot is in a rectangular maze of size n × m. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right (the symbol "R"), up (the symbol "U") or down (the s... | {"inputs": ["1 1 1\nX\n", "1 1 1\nX\n", "1 1 2\nX\n", "1 1 1\nX\n", "1 1 2\nX\n", "1 2 2\nX.\n", "1 2 2\n.X\n", "1 2 2\nX*\n"], "outputs": ["IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "IMPOSSIBLE\n", "RL\n", "LR\n", "IMPOSSIBLE\n"]} | 595 | 138 |
coding | Solve the programming task below in a Python markdown code block.
Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s_1 = a), and the difference between any two neighbouring elements is equal to c (s_{i} - s_{i} - 1 = c). In particular, Vasya ... | {"inputs": ["1 7 3\n", "0 1 0\n", "0 0 0\n", "0 0 1\n", "0 0 2\n", "0 1 0\n", "0 1 1\n", "0 1 2\n"], "outputs": ["YES\n", "NO\n", "YES\n", "YES\n", "YES\n", "NO\n", "YES\n", "NO\n"]} | 378 | 102 |
coding | Solve the programming task below in a Python markdown code block.
# Problem
In China,there is an ancient mathematical book, called "The Mathematical Classic of Sun Zi"(《孙子算经》). In the book, there is a classic math problem: “今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问物几何?”
Ahh, Sorry. I forgot that you don't know Chinese. Let's t... | {"functional": "_inputs = [[2, 3, 2], [1, 2, 3], [1, 3, 5], [0, 0, 0], [1, 1, 1]]\n_outputs = [[23], [52], [103], [105], [1]]\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)... | 530 | 215 |
coding | Solve the programming task below in a Python markdown code block.
You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number t of tables can be decorated if we know numb... | {"inputs": ["5 4 3\n", "1 1 1\n", "2 3 3\n", "0 1 0\n", "0 3 3\n", "4 0 4\n", "0 0 0\n", "3 5 2\n"], "outputs": ["4\n", "1\n", "2\n", "0\n", "2\n", "2\n", "0\n", "3\n"]} | 276 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Concatenation of two integers is obtained as follows: First, convert both integers to strings. Then concatenate both strings into one and convert this concatenated string back to integer.
For example, concatenation of 6 and 7 is CONC(6, 7) = 67, concate... | {"inputs": ["4\n2 10 52\n2 5\n3 58 100\n4 2 3\n4 100 1000\n1 10 100 1000\n5 28 102\n3 2 1 9 10\n"], "outputs": ["3\n0\n2\n11\n"]} | 681 | 93 |
coding | Solve the programming task below in a Python markdown code block.
There is Chef and Chef’s Crush who are playing a game of numbers.
Chef’s crush has a number $A$ and Chef has a number $B$.
Now, Chef wants Chef’s crush to win the game always, since she is his crush. The game ends when the greatest value of A^B is reac... | {"inputs": ["1\n4 5"], "outputs": ["2 7"]} | 590 | 18 |
coding | Solve the programming task below in a Python markdown code block.
# Definition (Primorial Of a Number)
*Is similar to factorial of a number*, **_In primorial_**, not all the natural numbers get multiplied, **_only prime numbers are multiplied to calculate the primorial of a number_**. It's denoted with **_P_****_#_** ... | {"functional": "_inputs = [[3], [4], [5], [8], [9]]\n_outputs = [[30], [210], [2310], [9699690], [223092870]]\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 l... | 585 | 199 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.
Return the number of consistent stri... | {"functional": "def check(candidate):\n assert candidate(allowed = \"ab\", words = [\"ad\",\"bd\",\"aaab\",\"baa\",\"badab\"]) == 2\n assert candidate(allowed = \"abc\", words = [\"a\",\"b\",\"c\",\"ab\",\"ac\",\"bc\",\"abc\"]) == 7\n assert candidate(allowed = \"cad\", words = [\"cc\",\"acd\",\"b\",\"ba\",\"b... | 98 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Tsetso likes to play with arrays.
An Array A[1,2,\ldots,N] is said to be a Tsetso array if A[1] \cdot A[N] = max(A_{1},A_{2},\ldots,A_{N-1},A_{N}).
Bedo, his teammate, likes to solve problems so much, so Tsetso gave him an array A of N \bf{distinct} i... | {"inputs": ["1\n7 3\n3 6 24 4 1 8 2\n1 7\n2 5\n4 7"], "outputs": ["7\n4\n4"]} | 648 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Toad Rash has a binary string s. A binary string consists only of zeros and ones.
Let n be the length of s.
Rash needs to find the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x,... | {"inputs": ["0\n", "1\n", "01\n", "00\n", "100\n", "101\n", "001\n", "000\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n"]} | 326 | 80 |
coding | Solve the programming task below in a Python markdown code block.
There are N events (numbered from 1 to N) and M contestants (numbered from 1 to M). For each event i, contestant j receives a predetermined number of points A_{i, j}.
A [subset] of these events will be selected, and the final score of contestant j, deno... | {"inputs": ["3\n1 1\n1\n3 3\n1 0 1\n1 2 1\n1 2 1\n4 2\n1 3\n5 1\n6 8\n2 1\n"], "outputs": ["0\n4\n5"]} | 634 | 65 |
coding | Solve the programming task below in a Python markdown code block.
On March 14, the day of the number $\pi$ is celebrated all over the world. This is a very important mathematical constant equal to the ratio of the circumference of a circle to its diameter.
Polycarp was told at school that the number $\pi$ is irrationa... | {"inputs": ["1\n1\n", "1\n3\n", "1\n0\n", "1\n00\n", "1\n31\n", "2\n0\n0\n", "1\n3444\n", "3\n8\n5\n8\n"], "outputs": ["0\n", "1\n", "0\n", "0\n", "2\n", "0\n0\n", "1\n", "0\n0\n0\n"]} | 446 | 103 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Let's play the minesweeper game (Wikipedia, online game)!
You are given an m x n char matrix board representing the game board where:
'M' represents an unrevealed mine,
'E' represents an unrevealed empty square,
'B' ... | {"functional": "def check(candidate):\n assert candidate(board = [[\"E\",\"E\",\"E\",\"E\",\"E\"],[\"E\",\"E\",\"M\",\"E\",\"E\"],[\"E\",\"E\",\"E\",\"E\",\"E\"],[\"E\",\"E\",\"E\",\"E\",\"E\"]], click = [3,0]) == [[\"B\",\"1\",\"E\",\"1\",\"B\"],[\"B\",\"1\",\"M\",\"1\",\"B\"],[\"B\",\"1\",\"1\",\"1\",\"B\"],[\"B\"... | 324 | 243 |
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, which contains distinct elements and an integer k.
A subset is called a k-Free subset if it contains no two elements with an absolute difference equal to k. Notice that the empty s... | {"functional": "def check(candidate):\n assert candidate(nums = [5,4,6], k = 1) == 5\n assert candidate(nums = [2,3,5,8], k = 5) == 12\n assert candidate(nums = [10,5,9,11], k = 20) == 16\n\n\ncheck(Solution().countTheNumOfKFreeSubsets)"} | 137 | 97 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums of size n, return the majority element.
The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
Please compl... | {"functional": "def check(candidate):\n assert candidate(nums = [3,2,3]) == 3\n assert candidate(nums = [2,2,1,1,1,2,2]) == 2\n\n\ncheck(Solution().majorityElement)"} | 94 | 60 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
There are $N$ students standing in a row and numbered $1$ through $N$ from left to right. You are given a string $S$ with length $N$, where for each ... | {"inputs": ["3\nxy\nxyxxy\nyy"], "outputs": ["1\n2\n0"]} | 473 | 24 |
coding | Solve the programming task below in a Python markdown code block.
Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented by the following formulas:
$ v = 9.8 t $
$ y = 4.9 t^2 $
A person is trying to drop down a glass ball and check whet... | {"inputs": ["25.4\n25.4", "26.000450676027395\n25.4", "26.601491934975797\n25.4", "44.72115406668142\n44.101745823639", "38.4955310270825\n37.15642943049945", "60.63345250628777\n63.4141206664841", "73.9111092448129\n75.52007039121814", "35.31260445827307\n34.47301494550142"], "outputs": ["8\n8", "8\n8\n", "9\n8\n", "2... | 262 | 304 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses hav... | {"functional": "def check(candidate):\n assert candidate(costs = [[1,5,3],[2,9,4]]) == 5\n assert candidate(costs = [[1,3],[2,4]]) == 5\n\n\ncheck(Solution().minCostII)"} | 176 | 62 |
coding | Solve the programming task below in a Python markdown code block.
A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforces^{ω} that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains som... | {"inputs": ["C\n", "C\n", "D\n", "B\n", "ABACABA\n", "ABACABA\n", "AABCABA\n", "CODEFORCE\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 427 | 77 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.