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.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Gritukan likes to take cyclic trips around the world. There are $N$ countries numbered $1$ through $N$ in the world. Before starting his travels, Gritukan chooses a permutati... | {"inputs": ["2\n6\n1 1 1 1 1 1\n6\n6 6 6 6 6 6"], "outputs": ["1\n120"]} | 595 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Passer ratings are the generally accepted standard for evaluating NFL quarterbacks.
I knew a rating of 100 is pretty good, but never knew what makes up the rating.
So out of curiosity I took a look at the wikipedia page and had an idea or my first kata: ... | {"functional": "_inputs = [[432, 3554, 291, 28, 2], [5, 76, 4, 1, 0], [48, 192, 19, 2, 3], [1, 2, 1, 1, 0], [34, 172, 20, 1, 1], [10, 17, 2, 0, 1]]\n_outputs = [[112.2], [158.3], [39.6], [118.8], [69.7], [0.0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n re... | 325 | 296 |
coding | Solve the programming task below in a Python markdown code block.
~~~if:csharp,javascript,cfml,php
Given a 2D array of size `m * n`. Your task is to find the sum of minimum value in each row.
~~~
~~~if:cpp
Given a 2D vector of size `m * n`. Your task is to find the sum of minimum value in each row.
~~~
~~~if:python,rub... | {"functional": "_inputs = [[[[7, 9, 8, 6, 2], [6, 3, 5, 4, 3], [5, 8, 7, 4, 5]]], [[[11, 12, 14, 54], [67, 89, 90, 56], [7, 9, 4, 3], [9, 8, 6, 7]]]]\n_outputs = [[9], [76]]\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, ... | 394 | 261 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n integer matrix matrix with the following two properties:
Each row is sorted in non-decreasing order.
The first integer of each row is greater than the last integer of the previous row.
Given a... | {"functional": "def check(candidate):\n assert candidate(matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3) == True\n assert candidate(matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13) == False\n\n\ncheck(Solution().searchMatrix)"} | 127 | 112 |
coding | Solve the programming task below in a Python markdown code block.
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.
Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:
* Operation: Ch... | {"inputs": ["4\nwest\neast\nw`it", "4\nwesu\neast\nw`it", "4\nwetu\neast\nw`it", "4\nwetv\n`est\ntiaw", "4\ntewv\n`ftt\nsaiw", "4\nwetu\ne`st\nw`it", "4\nwetu\n`est\nw`it", "4\nwetu\n`est\nwait"], "outputs": ["4\n", "5\n", "6\n", "7\n", "8\n", "5\n", "5\n", "5\n"]} | 252 | 144 |
coding | Solve the programming task below in a Python markdown code block.
Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutive... | {"inputs": ["P\n", "C\n", "CP\n", "PC\n", "PPPP\n", "PPPPP\n", "CPCCPPC\n", "CPPCCPC\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "1\n", "1\n", "5\n", "5\n"]} | 503 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the togg... | {"inputs": ["1 0 0\n0 0 0\n0 0 1\n", "1 0 1\n8 8 8\n2 0 3\n", "0 0 0\n0 0 0\n0 0 0\n", "0 0 0\n0 1 0\n0 0 0\n", "0 0 0\n0 0 0\n0 0 1\n", "0 0 0\n0 0 0\n0 0 1\n", "0 0 0\n0 1 0\n0 0 0\n", "0 0 0\n0 0 0\n0 0 0\n"], "outputs": ["001\n010\n100\n", "010\n011\n100\n", "111\n111\n111\n", "101\n000\n101\n", "111\n110\n100\n", ... | 318 | 278 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n integer matrix grid.
We define an hourglass as a part of the matrix with the following form:
Return the maximum sum of the elements of an hourglass.
Note that an hourglass cannot be rotated and... | {"functional": "def check(candidate):\n assert candidate(grid = [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]) == 30\n assert candidate(grid = [[1,2,3],[4,5,6],[7,8,9]]) == 35\n\n\ncheck(Solution().maxSum)"} | 105 | 91 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.
Given an integer n, return true if n is strictly palindro... | {"functional": "def check(candidate):\n assert candidate(n = 9) == False\n assert candidate(n = 4) == False\n\n\ncheck(Solution().isStrictlyPalindromic)"} | 129 | 46 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}] of length N.
You can right rotate it any number of times (possibly, zero). What is the maximum value of A_{1} + A_{N} you can get?
Note: Right rotating the array [A_{1}, A_{2}, \ldots, A_{N}] onc... | {"inputs": ["3\n2\n5 8\n3\n5 10 15\n4\n4 4 4 4\n"], "outputs": ["13\n25\n8\n"]} | 527 | 46 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0.
For example, for x = 7, the binary representation is 111 and we may choose any bit (including... | {"functional": "def check(candidate):\n assert candidate(start = 10, goal = 7) == 3\n assert candidate(start = 3, goal = 4) == 3\n\n\ncheck(Solution().minBitFlips)"} | 195 | 56 |
coding | Solve the programming task below in a Python markdown code block.
----- Statement -----
You need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediately after it. If there are many such strings, print the one which has the ... | {"inputs": ["2\n1\n2", "2\n2\n2", "2\n2\n3", "2\n3\n2", "2\n2\n5", "2\n4\n5", "2\n3\n5", "2\n5\n5"], "outputs": ["ba\ncba", "cba\ncba\n", "cba\ndcba\n", "dcba\ncba\n", "cba\nfedcba\n", "edcba\nfedcba\n", "dcba\nfedcba\n", "fedcba\nfedcba\n"]} | 161 | 121 |
coding | Solve the programming task below in a Python markdown code block.
Watson gives four 3-dimensional points to Sherlock and asks him if they all lie in the same plane. Your task here is to help Sherlock.
Input Format
First line contains T, the number of testcases.
Each test case consists of four lines. Each line c... | {"inputs": ["1\n1 2 0\n2 3 0\n4 0 0\n0 0 0\n"], "outputs": ["YES\n"]} | 213 | 38 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is constraints.
You are given a sequence $a$ consisting of $n$ positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements... | {"inputs": ["6\n8\n1 1 2 6 3 2 1 1\n3\n2 1 3\n4\n2 10 9 1\n1\n26\n2\n1 1\n3\n1 1 1\n", "6\n8\n1 1 2 6 3 2 1 1\n3\n2 3 3\n4\n2 10 9 1\n1\n26\n2\n1 1\n3\n2 1 1\n", "6\n8\n1 1 2 6 3 2 1 1\n3\n2 1 3\n4\n2 10 9 1\n1\n26\n2\n1 1\n3\n2 1 1\n", "6\n8\n1 1 2 6 3 2 1 2\n3\n2 1 3\n4\n2 10 9 1\n1\n26\n2\n1 1\n3\n2 1 1\n", "6\n8\n1... | 743 | 598 |
coding | Solve the programming task below in a Python markdown code block.
If you have not ever heard the term **Arithmetic Progrossion**, refer to:
http://www.codewars.com/kata/find-the-missing-term-in-an-arithmetic-progression/python
And here is an unordered version. Try if you can survive lists of **MASSIVE** numbers (whic... | {"functional": "_inputs = [[[3, 9, 1, 11, 13, 5]], [[5, -1, 0, 3, 4, -3, 2, -2]], [[2, -2, 8, -8, 4, -4, 6, -6]]]\n_outputs = [[7], [1], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(... | 193 | 224 |
coding | Solve the programming task below in a Python markdown code block.
Two moving objects A and B are moving accross the same orbit (those can be anything: two planets, two satellites, two spaceships,two flying saucers, or spiderman with batman if you prefer).
If the two objects start to move from the same point and the orb... | {"functional": "_inputs = [[12, 15, 5], [12, -15, 6], [-14, -5, 5], [23, 16, 5], [0, 0, 7], [12, 0, 10], [0, 15, 17], [-24, 0, 10], [0, -18, 14], [32, -14, 14]]\n_outputs = [['60.00'], ['6.67'], ['7.78'], ['52.57'], ['0.00'], ['12.00'], ['15.00'], ['24.00'], ['18.00'], ['9.74']]\nimport math\ndef _deep_eq(a, b, tol=1e-... | 234 | 323 |
coding | Solve the programming task below in a Python markdown code block.
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $... | {"inputs": ["6\n+-++--\n2\n9 7\n1 1\n", "1\n-\n1\n427470105 744658699\n", "8\n+-+---+-\n5\n2 1\n10 3\n7 9\n10 10\n5 3\n", "20\n+-----+--+--------+-\n2\n1000000000 99999997\n250000000 1000000000\n"], "outputs": ["YES\nYES\n", "NO\n", "YES\nNO\nNO\nNO\nYES\n", "NO\nYES\n"]} | 706 | 172 |
coding | Solve the programming task below in a Python markdown code block.
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes on... | {"inputs": ["1\n", "2\n", "3\n", "8\n", "4\n", "5\n", "6\n", "8\n"], "outputs": ["1\n", "2\n", "2 1\n", "4\n", "3\n", "3 1\n", "3 2\n", "4 \n"]} | 485 | 77 |
coding | Solve the programming task below in a Python markdown code block.
You probably know that the "mode" of a set of data is the data point that appears most frequently. Looking at the characters that make up the string `"sarsaparilla"` we can see that the letter `"a"` appears four times, more than any other letter, so the ... | {"functional": "_inputs = [['tomato'], [[1, 3, 3, 7]], [['redder']]]\n_outputs = [[['o', 't']], [[3]], [[]]]\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 le... | 393 | 181 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Chef has taken his first dose of vaccine D days ago. He may take the second dose no less than L days and no more than R days since his first dose.
Determine if Chef ... | {"inputs": ["4\n10 8 12 \n14 2 10\n4444 5555 6666 \n8 8 12\n"], "outputs": ["Take second dose now\nToo Late\nToo Early\nTake second dose now"]} | 479 | 67 |
coding | Solve the programming task below in a Python markdown code block.
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant,... | {"inputs": ["2\n1 1\n1 1\n", "2\n1 1\n2 2\n", "2\n2 2\n1 1\n", "2\n2 1\n1 2\n", "2\n3 2\n3 2\n", "2\n1 2\n2 1\n", "2\n3 1\n9 8\n", "2\n2 1\n1 1\n"], "outputs": ["maybe\n", "unrated\n", "maybe\n", "rated\n", "rated\n", "rated\n", "rated\n", "rated\n"]} | 630 | 135 |
coding | Solve the programming task below in a Python markdown code block.
3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is dead or alive
NEKO#ΦωΦ has just got a new maze game on her PC!
The game's main puzzle is a maze, in the forms of a $2 \times n$ rectangle grid. NEKO's task is to lead a Nekomimi girl from cell $(... | {"inputs": ["4 1\n1 4\n", "4 1\n1 4\n", "2 2\n2 1\n1 2\n", "2 2\n2 1\n1 2\n", "2 4\n2 1\n1 2\n1 2\n1 2\n", "2 4\n2 1\n1 2\n1 2\n1 2\n", "5 5\n2 3\n1 4\n2 4\n2 3\n1 4\n", "6 5\n2 3\n1 4\n2 4\n2 3\n1 4\n"], "outputs": ["Yes\n", "Yes\n", "Yes\nNo\n", "Yes\nNo\n", "Yes\nNo\nYes\nNo\n", "Yes\nNo\nYes\nNo\n", "Yes\nNo\nNo\nN... | 707 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
There are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with a timetab... | {"inputs": ["2\n3\n1 4 15\n1 2 1\n3\n18 40 30\n6 2 22", "2\n3\n1 4 15\n2 2 1\n3\n18 40 30\n6 2 22", "2\n3\n1 4 15\n1 2 1\n3\n26 40 30\n6 2 22", "2\n3\n2 4 15\n2 2 1\n3\n18 40 30\n6 2 22", "2\n3\n2 4 15\n2 0 1\n3\n18 40 30\n6 2 22", "2\n3\n1 4 5\n0 2 1\n3\n18 40 30\n13 0 35", "2\n3\n2 4 15\n2 0 1\n3\n18 40 30\n6 2 41", ... | 608 | 342 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer n. We say that two integers x and y form a prime number pair if:
1 <= x <= y <= n
x + y == n
x and y are prime numbers
Return the 2D sorted list of prime number pairs [xi, yi]. The list shou... | {"functional": "def check(candidate):\n assert candidate(n = 10) == [[3,7],[5,5]]\n assert candidate(n = 2) == []\n\n\ncheck(Solution().findPrimePairs)"} | 158 | 53 |
coding | Solve the programming task below in a Python markdown code block.
#Unflatten a list (Easy)
There are several katas like "Flatten a list".
These katas are done by so many warriors, that the count of available list to flattin goes down!
So you have to build a method, that creates new arrays, that can be flattened!
#Sh... | {"functional": "_inputs = [[[3, 5, 2, 1]], [[1, 4, 5, 2, 1, 2, 4, 5, 2, 6, 2, 3, 3]], [[1, 1, 1, 1]], [[1]], [[99, 1, 1, 1]], [[3, 1, 1, 3, 1, 1]]]\n_outputs = [[[[3, 5, 2], 1]], [[1, [4, 5, 2, 1], 2, [4, 5, 2, 6], 2, [3, 3]]], [[1, 1, 1, 1]], [[1]], [[[99, 1, 1, 1]]], [[[3, 1, 1], [3, 1, 1]]]]\nimport math\ndef _deep_... | 512 | 346 |
coding | Solve the programming task below in a Python markdown code block.
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.
At first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds a_{i} candies in a box, that is given by ... | {"inputs": ["1 9\n10\n", "1 7\n10\n", "1 9\n10\n", "2 3\n1 2\n", "2 8\n7 8\n", "2 9\n4 8\n", "2 3\n3 3\n", "2 2\n1 2\n"], "outputs": ["-1", "1\n", "-1\n", "2", "2", "2", "1", "2"]} | 473 | 110 |
coding | Solve the programming task below in a Python markdown code block.
There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.
Takahashi will begin the travel at town 1, with no apple in his possession. The actions ... | {"inputs": ["3 8\n100 7 21", "3 8\n100 8 21", "3 2\n100 8 21", "3 8\n100 4 21", "3 2\n100 2 21", "3 8\n100 7 200", "3 0\n100 0 200", "3 2\n100 12 21"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 769 | 153 |
coding | Solve the programming task below in a Python markdown code block.
Check Tutorial tab to know how to to solve.
You are given a string $N$.
Your task is to verify that $N$ is a floating point number.
In this task, a valid float number must satisfy all of the following requirements:
$>$ Number can start with +,... | {"inputs": ["4\n4.0O0\n-1.00\n+4.54\nSomeRandomStuff\n"], "outputs": ["False\nTrue\nTrue\nFalse\n"]} | 324 | 42 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a time represented in the format "HH:MM", form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused.
You may assume the given input string is always vali... | {"functional": "def check(candidate):\n assert candidate(\"19:34\") == \"19:39\"\n assert candidate(\"23:59\") == \"22:22\"\n\n\ncheck(Solution().nextClosestTime)"} | 135 | 59 |
coding | Solve the programming task below in a Python markdown code block.
IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each trans... | {"inputs": ["1\n", "1\n", "0\n", "9\n", "12\n", "18\n", "15\n", "27\n"], "outputs": ["1", "1\n", "0\n", "1\n", "2", "4\n", "3\n", "6\n"]} | 238 | 72 |
coding | Solve the programming task below in a Python markdown code block.
Lavrenty, a baker, is going to make several buns with stuffings and sell them.
Lavrenty has n grams of dough as well as m different stuffing types. The stuffing types are numerated from 1 to m. Lavrenty knows that he has ai grams left of the i-th stuffi... | {"inputs": ["2 1 2 1\n1 2 1 1\n", "1 1 1 1\n1 1 1 1\n", "2 1 2 1\n0 2 1 1\n", "2 1 1 1\n1 1 1 1\n", "2 1 2 1\n1 3 1 1\n", "2 1 1 1\n1 1 2 1\n", "4 1 2 4\n10 1 3 7\n", "4 1 2 4\n10 1 3 8\n"], "outputs": ["1", "1", "1\n", "2\n", "1\n", "2\n", "8", "8\n"]} | 445 | 181 |
coding | Solve the programming task below in a Python markdown code block.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numb... | {"inputs": ["1\n55 7\n", "1\n86 7\n", "1\n86 9\n", "1\n86 4\n", "1\n86 3\n", "1\n86 0\n", "1\n49 0\n", "1\n55 60\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0"]} | 627 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp plays "Game 23". Initially he has a number $n$ and his goal is to transform it to $m$. In one move, he can multiply $n$ by $2$ or multiply $n$ by $3$. He can perform any number of moves.
Print the number of moves needed to transform $n$ to $m$.... | {"inputs": ["1 1\n", "1 2\n", "1 4\n", "1 5\n", "1 6\n", "2 5\n", "4 9\n", "2 7\n"], "outputs": ["0\n", "1\n", "2\n", "-1\n", "2\n", "-1\n", "-1\n", "-1\n"]} | 364 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks wit... | {"inputs": ["6\n", "1\n", "2\n", "7\n", "8\n", "9\n", "2\n", "9\n"], "outputs": ["6 6\n", "1 1\n", "2 2\n", "7 7\n", "7 7\n", "7 7\n", "2 2\n", "7 7\n"]} | 541 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer.
Help Pasha count the... | {"inputs": ["300 0\n", "5 100\n", "5 100\n", "4 100\n", "360 0\n", "7 100\n", "700 0\n", "6 100\n"], "outputs": ["300\n", "5\n", "5\n", "4\n", "360\n", "7\n", "700\n", "6\n"]} | 224 | 108 |
coding | Solve the programming task below in a Python markdown code block.
The objective is to disambiguate two given names: the original with another
Let's start simple, and just work with plain ascii strings.
The function ```could_be``` is given the original name and another one to test
against.
```python
# should return... | {"functional": "_inputs = [['Carlos Ray Norris', 'Carlos Ray Norris'], ['Carlos Ray Norris', 'Carlos Ray'], ['Carlos Ray Norris', 'Ray Norris'], ['Carlos Ray Norris', 'Carlos Norris'], ['Carlos Ray Norris', 'Norris'], ['Carlos Ray Norris', 'Carlos'], ['Carlos Ray Norris', 'Norris Carlos'], ['Carlos Ray Norris', 'Carlos... | 472 | 357 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
For her birthday, Rima got an integer sequence $A_{1}, A_{2}, \dots, A_{N}$. Each element of this sequence is either 1 or 2.
Let's call an integer $s$ ($1 ≤ s... | {"inputs": ["1\n3\n2 1 2"], "outputs": ["4"]} | 317 | 20 |
coding | Solve the programming task below in a Python markdown code block.
At the annual meeting of Board of Directors of Acme Inc. If everyone attending shakes hands exactly one time with every other attendee, how many handshakes are there?
Example
$n=3$
There are $3$ attendees, ${p1}$, $p2$ and $p3$. ${p1}$ shakes han... | {"inputs": ["2\n1\n2\n"], "outputs": ["0\n1\n"]} | 280 | 20 |
coding | Solve the programming task below in a Python markdown code block.
You get a "text" and have to shift the vowels by "n" positions to the right.
(Negative value for n should shift to the left.)
"Position" means the vowel's position if taken as one item in a list of all vowels within the string.
A shift by 1 would mean, t... | {"functional": "_inputs = [[None, 0], ['', 0], ['This is a test!', 0], ['This is a test!', 1], ['This is a test!', 3], ['This is a test!', 4], ['This is a test!', -1], ['This is a test!', -5], ['Brrrr', 99], ['AEIOUaeiou', 1]]\n_outputs = [[None], [''], ['This is a test!'], ['Thes is i tast!'], ['This as e tist!'], ['T... | 229 | 296 |
coding | Solve the programming task below in a Python markdown code block.
The [half-life](https://en.wikipedia.org/wiki/Half-life) of a radioactive substance is the time it takes (on average) for one-half of its atoms to undergo radioactive decay.
# Task Overview
Given the initial quantity of a radioactive substance, the quan... | {"functional": "_inputs = [[10, 5, 1], [8, 4, 2], [12, 3, 2]]\n_outputs = [[1], [2], [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)):\n if len(a) != len(b): ret... | 264 | 187 |
coding | Solve the programming task below in a Python markdown code block.
Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that there are n piles of cows, with the i-th pile containing ... | {"inputs": ["1 2\n3\n", "1 1\n1\n", "1 2\n1\n", "1 2\n1\n", "1 1\n1\n", "1 0\n1\n", "1 2\n2\n", "1 0\n2\n"], "outputs": ["Nicky\n", "Kevin\n", "Kevin\n", "Kevin\n", "Kevin\n", "Kevin\n", "Kevin\n", "Kevin\n"]} | 414 | 103 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.
Please complete the following python code precisely:
```python
class Solution:
def findMaximumXOR(self, nums:... | {"functional": "def check(candidate):\n assert candidate(nums = [3,10,5,25,2,8]) == 28\n assert candidate(nums = [14,70,53,83,49,91,36,80,92,51,66,70]) == 127\n\n\ncheck(Solution().findMaximumXOR)"} | 78 | 94 |
coding | Solve the programming task below in a Python markdown code block.
There is a non-negative integer array A of length N. Chef and Cook will play a game on the array with Chef starting first.
In one turn the player will perform the following operation:
Choose two indices i,j such that 1 ≤ i < j ≤ N and A_{i} > 0.
Set A_... | {"inputs": ["3\n4\n1 0 1 0\n4\n1 2 3 4\n1\n420\n"], "outputs": ["Chef\nChef\nCook\n"]} | 565 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.
When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody win... | {"inputs": ["8 50 50 0", "1 000 0 0", "2 100 0 0", "6 50 50 0", "5 50 50 0", "3 50 50 0", "4 100 0 0", "2 50 50 0"], "outputs": ["127441420\n", "0\n", "2\n", "386718762\n", "351562510\n", "125000005\n", "4\n", "500000006\n"]} | 359 | 166 |
coding | Solve the programming task below in a Python markdown code block.
Nezzar's favorite digit among $1,\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.
Given $q$ integers $a_1,a_2,\ldots,a_q$, for each $1 \le i \le q$ Nezzar would like to know if $a_i$ can be e... | {"inputs": ["2\n3 2\n6 47 1\n10 3\n50 52 2 43 113 92 9 73 42 60\n", "2\n3 7\n24 44 40\n10 7\n4 52 4 54 64 54 66 2 25 60\n", "2\n3 2\n5 47 1\n10 3\n50 52 2 43 113 92 9 73 42 60\n", "2\n3 7\n10 25 27\n10 5\n13 52 53 2 55 56 57 58 9 8\n", "2\n3 2\n5 47 1\n10 3\n50 52 1 43 113 92 8 73 42 60\n", "2\n3 2\n24 44 10\n10 7\n4 5... | 399 | 622 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
A subsequence of a string is a new string generated from the original string with ... | {"functional": "def check(candidate):\n assert candidate(text1 = \"abcde\", text2 = \"ace\" ) == 3 \n assert candidate(text1 = \"abc\", text2 = \"abc\") == 3\n assert candidate(text1 = \"abc\", text2 = \"def\") == 0\n\n\ncheck(Solution().longestCommonSubsequence)"} | 153 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. T... | {"inputs": ["1\n3\n", "1\n5\n", "1\n2\n", "1\n1\n", "1\n10\n", "1\n10\n", "2\n1 2\n", "2\n2 3\n"], "outputs": ["3\n", "5\n", "2\n", "1\n", "10\n", "10\n", "6\n", "10\n"]} | 534 | 95 |
coding | Solve the programming task below in a Python markdown code block.
Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether S... | {"inputs": ["4 0", "1 2", "7 0", "0 2", "5 0", "0 8", "0 6", "0 0"], "outputs": ["Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n"]} | 205 | 78 |
coding | Solve the programming task below in a Python markdown code block.
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
-First-line will contain $T$, the number of test cases. Then th... | {"inputs": ["2\n2\n4"], "outputs": ["A\n12\nA\n12\nABC\n1234"]} | 186 | 31 |
coding | Solve the programming task below in a Python markdown code block.
For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.
Constraints
* $p1$ and $p2$ are different
* The circle and line have at least one cross point
* $1 \leq q \leq 1,000$
* $-10,000 \leq cx, cy, x1, y1, x2, y2 \leq ... | {"inputs": ["2 0 1\n2\n0 1 4 1\n3 0 3 3", "2 0 2\n2\n0 1 4 1\n3 0 3 3", "2 0 2\n2\n0 1 4 2\n3 0 3 3", "2 0 2\n2\n0 1 4 2\n3 0 5 3", "2 0 2\n1\n0 1 4 2\n3 0 5 3", "2 0 2\n1\n0 1 4 0\n3 0 5 3", "2 0 2\n1\n0 1 8 0\n1 0 5 3", "2 0 2\n1\n0 2 8 0\n1 0 5 3"], "outputs": ["2.00000000 1.00000000 2.00000000 1.00000000\n3.0000000... | 536 | 750 |
coding | Solve the programming task below in a Python markdown code block.
Problem
GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4.
GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo... | {"inputs": ["3\n1.000\n2.000\n3.000", "3\n1.000\n3.000\n3.000", "3\n1.000\n2.000\n3.4274102096399073", "3\n1.3153899733914476\n3.000\n3.000", "3\n1.000\n3.000\n3.1230319554116766", "3\n1.000\n2.000\n3.9759367558439593", "3\n1.000\n2.5451927881659007\n3.000", "3\n1.6470390157297516\n3.000\n3.000"], "outputs": ["0\n3\n6"... | 403 | 314 |
coding | Solve the programming task below in a Python markdown code block.
Problem Statement:
Nash, a high school student studies the concepts of Functions(Mathematics), for the first time.After learning the definitions of Domain and Range, he tries to find the number of functions possible,given the number of elements in domain... | {"inputs": ["5\n6 4\n4 6\n15 2\n2 85\n4 7", "47\n428 580\n692 254\n221 613\n14 794\n116 115\n926 200\n325 265\n517 290\n219 90\n947 543\n218 544\n149 976\n28 233\n879 494\n530 715\n853 618\n5 378\n369 781\n813 967\n880 841\n610 707\n205 655\n73 468\n187 715\n442 535\n413 765\n152 199\n72 58\n24 116\n900 962\n982 272\n6... | 294 | 897 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s consisting of lowercase English letters, return the first letter to appear twice.
Note:
A letter a appears twice before another letter b if the second occurrence of a is before the second occurrence ... | {"functional": "def check(candidate):\n assert candidate(s = \"abccbaacz\") == \"c\"\n assert candidate(s = \"abcdd\") == \"d\"\n\n\ncheck(Solution().repeatedCharacter)"} | 101 | 50 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.
We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based)... | {"functional": "def check(candidate):\n assert candidate(nums = [4,2,3]) == True\n assert candidate(nums = [4,2,1]) == False\n\n\ncheck(Solution().checkPossibility)"} | 115 | 50 |
coding | Solve the programming task below in a Python markdown code block.
# MOD 256 without the MOD operator
The MOD-operator % (aka mod/modulus/remainder):
```
Returns the remainder of a division operation.
The sign of the result is the same as the sign of the first operand.
(Different behavior in Python!)
```
The short unb... | {"functional": "_inputs = [[254], [256], [258], [-254], [-256], [-258]]\n_outputs = [[254], [0], [2], [2], [0], [254]]\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 ... | 437 | 204 |
coding | Solve the programming task below in a Python markdown code block.
We consider permutations of the numbers $1,..., N$ for some $N$. By permutation we mean a rearrangment of the number $1,...,N$. For example
24517638245176382 \quad 4 \quad 5 \quad 1 \quad 7 \quad 6 \quad 3 \quad 8
is a permutation of $1,2,...,8$. Of cour... | {"inputs": ["8\n2 4 5 1 7 6 3 8", "8\n1 2 3 4 5 6 7 8"], "outputs": ["4\n1 2 4 1\n3 5 7 3\n6 6\n8 8", "8\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8"]} | 747 | 106 |
coding | Solve the programming task below in a Python markdown code block.
In Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to the denominator (the bottom number) For example: ```5/3``` (five third).
A mixed numeral is a whole number and a fraction combined into one "mix... | {"functional": "_inputs = [['74/3'], ['9999/24'], ['74/30'], ['13/5'], ['5/3'], ['1/1'], ['10/10'], ['900/10'], ['9920/124'], ['6/2'], ['9/77'], ['96/100'], ['12/18'], ['6/36'], ['1/18'], ['-64/8'], ['-6/8'], ['-9/78'], ['-504/26'], ['-47/2'], ['-21511/21']]\n_outputs = [['24 2/3'], ['416 15/24'], ['2 14/30'], ['2 3/5'... | 275 | 429 |
coding | Solve the programming task below in a Python markdown code block.
You had $n$ positive integers $a_1, a_2, \dots, a_n$ arranged in a circle. For each pair of neighboring numbers ($a_1$ and $a_2$, $a_2$ and $a_3$, ..., $a_{n - 1}$ and $a_n$, and $a_n$ and $a_1$), you wrote down: are the numbers in the pair equal or not.... | {"inputs": ["2\nEEEEEN\nEE\n", "2\nEEEEEN\nEE\n", "2\nEENEEE\nEE\n", "2\nEEEEEN\nEEEEEN\n", "2\nEEEEEN\nEEEEEN\n", "2\nNEEEEE\nEEEEEN\n", "2\nEEEEEEN\nEEEEEEEN\n", "2\nEEEEEEN\nEEEEEEEN\n"], "outputs": ["NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n", "NO\nNO\n"]} | 624 | 136 |
coding | Solve the programming task below in a Python markdown code block.
In this kata, you've to count lowercase letters in a given string and return the letter count in a hash with 'letter' as key and count as 'value'. The key must be 'symbol' instead of string in Ruby and 'char' instead of string in Crystal.
Example:
```... | {"functional": "_inputs = [['codewars'], ['activity'], ['arithmetics'], ['traveller'], ['daydreamer']]\n_outputs = [[{'a': 1, 'c': 1, 'd': 1, 'e': 1, 'o': 1, 'r': 1, 's': 1, 'w': 1}], [{'a': 1, 'c': 1, 'i': 2, 't': 2, 'v': 1, 'y': 1}], [{'a': 1, 'c': 1, 'e': 1, 'h': 1, 'i': 2, 'm': 1, 'r': 1, 's': 1, 't': 2}], [{'a': 1... | 159 | 382 |
coding | Solve the programming task below in a Python markdown code block.
In this problem MEX of a certain array is the smallest positive integer not contained in this array.
Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including today.
You a... | {"inputs": ["1\n1\n", "1\n1\n", "3\n1 3 2\n", "3\n1 3 2\n", "4\n4 1 3 2\n", "5\n1 4 3 1 2\n", "5\n1 4 3 1 2\n", "9\n5 4 3 2 1 2 3 4 5\n"], "outputs": ["1\n", "1\n", "3\n", "3\n", "3\n", "6\n", "6\n", "7\n"]} | 350 | 132 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function which returns the weekday according to the input number:
* `1` returns `"Sunday"`
* `2` returns `"Monday"`
* `3` returns `"Tuesday"`
* `4` returns `"Wednesday"`
* `5` returns `"Thursday"`
* `6` returns `"Friday"`
* `7` returns `"Sa... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [0], [8], [20]]\n_outputs = [['Sunday'], ['Monday'], ['Tuesday'], ['Wednesday'], ['Thursday'], ['Friday'], ['Saturday'], ['Wrong, please enter a number between 1 and 7'], ['Wrong, please enter a number between 1 and 7'], ['Wrong, please enter a number betwee... | 120 | 243 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red card.
Vasya is watching ... | {"inputs": ["A\nAA\n2\n1 a 1 y\n2 h 1 y\n", "A\nAA\n2\n1 a 1 y\n2 h 1 y\n", "TANB\nXNCPR\n1\n15 h 6 r\n9 h 27 r\n", "AB\nBC\n3\n1 h 1 y\n2 h 1 y\n3 h 1 r\n", "AB\nBC\n3\n1 h 1 y\n2 h 1 y\n3 h 1 r\n", "TANC\nXNCOR\n2\n15 h 27 r\n6 h 27 r\n", "AB\nBC\n3\n1 h 1 y\n2 h 2 y\n3 h 1 r\n", "TANC\nXNCOR\n2\n15 h 54 r\n6 h 27 r\... | 597 | 272 |
coding | Solve the programming task below in a Python markdown code block.
Stephanie just learned about a game called Nim in which there are two players and $n$ piles of stones. During each turn, a player must choose any non-empty pile and take as many stones as they want. The first player who cannot complete their turn (i.e., ... | {"inputs": ["2 2\n"], "outputs": ["6\n"]} | 393 | 16 |
coding | Solve the programming task below in a Python markdown code block.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e... | {"inputs": ["1 1\na\ne\ne\na\n", "1 1\ne\na\ne\na\n", "1 1\na\ne\ne\ne\n", "1 1\ne\ne\ne\ne\n", "1 1\na\na\na\na\n", "1 1\na\ne\na\ne\n", "1 1\na\na\na\ne\n", "1 1\ne\na\ne\ne\n"], "outputs": ["abba\n", "abab\n", "NO\n", "aaaa\n", "aaaa\n", "abab\n", "NO\n", "NO\n"]} | 688 | 153 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Reversing an integer means to reverse all its digits.
For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.
Given an integer num, reverse num to get reversed1, then... | {"functional": "def check(candidate):\n assert candidate(num = 526) == True\n assert candidate(num = 1800) == False\n assert candidate(num = 0) == True\n\n\ncheck(Solution().isSameAfterReversals)"} | 134 | 61 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$.
Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at ... | {"inputs": ["3\n5\n3 1 5 2 3\n4\n17 8 19 45\n8\n265 265 265 265 265 265 265 265\n"], "outputs": ["6\n63\n0\n"]} | 695 | 78 |
coding | Solve the programming task below in a Python markdown code block.
You are making your very own boardgame. The game is played by two opposing players, featuring a 6 x 6 tile system, with the players taking turns to move their pieces (similar to chess). The design is finished, now it's time to actually write and implemen... | {"functional": "_inputs = [['K', 'A'], ['S', 'A'], ['k', 's'], ['a', 'a'], ['k', 'A'], ['K', 'a']]\n_outputs = [[-1], [-1], [-1], [-1], ['k'], ['K']]\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 isi... | 681 | 204 |
coding | Solve the programming task below in a Python markdown code block.
Initially, Chef had an array A of length N. Chef performs the following operation on A at most once:
Select L and R such that 1 ≤ L ≤ R ≤ N and set A_{i} := A_{i} + 1 for all L ≤ i ≤ R.
Determine the maximum number of *inversions* Chef can decrease from... | {"inputs": ["3\n5\n4 2 3 1 5\n6\n1 2 3 4 5 6\n4\n2 1 1 1\n"], "outputs": ["2\n0\n3\n"]} | 704 | 54 |
coding | Solve the programming task below in a Python markdown code block.
"Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up."
Let's call a string balanced if all characters that occur in this string occur in it the same number of... | {"inputs": ["2\nABCB\nBBC"], "outputs": ["1\n1"]} | 452 | 19 |
coding | Solve the programming task below in a Python markdown code block.
When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the b... | {"inputs": ["1 3\n5\n", "1 3\n5\n", "1 10\n4\n", "1 10\n4\n", "2 10\n6 4\n", "2 10\n6 4\n", "2 10\n6 6\n", "2 11\n6 6\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "2\n", "2\n", "1\n", "1\n"]} | 381 | 116 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.
You start your journey from building 0 and move to the next building by possibly using bricks or ladders.
Wh... | {"functional": "def check(candidate):\n assert candidate(heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1) == 4\n assert candidate(heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2) == 7\n assert candidate(heights = [14,3,19,3], bricks = 17, ladders = 0) == 3\n\n\ncheck(Solution().furthestBuildin... | 203 | 136 |
coding | Solve the programming task below in a Python markdown code block.
## Task
Your challenge is to write a function named `getSlope`/`get_slope`/`GetSlope` that calculates the slope of the line through two points.
## Input
```if:javascript,python
Each point that the function takes in is an array 2 elements long. The fir... | {"functional": "_inputs = [[[1, 1], [2, 2]], [[-5, -5], [9, 9]], [[1, 8], [2, 9]], [[8, 3], [-4, 5]], [[5, 3], [8, 9]], [[1, 3], [0, 3]], [[11, 1], [1, 11]], [[1, 1], [1, 2]], [[-5, 9], [-5, 12]], [[1, 1], [1, 1]], [[-5, 9], [-5, 9]]]\n_outputs = [[1], [1], [1], [-0.16666666666666666], [2], [0], [-1], [None], [None], [... | 315 | 338 |
coding | Solve the programming task below in a Python markdown code block.
Chef is in need of money, so he decided to play a game with Ramsay. In this game, there are $N$ rows of coins (numbered $1$ through $N$). For each valid $i$, the $i$-th row contains $C_i$ coins with values $A_{i, 1}, A_{i, 2}, \ldots, A_{i, C_i}$.
Chef a... | {"inputs": ["1\n2\n4 5 2 3 4\n2 1 6"], "outputs": ["8"]} | 589 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has recently got a broadband internet connection. His history of internet data usage is provided as below.
During the first T_{1} minutes, the internet data used was D_... | {"inputs": ["3\n2 2\n2 1\n2 3\n2 2\n1 2\n2 3\n3 0\n1 2\n2 4\n10 10"], "outputs": ["6\n3\n110"]} | 580 | 60 |
coding | Solve the programming task below in a Python markdown code block.
A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.
A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically... | {"inputs": ["1 2 2\n", "1 2 1\n", "2 0 0\n", "2 1 1\n", "0 2 1\n", "5 4 5\n", "2 0 2\n", "2 1 2\n"], "outputs": ["32", "32", "30", "32", "32", "38", "32", "32"]} | 625 | 102 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length N, containing lowercase Latin letters. You are also given an integer K.
You would like to create a new string S' by following the following process:
First, partition S into exactly K non-empty [subsequences] S_{1}, S_{... | {"inputs": ["3\n6 1\nwhizzy\n14 2\naaacdecdebacde\n4 3\ndbca\n"], "outputs": ["whizzy\naaaaccdecdebde\nabcd"]} | 598 | 49 |
coding | Solve the programming task below in a Python markdown code block.
The summer is at its peak in Chefland. Chef is planning to purchase a water cooler to keep his room cool. He has two options available:
Rent a cooler at the cost of X coins per month.
Purchase a cooler for Y coins.
Chef wonders what is the maximum numb... | {"inputs": ["2\n5 12\n5 5"], "outputs": ["2\n0"]} | 406 | 23 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have some apples and a basket that can carry up to 5000 units of weight.
Given an integer array weight where weight[i] is the weight of the ith apple, return the maximum number of apples you can put in the basket.... | {"functional": "def check(candidate):\n assert candidate(weight = [100,200,150,1000]) == 4\n assert candidate(weight = [900,950,800,1000,700,800]) == 5\n\n\ncheck(Solution().maxNumberOfApples)"} | 101 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin Chinese] and [Bengali].
Given n (n is even), determine the number of black cells in an n \times n chessboard.
------ Input Format ------
The only line of the input contains a single integer n.
------ Output Form... | {"inputs": ["8"], "outputs": ["32"]} | 168 | 13 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n binary matrix grid.
A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).
Every row of the matrix is in... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]]) == 39\n assert candidate(grid = [[0]]) == 1\n\n\ncheck(Solution().matrixScore)"} | 144 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\circ}$. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There... | {"inputs": ["1 1 1 1 1 1\n", "1 2 1 2 1 2\n", "2 4 5 3 3 6\n", "7 5 4 8 4 5\n", "3 2 1 4 1 2\n", "7 1 7 3 5 3\n", "9 2 9 3 8 3\n", "1 6 1 5 2 5\n"], "outputs": ["6\n", "13\n", "83\n", "175\n", "25\n", "102\n", "174\n", "58\n"]} | 352 | 160 |
coding | Solve the programming task below in a Python markdown code block.
A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car... | {"inputs": ["3 2 1 1\n", "5 4 3 1\n", "4 3 2 1\n", "98 2 1 1\n", "27 3 2 3\n", "13 7 6 2\n", "15 6 4 5\n", "21 3 1 3\n"], "outputs": ["4\n3\n1\n", "-1\n", "4\n3\n2\n", "98\n3\n1\n", "-1\n", "-1\n", "15\n11\n5\n", "-1\n"]} | 429 | 142 |
coding | Solve the programming task below in a Python markdown code block.
You will be given a fruit which a farmer has harvested, your job is to see if you should buy or sell.
You will be given 3 pairs of fruit. Your task is to trade your harvested fruit back into your harvested fruit via the intermediate pair, you should ret... | {"functional": "_inputs = [[[['apple', 'orange'], ['orange', 'pear'], ['apple', 'pear']], 'apple'], [[['orange', 'apple'], ['orange', 'pear'], ['pear', 'apple']], 'apple'], [[['apple', 'orange'], ['pear', 'orange'], ['apple', 'pear']], 'apple'], [[['orange', 'apple'], ['pear', 'orange'], ['pear', 'apple']], 'apple'], [... | 286 | 425 |
coding | Solve the programming task below in a Python markdown code block.
Johnny has just found the new, great tutorial: "How to become a grandmaster?". The tutorial tells many strange and unexpected for Johnny things, such as you have to be patient or that very important is solving many harder and harder problems.
The boy h... | {"inputs": ["1\n1 2\n88\n", "1\n1 2\n88\n", "1\n1 3\n88\n", "1\n1 2\n70\n", "1\n1 5\n88\n", "1\n1 3\n103\n", "1\n1 3\n198\n", "1\n1 1\n103\n"], "outputs": ["140130951\n", "140130951\n", "772681989\n", "270016253\n", "467137716\n", "923126036\n", "792924246\n", "1\n"]} | 613 | 185 |
coding | Solve the programming task below in a Python markdown code block.
Ma5termind is going through the Euler's book of knowledge when he finds the following function:
def function(L,R):
sum=0
for i in range(L,R+1): #[L,R]
for j in range(1,i+1): #[1,i]
cnt=0
if ... | {"inputs": ["2\n1 10\n2 5\n"], "outputs": ["9\n2\n"]} | 495 | 25 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef lives in Chefcity. Chefcity can be represented as a straight line with Chef's house at point 0 on this line. There is an infinite number of subway stations in Chefcity, ... | {"inputs": ["4\n1\n2\n3\n9"], "outputs": ["1\n2\n2\n5"]} | 525 | 26 |
coding | Solve the programming task below in a Python markdown code block.
There are N different types of colours numbered from 1 to N. Chef has A_{i} balls having colour i, (1≤ i ≤ N).
Chef will arrange some boxes and put each ball in exactly one of those boxes.
Find the minimum number of boxes Chef needs so that no box con... | {"inputs": ["3\n2\n8 5\n3\n5 10 15\n4\n4 4 4 4\n"], "outputs": ["8\n15\n4\n"]} | 537 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day:
* A: Swim in the sea. Gain a... | {"inputs": ["1\n110 1 0", "1\n010 3 0", "1\n011 3 1", "1\n001 3 0", "1\n001 4 0", "1\n001 6 0", "1\n000 2 0", "1\n100 16 1"], "outputs": ["110\n", "10\n", "11\n", "3\n", "4\n", "6\n", "2\n", "100\n"]} | 365 | 133 |
coding | Solve the programming task below in a Python markdown code block.
Consider an array containing cats and dogs. Each dog can catch only one cat, but cannot catch a cat that is more than `n` elements away. Your task will be to return the maximum number of cats that can be caught.
For example:
```Haskell
solve(['D','C','C... | {"functional": "_inputs = [[['D', 'C', 'C', 'D', 'C'], 1], [['C', 'C', 'D', 'D', 'C', 'D'], 2], [['C', 'C', 'D', 'D', 'C', 'D'], 1], [['D', 'C', 'D', 'C', 'C', 'D'], 3], [['C', 'C', 'C', 'D', 'D'], 3], [['C', 'C', 'C', 'D', 'D'], 2], [['C', 'C', 'C', 'D', 'D'], 1], [['C', 'C', 'C', 'D', 'D', 'D', 'C', 'D', 'D', 'D', 'C... | 263 | 353 |
coding | Solve the programming task below in a Python markdown code block.
Take an integer `n (n >= 0)` and a digit `d (0 <= d <= 9)` as an integer. Square all numbers `k (0 <= k <= n)` between 0 and n. Count the numbers of
digits `d` used in the writing of all the `k**2`. Call `nb_dig` (or nbDig or ...) the function taking `n... | {"functional": "_inputs = [[5750, 0], [11011, 2], [12224, 8], [11549, 1], [14550, 7], [8304, 7], [10576, 9], [12526, 1], [7856, 4], [14956, 1]]\n_outputs = [[4700], [9481], [7733], [11905], [8014], [3927], [7860], [13558], [7132], [17267]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isin... | 365 | 309 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef likes to write poetry. Today, he has decided to write a X pages long poetry, but unfortunately his notebook has only Y pages left in it. Thus he decided to buy a new CHEFMATE notebook and ... | {"inputs": ["3\n3 1 2 2\n3 4\n2 2 \n3 1 2 2\n2 3\n2 3 \n3 1 2 2\n1 1\n1 2"], "outputs": ["LuckyChef\nUnluckyChef\nUnluckyChef"]} | 753 | 76 |
coding | Solve the programming task below in a Python markdown code block.
HackerRank-city is an acyclic connected graph (or tree). Its not an ordinary place, the construction of the whole tree takes place in $N$ steps. The process is described below:
It initially has $\mbox{1}$ node.
At each step, you must create $3$ duplicat... | {"inputs": ["1\n1\n", "2\n2 1\n"], "outputs": ["29\n", "2641\n"]} | 661 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of strings strs. You could concatenate these strings together into a loop, where for each string, you could choose to reverse it or not. Among all the possible loops
Return the lexicographically... | {"functional": "def check(candidate):\n assert candidate(strs = [\"abc\",\"xyz\"]) == \"zyxcba\"\n assert candidate(strs = [\"abc\"]) == \"cba\"\n\n\ncheck(Solution().splitLoopedString)"} | 210 | 57 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$.
The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and... | {"inputs": ["3\n2 2 3\n2 0 4", "3\n1 2 3\n2 0 4", "3\n2 2 3\n2 -1 4", "3\n2 4 5\n2 -1 4", "3\n3 4 5\n2 -1 4", "3\n6 4 5\n2 -1 4", "3\n6 5 5\n2 -1 4", "3\n6 5 5\n2 -1 3"], "outputs": ["3.000000\n2.236068\n2.080084\n2.000000\n", "4.000000\n2.449490\n2.154435\n2.000000", "4.000000\n3.162278\n3.036589\n3.000000\n", "6.0000... | 554 | 432 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Hindi] , [Vietnamese] , [Mandarin Chinese] , [Russian] and [Bengali] as well.
"Every beginning has an end... and an editorial." - taran_{1407}
What the hell are all these interactive problems? What does flushing output mean? S... | {"inputs": ["2 1500\n1499\n1501"], "outputs": ["Bad boi\nGood boi"]} | 366 | 33 |
coding | Solve the programming task below in a Python markdown code block.
Let's imagine that you're playing the following simple computer game. The screen displays n lined-up cubes. Each cube is painted one of m colors. You are allowed to delete not more than k cubes (that do not necessarily go one after another). After that, ... | {"inputs": ["1 1 0\n1\n", "3 1 2\n1 1 1\n", "10 2 2\n1 1 1 2 1 2 1 2 1 1\n", "10 2 2\n1 2 1 2 1 1 2 1 1 2\n", "10 3 2\n1 2 1 1 3 2 1 1 2 2\n", "20 6 3\n4 1 2 6 3 3 2 5 2 5 2 1 1 4 1 2 2 1 1 4\n", "20 2 5\n2 2 1 2 1 2 1 2 1 1 2 1 2 2 1 2 2 1 2 1\n", "20 3 5\n2 2 3 1 2 2 3 3 3 2 1 2 3 1 1 3 3 3 2 3\n"], "outputs": ["1", ... | 359 | 288 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Kerim is an environment-friendly guy. Today, he accepted Samir's challenge of planting 20 million trees by 2020. Currently, there are $N$ trees (numbered $1$ ... | {"inputs": ["1\n3\n2 7 4"], "outputs": ["2"]} | 585 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that transforms any positive number to a string representing the number in words. The function should work for all numbers between 0 and 999999.
### Examples
```
number2words(0) ==> "zero"
number2words(1) ==> "one"
number2words(9... | {"functional": "_inputs = [[0], [1], [8], [5], [9], [10], [19], [20], [22], [54], [80], [98], [100], [301], [793], [800], [650], [1000], [1003], [3052], [7300], [7217], [8340], [99997], [888887]]\n_outputs = [['zero'], ['one'], ['eight'], ['five'], ['nine'], ['ten'], ['nineteen'], ['twenty'], ['twenty-two'], ['fifty-fo... | 448 | 392 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier.
He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.
Other than that, he finds the f... | {"inputs": ["0 3 6", "6 5 0", "4 2 6", "1 3 6", "1 0 6", "2 0 6", "4 0 6", "4 1 6"], "outputs": ["dangerous\n", "delicious\n", "safe\n", "dangerous\n", "dangerous\n", "dangerous\n", "dangerous\n", "dangerous\n"]} | 276 | 101 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks.
Today's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The ma... | {"inputs": ["6\n1 1\n2 1\n3 8\n4 1\n2 1\n2 4", "6\n1 2\n2 4\n6 8\n4 8\n1 1\n2 4", "6\n1 1\n2 4\n3 2\n4 4\n4 1\n1 4", "6\n2 2\n2 4\n6 8\n4 8\n1 1\n2 4", "6\n1 1\n2 1\n4 8\n5 1\n2 1\n2 4", "6\n1 1\n2 4\n3 8\n4 16\n4 1\n1 4", "6\n1 1\n2 4\n3 1\n4 16\n4 1\n1 4", "6\n1 1\n2 4\n3 8\n4 16\n1 1\n1 4"], "outputs": ["0\n1\n4\n2\... | 662 | 336 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.