task_type stringclasses 1
value | problem stringlengths 209 3.39k | answer stringlengths 35 6.15k | problem_tokens int64 60 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
While surfing in web I found interesting math problem called "Always perfect". That means if you add 1 to the product of four consecutive numbers the answer is ALWAYS a perfect square.
For example we have: 1,2,3,4 and the product will be 1X2X3X4=24. If w... | {"functional": "_inputs = [['4,5,6,7'], ['3,s,5,6'], ['11,13,14,15'], ['10,11,12,13,15'], ['10,11,12,13'], ['ad,d,q,tt,v'], ['//,;;,/,..,'], ['1,2,3,4'], ['1015,1016,1017,1018'], ['555,777,444,111'], ['20,21,22,24'], ['9,10,10,11'], ['11254,11255,11256,11258'], ['25000,25001,25002,25003'], ['2000000,2000001,2000002,200... | 208 | 608 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is the last.
Now Polycarp wants to ... | {"inputs": ["1 1\n3\n", "1 1\n3\n", "1 1\n5\n", "1 1\n8\n", "1 1\n2\n", "1 1\n1\n", "1 1\n10\n", "1 1\n14\n"], "outputs": ["Yes\n1 ", "Yes\n1 \n", "Yes\n1\n", "Yes\n1\n", "Yes\n1\n", "Yes\n1\n", "Yes\n1\n", "Yes\n1\n"]} | 667 | 120 |
coding | Solve the programming task below in a Python markdown code block.
Because of budget cuts one IT company established new non-financial reward system instead of bonuses.
Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critica... | {"inputs": ["2\n", "1\n", "3\n", "4\n", "5\n", "6\n", "7\n", "4\n"], "outputs": ["24", "1", "210", "1120", "4410", "14112", "38808", "1120"]} | 339 | 82 |
coding | Solve the programming task below in a Python markdown code block.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic tea... | {"inputs": ["1\n9876\n", "1\n1234\n", "1\n2771\n", "1\n2705\n", "2\n2004\n1000\n", "2\n9988\n8899\n", "2\n2037\n2025\n", "2\n2099\n1000\n"], "outputs": ["1876\n", "1034\n", "1771\n", "1705\n", "1004\n1004\n", "No solution", "1037\n2005\n", "1099\n1100\n"]} | 654 | 166 |
coding | Solve the programming task below in a Python markdown code block.
N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.
The i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.
You want to... | {"inputs": ["1", "0", "0\n", "1\n", "010", "100", "101", "011"], "outputs": ["0\n", "0", "0\n", "0\n", "0\n", "1\n", "0\n", "1\n"]} | 203 | 71 |
coding | Solve the programming task below in a Python markdown code block.
The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.
The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a l... | {"inputs": ["1\n1234 0 0\n", "1\n1234 2 2\n", "1\n0714 1 1\n", "1\n1234 3 1\n", "1\n1234 0 1\n", "1\n1234 1 2\n", "1\n0714 1 2\n", "1\n1234 3 0\n"], "outputs": ["Need more data", "Need more data", "Need more data", "Incorrect data\n", "Need more data\n", "Need more data\n", "Need more data\n", "Need more data\n"]} | 667 | 154 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it ... | {"inputs": ["4\n", "6\n", "8\n", "9\n", "8\n", "4\n", "6\n", "9\n"], "outputs": ["3\n", "3\n", "7\n", "7\n", "7", "3", "3", "7"]} | 422 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is ... | {"inputs": ["1\na 2400 2401\n", "1\nX 2400 2500\n", "1\nA 2400 2401\n", "1\na 2400 2455\n", "1\nx 2400 2401\n", "1\nb 2400 2401\n", "1\nx 2400 2401\n", "1\nb 2400 2401\n"], "outputs": ["YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES"]} | 529 | 158 |
coding | Solve the programming task below in a Python markdown code block.
«Next please», — the princess called and cast an estimating glance at the next groom.
The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a m... | {"inputs": ["4 1 2\n", "4 1 0\n", "4 3 0\n", "4 2 0\n", "7 4 0\n", "2 1 0\n", "2 0 0\n", "5 2 2\n"], "outputs": ["1 2 4 5 ", "1 1 2 1 ", "-1\n", "1 1 2 3 ", "1 1 2 3 4 5 1 ", "-1\n", "1 1 ", "1 2 4 5 6 "]} | 501 | 137 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that takes an array/list of numbers and returns a number such that
Explanation
total([1,2,3,4,5]) => 48
1+2=3--\ 3+5 => 8 \
2+3=5--/ \ == 8+12=>20\
==>5+7=> 12 / \ 20+28 => 48
3+4=7--\ / ... | {"functional": "_inputs = [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4]], [[1, 2, 3]], [[4, 4, 52, 23, 32, 1, -1]], [[4, 4, 5, -1]], [[-1, -1, -1]], [[-1, -1, -10, 42, 92, 1, 23, 6, -3]], [[-1, 1, -1, 1]], [[42]]]\n_outputs = [[48], [20], [8], [1753], [30], [-4], [9248], [0], [42]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n ... | 263 | 315 |
coding | Solve the programming task below in a Python markdown code block.
Chef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands the importance of the spoon and r... | {"inputs": ["3\n3 6\nabDefb\nbSpoon\nNIKHil\n6 6\naaaaaa\nssssss\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\nbdfhj\ncacac\nopqrs\nddddd\nindia\nyucky"], "outputs": ["There is a spoon!\nThere is a spoon!\nThere is indeed no spoon!"]} | 475 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi is going to buy N items one by one.
The price of the i-th item he buys is A_i yen (the currency of Japan).
He has M discount tickets, and he can use any number of them when buying an item.
If Y tickets are used when buying an item priced X yen,... | {"inputs": ["1 1\n1\n", "3 3\n2 3 8", "3 3\n2 3 5", "3 4\n2 3 5", "3 0\n3 8 2", "3 3\n2 13 3", "3 2\n2 13 3", "3 2\n2 13 2"], "outputs": ["0\n", "5\n", "4\n", "3\n", "13\n", "6\n", "8\n", "7\n"]} | 288 | 127 |
coding | Solve the programming task below in a Python markdown code block.
A string $a=a_1a_2\dots a_n$ is called even if it consists of a concatenation (joining) of strings of length $2$ consisting of the same characters. In other words, a string $a$ is even if two conditions are satisfied at the same time:
its length $n$ is ... | {"inputs": ["6\naabbdabdccc\nzyx\naaababbb\naabbcc\noaoaaaoo\nbmefbmuyw\n"], "outputs": ["3\n3\n2\n0\n2\n7\n"]} | 542 | 52 |
coding | Solve the programming task below in a Python markdown code block.
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \... | {"inputs": ["2\n17 23\n11 15\n", "3\n12 15\n2 3\n8 13\n"], "outputs": ["16\n8\n", "12\n2\n8\n"]} | 611 | 57 |
coding | Solve the programming task below in a Python markdown code block.
Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.
Some of the squares have a lotus leaf on... | {"inputs": ["1 6 4\n1 1 1 1\n......", "1 6 4\n1 2 1 6\n......", "1 6 1\n1 1 1 6\n......", "1 6 2\n1 1 1 1\n......", "1 8 1\n1 1 1 6\n......", "1 6 4\n1 1 1 4\n......", "1 6 4\n1 1 1 1\n...-..", "1 8 2\n1 1 1 1\n......"], "outputs": ["0\n", "1\n", "5\n", "0\n", "5\n", "1\n", "0\n", "0\n"]} | 664 | 176 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.
For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ... | {"inputs": ["5\n", "9\n", "1\n", "0\n", "3\n", "4\n", "6\n", "7\n"], "outputs": ["0\n", "10\n", "0\n", "0\n", "0\n", "0\n", "10\n", "10\n"]} | 289 | 73 |
coding | Solve the programming task below in a Python markdown code block.
A Hitachi string is a concatenation of one or more copies of the string `hi`.
For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not.
Given a string S, determine whether S is a Hitachi string.
Constraints
* The length of S is ... | {"inputs": ["ah", "ih", "hb", "hh", "bh", "gi", "gb", "hg"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 164 | 62 |
coding | Solve the programming task below in a Python markdown code block.
A squarer is a simple and convenient device. You give it some positive integer X and it calculates its square.
Leha is implementing a module of this device which is responsible for squaring the numbers consisting of multiple repetitions of one digit. But... | {"inputs": ["3\n1 4\n3 6\n3 5"], "outputs": ["139\n40079781\n32745632"]} | 442 | 44 |
coding | Solve the programming task below in a Python markdown code block.
The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.
There are two armies on the playing field each of... | {"inputs": ["6\n", "8\n", "2\n", "4\n", "10\n", "16\n", "98\n", "18\n"], "outputs": ["9", "12", "3", "6", "15", "24\n", "147\n", "27\n"]} | 400 | 75 |
coding | Solve the programming task below in a Python markdown code block.
# Task
In the field, two beggars A and B found some gold at the same time. They all wanted the gold, and they decided to use simple rules to distribute gold:
```
They divided gold into n piles and be in line.
The amount of each pile and the order of pi... | {"functional": "_inputs = [[[4, 7, 2, 9, 5, 2]], [[10, 1000, 2, 1]]]\n_outputs = [[[11, 18]], [[12, 1001]]]\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... | 546 | 201 |
coding | Solve the programming task below in a Python markdown code block.
Sam is playing with an array, $\mbox{A}$, of $N$ positive integers. Sam writes a list, $\mbox{S}$, containing all $\mbox{A}$'s contiguous subarrays, and then replaces each subarray with its respective maximum element.
For example, consider the following... | {"inputs": ["2\n3 2\n1 2 3 \n3 1 \n1 2 3 \n"], "outputs": ["3\n5\n"]} | 613 | 39 |
coding | Solve the programming task below in a Python markdown code block.
There is an event in DUCS where boys get a chance to show off their skills to impress girls. The boy who impresses the maximum number of girls will be honoured with the title “Charming Boy of the year”.
There are $N$ girls in the department. Each girl gi... | {"inputs": ["2\n10\njohn berry berry thomas thomas john john berry thomas john\n4\nramesh suresh suresh ramesh"], "outputs": ["john\nramesh"]} | 468 | 44 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return the number of segments in the string.
A segment is defined to be a contiguous sequence of non-space characters.
Please complete the following python code precisely:
```python
class Solution:... | {"functional": "def check(candidate):\n assert candidate(s = \"Hello, my name is John\") == 5\n assert candidate(s = \"Hello\") == 1\n\n\ncheck(Solution().countSegments)"} | 75 | 48 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a programming language with only four operations and one variable X:
++X and X++ increments the value of the variable X by 1.
--X and X-- decrements the value of the variable X by 1.
Initially, the value of... | {"functional": "def check(candidate):\n assert candidate(operations = [\"--X\",\"X++\",\"X++\"]) == 1\n assert candidate(operations = [\"++X\",\"++X\",\"X++\"]) == 3\n assert candidate(operations = [\"X++\",\"++X\",\"--X\",\"X--\"]) == 0\n\n\ncheck(Solution().finalValueAfterOperations)"} | 131 | 90 |
coding | Solve the programming task below in a Python markdown code block.
You may have helped Chef and prevented Doof from destroying the even numbers. But, it has only angered Dr Doof even further. However, for his next plan, he needs some time. Therefore, Doof has built $N$ walls to prevent Chef from interrupting him. You ha... | {"inputs": ["1\n2\n1 3\n5\n0 0\n2 0\n0 4\n1 1\n1 2"], "outputs": ["0\n1\n2\n1\n-1"]} | 710 | 49 |
coding | Solve the programming task below in a Python markdown code block.
Inna likes sweets and a game called the "Candy Matrix". Today, she came up with the new game "Candy Matrix 2: Reload".
The field for the new game is a rectangle table of size n × m. Each line of the table contains one cell with a dwarf figurine, one cel... | {"inputs": ["1 2\nSG\n", "1 2\nGS\n", "1 2\nSG\n", "1 2\nGS\n", "1 3\nS*G\n", "1 3\nG*S\n", "1 3\nS*G\n", "1 4\nSG**\n"], "outputs": ["-1\n", "1\n", "-1\n", "1\n", "-1\n", "1\n", "-1\n", "-1\n"]} | 485 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.
Fortu... | {"inputs": ["A.a\nB.b\nC.c\nD.d\n", "A.a\nB.b\nC.c\nD.d\n", "a.A\nB.b\nC.c\nD.d\n", "A.c\nB.cc\nC.c\nD.c\n", "A.c\nB.cc\nC.c\nD.c\n", "A.aa\nB.bb\nC.cc\nD.ddd\n", "A.aa\nB.bb\nC.cc\nD.ddd\n", "A.ab\nB.abcde\nC.ab\nD.abc\n"], "outputs": ["C\n", "C\n", "C\n", "B\n", "B", "C\n", "C\n", "C\n"]} | 536 | 156 |
coding | Solve the programming task below in a Python markdown code block.
According to a recent survey, Biryani is the most ordered food. Chef wants to learn how to make world-class Biryani from a MasterChef. Chef will be required to attend the MasterChef's classes for X weeks, and the cost of classes per week is Y coins. What... | {"inputs": ["4\n1 10\n1 15\n2 10\n2 15"], "outputs": ["10\n15\n20\n30\n"]} | 453 | 43 |
coding | Solve the programming task below in a Python markdown code block.
# Description
Write a function that checks whether a credit card number is correct or not, using the Luhn algorithm.
The algorithm is as follows:
* From the rightmost digit, which is the check digit, moving left, double the value of every second digit;... | {"functional": "_inputs = [['5457 6238 9823 4311'], ['8895 6238 9323 4311'], ['5457 6238 5568 4311'], ['5457 6238 9323 4311'], ['2222 2222 2222 2224'], ['5457 1125 9323 4311'], ['1252 6238 9323 4311'], ['9999 9999 9999 9995'], ['0000 0300 0000 0000'], ['4444 4444 4444 4448'], ['5457 6238 9323 1252'], ['5457 6238 1251 4... | 383 | 772 |
coding | Solve the programming task below in a Python markdown code block.
A lot of goods have an International Article Number (formerly known as "European Article Number") abbreviated "EAN". EAN is a 13-digits barcode consisting of 12-digits data followed by a single-digit checksum (EAN-8 is not considered in this kata).
Th... | {"functional": "_inputs = [['9783815820865'], ['9783815820864'], ['9783827317100']]\n_outputs = [[True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n... | 525 | 203 |
coding | Solve the programming task below in a Python markdown code block.
This version of the problem differs from the next one only in the constraint on n.
Note that the memory limit in this problem is lower than in others.
You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.
You a... | {"inputs": ["29 2839\n", "29 3120\n", "54 3120\n", "54 2819\n", "54 3493\n", "54 3635\n", "54 3180\n", "84 3180\n"], "outputs": ["2780\n", "1565\n", "371\n", "1134\n", "224\n", "1941\n", "911\n", "2568\n"]} | 513 | 139 |
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.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy... | {"inputs": ["1\n4 1\n3 4 5 1"], "outputs": ["4"]} | 626 | 24 |
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.
You are given a rooted tree with $N$ nodes (numbered $1$ through $N$); node $1$ is the root. Each node has a value; let's denote the value of node $i... | {"inputs": ["1\n3 5\n1 -5 -10\n1 2\n2 3"], "outputs": ["-4"]} | 475 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a minutes and arrives to the city B in a t_{a} minutes, and a bus from the city B departs every b ... | {"inputs": ["1 1\n1 1\n10:28\n", "4 1\n5 4\n18:40\n", "8 8\n1 1\n13:24\n", "1 1\n1 1\n23:59\n", "3 1\n2 3\n05:03\n", "1 1\n3 2\n08:44\n", "1 3\n1 2\n21:43\n", "1 1\n3 2\n08:44\n"], "outputs": ["1\n", "1\n", "8\n", "1\n", "1\n", "0\n", "4\n", "0\n"]} | 555 | 166 |
coding | Solve the programming task below in a Python markdown code block.
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student h... | {"inputs": ["2 2\n2 0\n0 -1\n0 0\n1 1", "2 2\n2 0\n0 0\n0 -1\n1 0", "2 2\n2 0\n0 -1\n0 0\n1 0", "2 2\n2 0\n0 0\n0 -1\n1 1", "2 2\n2 1\n0 0\n0 -1\n1 1", "2 2\n2 0\n1 -1\n0 0\n1 1", "2 2\n2 0\n1 -1\n1 0\n1 1", "2 2\n2 0\n0 0\n-1 0\n1 0"], "outputs": ["1\n1\n", "2\n1\n", "2\n1\n", "2\n1\n", "2\n1\n", "1\n1\n", "1\n1\n", "... | 503 | 222 |
coding | Solve the programming task below in a Python markdown code block.
We have a sequence of length N, a = (a_1, a_2, ..., a_N).
Each a_i is a positive integer.
Snuke's objective is to permute the element in a so that the following condition is satisfied:
- For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a mult... | {"inputs": ["2\n0 0", "2\n1 1", "2\n1 1\n", "3\n0 4 1", "3\n0 1 1", "3\n0 0 0", "3\n0 0 1", "3\n0 1 0"], "outputs": ["Yes\n", "No", "No\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]} | 226 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civil... | {"inputs": ["1\n654 61\n", "2\n6 5\n5 6\n", "1\n139 252\n", "1\n139 252\n", "1\n139 361\n", "1\n220 361\n", "1\n340 361\n", "1\n654 361\n"], "outputs": ["0", "1\n", "0\n", "0\n", "0", "0", "0", "0"]} | 744 | 128 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two arrays nums1 and nums2.
Return the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.
A subsequence of a array is a new array which is formed from the original array ... | {"functional": "def check(candidate):\n assert candidate(nums1 = [2,1,-2,5], nums2 = [3,0,-6]) == 18\n assert candidate(nums1 = [3,-2], nums2 = [2,-6,7]) == 21\n assert candidate(nums1 = [-1,-1], nums2 = [1,1]) == -1\n\n\ncheck(Solution().maxDotProduct)"} | 169 | 99 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integers num1 and num2, return the sum of the two integers.
Please complete the following python code precisely:
```python
class Solution:
def sum(self, num1: int, num2: int) -> int:
``` | {"functional": "def check(candidate):\n assert candidate(num1 = 12, num2 = 5) == 17\n assert candidate(num1 = -10, num2 = 4) == -6\n\n\ncheck(Solution().sum)"} | 69 | 59 |
coding | Solve the programming task below in a Python markdown code block.
We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.
Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i,... | {"inputs": ["6 2\n1 2\n2 3", "6 2\n1 0\n2 6", "6 2\n1 2\n2 6", "6 2\n2 0\n2 6", "3 2\n1 0\n2 3", "6 2\n1 2\n4 6", "3 2\n2 0\n2 3", "6 2\n0 2\n4 6"], "outputs": ["2\n", "1\n", "2\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 280 | 142 |
coding | Solve the programming task below in a Python markdown code block.
Snuke Festival 2017 will be held in a tree with N vertices numbered 1,2, ...,N. The i-th edge connects Vertex a_i and b_i, and has joyfulness c_i.
The staff is Snuke and N-1 black cats. Snuke will set up the headquarters in some vertex, and from there h... | {"inputs": ["3\n1 3 6\n2 3 4", "3\n1 3 3\n2 3 20", "3\n1 3 6\n2 3 20", "3\n1 3 4\n2 3 20", "3\n1 3 4\n2 3 21", "3\n1 3 8\n2 3 20", "3\n1 3 4\n2 1 20", "3\n1 3 10\n2 3 20"], "outputs": ["10\n8\n10\n", "6\n23\n23\n", "12\n26\n26\n", "8\n24\n24\n", "8\n25\n25\n", "16\n28\n28\n", "24\n24\n8\n", "20\n30\n30\n"]} | 738 | 217 |
coding | Solve the programming task below in a Python markdown code block.
A `Nice array` is defined to be an array where for every value `n` in the array, there is also an element `n-1` or `n+1` in the array.
example:
```
[2,10,9,3] is Nice array because
2=3-1
10=9+1
3=2+1
9=10-1
```
Write a function named `isNice`/`IsNice`... | {"functional": "_inputs = [[[2, 10, 9, 3]], [[3, 4, 5, 7]], [[0, 2, 19, 4, 4]], [[3, 2, 1, 0]], [[3, 2, 10, 4, 1, 6]], [[1, 1, 8, 3, 1, 1]], [[0, 1, 2, 3]], [[1, 2, 3, 4]], [[0, -1, 1]], [[0, 2, 3]], [[0]], [[]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 3, -2, 5, 4]], [[0, -1, -2, -3, -4]], [[1, -1, 3]], [[1, -1, 2, -... | 173 | 469 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef wants to shor... | {"inputs": ["2\n1\n2", "2\n1\n3", "2\n2\n3", "2\n2\n5", "2\n2\n2", "2\n2\n1", "2\n4\n5", "2\n4\n1"], "outputs": ["1\n3", "1\n4\n", "3\n4\n", "3\n6\n", "3\n3\n", "3\n1\n", "7\n6\n", "7\n1\n"]} | 384 | 109 |
coding | Solve the programming task below in a Python markdown code block.
The aim of this kata is to split a given string into different strings of equal size (note size of strings is passed to the method)
Example:
Split the below string into other strings of size #3
'supercalifragilisticexpialidocious'
Will re... | {"functional": "_inputs = [['supercalifragilisticexpialidocious', 3], ['HelloKata', 1], ['HelloKata', 9]]\n_outputs = [['sup erc ali fra gil ist ice xpi ali doc iou s'], ['H e l l o K a t a'], ['HelloKata']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retur... | 147 | 215 |
coding | Solve the programming task below in a Python markdown code block.
Chef has two numbers A and B.
In one operation, Chef can choose either A or B and multiply it by 2.
Determine whether he can make both A and B equal after any number (possibly, zero) of moves.
------ Input Format ------
- The first line of input wil... | {"inputs": ["4\n5 20\n6 6\n12 2\n50 20\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | 311 | 40 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.
Berland bills somehow come in lots of different sizes. However, all of them are shaped as rectangles (possibly squares). All wal... | {"inputs": ["2\n+ 2 2\n? 2 2\n", "2\n+ 2 2\n? 2 2\n", "2\n+ 2 2\n? 4 2\n", "2\n+ 2 1\n? 2 2\n", "2\n+ 2 2\n? 8 2\n", "2\n+ 1 1\n? 2 2\n", "2\n+ 2 2\n? 6 2\n", "2\n+ 1 2\n? 6 2\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 721 | 166 |
coding | Solve the programming task below in a Python markdown code block.
Create a function with two arguments that will return an array of the first (n) multiples of (x).
Assume both the given number and the number of times to count will be positive numbers greater than 0.
Return the results as an array (or list in Python... | {"functional": "_inputs = [[1, 5], [2, 5], [3, 5], [50, 5], [100, 5]]\n_outputs = [[[1, 2, 3, 4, 5]], [[2, 4, 6, 8, 10]], [[3, 6, 9, 12, 15]], [[50, 100, 150, 200, 250]], [[100, 200, 300, 400, 500]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.i... | 161 | 278 |
coding | Solve the programming task below in a Python markdown code block.
Cyael is a teacher at a very famous school in Byteland and she is known by her students for being very polite to them and also to encourage them to get good marks on their tests.
Then, if they get good marks she will reward them with candies :) However, ... | {"inputs": ["2\n2 0\n000 0", "2\n1 0\n000 0", "2\n2 0\n100 0", "2\n1 0\n010 0", "2\n1 0\n011 0", "2\n3 0\n000 3", "2\n4 1\n010 0", "2\n6 0\n100 1"], "outputs": ["0 2\n0 0\n", "0 1\n0 0\n", "0 2\n0 100\n", "0 1\n0 10\n", "0 1\n0 11\n", "0 3\n0 0\n", "4 0\n0 10\n", "0 6\n100 0\n"]} | 435 | 197 |
coding | Solve the programming task below in a Python markdown code block.
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.
Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbe... | {"inputs": ["7\n4\n0\n6\n1\n11010\n-1", "7\n4\n0\n0\n1\n11010\n-1", "7\n0\n0\n0\n6\n10000\n-1", "7\n4\n0\n0\n2\n11010\n-1", "7\n0\n0\n0\n6\n11000\n-1", "7\n0\n0\n0\n7\n11000\n-1", "7\n0\n0\n1\n7\n11000\n-1", "7\n2\n0\n7\n6\n11010\n-1"], "outputs": ["13\n10\n0\n12\n1\n2230002\n", "13\n10\n0\n0\n1\n2230002\n", "13\n0\n0\... | 502 | 344 |
coding | Solve the programming task below in a Python markdown code block.
Write a function ```x(n)``` that takes in a number ```n``` and returns an ```nxn``` array with an ```X``` in the middle. The ```X``` will be represented by ```1's``` and the rest will be ```0's```.
E.g.
```python
x(5) == [[1, 0, 0, 0, 1],
[0,... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6]]\n_outputs = [[[[1]]], [[[1, 1], [1, 1]]], [[[1, 0, 1], [0, 1, 0], [1, 0, 1]]], [[[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]], [[[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]], [[[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, ... | 302 | 445 |
coding | Solve the programming task below in a Python markdown code block.
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles.
Sereja knows that the i-th bottle is from brand a_{i}, besides, you ... | {"inputs": ["2\n1 1\n1 1\n", "2\n1 1\n1 1\n", "2\n1 0\n1 1\n", "2\n1 0\n1 0\n", "2\n1 1\n1 0\n", "2\n2 1\n1 0\n", "2\n2 1\n1 1\n", "2\n2 2\n1 1\n"], "outputs": ["0\n", "0\n", "1\n", "2\n", "1\n", "1\n", "1\n", "2\n"]} | 295 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Let's denote as L(x, p) an infinite sequence of integers y such that gcd(p, y) = 1 and y > x (where gcd is the greatest common divisor of two integer numbers), sorted in ascending order. The elements of L(x, p) are 1-indexed; for example, 9, 13 and 15 ar... | {"inputs": ["3\n4 3 1\n7 1 2\n1 28 1\n", "3\n4 5 1\n7 1 2\n2 28 2\n", "3\n4 5 1\n7 1 2\n2 25 2\n", "3\n6 5 1\n7 1 2\n2 25 2\n", "3\n6 5 1\n9 1 2\n2 25 2\n", "3\n6 5 1\n1 1 2\n2 25 2\n", "3\n4 3 1\n7 1 2\n1 28 2\n", "3\n4 3 1\n7 1 2\n2 28 1\n"], "outputs": ["5\n9\n3\n", "6\n9\n5\n", "6\n9\n4\n", "7\n9\n4\n", "7\n11\n4\n... | 336 | 255 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S constisting of uppercase Latin letters. Is it possible to reorder the characters in this string to get a string with prefix "LTIME" and suffix "EMITL"?
We remind you that a prefix of a string is any substring which contains its f... | {"inputs": ["3\nLTIMEAZAZAITLME\nLLLTTTIIIMMMEEEAHA\nLTIMEM"], "outputs": ["YES\nYES\nNO"]} | 392 | 38 |
coding | Solve the programming task below in a Python markdown code block.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
$f(i, j) = \left\{\begin{array}{ll}{P [ i ]} & {\text{if} j = 1} \\{f(P [ i ], j - 1)} & {\text{otherwise}} \end{array} \right.$
Let g(i) be the minimum positive i... | {"inputs": ["9 2 5\n", "3 2 1\n", "7 4 4\n", "1 1 1\n", "9 7 9\n", "4 3 2\n", "5 4 5\n", "5 3 4\n"], "outputs": ["2 1 4 3 6 7 8 9 5 ", "1 2 3 ", "-1", "1 ", "2 3 4 5 6 7 8 9 1 ", "2 1 4 3 ", "2 3 4 5 1 ", "-1"]} | 351 | 144 |
coding | Solve the programming task below in a Python markdown code block.
The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are ... | {"inputs": ["3\n-2 0 0\n", "3\n-2 1 0\n", "3\n-1 1 0\n", "3\n-1 0 0\n", "3\n-2 0 -1\n", "3\n-2 0 -2\n", "3\n-1 -1 -1\n", "3\n-2 -1 -1\n"], "outputs": ["-2\n", "-1\n", "0\n", "-1\n", "-3\n", "-4\n", "-3\n", "-4\n"]} | 452 | 127 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.
Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachach... | {"inputs": ["0 1 4", "9 2 9", "0 0 4", "3 2 9", "0 2 0", "0 0 0", "2 2 9", "3 1 4"], "outputs": ["3\n", "11\n", "1\n", "8\n", "2\n", "0\n", "7\n", "5"]} | 220 | 94 |
coding | Solve the programming task below in a Python markdown code block.
In the following 6 digit number:
```
283910
```
`91` is the greatest sequence of 2 consecutive digits.
In the following 10 digit number:
```
1234567890
```
`67890` is the greatest sequence of 5 consecutive digits.
Complete the solution so that it re... | {"functional": "_inputs = [['1234567898765']]\n_outputs = [[98765]]\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 ret... | 174 | 169 |
coding | Solve the programming task below in a Python markdown code block.
Mihai plans to watch a movie. He only likes palindromic movies, so he wants to skip some (possibly zero) scenes to make the remaining parts of the movie palindromic.
You are given a list $s$ of $n$ non-empty strings of length at most $3$, representing t... | {"inputs": ["6\n5\nzx\nab\ncc\nzx\nba\n2\nab\nbad\n4\nco\ndef\norc\nes\n3\na\nb\nc\n3\nab\ncd\ncba\n2\nab\nab\n"], "outputs": ["YES\nNO\nNO\nYES\nYES\nNO\n"]} | 509 | 76 |
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 | Solve the programming task below in a Python markdown code block.
Given is an integer N. Find the number of digits that N has in base K.
-----Notes-----
For information on base-K representation, see Positional notation - Wikipedia.
-----Constraints-----
- All values in input are integers.
- 1 \leq N \leq 10^9
- 2 ... | {"inputs": ["1 2", "1 3", "1 2\n", "22 2", "15 2", "11 4", "25 2", "20 2"], "outputs": ["1\n", "1\n", "1\n", "5\n", "4\n", "2\n", "5\n", "5\n"]} | 151 | 84 |
coding | Solve the programming task below in a Python markdown code block.
You are given a tree of $n$ vertices numbered from $1$ to $n$, with edges numbered from $1$ to $n-1$. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a p... | {"inputs": ["3\n2\n1 2\n4\n1 3\n4 3\n2 1\n7\n1 2\n1 3\n3 4\n3 5\n6 2\n7 2\n"], "outputs": ["2 \n3 2 2 \n-1\n"]} | 690 | 71 |
coding | Solve the programming task below in a Python markdown code block.
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is considered to have W ... | {"inputs": ["5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0", "5 5\n%#... .%.#.\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0", "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n... | 729 | 659 |
coding | Solve the programming task below in a Python markdown code block.
Every natural number, ```n```, may have a prime factorization like:
We define the **geometric derivative of n**, as a number with the following value:
For example: calculate the value of ```n*``` for ```n = 24500```.
```
24500 = 2²5³7²
n* = (2*2) *... | {"functional": "_inputs = [[24500], [997]]\n_outputs = [[4200], [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): return False\n re... | 237 | 168 |
coding | Solve the programming task below in a Python markdown code block.
We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possibl... | {"inputs": ["2 6\n7 9", "2 6\n1 9", "2 6\n1 6", "4 1\n7 9", "2 0\n4 9", "2 0\n1 8", "2 3\n7 9", "2 3\n7 9\n"], "outputs": ["3\n", "2\n", "1\n", "7\n", "9\n", "8\n", "4", "4\n"]} | 389 | 110 |
coding | Solve the programming task below in a Python markdown code block.
Remove the parentheses
=
In this kata you are given a string for example:
```python
"example(unwanted thing)example"
```
Your task is to remove everything inside the parentheses as well as the parentheses themselves.
The example above would return:
`... | {"functional": "_inputs = [['example(unwanted thing)example'], ['example (unwanted thing) example'], ['a (bc d)e'], ['a(b(c))'], ['hello example (words(more words) here) something'], ['(first group) (second group) (third group)']]\n_outputs = [['exampleexample'], ['example example'], ['a e'], ['a'], ['hello example s... | 132 | 233 |
coding | Solve the programming task below in a Python markdown code block.
Given are strings s and t of length N each, both consisting of lowercase English letters.
Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second char... | {"inputs": ["1\nt j\n", "2\nip cd", "2\nip dc", "2\npi cd", "2\npi ce", "2\noi ce", "2\nni ce", "2\nni ec"], "outputs": ["tj\n", "icpd\n", "idpc\n", "pcid\n", "pcie\n", "ocie\n", "ncie\n", "neic\n"]} | 179 | 95 |
coding | Solve the programming task below in a Python markdown code block.
Chef and his competitor Kefa own two restaurants located at a straight road. The position of Chef's restaurant is $X_1$, the position of Kefa's restaurant is $X_2$.
Chef and Kefa found out at the same time that a bottle with a secret recipe is located on... | {"inputs": ["3\n1 3 2 1 2\n1 5 2 1 2\n1 5 3 2 2"], "outputs": ["Kefa\nChef\nDraw"]} | 462 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Matrix of given integers
a1,1 a1,2 ... a1, n
a2,1 a2,2 ... a2, n
::
an, 1 an, 2 ... an, n
Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends... | {"inputs": ["3\n1 -2 3\n-1 5 6\n7 8 -9", "3\n1 -2 3\n-1 5 6\n7 8 -2", "3\n1 -2 5\n-1 2 1\n6 2 -3", "3\n-2 -7 3\n0 0 1\n45 0 0", "3\n2 -4 5\n0 2 0\n1 4 -25", "3\n1 -2 3\n-4 5 6\n7 8 -9", "3\n1 -2 3\n-1 5 6\n6 8 -15", "3\n1 -2 5\n-1 3 1\n6 8 -25"], "outputs": ["19\n", "25\n", "11\n", "46\n", "7\n", "16", "18\n", "16\n"]} | 266 | 223 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array nums of n positive integers.
You can perform two types of operations on any element of the array any number of times:
If the element is even, divide it by 2.
For example, if the array is [1,... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == 1\n assert candidate(nums = [4,1,5,20,3]) == 3\n assert candidate(nums = [2,10,8]) == 3\n\n\ncheck(Solution().minimumDeviation)"} | 220 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Chef is asked to write a program that takes an array A of length N and two integers X, Y as input and modifies it as follows:
Choose a random subset of elements of A (possibly empty)
Increase all the elements of the chosen subset by X
Increase the remai... | {"inputs": ["3\n3 2 5\n9 5 1\n11 10 3\n3 2 5\n9 5 1\n11 7 3\n3 2 5\n9 5 1\n11 7 7"], "outputs": ["Yes\nYes\nNo"]} | 619 | 74 |
coding | Solve the programming task below in a Python markdown code block.
Let f(A, B), where A and B are positive integers, be the string satisfying the following conditions:
* f(A, B) has length A + B;
* f(A, B) contains exactly A letters `A` and exactly B letters `B`;
* The length of the longest substring of f(A, B) consist... | {"inputs": ["5\n2 6 1 5\n9 4 1 2\n2 3 6 4\n6 4 3 7\n7 2 5 8", "5\n1 6 1 5\n1 4 1 2\n2 3 6 3\n6 4 3 7\n8 2 5 8", "5\n1 6 1 5\n1 4 1 2\n2 3 6 3\n6 4 3 6\n8 2 5 8", "5\n1 6 1 5\n1 5 1 2\n2 3 6 1\n6 4 3 7\n8 2 5 7", "5\n1 6 1 5\n1 6 1 2\n2 3 6 1\n6 4 1 7\n8 2 5 7", "5\n1 6 1 5\n1 6 1 2\n2 3 6 1\n6 4 1 7\n8 4 5 7", "5\n0 6 ... | 421 | 458 |
coding | Solve the programming task below in a Python markdown code block.
**This Kata is intended as a small challenge for my students**
All Star Code Challenge #16
Create a function called noRepeat() that takes a string argument and returns a single letter string of the **first** not repeated character in the entire string.... | {"functional": "_inputs = [['aabbccdde'], ['wxyz'], ['testing'], ['codewars'], ['Testing']]\n_outputs = [['e'], ['w'], ['e'], ['c'], ['T']]\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,... | 162 | 184 |
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.
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of ... | {"inputs": ["2 4\n1 2\n", "2 2\n1 1\n", "2 3\n1 1\n", "2 9\n5 5\n", "2 1\n2 2\n", "2 1\n1 1\n", "2 4\n2 2\n", "2 9\n6 5\n"], "outputs": ["2.500000\n1.500000\n", "1.000000\n1.000000\n", "1.500000\n1.500000\n", "4.500000\n4.500000\n", "0.500000\n0.500000\n", "0.500000\n0.500000\n", "2.000000\n2.000000\n", "4.000000\n5.00... | 534 | 246 |
coding | Solve the programming task below in a Python markdown code block.
You have two integers $l$ and $r$. Find an integer $x$ which satisfies the conditions below:
$l \le x \le r$. All digits of $x$ are different.
If there are multiple answers, print any of them.
-----Input-----
The first line contains two integers... | {"inputs": ["1 1\n", "5 5\n", "5 5\n", "1 1\n", "0 1\n", "0 0\n", "7 10\n", "6 39\n"], "outputs": ["1\n", "5\n", "5\n", "1\n", "0\n", "0\n", "7\n", "6\n"]} | 216 | 88 |
coding | Solve the programming task below in a Python markdown code block.
A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.
You are given a set of strings. A string (not necessarily from this set) is called good if all elemen... | {"inputs": ["1\nz\n", "1\ny\n", "1\nx\n", "1\nlol\n", "1\noll\n", "2\naa\nb\n", "2\naz\nzb\n", "2\nab\nbb\n"], "outputs": ["z\n", "y\n", "x\n", "NO\n", "NO\n", "NO\n", "azb\n", "NO\n"]} | 415 | 93 |
coding | Solve the programming task below in a Python markdown code block.
### Problem Context
The [Fibonacci](http://en.wikipedia.org/wiki/Fibonacci_number) sequence is traditionally used to explain tree recursion.
```python
def fibonacci(n):
if n in [0, 1]:
return n
return fibonacci(n - 1) + fibonacci(n - ... | {"functional": "_inputs = [[70], [60], [50]]\n_outputs = [[190392490709135], [1548008755920], [12586269025]]\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... | 429 | 206 |
coding | Solve the programming task below in a Python markdown code block.
Define a function that takes in two non-negative integers `$a$` and `$b$` and returns the last decimal digit of `$a^b$`. Note that `$a$` and `$b$` may be very large!
For example, the last decimal digit of `$9^7$` is `$9$`, since `$9^7 = 4782969$`. The ... | {"functional": "_inputs = [[4, 1], [4, 2], [9, 7], [10, 1000000000], [38710248912497124917933333333284108412048102948908149081409204712406, 226628148126342643123641923461846128214626], [3715290469715693021198967285016729344580685479654510946723, 68819615221552997273737174557165657483427362207517952651]]\n_outputs = [[4... | 324 | 432 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given an integer `n`, find the maximal number you can obtain by deleting exactly one digit of the given number.
# Example
For `n = 152`, the output should be `52`;
For `n = 1001`, the output should be `101`.
# Input/Output
- `[input]` ... | {"functional": "_inputs = [[152], [1001], [10]]\n_outputs = [[52], [101], [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): return False\n... | 142 | 175 |
coding | Solve the programming task below in a Python markdown code block.
In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are n exte... | {"inputs": ["5 5 1 2 3\n2 2 3\n", "3 4 1 1 3\n2 3 2\n", "5 5 1 2 3\n2 2 2\n", "5 5 1 2 3\n2 2 3\n", "3 4 1 1 3\n2 3 2\n", "1 1 1 1 1\n100000\n", "1 1 1 1 1\n100000\n", "3 3 2 4 4\n2 5 4 10\n"], "outputs": ["-1\n", "3\n", "-1\n", "-1", "3", "0\n", "0", "1\n"]} | 502 | 185 |
coding | Solve the programming task below in a Python markdown code block.
Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shuf... | {"inputs": ["4\n2\n", "1\n1\n", "2\n2\n", "3\n1\n", "3\n2\n", "3\n0\n", "2\n0\n", "2\n1\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "1\n", "2\n"]} | 469 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: "0001", "11", "0" and "0011100".
Polycarp wants to offer his set of n binary words to play a game "words". In th... | {"inputs": ["4\n4\n0001\n1000\n0011\n0111\n3\n010\n111\n0\n2\n00000\n00001\n4\n0\n001\n0001\n00001\n", "4\n4\n0001\n1000\n0011\n0111\n3\n010\n111\n0\n2\n00000\n00001\n4\n0\n101\n0001\n00001\n", "4\n4\n0001\n1000\n0011\n0111\n3\n011\n111\n0\n2\n00000\n00001\n4\n0\n001\n0011\n00000\n", "4\n4\n0001\n0000\n0011\n0111\n3\n0... | 730 | 700 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Your friend Сhef has prepared a rectangular cake for you. Both of you want to divide the cake among yourselves. Your friend is generous enough to let you choose your share first. You have... | {"inputs": ["2\n1 1 18 7\n8 20 32 6\n0 1 8 17\n22 1 90 8", "2\n1 1 18 7\n8 20 32 6\n0 1 8 17\n22 0 90 8", "2\n1 1 18 7\n2 20 32 6\n0 1 8 17\n22 0 90 8", "2\n1 1 18 7\n0 20 32 6\n0 1 8 17\n22 0 90 8", "2\n1 1 18 7\n0 20 32 6\n0 1 8 17\n22 0 90 2", "2\n0 2 7 1\n3 8 8 20\n1 0 20 20\n16 11 39 30", "2\n0 2 7 1\n3 8 8 20\n2 ... | 563 | 415 |
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.
Input
The input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.
Output
Output "YES" or "NO".
Examples
Input
2 3
Output
YES
Input
3 2
Output
NO
Input
33 16
Output
YES
Input
26 5
Output
... | {"inputs": ["4 3\n", "2 2\n", "5 3\n", "2 4\n", "2 5\n", "1 9\n", "1 2\n", "9 4\n"], "outputs": ["NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]} | 103 | 86 |
coding | Solve the programming task below in a Python markdown code block.
In Snakeland, there are some snakes and mongooses. They are lined up in a row. The information about how exactly they are lined up it is provided to you by a string of length n. If the i-th character of this string is 's', then it means that there is a s... | {"inputs": ["4\nsm\nssm\nsms\nssmmmssss"], "outputs": ["mongooses\ntie\ntie\nsnakes"]} | 647 | 34 |
coding | Solve the programming task below in a Python markdown code block.
You came to a local shop and want to buy some chocolate bars. There are $n$ bars in the shop, $i$-th of them costs $a_i$ coins (and you want to buy all of them).
You have $m$ different coupons that allow you to buy chocolate bars. $i$-th coupon allows y... | {"inputs": ["2\n5 7\n1\n2\n", "2\n5 7\n1\n2\n", "2\n123456 656\n1\n2\n", "2\n123456 1214\n1\n2\n", "2\n1000000000 1\n1\n2\n", "2\n1000000000 1\n1\n2\n", "2\n123456 13640\n1\n2\n", "2\n170815 20668\n1\n2\n"], "outputs": ["7\n", "7\n", "123456\n", "123456\n", "1000000000\n", "1000000000\n", "123456\n", "170815\n"]} | 601 | 223 |
coding | Solve the programming task below in a Python markdown code block.
Doremy's new city is under construction! The city can be regarded as a simple undirected graph with $n$ vertices. The $i$-th vertex has altitude $a_i$. Now Doremy is deciding which pairs of vertices should be connected with edges.
Due to economic reason... | {"inputs": ["4\n4\n2 2 3 1\n6\n5 2 3 1 5 2\n12\n7 2 4 9 1 4 6 3 7 4 2 3\n4\n1000000 1000000 1000000 1000000\n"], "outputs": ["3\n9\n35\n2\n"]} | 746 | 106 |
coding | Solve the programming task below in a Python markdown code block.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cell... | {"inputs": ["2 3\n", "6 5\n", "2 1\n", "1 0\n", "2 4\n", "2 0\n", "1 1\n", "2 2\n"], "outputs": ["NO", "YES\nLSLSLS\nSLSLSS\nSSSSSS\nSSSSSS\nSSSSSS\nSSSSSS\n", "YES\nLS\nSS\n", "YES\nS\n", "NO", "YES\nSS\nSS\n", "YES\nL\n", "YES\nLS\nSL\n"]} | 384 | 125 |
coding | Solve the programming task below in a Python markdown code block.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number... | {"inputs": ["1 10\n3", "1 10\n9", "1 10\n17", "2 0\n0 0", "3 4\n1 2 3", "4 100000\n101000 100000 100000 100000", "4 101000\n101000 100000 100100 101000", "4 110000\n101000 100000 100000 100000"], "outputs": ["0\n", "0", "1\n", "1", "5", "665683269\n", "744244119\n", "741473440\n"]} | 324 | 218 |
coding | Solve the programming task below in a Python markdown code block.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to the student h... | {"inputs": ["2\nL\n", "3\nR=\n", "3\n=R\n", "4\nRRL\n", "4\nLRR\n", "4\nRLR\n", "5\nRLRL\n", "5\nRRR=\n"], "outputs": ["2 1 \n", "1 2 2 \n", "1 1 2\n", "1 2 3 1 \n", "2 1 2 3\n", "1 2 1 2\n", "1 2 1 2 1\n", "1 2 3 4 4\n"]} | 316 | 140 |
coding | Solve the programming task below in a Python markdown code block.
You are given the strings $a$ and $b$, consisting of lowercase Latin letters. You can do any number of the following operations in any order:
if $|a| > 0$ (the length of the string $a$ is greater than zero), delete the first character of the string $a$,... | {"inputs": ["5\na\na\nabcd\nbc\nhello\ncodeforces\nhello\nhelo\ndhjakjsnasjhfksafasd\nadjsnasjhfksvdafdser\n", "5\na\na\nabcc\nbc\nhello\ncodeforces\nhello\nhelo\ndhjakjsnasjhfksafasd\nadjsnasjhfksvdafdser\n", "5\na\na\nabcc\nbc\nhello\ncodeforces\nhello\nhelo\ndhjakjsnasjhfksafasd\nadjsnasjhgksrdafdsev\n", "5\na\na\na... | 655 | 500 |
coding | Solve the programming task below in a Python markdown code block.
*SCHEDULE YOUR DA(RRA)Y*
The best way to have a productive day is to plan out your work schedule. Given the following three inputs, please create an an array of time alloted to work, broken up with time alloted with breaks:
Input 1: Hou... | {"functional": "_inputs = [[8, 5, 30], [3, 5, 60], [2, 2, 60], [2, 1, 60], [2, 0, 60]]\n_outputs = [[[30, 82, 30, 82, 30, 82, 30, 82, 30]], [\"You're not sleeping tonight!\"], [[60, 0, 60]], [[60]], [[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return m... | 283 | 261 |
coding | Solve the programming task below in a Python markdown code block.
The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the condition: fo... | {"inputs": ["1 99\n1\n", "1 99\n1\n", "1 65\n1\n", "1 99\n2\n", "3 1\n1 1 2\n", "3 1\n1 1 2\n", "3 1\n2 1 2\n", "3 1\n1 0 2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "2\n+ 2 1\n+ 3 1\n", "2\n+ 2 1\n+ 3 1\n", "2\n+ 2 2\n+ 3 2\n", "2\n+ 2 2\n+ 3 1\n"]} | 464 | 170 |
coding | Solve the programming task below in a Python markdown code block.
There is a blackboard on which all integers from -10^{18} through 10^{18} are written, each of them appearing once. Takahashi will repeat the following sequence of operations any number of times he likes, possibly zero:
* Choose an integer between 1 and... | {"inputs": ["14 4 24336", "20 4 24336", "20 4 13351", "3 3 9645713", "7 6 9645713", "4 1 2216083", "13 1 725909", "13 2 725909"], "outputs": ["6561\n", "10656\n", "347\n", "8\n", "120\n", "13\n", "3136\n", "714\n"]} | 394 | 156 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of integers, return the smallest common factors of all integers in the array.
When i say **Smallest Common Factor** i mean the smallest number above 1 that can divide all numbers in the array without a remainder.
If there are no common f... | {"functional": "_inputs = [[[200, 30, 18, 8, 64, 34]], [[21, 45, 51, 27, 33]], [[133, 147, 427, 266]], [[3, 5, 7]], [[]]]\n_outputs = [[2], [3], [7], [1], [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... | 105 | 238 |
coding | Solve the programming task below in a Python markdown code block.
*CodeChef recently revamped its [practice page] to make it easier for users to identify the next problems they should solve by introducing some new features:*
*Recent Contest Problems - contains only problems from the last 2 contests*
*Separate Un-Attem... | {"inputs": ["10 4", "10 10", "500 1", "1000 990"], "outputs": ["6", "0", "499", "10"]} | 566 | 51 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed binary arrays nums1 and nums2. Find the widest pair of indices (i, j) such that i <= j and nums1[i] + nums1[i+1] + ... + nums1[j] == nums2[i] + nums2[i+1] + ... + nums2[j].
The widest pair ... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,1,0,1], nums2 = [0,1,1,0]) == 3\n assert candidate(nums1 = [0,1], nums2 = [1,1]) == 1\n assert candidate(nums1 = [0], nums2 = [1]) == 0\n\n\ncheck(Solution().widestPairOfIndices)"} | 184 | 95 |
coding | Solve the programming task below in a Python markdown code block.
I have a plan to go on a school trip at a school. I conducted a questionnaire survey for that purpose. Students have student numbers from 1 to n, and the locations of travel candidates are represented by numbers from 1 to m, and where they want to go ○ ,... | {"inputs": ["4 6\n1 0 1 0 1 1\n1 2 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0", "4 6\n1 0 1 0 1 1\n1 2 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n2 1 0 1 1 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0", "4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n0 0... | 469 | 1,086 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Little Elephant from Zoo of Lviv likes to watch movies.
There are N different movies (numbered from 0 to N − 1) he wants to watch in some order. Of course, he will watch each movie exactly once.... | {"inputs": ["2\n3 1\n3 1 2\n4 3\n1 2 2 3"], "outputs": ["2\n24"]} | 449 | 37 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.