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.
VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.
The latest A/B test sugge... | {"inputs": ["1\n1\n72\n", "1\n5\n16\n", "1\n3\n31\n", "1\n5\n12\n", "1\n3\n47\n", "1\n5\n15\n", "1\n1\n100\n", "1\n1\n101\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 365 | 112 |
coding | Solve the programming task below in a Python markdown code block.
This is a peculiar functioning setup.
Two Tanks are separated from each other by a wall .There is a pipe in the wall which connects both tanks which allows flow of water between them . Due to this ,there is change in temperature of both tanks , every m... | {"inputs": ["2\n4 5 10\n2 2 5"], "outputs": ["Yes\nNo"]} | 346 | 27 |
coding | Solve the programming task below in a Python markdown code block.
A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.
A substring $s[l \ldots r]... | {"inputs": ["a\n", "l\n", "v\n", "l\n", "a\n", "v\n", "k\n", "b\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 501 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Given $n$ two-dimensional points in space, determine whether they lie on some vertical or horizontal line. If yes, print YES; otherwise, print NO.
Input Format
The first line contains a single positive integer, $n$, denoting the number of points.
Eac... | {"inputs": ["5\n0 1\n0 2\n0 3\n0 4\n0 5\n", "5\n0 1\n0 2\n1 3\n0 4\n0 5\n"], "outputs": ["YES\n", "NO\n"]} | 268 | 62 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap.
Return any duplicated substring that has the longest possible length. If s do... | {"functional": "def check(candidate):\n assert candidate(s = \"banana\") == \"ana\"\n assert candidate(s = \"abcd\") == \"\"\n\n\ncheck(Solution().longestDupSubstring)"} | 109 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Given the values at the leaf nodes of a complete binary tree. The total number of nodes in the binary tree, is also given. Sum of the values at both the children of a node is equal to the value of the node itself. You can add any value or subtract any va... | {"inputs": ["1:\nInput:\n1\n50"], "outputs": ["0"]} | 411 | 21 |
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.
You are given a binary string S of length N (i.e. every character of S is either 0 or 1).
You can perform the following operation on S:
select any two indices i, j of the same parity, i.e. either both i, j are odd or both i, j are even
swap S_{i} and S_... | {"inputs": ["3\n5\n00100\n5\n01010\n5\n10001"], "outputs": ["1\n2\n2"]} | 666 | 40 |
coding | Solve the programming task below in a Python markdown code block.
Complete the function/method so that it takes CamelCase string and returns the string in snake_case notation. Lowercase characters can be numbers. If method gets number, it should return string.
Examples:
``` javascript
// returns test_controller
toUn... | {"functional": "_inputs = [['TestController'], ['ThisIsBeautifulDay'], ['Am7Days'], ['My3CodeIs4TimesBetter'], [5]]\n_outputs = [['test_controller'], ['this_is_beautiful_day'], ['am7_days'], ['my3_code_is4_times_better'], ['5']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, f... | 198 | 205 |
coding | Solve the programming task below in a Python markdown code block.
You are given strings $S$ and $T$, consisting of lowercase English letters. It is guaranteed that $T$ is a permutation of the string abc.
Find string $S'$, the lexicographically smallest permutation of $S$ such that $T$ is not a subsequence of $S'$.
St... | {"inputs": ["7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabc\nac\nabc\n", "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabd\nac\nabc\n", "7\nabacaba\nabc\ncccba\nacb\nebsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabc\nac\nabc\n", "7\na... | 559 | 587 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array of strings and your task is to remove all consecutive duplicate letters from each string in the array.
For example:
* `dup(["abracadabra","allottee","assessee"]) = ["abracadabra","alote","asese"]`.
* `d... | {"functional": "_inputs = [[['ccooddddddewwwaaaaarrrrsssss', 'piccaninny', 'hubbubbubboo']], [['abracadabra', 'allottee', 'assessee']], [['kelless', 'keenness']], [['Woolloomooloo', 'flooddoorroommoonlighters', 'chuchchi']], [['adanac', 'soonness', 'toolless', 'ppellee']], [['callalloo', 'feelless', 'heelless']], [['pu... | 257 | 387 |
coding | Solve the programming task below in a Python markdown code block.
Complete the `greatestProduct` method so that it'll find the greatest product of five consecutive digits in the given string of digits.
For example:
The input string always has more than five digits.
Adapted from Project Euler.
Also feel free to reuse... | {"functional": "_inputs = [['123834539327238239583'], ['395831238345393272382'], ['92494737828244222221111111532909999'], ['02494037820244202221011110532909999']]\n_outputs = [[3240], [3240], [5292], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return m... | 81 | 290 |
coding | Solve the programming task below in a Python markdown code block.
Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so on). For... | {"inputs": ["1\na\n", "1\nf\n", "1\na\n", "1\nf\n", "1\nb\n", "1\ng\n", "1\nc\n", "1\nh\n"], "outputs": ["1\n\n", "1\n\n", "1\n\n", "1\n\n", "1\n\n", "1\n\n", "1\n\n", "1\n\n"]} | 300 | 94 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array a_1, a_2, ..., a_{n} consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k ... | {"inputs": ["2 1\n1 2\n", "2 2\n5 2\n", "2 2\n5 2\n", "2 1\n1 2\n", "2 3\n5 2\n", "2 6\n5 2\n", "2 6\n5 0\n", "2 6\n1 0\n"], "outputs": ["1\n", "5\n", "5\n", "1\n", "5\n", "5\n", "5\n", "1\n"]} | 626 | 118 |
coding | Solve the programming task below in a Python markdown code block.
On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If at least one bulb in the set is on at any given... | {"inputs": ["2\n1\n2\n"], "outputs": ["1\n3\n"]} | 234 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar... | {"inputs": ["1 7\n", "1 1\n", "2 7\n", "2 1\n", "8 6\n", "1 1\n", "1 2\n", "1 3\n"], "outputs": ["6\n", "5\n", "5\n", "4\n", "6\n", "5\n", "5\n", "5\n"]} | 504 | 86 |
coding | Solve the programming task below in a Python markdown code block.
To pass the series of gates guarded by the owls, Kenneth needs to present them each with a highly realistic portrait of one. Unfortunately, he is absolutely rubbish at drawing, and needs some code to return a brand new portrait with a moment's notice.
... | {"functional": "_inputs = [['xwe'], ['kuawd6r8q27y87t93r76352475437'], ['t6ggggggggWw'], ['xweWXo']]\n_outputs = [[\"XW''0v0''WX\"], [\"UAW8Y8T''0v0''T8Y8WAU\"], [\"TWW''0v0''WWT\"], [\"XWWXO''0v0''OXWWX\"]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n retur... | 250 | 259 |
coding | Solve the programming task below in a Python markdown code block.
Jimmy loves playing with strings. He thinks string $\mbox{A}$ is similar to string $\mbox{B}$ if the following conditions are satisfied:
Both strings have the same length (i.e., $A=a_{0}a_{1}\ldots a_{n-1}$ and $B=b_0b_1\ldots b_{n-1}$).
For each valid... | {"inputs": ["8 4\ngiggabaj\n1 1\n1 2\n1 3\n2 4\n"], "outputs": ["8\n6\n2\n1\n"]} | 651 | 42 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.
At ... | {"functional": "def check(candidate):\n assert candidate(memory1 = 2, memory2 = 2) == [3,1,0]\n assert candidate(memory1 = 8, memory2 = 11) == [6,0,4]\n\n\ncheck(Solution().memLeak)"} | 204 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows:
* For every positive integer j, add x_i to the value of ... | {"inputs": ["3\n4 9\n3 -20\n2 18", "3\n7 9\n62 0\n111 1", "3\n2 10\n3 -4\n6 15", "3\n2 1\n4 -20\n6 15", "3\n2 18\n3 -20\n6 15", "3\n7 -3\n15 0\n110 0", "3\n2 18\n4 -20\n6 15", "3\n36 -3\n6 4\n111 2"], "outputs": ["27\n", "10\n", "21\n", "16\n", "18\n", "0\n", "33\n", "6\n"]} | 310 | 185 |
coding | Solve the programming task below in a Python markdown code block.
You play a computer game. In this game, you lead a party of $m$ heroes, and you have to clear a dungeon with $n$ monsters. Each monster is characterized by its power $a_i$. Each hero is characterized by his power $p_i$ and endurance $s_i$.
The heroes cl... | {"inputs": ["2\n6\n1 3 11 8 1 8\n2\n3 2\n100 1\n5\n0 5 100 3 3\n2\n5 5\n95 1\n", "2\n6\n1 3 11 8 1 8\n2\n3 2\n000 1\n5\n0 5 100 3 3\n2\n5 5\n95 1\n", "2\n6\n3 1 2 3 1 8\n2\n3 2\n000 1\n5\n3 5 100 2 3\n2\n30 5\n90 2\n", "2\n6\n1 3 11 8 1 8\n2\n0 2\n000 1\n5\n0 5 100 3 3\n2\n5 5\n95 1\n", "2\n6\n1 3 11 8 1 8\n2\n3 2\n100... | 728 | 514 |
coding | Solve the programming task below in a Python markdown code block.
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are:
* 232
* 110011
* 54322345
Complete the function to test if the given number (`num`) **can be rearr... | {"functional": "_inputs = [[5], [1212], ['ololo'], [1331], [194], [111222], ['Hello world!'], [3357665], ['357665'], [-42]]\n_outputs = [[False], [True], ['Not valid'], [True], [False], [False], ['Not valid'], [True], ['Not valid'], ['Not valid']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float)... | 256 | 241 |
coding | Solve the programming task below in a Python markdown code block.
Mathematician Shikhar has invented a new type of fibonacci series in which
fib(1)=a
fib(2)=b
fib(n)=(fib(n-1)+fib(n-2))%1000000007 for all n>2
and now help him find the nth term of this series.
Input contains 3 space separated integers a,b and n.... | {"inputs": ["2 4 35"], "outputs": ["29860704"]} | 160 | 24 |
coding | Solve the programming task below in a Python markdown code block.
You work in the quality control department of technical support for a large company. Your job is to make sure all client issues have been resolved.
Today you need to check a copy of a dialog between a client and a technical support manager. According to... | {"inputs": ["5\n4\nQQAA\n4\nQQAQ\n3\nQAA\n1\nQ\n14\nQAQQAQAAQQQAAA\n"], "outputs": ["Yes\nNo\nYes\nNo\nYes\n"]} | 511 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Today is Devu's birthday. He has obtained few colored balloons from his friends. You are given this information by a string s consisting of lower case English Latin letters. Each letter ... | {"inputs": ["3\naab\nab\naa"], "outputs": ["aba\nab\n-1"]} | 430 | 23 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ of size $n$. Each element in this array is an integer between $1$ and $10^9$.
You can perform several operations to this array. During an operation, you can replace an element in the array with any integer between $1$ and $10^... | {"inputs": ["5\n3\n2 1 2\n4\n1 2 3 1\n5\n1 2 1 2 1\n9\n1 2 1 3 2 3 1 2 1\n9\n2 1 3 1 3 1 3 1 3\n"], "outputs": ["0\n2 1 2 \n1\n1 2 3 3 \n1\n1 2 2 2 1 \n2\n1 2 3 3 2 3 3 2 1 \n2\n2 1 3 3 3 1 3 3 3 \n"]} | 627 | 157 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Some children are playing rope skipping game. Children skip the rope at roughly the same speed: `once per second`. If the child fails during the jump, he needs to tidy up the rope and continue. This will take `3 seconds`.
You are given an array `... | {"functional": "_inputs = [[[]], [[12, 23, 45]], [[17]], [[10, 20, 30, 40]], [[10, 20, 30, 40, 58]], [[10, 20, 30, 40, 47, 60]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]]\n_outputs = [[60], [51], [57], [48], [48], [47], [30]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ... | 481 | 288 |
coding | Solve the programming task below in a Python markdown code block.
## Task
Given a positive integer `n`, calculate the following sum:
```
n + n/2 + n/4 + n/8 + ...
```
All elements of the sum are the results of integer division.
## Example
```
25 => 25 + 12 + 6 + 3 + 1 = 47
```
Also feel free to reuse/extend th... | {"functional": "_inputs = [[25], [127], [38], [1], [320], [13], [15], [47], [101], [257]]\n_outputs = [[47], [247], [73], [1], [638], [23], [26], [89], [198], [512]]\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=... | 115 | 236 |
coding | Solve the programming task below in a Python markdown code block.
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pa... | {"inputs": ["5 6\n4 2\n", "1 1\n5 1\n", "1 1\n5 2\n", "1 1\n2 1\n", "1 2\n2 1\n", "1 5\n3 2\n", "2 1\n2 2\n", "1 1\n3 5\n"], "outputs": ["26", "9", "13", "2", "3", "9", "3", "8"]} | 457 | 112 |
coding | Solve the programming task below in a Python markdown code block.
You are given a grid with $n$ rows and $m$ columns. Rows and columns are numbered from $1$ to $n$, and from $1$ to $m$. The intersection of the $a$-th row and $b$-th column is denoted by $(a, b)$.
Initially, you are standing in the top left corner $(1, ... | {"inputs": ["6\n1 1\n2 1\n1 3\n4 2\n4 6\n10 5\n"], "outputs": ["0\n1\n-1\n6\n10\n17\n"]} | 561 | 52 |
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 has always been fond of girls, but he could not make any girl his friend. In order to finally make one, he was asked to solve the following prob... | {"inputs": ["1\n4\nanxa"], "outputs": ["1"]} | 534 | 17 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Given an array A of N non-negative integers, you can choose any non-negative integer X and replace every element A_{i} with (A_{i}\oplus X) Here, \oplus deno... | {"inputs": ["1\n2\n4 6"], "outputs": ["6 2"]} | 409 | 20 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the training capacity of ... | {"functional": "def check(candidate):\n assert candidate(players = [4,7,9], trainers = [8,2,5,8]) == 2\n assert candidate(players = [1,1,1], trainers = [10]) == 1\n\n\ncheck(Solution().matchPlayersAndTrainers)"} | 178 | 71 |
coding | Solve the programming task below in a Python markdown code block.
You are given a text consisting of $n$ space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letter... | {"inputs": ["1\nu\n", "1\nu\n", "1\nt\n", "1\ns\n", "7\na a b a a a b\n", "2\nxnnlpp jpymdh\n", "7\na a b a a a b\n", "2\nxnnlpp jpymdh\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "9\n", "13\n", "9\n", "13\n"]} | 666 | 112 |
coding | Solve the programming task below in a Python markdown code block.
Given an array containing only integers, add all the elements and return the binary equivalent of that sum.
If the array contains any non-integer element (e.g. an object, a float, a string and so on), return false.
**Note:** The sum of an empty array i... | {"functional": "_inputs = [[[1, 2]], [[1, 2, 3, 4, 5]], [[1, 10, 100, 1000]], [[1, 2, -1, -2]], [[1, 2, -1, -2, 1]], [[]]]\n_outputs = [['11'], ['1111'], ['10001010111'], ['0'], ['1'], ['0']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a... | 126 | 249 |
coding | Solve the programming task below in a Python markdown code block.
School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examinati... | {"inputs": ["1 1\n1 1\n", "5 1\n1 5\n", "10 1\n2 3\n", "6 2\n1 5\n6 6\n", "5 2\n1 1\n3 3\n", "5 2\n2 1\n3 3\n", "5 2\n1 1\n3 5\n", "5 2\n1 2\n3 5\n"], "outputs": ["OK\n", "OK\n", "1 0\n", "OK\n", "2 0\n", "1 0\n", "2 0\n", "OK\n"]} | 528 | 147 |
coding | Solve the programming task below in a Python markdown code block.
You are given two positive integers A and B. You need to construct two different binary strings (i.e, they are strings which consist of only 0s and 1s), which satisfy these two conditions:
Both the strings should be palindromes.
Each string should have ... | {"inputs": ["3\n2 2\n2 3\n3 3\n"], "outputs": ["Yes\nYes\nNo\n"]} | 488 | 30 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a pattern and a string s, find if s follows the same pattern.
Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Specifically:
Each letter in p... | {"functional": "def check(candidate):\n assert candidate(pattern = \"abba\", s = \"dog cat cat dog\") == True\n assert candidate(pattern = \"abba\", s = \"dog cat cat fish\") == False\n assert candidate(pattern = \"aaaa\", s = \"dog cat cat dog\") == False\n\n\ncheck(Solution().wordPattern)"} | 143 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Given are a positive integer N and a string S of length N consisting of lowercase English letters.
Determine whether the string is a concatenation of two copies of some string.
That is, determine whether there is a string T such that S = T + T.
-----Con... | {"inputs": ["1\n{", "1\ny", "1\n|", "1\n}", "1\n~", "1\n\u007f", "1\nz", "1\nz\n"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No", "No\n"]} | 169 | 81 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
The ugliness of a string is defined as the count of two consecutive ones i.e. "11" in the given string. For example, the ugliness of string "10111" is $2$.
You are... | {"inputs": ["2 \n3\n3 6 5\n2\n7 6"], "outputs": ["5 6 3\n6 7"]} | 507 | 35 |
coding | Solve the programming task below in a Python markdown code block.
Given is an integer sequence of length N: A_1, A_2, \cdots, A_N.
An integer sequence X, which is also of length N, will be chosen randomly by independently choosing X_i from a uniform distribution on the integers 1, 2, \ldots, A_i for each i (1 \leq i \l... | {"inputs": ["3\n1 2 3\n", "3\n2 1 2\n", "1\n78261382\n", "5\n9 7 4 4 1\n", "5\n4 5 7 10 9\n", "6\n7 4 4 2 6 1\n", "6\n6 3 4 5 5 5\n", "6\n1 1 1 1 1 1\n"], "outputs": ["2\n", "500000005\n", "1\n", "825396833\n", "966269851\n", "420386910\n", "880111120\n", "1\n"]} | 595 | 188 |
coding | Solve the programming task below in a Python markdown code block.
Write function heron which calculates the area of a triangle with sides a, b, and c.
Heron's formula: sqrt (s \* (s - a) \* (s - b) \* (s - c)), where s = (a + b + c) / 2.
Output should have 2 digits precision.
Also feel free to reuse/extend the followi... | {"functional": "_inputs = [[3, 4, 5], [6, 8, 10]]\n_outputs = [[6], [24]]\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 ... | 107 | 175 |
coding | Solve the programming task below in a Python markdown code block.
## Task
You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input.
## Example
For `arr = [1, 1, 1]... | {"functional": "_inputs = [[[1, 1, 1]], [[-1000, 0, -2, 0]], [[2, 1, 10, 1]], [[2, 3, 3, 5, 5, 5, 4, 12, 12, 10, 15]]]\n_outputs = [[3], [5], [12], [13]]\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... | 203 | 237 |
coding | Solve the programming task below in a Python markdown code block.
Problem
One day, Kawabayashi is about to have lunch at the school cafeteria. There are three types of daily lunch menus for school cafeterias: A lunch, B lunch, and C lunch.
Kawabayashi is a glutton, so I would like to eat all three types of daily lunch... | {"inputs": ["0011 2 329", "0011 1 329", "0011 0 329", "0010 0 329", "0010 0 256", "0010 0 413", "0011 0 413", "0001 0 413"], "outputs": ["C\n", "C\n", "C\n", "C\n", "C\n", "C\n", "C\n", "C\n"]} | 337 | 134 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future.
`Time` is the sum of characters that increase time (i.e. numbers in range ['1'..... | {"functional": "_inputs = [['12:30 am'], ['12:02 pm'], ['01:00 pm'], ['11:12 am'], ['05:20 pm'], ['04:20 am']]\n_outputs = [[[False, False, True]], [[False, True, False]], [[True, False, False]], [[False, False, True]], [[False, False, True]], [[False, True, False]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if ... | 451 | 241 |
coding | Solve the programming task below in a Python markdown code block.
Welcome. In this kata, you are asked to square every digit of a number and concatenate them.
For example, if we run 9119 through the function, 811181 will come out, because 9^(2) is 81 and 1^(2) is 1.
**Note:** The function accepts an integer and retur... | {"functional": "_inputs = [[3212], [2112]]\n_outputs = [[9414], [4114]]\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 ... | 113 | 172 |
coding | Solve the programming task below in a Python markdown code block.
You have N cards placed in front of you on the table. The i^{th} card has the number A_{i} written on it.
In one move, you can remove any one card from the remaining cards on the table.
Find the minimum number of moves required so that all the cards ... | {"inputs": ["3\n5\n1 1 2 2 3\n4\n8 8 8 8\n6\n5 6 7 8 9 10\n"], "outputs": ["3\n0\n5\n"]} | 602 | 55 |
coding | Solve the programming task below in a Python markdown code block.
There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct.
Snuke wants to connect each compu... | {"inputs": ["2\n-1\n1\n7\n78", "2\n1\n11\n4\n68", "2\n0\n2\n3\n312", "2\n0\n2\n20\n48", "2\n2\n11\n4\n68", "2\n1\n2\n3\n312", "2\n0\n2\n20\n56", "2\n0\n2\n21\n78"], "outputs": ["2\n", "1\n", "2\n", "2\n", "1\n", "2\n", "2\n", "2\n"]} | 255 | 142 |
coding | Solve the programming task below in a Python markdown code block.
The Collatz Conjecture states that for any natural number n, if n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. If you repeat the process continuously for n, n will eventually reach 1.
For example, if n = 20, the resulting sequence w... | {"functional": "_inputs = [[100], [10], [500], [73567465519280238573], [1000000000], [1000000000000000]]\n_outputs = [[26], [7], [111], [362], [101], [276]]\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 ... | 184 | 241 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps:
Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If... | {"functional": "def check(candidate):\n assert candidate(nums = [5,1,3]) == 3\n assert candidate(nums = [1,1,1]) == 0\n assert candidate(nums = [1,1,2,2,3]) == 4\n\n\ncheck(Solution().reductionOperations)"} | 154 | 72 |
coding | Solve the programming task below in a Python markdown code block.
Chef is frustrated in this lockown. So to overcome this he plans to travel various mountains.
He is very strange so he sets some conditions for $each$ Type 2 query(mentioned below) (i.e. $1$ $i$) :
- Let Chef has travelled till $ith$ mountain from left ... | {"inputs": ["1\n10 5\n1 3 5 4 5 6 7 8 4 5\n1 7\n1 3\n1 1\n0 2 7\n1 3"], "outputs": ["-1\n6\n5\n5"]} | 687 | 67 |
coding | Solve the programming task below in a Python markdown code block.
To get on the Shinkansen, you need two tickets, a "ticket" and a "limited express ticket". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen, one ticket can be used as both a tic... | {"inputs": ["0 0 0", "1 1 0", "1 0 0", "0 1 0", "0 0 0", "0 1 0", "1 0 0", "1 1 0"], "outputs": ["Close\n", "Open\n", "Close\n", "Close\n", "Close\n", "Close\n", "Close\n", "Open\n"]} | 416 | 94 |
coding | Solve the programming task below in a Python markdown code block.
One of the most important skills a programmer needs to learn early on is the ability to pose a problem in an abstract way. This skill is important not just for researchers but also in applied fields like software engineering and web development.
You a... | {"inputs": ["4\n10 -5 5 20\n", "5\n7 12 24 6 5\n"], "outputs": ["50\n", "144\n"]} | 529 | 47 |
coding | Solve the programming task below in a Python markdown code block.
One day, Tanya was studying graph theory. She is very inquisitive, so the following problem soon came to her mind.
Find the number of undirected unweighted connected simple graphs with $N$ vertices (numbered $1$ through $N$) and $M$ edges, such that for ... | {"inputs": ["3\n4 3\n1 2 1\n4 6\n1 2 1\n3 2\n2 2"], "outputs": ["2\n0\n0"]} | 596 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a binary string S. He can replace any occurrence of -
- 01 with a
- 10 with b
- 010 with ab
- 101 with ba
While doing these operations, Chef noticed that he can end up with different strings depending upon the order of application of the opera... | {"inputs": ["3\nab\naa\nabb\n"], "outputs": ["2\n1\n2\n"]} | 589 | 24 |
coding | Solve the programming task below in a Python markdown code block.
Mark and Jane are very happy after having their first child. Their son loves toys, so Mark wants to buy some. There are a number of different toys lying in front of him, tagged with their prices. Mark has only a certain amount to spend, and he wants to ... | {"inputs": ["7 50\n1 12 5 111 200 1000 10\n"], "outputs": ["4\n"]} | 420 | 40 |
coding | Solve the programming task below in a Python markdown code block.
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.
You ... | {"inputs": ["3\n2 5 -1", "3\n2 5 -2", "3\n3 5 -2", "3\n3 2 -2", "3\n0 2 -2", "3\n0 3 -2", "3\n0 3 -4", "3\n0 6 -5"], "outputs": ["12\n6\n10\n", "14\n8\n10\n", "14\n10\n10\n", "8\n10\n6\n", "8\n4\n4\n", "10\n4\n6\n", "14\n8\n6\n", "22\n10\n12\n"]} | 460 | 155 |
coding | Solve the programming task below in a Python markdown code block.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertic... | {"inputs": ["1\n0 1", "1\n1 1", "2\n0 3 2", "2\n0 1 1", "2\n0 2 2", "2\n0 3 1", "2\n-1 3 2", "2\n-2 3 2"], "outputs": ["2\n", "-1", "-1\n", "4\n", "-1\n", "-1", "7\n", "8\n"]} | 306 | 106 |
coding | Solve the programming task below in a Python markdown code block.
Asmany strings are strings of '0's and '1's that have as many 00 as 11. A string such as 00110001 consists of 3 "00" and
1 "11". Of course this is not an Asmany string. 0011, 1100, 000111000111 are Asmany strings. An L'th Asmany number is the number of
A... | {"inputs": ["2\n3\n4", "2\n1\n4", "2\n2\n4", "2\n2\n1", "2\n1\n1", "2\n4\n4", "2\n5\n4", "2\n1\n6"], "outputs": ["NO\nYES", "NO\nYES\n", "YES\nYES\n", "YES\nNO\n", "NO\nNO\n", "YES\nYES\n", "NO\nYES\n", "NO\nYES\n"]} | 384 | 109 |
coding | Solve the programming task below in a Python markdown code block.
For the first place at the competition, Alex won many arrays of integers and was assured that these arrays are very expensive. After the award ceremony Alex decided to sell them. There is a rule in arrays pawnshop: you can sell array only if it can be co... | {"inputs": ["1\n1\n1\n", "1\n5\n1 3 1 3 0\n", "1\n5\n0 1000000000 999999999 999999998 999999997\n", "6\n6\n1 9 17 6 14 3\n3\n4 2 2\n3\n7 3 4\n3\n2 2 4\n5\n0 1000000000 0 1000000000 0\n2\n1 1\n"], "outputs": ["0\n", "-1\n", "1000000001 1000000000\n", "19 8\n-1\n-1\n-1\n2000000000 1000000000\n0\n"]} | 654 | 231 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of t... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1,0,2]), low = 1, high = 2), tree_node([1,None,2]))\n assert is_same_tree(candidate(root = tree_node([3,0,4,None,2,None,None,1]), low = 1, high = 3), tree_node([3,2,None,1]))\n\n\ncheck(Solution().trimBST)"} | 209 | 102 |
coding | Solve the programming task below in a Python markdown code block.
Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place.
To decide who exactly would clean the apartment, the friends want to play... | {"inputs": ["1\n1\n", "1\n2\n", "1\n5\n", "1\n5\n", "1\n4\n", "1\n3\n", "1\n2\n", "1\n1\n"], "outputs": ["3\n", "2\n", "3\n", "3\n", "2\n", "3\n", "2\n", "3\n"]} | 447 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Initially, two non-touching spheres of radii R1 and R2 are lying in space at rest. Both of them are then given accelerations a1 and a2 respectively at time=0. Find whether they will ever come in contact. Their initial positions are represented as (x1,y1,... | {"inputs": ["2\n1 2\n0 0 0\n-1 0 0\n4 0 0\n1 0 0\n1 2\n0 0 0\n100 0 0\n4 0 0\n0 0 0\n"], "outputs": ["NO\nYES\n"]} | 464 | 75 |
coding | Solve the programming task below in a Python markdown code block.
You're given an array A of N integers. You need to find the minimum cost of creating another array B of N integers with the following properties
B_{i} ≥ 0 for each 1 ≤ i ≤ N
The GCD of adjacent elements of B is equal to 1, i.e, \gcd(B_{i}, B_{i+1}) = 1 ... | {"inputs": ["3\n3\n15 16 19\n2\n5 10\n7\n9 15 7 19 10 7 1\n"], "outputs": ["3\n3\n8"]} | 603 | 54 |
coding | Solve the programming task below in a Python markdown code block.
The campus has $m$ rooms numbered from $0$ to $m - 1$. Also the $x$-mouse lives in the campus. The $x$-mouse is not just a mouse: each second $x$-mouse moves from room $i$ to the room $i \cdot x \mod{m}$ (in fact, it teleports from one room to another si... | {"inputs": ["4 3\n", "5 2\n", "7 2\n", "2 1\n", "2 1\n", "7 2\n", "3 2\n", "4 3\n"], "outputs": ["3\n", "2\n", "3\n", "2\n", "2\n", "3\n", "2\n", "3\n"]} | 439 | 86 |
coding | Solve the programming task below in a Python markdown code block.
# Task
John is an orchard worker.
There are `n` piles of fruits waiting to be transported. Each pile of fruit has a corresponding weight. John's job is to combine the fruits into a pile and wait for the truck to take them away.
Every time, John can co... | {"functional": "_inputs = [[[1, 2, 9]], [[100]], [[1, 2]], [[4, 3, 5, 6, 10, 20]], [[87, 84, 42, 34, 24, 81, 60, 48, 75]], [[11, 9, 20, 10, 21, 35, 15, 34, 48, 76, 94, 28, 79, 16, 4, 41, 98, 30, 35, 92, 93, 33, 100, 93, 64, 23, 37, 6, 86, 27, 48, 16, 66, 99, 61, 83, 3, 5, 95]]]\n_outputs = [[15], [0], [3], [111], [1663... | 452 | 402 |
coding | Solve the programming task below in a Python markdown code block.
There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.
First, Snuke will arrange the N balls in a row from left to right.
Then, Takahashi will collect only the K bl... | {"inputs": ["7 3", "7 5", "5 5", "7 4", "7 2", "5 2", "3 3", "2 3"], "outputs": ["5\n20\n10\n", "3\n12\n6\n0\n0\n", "1\n0\n0\n0\n0\n", "4\n18\n12\n1\n", "6\n15\n", "4\n6\n", "1\n0\n0\n", "0\n0\n0\n"]} | 465 | 122 |
coding | Solve the programming task below in a Python markdown code block.
Chef has started working at the candy store. The store has 100 chocolates in total.
Chef’s daily goal is to sell X chocolates. For each chocolate sold, he will get 1 rupee.
However, if Chef exceeds his daily goal, he gets 2 rupees per chocolate for eac... | {"inputs": ["4\n3 1\n5 5\n4 7\n2 3\n"], "outputs": ["1\n5\n10\n4\n"]} | 456 | 37 |
coding | Solve the programming task below in a Python markdown code block.
Notes
Template in C
Constraints
* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 1000
* 1 ≤ timei ≤ 50000
* 1 ≤ length of namei ≤ 10
* 1 ≤ Sum of timei ≤ 1000000
Input
n q
name1 time1
name2 time2
...
namen timen
In the first line the number of processes n and the quant... | {"inputs": ["5 100\np1 54\n2p 80\n3p 200\np4 350\np5 14", "5 100\np1 54\n2p 80\n3p 200\n4p 350\np5 14", "4 100\np1 150\np2 80\np3 240\n4p 350\np5 8", "2 100\np1 54\n2p 80\n3p 200\n4p 350\np5 14", "4 100\np1 150\no2 80\np3 240\n4p 350\np5 8", "4 101\np1 150\no2 80\np3 240\n4p 350\np4 8", "4 101\n1p 150\no2 80\np3 240\n4... | 259 | 555 |
coding | Solve the programming task below in a Python markdown code block.
JJ has an array A of length N and an integer X. JJ can perform the following operation at most once:
Select a [subsequence] of A and add X to all the elements of that subsequence.
For example, if A = [2, 1, 6, 3, 5] and X = 7, we can select the subseque... | {"inputs": ["3\n2 1\n1 2\n4 1\n2 2 3 3\n5 2\n5 3 6 2 8\n"], "outputs": ["3\n15\n43\n"]} | 629 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get ... | {"inputs": ["1 1\na\n1 1 a b\n", "1 1\na\n1 1 a b\n", "3 1\nioi\n1 1 i n\n", "3 1\nioi\n1 1 i n\n", "2 2\naa\n1 2 a b\n1 2 b c\n", "2 2\naa\n2 2 a b\n1 1 a b\n", "2 2\naa\n1 2 a b\n1 2 b c\n", "2 2\naa\n2 2 a b\n1 1 a b\n"], "outputs": ["b", "b\n", "noi", "noi\n", "cc", "bb", "cc\n", "bb\n"]} | 407 | 174 |
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.
Our Chef who was a renouned mathematician has recently got into diamonds' business.
She has accidentally misplaced $Q$ diamonds into a jar which already had $N$ chocolates. She then started wondering about an interesting question as following.
If we pi... | {"inputs": ["1\n2 2"], "outputs": ["3.3333333333"]} | 396 | 27 |
coding | Solve the programming task below in a Python markdown code block.
Let's consider one interesting word game. In this game you should transform one word into another through special operations.
Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transfo... | {"inputs": ["ab\nba\n0\n", "hi\nhi\n1\n", "ab\nba\n9\n", "aa\naa\n1\n", "ab\nab\n0\n", "ba\naa\n1\n", "ab\nb`\n2\n", "bb\nab\n2\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1\n", "0\n", "0\n", "0\n"]} | 453 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format "name_1price_1nam... | {"inputs": ["a1.01\n", "a0.11\n", "a0.01\n", "a0.40\n", "a0.11\n", "a0.40\n", "a1.01\n", "a0.01\n"], "outputs": ["1.01\n", "0.11\n", "0.01\n", "0.40\n", "0.11", "0.40", "1.01", "0.01"]} | 547 | 122 |
coding | Solve the programming task below in a Python markdown code block.
In this problem, we'll use the term "longest common substring" loosely. It refers to substrings differing at some number or fewer characters when compared index by index. For example, 'abc' and 'adc' differ in one position, 'aab' and 'aba' differ in tw... | {"inputs": ["3\n2 tabriz torino\n0 abacba abcaba\n3 helloworld yellomarin\n"], "outputs": ["4\n3\n8\n"]} | 677 | 37 |
coding | Solve the programming task below in a Python markdown code block.
The goal of this Kata is to remind/show you, how Z-algorithm works and test your implementation.
For a string str[0..n-1], Z array is of same length as string. An element Z[i] of Z array stores length of the longest substring starting from str[i] which ... | {"functional": "_inputs = [['ababcaba'], [''], ['aaaaaaaa'], ['ababababab'], ['aaaa$aaaa'], ['abracadabra']]\n_outputs = [[[8, 0, 2, 0, 0, 3, 0, 1]], [[]], [[8, 7, 6, 5, 4, 3, 2, 1]], [[10, 0, 8, 0, 6, 0, 4, 0, 2, 0]], [[9, 3, 2, 1, 0, 4, 3, 2, 1]], [[11, 0, 0, 1, 0, 1, 0, 4, 0, 0, 1]]]\nimport math\ndef _deep_eq(a, b,... | 345 | 318 |
coding | Solve the programming task below in a Python markdown code block.
On a certain train, Chef-the ticket collector, collects a fine of Rs. X if a passenger is travelling without a ticket. It is known that a passenger carries either a single ticket or no ticket.
P passengers are travelling and they have a total of Q tick... | {"inputs": ["4\n4 1 1\n2 10 7\n8 5 4\n9 7 0"], "outputs": ["0\n6\n8\n63"]} | 461 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Monk and his P-1 friends recently joined a college. He finds that N students have already applied for different courses before him. Courses are assigned numbers from 1 to C. He and his friends will follow the following conditions when choosing courses:-... | {"inputs": ["10 10 10\n2 8 5 1 10 5 9 9 3 5\n2 5 1 8 6 5 1 10 1 6", "100 100 90\n2 8 5 1 10 5 9 9 3 5 6 6 2 8 2 2 6 3 8 7 2 5 3 4 3 3 2 7 9 6 8 7 2 9 10 3 8 10 6 5 4 2 3 4 4 5 2 2 4 9 8 5 3 8 8 10 4 2 10 9 7 6 1 3 9 7 1 3 5 9 7 6 1 10 1 1 7 2 4 9 10 4 5 5 7 1 7 7 2 9\n1 6 2 4 4 9 7 2 2 9 10 8 5 1 7 3 4 10 5 6 3 9 5 10 ... | 585 | 784 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You work as an engineer. You were given an empty board with $K$ consecutive cells; at any moment, each cell can display one character.
You want the board to display a string... | {"inputs": ["3\n6 3\naabbcc\n5 2\nabccc\n4 3\naabb"], "outputs": ["4\n3\n1"]} | 716 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Let's call the string beautiful if it does not contain a substring of length at least $2$, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. ... | {"inputs": ["1 1\na\n1 1\n", "1 1\na\n1 1\n", "5 4\nbaacb\n1 3\n1 5\n4 5\n2 3\n", "5 4\nbaacb\n1 3\n1 5\n4 5\n2 4\n", "5 4\nbaacb\n1 3\n2 5\n4 5\n2 4\n", "5 4\nbaacb\n1 3\n1 1\n4 5\n2 3\n", "5 4\nbaacb\n3 3\n1 3\n4 5\n2 3\n", "5 4\nbabcb\n2 3\n1 3\n3 5\n2 3\n"], "outputs": ["0\n", "0\n", "1\n2\n0\n1\n", "1\n2\n0\n1\n",... | 520 | 248 |
coding | Solve the programming task below in a Python markdown code block.
There are N people. The name of the i-th person is S_i.
We would like to choose three people so that the following conditions are met:
- The name of every chosen person begins with M, A, R, C or H.
- There are no multiple people whose names begin with ... | {"inputs": ["1\nAAA\n", "5\nM\nA\nR\nC\nH\n", "4\nZY\nZZZ\nZ\nZZZZZZZZZZ", "4\nZY\nZZY\nZ\nZZZZZZZZZZ", "4\nZY\nYZZ\nZ\nZZZZZZZZZZ", "4\nZY\nYZZ\nY\nZZZZZZZZZZ", "4\nZY\nZYZ\nY\nZZZZZZZZZZ", "4\nZY\nZYZ\nY\nZYZZZZZZZZ"], "outputs": ["0\n", "10\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 294 | 155 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array digits, where each element is a digit. The array may contain duplicates.
You need to find all the unique integers that follow the given requirements:
The integer consists of the concate... | {"functional": "def check(candidate):\n assert candidate(digits = [2,1,3,0]) == [102,120,130,132,210,230,302,310,312,320]\n assert candidate(digits = [2,2,8,8,2]) == [222,228,282,288,822,828,882]\n assert candidate(digits = [3,7,5]) == []\n\n\ncheck(Solution().findEvenNumbers)"} | 155 | 140 |
coding | Solve the programming task below in a Python markdown code block.
In 21XX, an annual programming contest, Japan Algorithmist GrandPrix (JAG) has become one of the most popular mind sports events.
JAG is conducted as a knockout tournament. This year, $N$ contestants will compete in JAG. A tournament chart is represente... | {"inputs": ["[[r-i]-[m-e]]\ne 0\nr 1\ni 1\nn 2", "[[m-y]-[a-o]]\nn 0\na 1\ny 2\nm 0", "[[r-i]-[m-e]]\nd 0\nr 1\ni 1\nn 2", "[[r-i]-[m-e]]\nd 0\nr 1\ni 1\nn 3", "[[r-i]-[m-e]]\nd 0\nr 1\nh 1\nn 3", "[[r-i]-[m-e]]\nd 0\nr 1\ng 1\nn 3", "[[r-i]-[m-e]]\nd 0\nr 1\ng 1\nm 3", "[[m-y]-[a-o]]\no 0\nb 1\ny 2\nm 0"], "outputs": ... | 636 | 246 |
coding | Solve the programming task below in a Python markdown code block.
In ACM-ICPC contests, there are usually three people in a team. For each person in the team, you know their scores in three skills - hard work, intelligence and persistence.
You want to check whether it is possible to order these people (assign them numb... | {"inputs": ["3\n1 2 3\n2 3 4\n2 3 5\n1 2 3\n2 3 4\n2 3 4\n5 6 5\n1 2 3\n2 3 4"], "outputs": ["yes\nno\nyes"]} | 437 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly n/2 ... | {"inputs": ["2\n1 1\n", "2\n8 8\n", "4\n2 3 3 3\n", "4\n1 2 2 2\n", "4\n2 1 1 1\n", "4\n1 1 1 4\n", "4\n1 3 3 3\n", "4\n1 2 2 3\n"], "outputs": ["Bob\n", "Bob\n", "Alice\n", "Alice\n", "Bob\n", "Bob\n", "Alice\n", "Alice\n"]} | 344 | 126 |
coding | Solve the programming task below in a Python markdown code block.
The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she k... | {"inputs": ["1 1\ng\ng\n", "1 1\ng\ng\n", "10 5\nsomer\nandom\nnoise\nmayth\neforc\nebewi\nthyou\nhctwo\nagain\nnoise\nsomermayth\nandomeforc\nnoiseebewi\nagainthyou\nnoisehctwo\n", "10 5\nsomer\nandom\nnoise\nmayth\neforc\nebewi\nthyou\nhctwo\nagain\nooise\nsomermayth\nandomeforc\nnoiseebewi\nagainthyou\nnoisehctwo\n"... | 499 | 432 |
coding | Solve the programming task below in a Python markdown code block.
Chef Leonardo has a decimal integer $N$ and a non-zero decimal digit $d$. $N$ does not contain the digit zero; specifically, $N$ should always be treated as a decimal integer without leading zeroes.
Chef likes $d$ and does not like any other digit, so he... | {"inputs": ["3\n35 4\n42 4\n24 9"], "outputs": ["34\n24\n24"]} | 496 | 34 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.
You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai an... | {"functional": "def check(candidate):\n assert candidate(n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]) == [8,12,6,10,10,10]\n assert candidate(n = 1, edges = []) == [0]\n assert candidate(n = 2, edges = [[1,0]]) == [1,1]\n\n\ncheck(Solution().sumOfDistancesInTree)"} | 148 | 111 |
coding | Solve the programming task below in a Python markdown code block.
Madoka finally found the administrator password for her computer. Her father is a well-known popularizer of mathematics, so the password is the answer to the following problem.
Find the maximum decimal number without zeroes and with no equal digits in a... | {"inputs": ["5\n1\n2\n3\n4\n5\n"], "outputs": ["1\n2\n21\n121\n212\n"]} | 441 | 37 |
coding | Solve the programming task below in a Python markdown code block.
This is another problem about Indraneel's library. His library has one long shelf. His books are numbered and he identifies the books by their number. Each book has a distinct number.
He has lost many books, since many of his friends borrow his books and... | {"inputs": ["5\n26 1 42 15 3\n2\n3\n4"], "outputs": ["42\n3"]} | 622 | 34 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Lonerz got some crazy growing plants and he wants to grow them nice and well.
Initially, the garden is completely barren.
Each morning, Lonerz can put any number of plants into the garden to grow.
And at night, each plant mutates into ... | {"functional": "_inputs = [[5], [8], [536870911], [1]]\n_outputs = [[2], [1], [29], [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): retu... | 340 | 184 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidd... | {"functional": "def check(candidate):\n assert candidate(differences = [1,-3,4], lower = 1, upper = 6) == 2\n assert candidate(differences = [3,-4,5,1,-2], lower = -4, upper = 5) == 4\n assert candidate(differences = [4,-7,2], lower = 3, upper = 6) == 0\n\n\ncheck(Solution().numberOfArrays)"} | 294 | 104 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows:
Jumbo Burger: 4 tomato slices and 1 cheese slice.
Small Burger: 2 Tomato slices and 1 cheese slice.
Return [tota... | {"functional": "def check(candidate):\n assert candidate(tomatoSlices = 16, cheeseSlices = 7) == [1,6]\n assert candidate(tomatoSlices = 17, cheeseSlices = 4) == []\n assert candidate(tomatoSlices = 4, cheeseSlices = 17) == []\n assert candidate(tomatoSlices = 0, cheeseSlices = 0) == [0,0]\n assert candi... | 163 | 149 |
coding | Solve the programming task below in a Python markdown code block.
Sinchan and his friends loves to eat. They have a 2D rectangular cake which they want to share. Sinchan is very kind and offers his friends to eat the cake first, all friends goes one by one to eat the cake. Each friend will cut cake into two parts. Firs... | {"inputs": ["3\n2\n5 3\n4\n4 8\n1\n1 2"], "outputs": ["Yes 2\nNo\nYes 1"]} | 379 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers nums, half of the integers in nums are odd, and the other half are even.
Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even.
Return any answer ... | {"functional": "def check(candidate):\n assert candidate(nums = [4,2,5,7]) == [4,5,2,7]\n assert candidate(nums = [2,3]) == [2,3]\n\n\ncheck(Solution().sortArrayByParityII)"} | 113 | 65 |
coding | Solve the programming task below in a Python markdown code block.
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.
Input
The first line contain... | {"inputs": ["2 5 3"], "outputs": ["6 -3"]} | 201 | 18 |
coding | Solve the programming task below in a Python markdown code block.
## The galactic games have begun!
It's the galactic games! Beings of all worlds come together to compete in several interesting sports, like nroogring, fredling and buzzing (the beefolks love the last one). However, there's also the traditional marathon... | {"functional": "_inputs = [[10], [100], [1000], [10000], [16], [20], [200], [1000000], [50000000], [50000000000000000000000000000000000000000]]\n_outputs = [[23], [2318], [233168], [23331668], [60], [78], [9168], [233333166668], [583333291666668], [58333333333333333333333333333333333333329166666666666666666666666666666... | 379 | 400 |
coding | Solve the programming task below in a Python markdown code block.
Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).
Nick has decided to pour all remaining soda into minimal number of bottles, moreover he h... | {"inputs": ["1\n1\n1\n", "1\n1\n2\n", "1\n1\n1\n", "1\n1\n2\n", "1\n2\n2\n", "1\n1\n100\n", "1\n1\n100\n", "1\n50\n100\n"], "outputs": ["1 0\n", "1 0\n", "1 0\n", "1 0\n", "1 0", "1 0\n", "1 0\n", "1 0\n"]} | 537 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of s... | {"inputs": ["1\n4\n5\n", "1\n5\n4\n", "1\n5\n5\n", "1\n5\n4\n", "1\n4\n5\n", "1\n5\n5\n", "1\n5\n2\n", "1\n4\n6\n"], "outputs": ["4\n", "4\n", "5\n", "4 ", "4 ", "5 ", "2\n", "4\n"]} | 578 | 99 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.