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.
There are N islands and M bridges.
The i-th bridge connects the A_i-th and B_i-th islands bidirectionally.
Initially, we can travel between any two islands using some of these bridges.
However, the results of a survey show that these bridges will all col... | {"inputs": ["2 1\n2 2", "2 1\n1 2", "2 1\n1 2\n", "6 5\n3 3\n1 2\n5 6\n3 4\n4 5", "4 5\n1 2\n3 4\n1 3\n3 3\n1 4", "6 5\n3 3\n1 2\n5 6\n3 4\n2 5", "4 5\n1 2\n3 4\n1 3\n3 3\n1 1", "6 5\n2 3\n1 2\n5 6\n3 4\n4 3"], "outputs": ["1\n", "1", "1\n", "8\n9\n12\n14\n15\n", "3\n3\n5\n5\n6\n", "8\n11\n13\n14\n15\n", "3\n5\n6\n6\n6... | 411 | 242 |
coding | Solve the programming task below in a Python markdown code block.
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:
Given two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (only in $a$, not $b$) so that bitwise... | {"inputs": ["2\n00\n00\n", "2\n00\n11\n", "2\n00\n11\n", "2\n00\n00\n", "5\n01011\n11001\n", "5\n01011\n11011\n", "5\n01011\n10011\n", "5\n11001\n10111\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "4\n", "3\n", "4\n", "2\n"]} | 516 | 142 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting of $n$ lowercase Latin letters.
Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position $3$ and ends in position $6$), but "aa" or "d" ... | {"inputs": ["2\nba\n", "2\naa\n", "2\nba\n", "2\naa\n", "2\nab\n", "2\nb`\n", "2\nb_\n", "2\nac\n"], "outputs": ["YES\n1 2\n", "NO\n", "YES\n1 2\n", "NO\n", "NO\n", "YES\n1 2\n", "YES\n1 2\n", "NO\n"]} | 547 | 104 |
coding | Solve the programming task below in a Python markdown code block.
Make a program that takes a value (x) and returns "Bang" if the number is divisible by 3, "Boom" if it is divisible by 5, "BangBoom" if it divisible by 3 and 5, and "Miss" if it isn't divisible by any of them.
Note: Your program should only return one va... | {"functional": "_inputs = [[30], [3], [98], [65], [23], [15], [4], [2], [45], [90], [21], [7], [6], [10003823], [41535], [712], [985], [164523]]\n_outputs = [['BangBoom'], ['Bang'], ['Miss'], ['Boom'], ['Miss'], ['BangBoom'], ['Miss'], ['Miss'], ['BangBoom'], ['BangBoom'], ['Bang'], ['Miss'], ['Bang'], ['Miss'], ['Bang... | 146 | 289 |
coding | Solve the programming task below in a Python markdown code block.
Chef has opened up a new restaurant. Like every other restaurant, critics critique this place. The Chef wants to gather as much positive publicity as he can. Also, he is very aware of the fact that people generally do not tend to go through all the revie... | {"inputs": ["10\n1 1\n1 7\n2\n1 9\n1 21\n1 8\n1 5\n2\n1 9\n2"], "outputs": ["No reviews yet\n9\n9"]} | 759 | 54 |
coding | Solve the programming task below in a Python markdown code block.
You are standing on the $\mathit{OX}$-axis at point $0$ and you want to move to an integer point $x > 0$.
You can make several jumps. Suppose you're currently at point $y$ ($y$ may be negative) and jump for the $k$-th time. You can:
either jump to the ... | {"inputs": ["1\n8\n", "1\n6\n", "1\n3\n", "1\n1\n", "1\n4\n", "1\n7\n", "1\n10\n", "1\n10\n"], "outputs": ["4\n", "3\n", "2\n", "1\n", "3\n", "4\n", "4\n", "4\n"]} | 672 | 88 |
coding | Solve the programming task below in a Python markdown code block.
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant, but there ca... | {"inputs": ["n\n", "a\n", "b\n", "y\n", "g\n", "x\n", "z\n", "m\n"], "outputs": ["YES\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"]} | 369 | 70 |
coding | Solve the programming task below in a Python markdown code block.
A [Power Law](https://en.wikipedia.org/wiki/Power_law) distribution occurs whenever "a relative change in one quantity results in a proportional relative change in the other quantity." For example, if *y* = 120 when *x* = 1 and *y* = 60 when *x* = 2 (i.e... | {"functional": "_inputs = [[[1, 120], [2, 60], 4], [[1, 120], [2, 60], 8], [[1, 120], [4, 30], 8], [[1, 120], [3, 60], 9], [[1, 120], [3, 60], 27], [[1, 120], [9, 30], 27], [[1, 81], [2, 27], 4], [[1, 81], [2, 27], 8], [[1, 81], [4, 9], 8], [[1, 81], [5, 27], 25], [[1, 81], [5, 27], 125], [[1, 81], [25, 9], 125], [[4, ... | 415 | 532 |
coding | Solve the programming task below in a Python markdown code block.
Imagine you have a rooted tree consisting of $n$ vertices. Consider the following function:
int order[n]; // initially consists of -1
int pointer = 0;
void dfs(int vertex, int depth) {
order[pointer] = depth;
pointer++;
for each child of vertex
... | {"inputs": ["2\n1 ?\n", "4\n0 ? 1 ?\n", "3\n? ? ? \n"], "outputs": ["0\n", "2\n", "2\n"]} | 427 | 47 |
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 is playing a card game called Blackjack. He starts with a deck of $N$ cards (numbered $1$ through $N$), where for each valid $i$, the $i$-th car... | {"inputs": ["3\n3 4 5\n1 2 3\n3 3 4\n1 2 3\n2 20 30\n40 10"], "outputs": ["1\n0\n-1"]} | 636 | 55 |
coding | Solve the programming task below in a Python markdown code block.
In a coding contest, there are two types of problems:
Easy problems, which are worth 1 point each
Hard problems, which are worth 2 points each
To qualify for the next round, a contestant must score at least X points. Chef solved A Easy problems and B H... | {"inputs": ["3\n15 9 3\n5 3 0\n6 2 8\n"], "outputs": ["Qualify\nNotQualify\nQualify\n"]} | 489 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Alexandra has some distinct integer numbers a_{1},a_{2}...a_{n}.
Count number of pairs (i,j) such that:
1≤ i ≤ n
1≤ j ≤ n
a_{i} < a_{j}
------ Input ------
The first line of the input contai... | {"inputs": ["2\n2\n12 11\n3\n13 11 12"], "outputs": ["1\n3"]} | 329 | 33 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Vietnamese as well.
It is well-known that ∑sqrt(a_{i}), a_{i} ∈ N is a root of some integer-coefficient polynomial. For example: sqrt(2) is a root of polynomial: x^{2} − 2. Now, your task is to find not ... | {"inputs": ["2\n1\n2\n2\n2 3"], "outputs": ["2\n1000000005 0 1\n4\n1 0 999999997 0 1"]} | 440 | 57 |
coding | Solve the programming task below in a Python markdown code block.
You are given a book with n chapters.
Each chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list.
... | {"inputs": ["5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1\n1 1\n1 3\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 3\n0\n0\n2 3 2\n5\n1 2\n1 3\n1 4\n1 5\n0\n", "5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1\n1 1\n1 3\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 3\n0\n0\n2 3 2\n5\n1 2\n1 3\n1 4\n1 3\n0\n", "5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1... | 652 | 947 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is an intern at Zoozle. He has a co-intern named Ajar who's good at maths. Chef wants to impress Ajar with his zoozliness, so he decided to play the following game with ... | {"inputs": ["5\n5"], "outputs": ["187500002"]} | 566 | 22 |
coding | Solve the programming task below in a Python markdown code block.
You came across this story while reading a book. Long a ago when the modern entertainment systems did not exist people used to go to watch plays in theaters, where people would perform live in front of an audience. There was a beautiful actress who had a... | {"inputs": ["2\nabc\naba"], "outputs": ["4\n6"]} | 477 | 18 |
coding | Solve the programming task below in a Python markdown code block.
We guessed some integer number $x$. You are given a list of almost all its divisors. Almost all means that there are all divisors except $1$ and $x$ in the list.
Your task is to find the minimum possible integer $x$ that can be the guessed number, or sa... | {"inputs": ["2\n1\n25\n2\n5 25\n", "2\n1\n25\n2\n5 25\n", "2\n1\n31\n2\n5 25\n", "1\n2\n141440 554400\n", "1\n2\n141440 554400\n", "2\n8\n8 2 12 6 4 24 16 3\n1\n2\n", "2\n8\n8 2 12 6 4 24 16 3\n1\n2\n", "2\n5\n999983 999979 999961 999959 999952\n1\n23\n"], "outputs": ["-1\n125\n", "-1\n125\n", "961\n125\n", "-1\n", "-1... | 347 | 255 |
coding | Solve the programming task below in a Python markdown code block.
Chef is solving mathematics problems. He is preparing for Engineering Entrance exam. He's stuck in a problem.
$f(n)=1^n*2^{n-1}*3^{n-2} * \ldots * n^{1} $
Help Chef to find the value of $f(n)$.Since this number could be very large, compute it modulo $10... | {"inputs": ["1\n3"], "outputs": ["12"]} | 284 | 15 |
coding | Solve the programming task below in a Python markdown code block.
Related to MrZizoScream's Product Array kata. You might want to solve that one first :)
```if:javascript
**Note:** Node 10 has now been enabled, and you can now use its BigInt capabilities if you wish, though your resulting array must still contain stri... | {"functional": "_inputs = [[[1, 1, 1]], [[0, -99, 0]], [[9, 0, -2]], [[1, 2, 3, 4]], [[2, 3, 4, 5]], [[-8, 1, 5, 13, -1]], [[3, 14, 9, 11, 11]], [[4, 7, 3, 6, 2, 11, 14, 4, 7, 5]]]\n_outputs = [[[1, 1, 1]], [[0, 0, 0]], [[0, -18, 0]], [[24, 12, 8, 6]], [[60, 40, 30, 24]], [[-65, 520, 104, 40, -520]], [[15246, 3267, 508... | 298 | 473 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is the maximum value of $n$.
You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$.
The positive integer is... | {"inputs": ["1\n6\n", "1\n8\n", "1\n662\n", "1\n937\n", "1\n150\n", "1\n719\n", "1\n940\n", "1\n435\n"], "outputs": ["9\n", "9\n", "729\n", "972\n", "243\n", "729\n", "972\n", "729\n"]} | 619 | 110 |
coding | Solve the programming task below in a Python markdown code block.
This is the hard version of the problem. The only difference is that in this version $n \leq 200000$. You can make hacks only if both versions of the problem are solved.
There are $n$ potions in a line, with potion $1$ on the far left and potion $n$ on ... | {"inputs": ["1\n0\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n5\n", "1\n7\n"], "outputs": ["1", "1", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 366 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Chef came across a new online judge that has N problems, and decided that he wants to solve them.
Chef takes A_{i} consecutive minutes to solve the i-th problem, and will take a break of B_{i} minutes immediately after solving it.
That is, Chef will... | {"inputs": ["4\n3 10\n3 4 5\n2 4 2\n3 8\n3 4 5\n2 4 2\n5 20\n23 54 124 54 83\n2 9 5 2 10\n5 20\n4 7 12 34 13\n30 4 3 0 9\n"], "outputs": ["2\n1\n0\n2\n"]} | 736 | 114 |
coding | Solve the programming task below in a Python markdown code block.
Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card of the i-... | {"inputs": ["1\n1 1\n", "1\n1 1\n", "1\n1 2\n", "2\n1 1\n1 1\n", "2\n1 2\n1 3\n", "2\n1 2\n1 3\n", "2\n1 4\n1 3\n", "2\n1 2\n1 1\n"], "outputs": ["YES\n", "YES\n", "YES\n", "NO\nNO\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n"]} | 474 | 132 |
coding | Solve the programming task below in a Python markdown code block.
Burger Town is a city that consists of $N$ special junctions and $N-1$ pathways. There is exactly one shortest path between each pair of junctions. Junction $\boldsymbol{i}$ is located at $(x_i,y_i)$ and the distance between two junctions $i,j$ is define... | {"inputs": ["3 2 1\n0 0\n1 1\n2 0\n1 2\n2 3\n"], "outputs": ["1\n"]} | 630 | 38 |
coding | Solve the programming task below in a Python markdown code block.
We have a sequence of k numbers: d_0,d_1,...,d_{k - 1}.
Process the following q queries in order:
- The i-th query contains three integers n_i, x_i, and m_i.
Let a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \begin{eqnarray} a_j = \... | {"inputs": ["3 1\n2 1 4\n5 3 2", "3 1\n3 1 3\n5 3 2", "3 1\n3 1 4\n5 3 2", "3 1\n3 1 4\n5 3 2\n", "7 2\n42 28 8 0 9 214 1000000010\n1001001011 2 5\n0000001001 0 4\n1011010001 0 1", "7 1\n39 18 39 0 9 214 1000000010\n1001001010 0 5\n0000000001 0 2\n1010010000 0 9", "7 1\n39 18 39 0 9 214 1000000010\n1001000010 0 5\n0000... | 632 | 453 |
coding | Solve the programming task below in a Python markdown code block.
Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows?
Every one of them has an integer sequences a and b of l... | {"inputs": ["3\n3 3 3\n1 1 1\n", "3\n1 1 1\n2 2 2\n", "3\n1 1 1\n2 2 2\n", "3\n1 2 0\n2 2 2\n", "3\n1 1 0\n2 2 2\n", "3\n3 3 6\n1 1 1\n", "3\n3 2 6\n1 1 1\n", "3\n0 2 0\n2 2 2\n"], "outputs": ["0\n", "0\n", "0", "4\n", "0\n", "0\n", "0\n", "4\n"]} | 556 | 165 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata you are to implement a function that parses a string which is composed from tokens of the form 'n1-n2,n3,n4-n5:n6' where 'nX' is a positive integer. Each token represent a different range:
'n1-n2' represents the range n1 to n2 (inclusive in... | {"functional": "_inputs = [['1-10,14, 20-25:2'], ['5-10'], ['2'], ['1-10,3'], ['1-10:5']]\n_outputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 20, 22, 24]], [[5, 6, 7, 8, 9, 10]], [[2]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3]], [[1, 6]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b... | 302 | 300 |
coding | Solve the programming task below in a Python markdown code block.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotage his res... | {"inputs": ["2\n-1 -1\n", "2\n-1 -1\n", "5\n-1 -1 4 5 1\n", "5\n-1 -1 4 2 1\n", "5\n-1 -1 4 3 -1\n", "5\n-1 -1 4 1 -1\n", "5\n-1 -1 4 5 -1\n", "5\n-1 -1 4 2 -1\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "2\n", "3\n", "3\n", "3\n"]} | 472 | 146 |
coding | Solve the programming task below in a Python markdown code block.
Your friend has been out shopping for puppies (what a time to be alive!)... He arrives back with multiple dogs, and you simply do not know how to respond!
By repairing the function provided, you will find out exactly how you should respond, depending on... | {"functional": "_inputs = [[26], [8], [14], [80], [100], [50], [10], [101]]\n_outputs = [['More than a handful!'], ['Hardly any'], ['More than a handful!'], [\"Woah that's a lot of dogs!\"], [\"Woah that's a lot of dogs!\"], ['More than a handful!'], ['Hardly any'], ['101 DALMATIONS!!!']]\nimport math\ndef _deep_eq(a, ... | 237 | 252 |
coding | Solve the programming task below in a Python markdown code block.
Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration $\frac{a_{i}}{1000}$. Today, on the party in honour of Sergiy of Vancouver they decided to prepare ... | {"inputs": ["0 1\n0\n", "0 1\n0\n", "0 1\n1000\n", "0 1\n1000\n", "500 1\n1000\n", "500 1\n1000\n", "430 1\n1000\n", "50 2\n100 25\n"], "outputs": ["1\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "3\n"]} | 606 | 129 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays nums1 and nums2 of equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is incremented by nums2[i]. After this is done, you can do the followi... | {"functional": "def check(candidate):\n assert candidate(nums1 = [1,2,3], nums2 = [1,2,3], x = 4) == 3\n assert candidate(nums1 = [1,2,3], nums2 = [3,3,3], x = 4) == -1\n\n\ncheck(Solution().minimumTime)"} | 182 | 83 |
coding | Solve the programming task below in a Python markdown code block.
The Kingdom of Takahashi has N towns, numbered 1 through N.
There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i.
Takahashi, the king, loves the positive integer K. The selfish king wonders what town he w... | {"inputs": ["4 9\n3 2 4 1", "4 0\n3 2 4 1", "4 0\n3 2 1 1", "4 0\n3 0 4 1", "4 0\n3 1 4 1", "4 5\n3 2 4 1", "4 5\n3 2 4 1\n", "4 16\n3 2 4 1"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "4", "4\n", "3\n"]} | 296 | 143 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
Return the single element that appears only once.
Your solution mu... | {"functional": "def check(candidate):\n assert candidate(nums = [1,1,2,3,3,4,4,8,8]) == 2\n assert candidate(nums = [3,3,7,7,10,11,11]) == 10\n\n\ncheck(Solution().singleNonDuplicate)"} | 101 | 76 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times:
Pick any nums[i] and delete it to earn nums[i] points. Afterwards, you... | {"functional": "def check(candidate):\n assert candidate(nums = [3,4,2]) == 6\n assert candidate(nums = [2,2,3,3,3,4]) == 9\n\n\ncheck(Solution().deleteAndEarn)"} | 138 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Chef will not be able to attend the birthday of his best friend Rock. He promised Rock that this will not be the case on his half birthday. To keep his promise Chef must know Rock’s next half birthday accurately. Being busy, he is assigning this work to ... | {"inputs": ["3\n15 january\n31 august\n10 october"], "outputs": ["16 july\n1 march\n10 april"]} | 334 | 36 |
coding | Solve the programming task below in a Python markdown code block.
One of the oddest traditions of the town of Gameston may be that even the town mayor of the next term is chosen according to the result of a game. When the expiration of the term of the mayor approaches, at least three candidates, including the mayor of ... | {"inputs": ["3 2\n3 3\n4 50\n5 29\n57 4\n50 2\n50 50\n0 0", "3 2\n6 3\n4 50\n5 29\n57 4\n50 2\n50 50\n0 0", "3 2\n1 2\n3 10\n10 4\n4 32\n39 2\n50 50\n0 0", "3 2\n3 3\n6 50\n10 4\n74 4\n17 1\n66 50\n0 0", "3 5\n3 2\n3 50\n17 6\n65 6\n50 2\n50 50\n0 0", "6 2\n1 2\n3 10\n1 4\n66 38\n39 2\n50 50\n0 0", "3 2\n3 3\n3 76\n10 ... | 677 | 455 |
coding | Solve the programming task below in a Python markdown code block.
Tokitsukaze is one of the characters in the game "Kantai Collection". In this game, every character has a common attribute — health points, shortened to HP.
In general, different values of HP are grouped into $4$ categories: Category $A$ if HP is in th... | {"inputs": ["6\n", "4\n", "5\n", "8\n", "3\n", "9\n", "0\n", "2\n"], "outputs": ["1 B\n", "1 A\n", "0 A\n", "1 A\n", "2 A\n", "0 A\n", "1 A\n", "1 B\n"]} | 640 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.
Constraints
* 1 ≤ H ≤ 300
* 1 ≤ W ≤ 300
Input
The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a sin... | {"inputs": ["3 4\n5 6\n2 3\n0 0", "3 4\n5 6\n2 0\n0 0", "3 4\n5 6\n2 4\n0 0", "4 4\n5 6\n2 0\n0 0", "4 4\n5 6\n4 0\n0 0", "3 5\n5 6\n2 2\n0 0", "3 4\n5 0\n2 2\n0 0", "3 4\n5 6\n2 1\n0 0"], "outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n###\n###\n\n", "####\n####\n####\n\n######\n######\n####... | 163 | 406 |
coding | Solve the programming task below in a Python markdown code block.
A ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \leq i \leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.
How many times will the ball make a bounce where the coordin... | {"inputs": ["3 6\n3 1 5", "2 6\n3 4 5", "3 6\n6 1 5", "1 6\n3 4 5", "3 6\n7 1 5", "3 6\n3 4 5", "3 6\n3 4 5\n", "4 9\n3 6 3 3"], "outputs": ["3\n", "2\n", "2\n", "2\n", "1\n", "2", "2\n", "3\n"]} | 266 | 128 |
coding | Solve the programming task below in a Python markdown code block.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 ... | {"inputs": ["@\n", "/\n", ".\n", "@ops\n", "$@ru\n", "o@ps\n", "%@ru\n", "@mike\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n"]} | 343 | 75 |
coding | Solve the programming task below in a Python markdown code block.
In music, if you double (or halve) the pitch of any note you will get to the same note again.
"Concert A" is fixed at 440 Hz, and every other note is defined based on that. 880 Hz is also an A, as is 1760 Hz, as is 220 Hz.
There are 12 notes in Western... | {"functional": "_inputs = [[440], [220], [880], [523.25], [261.625], [1046.5]]\n_outputs = [['A'], ['A'], ['A'], ['C'], ['C'], ['C']]\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... | 396 | 206 |
coding | Solve the programming task below in a Python markdown code block.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is repres... | {"inputs": ["3\n1 2 3\n3 2\n2\n", "3\n1 2 3\n3 2\n2\n", "3\n2 2 3\n3 2\n2\n", "3\n2 1 3\n3 2\n2\n", "3\n2 2 3\n3 2\n3\n", "3\n84 7 9\n9 84\n9\n", "3\n84 30 9\n9 84\n9\n", "3\n84 30 9\n9 84\n9\n"], "outputs": ["1\n3\n", "1\n3\n", "2\n3\n", "1\n3\n", "2\n2\n", "7\n84\n", "30\n84\n", "30\n84\n"]} | 563 | 195 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A containing N integers. Find if it is possible to choose exactly M elements from the array such that the MEX of the chosen elements is exactly K.
Recall that the *MEX* of an array is the smallest non-negative integer that does no... | {"inputs": ["6\n5 4 2\n0 1 3 0 3\n2 1 2\n0 1\n3 3 3\n0 1 2\n4 3 3\n2 0 4 3\n5 4 2\n0 2 1 2 5\n6 5 2\n0 1 0 2 0 3\n"], "outputs": ["YES\nNO\nYES\nNO\nNO\nYES\n"]} | 635 | 110 |
coding | Solve the programming task below in a Python markdown code block.
As you probably know, Fibonacci sequence are the numbers in the following integer sequence:
1, 1, 2, 3, 5, 8, 13...
Write a method that takes the index as an argument and returns last digit from fibonacci number. Example:
getLastDigit(15) - 610. Your m... | {"functional": "_inputs = [[193150], [300], [20001], [800], [1001], [100], [260], [1111], [1234], [99999], [10], [234], [193241], [79], [270]]\n_outputs = [[5], [0], [6], [5], [1], [5], [5], [9], [7], [6], [5], [2], [1], [1], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b,... | 192 | 280 |
coding | Solve the programming task below in a Python markdown code block.
I love Fibonacci numbers in general, but I must admit I love some more than others.
I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence.
For example:
```python
nth_fib(4) == 2... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25]]\n_outputs = [[0], [1], [1], [2], [3], [5], [8], [13], [21], [34], [55], [89], [144], [233], [377], [610], [987], [1597], [2584], [4181], [6765], [10946]... | 146 | 359 |
coding | Solve the programming task below in a Python markdown code block.
You are given a tree with N vertices and N-1 edges. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and b_i.
You have coloring materials of K colors.
For each vertex in the tree, you will choose one of the K colors to paint it, so... | {"inputs": ["4 3\n1 2\n2 3\n3 4\n", "5 4\n1 2\n1 3\n1 4\n4 5\n", "16 22\n12 1\n3 1\n4 16\n7 12\n6 2\n2 15\n5 16\n14 16\n10 11\n3 10\n3 13\n8 6\n16 8\n9 12\n4 3\n"], "outputs": ["6\n", "48\n", "271414432\n"]} | 352 | 148 |
coding | Solve the programming task below in a Python markdown code block.
You are given a function $f$ written in some basic language. The function accepts an integer value, which is immediately written into some variable $x$. $x$ is an integer variable and can be assigned values from $0$ to $2^{32}-1$. The function contains t... | {"inputs": ["1\nadd\n", "1\nadd\n", "2\nfor 4\nend\n", "2\nfor 62\nend\n", "2\nfor 15\nend\n", "2\nfor 14\nend\n", "2\nfor 16\nend\n", "2\nfor 24\nend\n"], "outputs": ["1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 640 | 115 |
coding | Solve the programming task below in a Python markdown code block.
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array.... | {"inputs": ["4 1 2\n", "1 1 0\n", "2 1 1\n", "2 2 0\n", "3 1 2\n", "3 2 2\n", "3 3 1\n", "4 2 0\n"], "outputs": ["6\n", "1\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n"]} | 604 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Create a program that converts data based on the given conversion table.
The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion tabl... | {"inputs": ["3\nA a\n0 0\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\n@ a\n0 5\n5 4\n3\nA\nB\nC\n0\n1\n4\n5\na\nb\n@\n0", "3\nA a\n0 0\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nc\nA\n3\n@ a\n0 5\n5 4\n3\nA\nB\nC\n0\n1\n1\n5\na\nb\n@\n0", "3\nA a\n0 1\n5 5\n10\nB\nB\nC\n0\n1\n0\n5\na\nc\nA\n3\n@ a\n0 5\n5 5\n3\nA\nB\nC\n0\n1\n4\n... | 469 | 707 |
coding | Solve the programming task below in a Python markdown code block.
For every good kata idea there seem to be quite a few bad ones!
In this kata you need to check the provided array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas, return 'Publish!', if there are more than 2 return 'I sm... | {"functional": "_inputs = [[['bad', 'bad', 'bad']], [['good', 'bad', 'bad', 'bad', 'bad']], [['good', 'bad', 'bad', 'bad', 'bad', 'good', 'bad', 'bad', 'good']]]\n_outputs = [['Fail!'], ['Publish!'], ['I smell a series!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):... | 142 | 216 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order.
Return the shortest ... | {"functional": "def check(candidate):\n assert candidate(nums = [2,6,4,8,10,9,15]) == 5\n assert candidate(nums = [1,2,3,4]) == 0\n assert candidate(nums = [1]) == 0\n\n\ncheck(Solution().findUnsortedSubarray)"} | 104 | 78 |
coding | Solve the programming task below in a Python markdown code block.
The elections in which three candidates participated have recently ended. The first candidate received $a$ votes, the second one received $b$ votes, the third one received $c$ votes. For each candidate, solve the following problem: how many votes should ... | {"inputs": ["1\n47 74 4774\n", "5\n0 0 0\n10 75 15\n13 13 17\n1000 0 0\n0 1000000000 0\n"], "outputs": ["4728 4701 0\n", "1 1 1\n66 0 61\n5 5 0\n0 1001 1001\n1000000001 0 1000000001\n"]} | 390 | 145 |
coding | Solve the programming task below in a Python markdown code block.
Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right.
Once Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed t... | {"inputs": ["3 3\n2 3 1\n", "3 3\n4 3 1\n", "3 3\n2 3 1\n", "4 4\n4 3 1 6\n", "4 4\n4 3 1 6\n", "5 2\n3 2 0 2 7\n", "5 4\n3 1 3 1 3\n", "5 4\n3 1 3 1 3\n"], "outputs": ["1 2 3 ", "3 2 3\n", "1 2 3\n", "3 2 5 4 ", "3 2 5 4\n", "2 1 4 1 6 ", "2 0 2 5 2 ", "2 0 2 5 2\n"]} | 737 | 194 |
coding | Solve the programming task below in a Python markdown code block.
The dragon's curve is a self-similar fractal which can be obtained by a recursive method.
Starting with the string `D0 = 'Fa'`, at each step simultaneously perform the following operations:
```
replace 'a' with: 'aRbFR'
replace 'b' with: 'LFaLb'
```
... | {"functional": "_inputs = [['a'], [1.1], [-1]]\n_outputs = [[''], [''], ['']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ... | 359 | 165 |
coding | Solve the programming task below in a Python markdown code block.
If we want to add a single element to an existing set, we can use the .add() operation.
It adds the element to the set and returns 'None'.
Example
>>> s = set('HackerRank')
>>> s.add('H')
>>> print s
set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])
>>> ... | {"inputs": ["7\nUK\nChina\nUSA\nFrance\nNew Zealand\nUK\nFrance \n"], "outputs": ["5\n"]} | 328 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another stage of the... | {"inputs": ["4 4\n1 7 4 7\n1 4 3\n2 10\n2 2\n1 3 3\n", "4 5\n5 2 6 1\n2 8\n2 7\n1 4 4\n2 9\n1 3 9\n", "4 5\n6 9 5 1\n1 4 9\n1 3 9\n1 4 7\n2 10\n2 7\n", "5 4\n4 8 3 4 10\n1 4 10\n1 4 6\n1 3 10\n2 1\n", "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1\n", "5 5\n5 6 2 10 10\n1 2 7\n2 4\n1 1 10\n2 8\n1 3 4\n", "5 6\n1 2 3 ... | 737 | 411 |
coding | Solve the programming task below in a Python markdown code block.
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a dif... | {"inputs": ["4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacc\nc\nb\nb\n0", "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacc\nd\nb\nb\n0", "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\ncba\nacb\nb\nc\nc\n5\nabc\nacc\nd\nb\nb\n0", "4\nabc\ncab\nb\na\n3\nacb\nac\na\n5\nabc\nacb\nb\nc\nc\n5\... | 389 | 461 |
coding | Solve the programming task below in a Python markdown code block.
You can print your name on a billboard ad. Find out how much it will cost you. Each letter has a default price of £30, but that can be different if you are given 2 parameters instead of 1.
You can not use multiplier "*" operator.
If your name would be ... | {"functional": "_inputs = [['Jeong-Ho Aristotelis'], ['Abishai Charalampos'], ['Idwal Augustin'], ['Hadufuns John', 20], ['Zoroaster Donnchadh'], ['Claude Miljenko'], ['Werner Vigi', 15], ['Anani Fridumar'], ['Paolo Oli'], ['Hjalmar Liupold', 40], ['Simon Eadwulf']]\n_outputs = [[600], [570], [420], [260], [570], [450]... | 134 | 294 |
coding | Solve the programming task below in a Python markdown code block.
You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck.
$\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\... | {"inputs": ["chris alan\n"], "outputs": ["Chris Alan\n"]} | 641 | 17 |
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$); the root is node $1$. For each valid $i$, node $i$ has weight $w_{i}$, which i... | {"inputs": ["1\n3\n1 0 1\n1 2\n1 3"], "outputs": ["1"]} | 585 | 28 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You ... | {"functional": "def check(candidate):\n assert candidate(security = [5,3,3,3,5,6,2], time = 2) == [2,3]\n assert candidate(security = [1,1,1,1,1], time = 0) == [0,1,2,3,4]\n assert candidate(security = [1,2,3,4,5,6], time = 2) == []\n\n\ncheck(Solution().goodDaysToRobBank)"} | 267 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Let next(x) be the minimum lucky n... | {"inputs": ["4 7\n", "1 9\n", "5 6\n", "1 2\n", "6 6\n", "3 4\n", "1 1\n", "4 8\n"], "outputs": ["25", "125", "14", "8", "7", "8\n", "4\n", "69\n"]} | 334 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Write a function that takes an arbitrary number of strings and interlaces them (combines them by alternating characters from each string).
For example `combineStrings('abc', '123')` should return `'a1b2c3'`.
If the strings are different lengths the fun... | {"functional": "_inputs = [['abc'], ['abc', '123'], ['abcd', '123'], ['abc', '1234'], ['abc', '123', '$%'], ['abcd', '123', '$%'], ['abcd', '123', '$%^&'], ['abcd', '123', '$%^&', 'qwertyuiop'], ['abcd', '123', '$%^&', 'qwertyuiop', 'X']]\n_outputs = [['abc'], ['a1b2c3'], ['a1b2c3d'], ['a1b2c34'], ['a1$b2%c3'], ['a1$b2... | 206 | 340 |
coding | Solve the programming task below in a Python markdown code block.
Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:
- Operation A: The displayed value is doubled.
- Operation B: The displayed value increases by K.
Square1001 ... | {"inputs": ["4\n4", "4\n7", "4\n2", "4\n0", "4\n1", "4\n6", "4\n5", "4\n3"], "outputs": ["12\n", "15\n", "8\n", "1\n", "5\n", "14\n", "13\n", "10"]} | 218 | 82 |
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.
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well.
You are given a binary string S. You can perform the following operations on S:
Flip: Pick an index i (1 ≤ i ≤ |S|) and flip the i-th character (i.e change 1 to 0 or ... | {"inputs": ["3\n100011\n1110011\n000101110\n"], "outputs": ["2\n2\n3\n"]} | 758 | 43 |
coding | Solve the programming task below in a Python markdown code block.
There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.
Adjacent ... | {"inputs": ["1\nq\n", "5\naaaab", "5\naa`ab", "5\naa``b", "5\nba_`a", "5\nbaaaa", "5\naa_`b", "5\nca_`a"], "outputs": ["1\n", "2\n", "4\n", "3\n", "5\n", "2\n", "4\n", "5\n"]} | 213 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Manasa loves the nim game, in which there are $n$ buckets, each having $A_i$ balls. Two players play alternately. Each turn consists of removing some non-zero number of balls from one of the bucket. A player with lack of moves looses. But, Manasa having ... | {"inputs": ["2\n2\n10 10\n3\n2 2 3\n"], "outputs": ["Sandy\nManasa\n"]} | 641 | 34 |
coding | Solve the programming task below in a Python markdown code block.
A Hackerrank number is a magic number that can be used to get sudo permissions on the site. We are going to generate a hackerrank number from two integers A & B. Each number has two parts to it - the left (L) & the right side (R).
For eg: for the numb... | {"inputs": ["2 4\n"], "outputs": ["14502\n"]} | 745 | 20 |
coding | Solve the programming task below in a Python markdown code block.
## Task
In your favorite game, you must shoot a target with a water-gun to gain points. Each target can be worth a different amount of points.
You are guaranteed to hit every target that you try to hit. You cannot hit consecutive targets though beca... | {"functional": "_inputs = [[[1, 2, 3, 4]], [[1, 3, 1]], [[5, 5, 5, 5, 5]], [[36, 42, 93, 29, 0, 33, 15, 84, 14, 24, 81, 11]], [[73, 80, 40, 86, 14, 96, 10, 56, 61, 84, 82, 36, 85]], [[11, 82, 47, 48, 80, 35, 73, 99, 86, 32, 32]], [[26, 54, 36, 35, 63, 58, 31, 80, 59, 61, 34, 54, 62, 73, 89, 7, 98, 91, 78]], [[0, 0, -1,... | 447 | 477 |
coding | Solve the programming task below in a Python markdown code block.
Родители Васи хотят, чтобы он как можно лучше учился. Поэтому если он получает подряд три положительные оценки («четвёрки» или «пятёрки»), они дарят ему подарок. Соответственно, оценки «единица», «двойка» и «тройка» родители Васи считают плохими. Когда В... | {"inputs": ["3\n4 5 4\n", "3\n4 5 1\n", "4\n5 4 3 5\n", "6\n4 5 4 5 4 4\n", "6\n4 5 3 4 5 4\n", "6\n3 3 3 4 5 5\n", "7\n4 5 3 4 5 4 1\n", "8\n4 4 4 4 5 5 5 5\n"], "outputs": ["1\n", "0\n", "0\n", "2\n", "1\n", "1\n", "1\n", "2\n"]} | 518 | 156 |
coding | Solve the programming task below in a Python markdown code block.
By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, so the col... | {"inputs": ["100 1\n+ 6\n", "100 1\n+ 51\n", "100 1\n+ 10\n", "101 1\n+ 51\n", "100 1\n+ 16\n", "101 1\n+ 74\n", "100 1\n+ 63\n", "100 1\n+ 25\n"], "outputs": ["Success\n", "Success\n", "Success\n", "Success\n", "Success\n", "Success\n", "Success\n", "Success\n"]} | 743 | 141 |
coding | Solve the programming task below in a Python markdown code block.
Teja likes cricket very much and likes to watch it all the time, but he is bored of watching the
matches alone and asks his friend to give him company. But his friend doesn’t know how to read
cricket scores so Teja decided to teach him. To make him under... | {"inputs": ["3\n1 1\n4 1\n7 6", "3\n1 1\n9 1\n7 6"], "outputs": ["YES", "NO"]} | 421 | 42 |
coding | Solve the programming task below in a Python markdown code block.
# The museum of incredible dull things
The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring exhibitions. She gives them a rating, and then removes the o... | {"functional": "_inputs = [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4]], [[5, 3, 2, 1, 4]], [[1, 2, 3, 1, 1]], [[]]]\n_outputs = [[[2, 3, 4, 5]], [[2, 3, 4]], [[5, 3, 2, 4]], [[2, 3, 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, r... | 284 | 255 |
coding | Solve the programming task below in a Python markdown code block.
Fibonacci numbers have the following form:
$\begin{aligned}F_1&-1\\ F_2&=1\\ F_3&=2\\ \vdots\\ F_n&=F_{n-2}+F_{n-1}\end{aligned}$
We have an array $a_1,a_2,\ldots,a_N$ which contains $N$ elements.
We want to find $\text{gcd}(F_{a_1},F_{a_2},F_{a... | {"inputs": ["2\n3\n6\n", "3\n2\n3\n5\n"], "outputs": ["2\n", "1\n"]} | 356 | 32 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 2D integer array items where items[i] = [pricei, weighti] denotes the price and weight of the ith item, respectively.
You are also given a positive integer capacity.
Each item can be divided into two i... | {"functional": "def check(candidate):\n assert candidate(items = [[50,1],[10,8]], capacity = 5) == 55.00000\n assert candidate(items = [[100,30]], capacity = 50) == -1.00000\n\n\ncheck(Solution().maxPrice)"} | 220 | 80 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.
Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists).
When a slime with a v... | {"inputs": ["1\n6\n", "1\n11\n", "1\n11\n", "1\n-8\n", "1\n-4\n", "1\n-3\n", "1\n10\n", "1\n20\n"], "outputs": ["6\n", "11", "11\n", "-8\n", "-4\n", "-3\n", "10\n", "20\n"]} | 379 | 96 |
coding | Solve the programming task below in a Python markdown code block.
Task:
Given an array arr of strings complete the function landPerimeter by calculating the total perimeter of all the islands. Each piece of land will be marked with 'X' while the water fields are represented as 'O'. Consider each tile being a perfect 1 ... | {"functional": "_inputs = [[['OXOOOX', 'OXOXOO', 'XXOOOX', 'OXXXOO', 'OOXOOX', 'OXOOOO', 'OOXOOX', 'OOXOOO', 'OXOOOO', 'OXOOXX']], [['OXOOO', 'OOXXX', 'OXXOO', 'XOOOO', 'XOOOO', 'XXXOO', 'XOXOO', 'OOOXO', 'OXOOX', 'XOOOO', 'OOOXO']], [['XXXXXOOO', 'OOXOOOOO', 'OOOOOOXO', 'XXXOOOXO', 'OXOXXOOX']], [['XOOOXOO', 'OXOOOOO'... | 200 | 426 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.
You must not use any built-in exponent function or operator.
For e... | {"functional": "def check(candidate):\n assert candidate(x = 4) == 2\n assert candidate(x = 8) == 2\n\n\ncheck(Solution().mySqrt)"} | 117 | 44 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino... | {"functional": "def check(candidate):\n assert candidate(dominoes = [[1,2],[2,1],[3,4],[5,6]]) == 1\n assert candidate(dominoes = [[1,2],[1,2],[1,1],[1,2],[2,2]]) == 3\n\n\ncheck(Solution().numEquivDominoPairs)"} | 168 | 83 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.
You can swap the characters at any pair of indices in the given pair... | {"functional": "def check(candidate):\n assert candidate(s = \"dcab\", pairs = [[0,3],[1,2]]) == \"bacd\"\n assert candidate(s = \"dcab\", pairs = [[0,3],[1,2],[0,2]]) == \"abcd\"\n assert candidate(s = \"cba\", pairs = [[0,1],[1,2]]) == \"abc\"\n\n\ncheck(Solution().smallestStringWithSwaps)"} | 144 | 102 |
coding | Solve the programming task below in a Python markdown code block.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one ... | {"inputs": ["2 5 4 0 4\n", "4 5 9 2 1\n", "0 0 0 0 0\n", "1 2 1 2 3\n", "2 3 4 5 6\n", "1 1 1 1 1\n", "0 1 2 3 4\n", "0 0 0 0 1\n"], "outputs": ["3\n", "-1\n", "-1\n", "-1\n", "4\n", "1\n", "2\n", "-1\n"]} | 368 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function solveMeFirst to compute the sum of two integers.
Example
$a=7$
$b=3$
Return $10$.
Function Description
Complete the solveMeFirst function in the editor below.
solveMeFirst has the following parameters:
int a: the fir... | {"inputs": ["2\n3\n"], "outputs": ["5\n"]} | 140 | 16 |
coding | Solve the programming task below in a Python markdown code block.
# Description:
Find the longest successive exclamation marks and question marks combination in the string. A successive exclamation marks and question marks combination must contains two part: a substring of "!" and a substring "?", they are adjacent. ... | {"functional": "_inputs = [['!!'], ['!??'], ['!?!!'], ['!!???!????'], ['!!???!?????'], ['!????!!!?'], ['!?!!??!!!?']]\n_outputs = [[''], ['!??'], ['?!!'], ['!!???'], ['!?????'], ['????!!!'], ['??!!!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math... | 280 | 211 |
coding | Solve the programming task below in a Python markdown code block.
A permutation $p_1,p_2...p_N$ of $\{1, 2, ..., N\}$ is beautiful if $p_i \& p_{i+1}$ is greater than 0 for every $1 \leq i < N$ . You are given an integer $N$, and your task is toconstruct a beautiful permutation of length $N$ or determine that it's impo... | {"inputs": ["3\n4\n3\n5"], "outputs": ["-1\n1 3 2\n2 3 1 5 4"]} | 314 | 35 |
coding | Solve the programming task below in a Python markdown code block.
1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:
- the dogs numbered 1,2,\cdots,26 were respectively ... | {"inputs": ["1", "4", "3", "6", "9", "7", "5", "8"], "outputs": ["a\n", "d\n", "c\n", "f\n", "i\n", "g\n", "e\n", "h\n"]} | 484 | 62 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers.
Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and ... | {"inputs": ["2\n5 4 1\n1 5 4 3 2\n5 4 1\n1 5 4 3 2\n", "2\n5 4 1\n1 5 4 3 2\n5 4 1\n1 5 4 3 2\n", "2\n5 4 1\n1 5 2 3 2\n5 4 1\n1 5 4 3 2\n", "2\n5 4 1\n1 5 2 3 2\n5 1 1\n1 5 4 3 2\n", "2\n5 4 1\n1 5 4 3 2\n5 4 1\n1 5 4 6 2\n", "2\n5 4 1\n1 5 4 3 2\n5 4 1\n1 5 7 6 2\n", "2\n5 4 1\n2 5 2 3 2\n5 1 0\n1 5 4 0 2\n", "2\n5 4... | 725 | 355 |
coding | Solve the programming task below in a Python markdown code block.
One day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of "x y" are there, such that x is a substring of string s, y... | {"inputs": ["a\nb\n", "`\nb\n", "`\nc\n", "_\nb\n", "_\na\n", "b\nab\n", "ab\na\n", "b\nba\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "1\n"]} | 645 | 82 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.
The first node is considered odd, and the second node is ev... | {"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,2,3,4,5])), list_node([1,3,5,2,4]))\n assert is_same_list(candidate(head = list_node([2,1,3,5,6,4,7])), list_node([2,3,6,7,1,5,4]))\n\n\ncheck(Solution().oddEvenList)"} | 184 | 100 |
coding | Solve the programming task below in a Python markdown code block.
Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty of the i-th string by a_{i}. It ca... | {"inputs": ["1 1\ne -1\n", "1 2\nyy 1\n", "1 2\nyy 1\n", "1 1\ne -1\n", "1 2\nzy 1\n", "1 1\nf -1\n", "0 1\nf -1\n", "0 1\ne -1\n"], "outputs": ["0\n", "1\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 506 | 118 |
coding | Solve the programming task below in a Python markdown code block.
In Berland a money reform is being prepared. New coins are being introduced. After long economic calculations was decided that the most expensive coin should possess the denomination of exactly n Berland dollars. Also the following restriction has been i... | {"inputs": ["8\n", "7\n", "9\n", "6\n", "1\n", "2\n", "5\n", "3\n"], "outputs": ["8 4 2 1\n", "7 1\n", "9 3 1\n", "6 3 1\n", "1\n", "2 1\n", "5 1\n", "3 1\n"]} | 269 | 92 |
coding | Solve the programming task below in a Python markdown code block.
White Falcon was amazed by what she can do with heavy-light decomposition on trees. As a resut, she wants to improve her expertise on heavy-light decomposition. Her teacher gave her an another assignment which requires path updates. As always, White Falc... | {"inputs": ["3 2\n0 1\n1 2\n1 0 2 1\n2 1 2\n"], "outputs": ["5\n"]} | 475 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Pr and Ms. Ad are at $a$ and $b$ respectively on an infinite number line. Mr. Pr wants to meet Ms. Ad.
Mr. Pr can choose to move $c$ or $d$ units in 1 second. If Mr. Pr moves $c$ units then Ms. Ad will move $d$ units and vice versa. (Both of them al... | {"inputs": ["2\n3 4 1 2\n10 20 3 7"], "outputs": ["YES\nNO"]} | 350 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Everyone Knows AdFly and their Sister Sites.
If we see the Page Source of an ad.fly site we can see this perticular line:
Believe it or not This is actually the Encoded url which you would skip to.
The Algorithm is as Follows:
```
1) The ysmm value is ... | {"functional": "_inputs = [['O=T0ZToPdRHJRmwdcOz1oGvTL22lFzkRZhih5GsbezSw9kndbvyR50wYawHIAF/SdhT1'], ['N=z0dDoMdyHIRmwac1zMolvWLz2RFmkMZiiZ5HsZeySw9kndbvyR50wYawHIAF/SdhT1'], ['lololol']]\n_outputs = [['http://yahoo.com'], ['http://google.com'], ['Invalid']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstanc... | 326 | 266 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k.
The value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <=... | {"functional": "def check(candidate):\n assert candidate(matrix = [[5,2],[1,6]], k = 1) == 7\n assert candidate(matrix = [[5,2],[1,6]], k = 2) == 5\n assert candidate(matrix = [[5,2],[1,6]], k = 3) == 4\n assert candidate(matrix = [[5,2],[1,6]], k = 4) == 0\n\n\ncheck(Solution().kthLargestValue)"} | 147 | 114 |
coding | Solve the programming task below in a Python markdown code block.
Chef is very organised in whatever he does and likes to maintain statistics of his work. Chef has expertise in web development and hence is a regular contributor on a forum. Chef sometimes makes multiple contributions in a single day.. Each day chef make... | {"inputs": ["1\n7\n20 6 5 3 3 1 1"], "outputs": ["1: 2\n3: 2\n5: 1\n6: 1\n20: 1"]} | 310 | 53 |
coding | Solve the programming task below in a Python markdown code block.
dot
The dot tool returns the dot product of two arrays.
import numpy
A = numpy.array([ 1, 2 ])
B = numpy.array([ 3, 4 ])
print numpy.dot(A, B) #Output : 11
cross
The cross tool returns the cross product of two arrays.
import numpy
A = numpy... | {"inputs": ["2\n1 2\n3 4\n1 2\n3 4\n"], "outputs": ["[[ 7 10]\n [15 22]]\n"]} | 278 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written... | {"inputs": ["a\n0\n", "a\n1\n", "a\n2\n", "a\n4\n", "aa\n2\n", "aa\n1\n", "ab\n1\n", "ba\n1\n"], "outputs": ["1\na\n", "0\n\n", "0\n", "0\n", "0\n\n", "1\naa\n", "1\nb\n", "1\nb\n"]} | 524 | 96 |
coding | Solve the programming task below in a Python markdown code block.
B-Mansion and courier
Problem Statement
Taro lives alone in a mansion. Taro, who loves studying, intends to study in his study in the house today. Taro can't concentrate outside the study, so he always studies in the study.
However, on this day, $ N $... | {"inputs": ["1 1 5\n6", "1 2 9\n9", "1 1 5\n5", "1 1 5\n1", "1 1 2\n3", "1 2 4\n3", "1 1 0\n1", "1 1 5\n3"], "outputs": ["5\n", "7\n", "4\n", "3\n", "2\n", "1\n", "0\n", "3"]} | 535 | 109 |
coding | Solve the programming task below in a Python markdown code block.
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).
Your objective is to remove some of the elements in a so that a will be a good sequence.
Here, an sequence b is a good sequence when the following condition holds true:
... | {"inputs": ["4\n3 3 3 3\n", "5\n2 4 1 4 2\n", "1\n1000000000\n", "6\n1 2 2 3 3 3\n", "8\n2 7 1 8 2 8 1 8\n"], "outputs": ["1\n", "2\n", "1\n", "0\n", "5\n"]} | 331 | 103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.