task_type stringclasses 1
value | problem stringlengths 209 3.39k | answer stringlengths 35 6.15k | problem_tokens int64 60 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Given an integer A that contains n > 1 digits. You are asked to remove exactly one digit to make the result number is divisible by 6, also make it biggest possible.
------ ... | {"inputs": ["3\n123\n100222\n10003"], "outputs": ["12\n00222\n-1"]} | 296 | 39 |
coding | Solve the programming task below in a Python markdown code block.
It's your Birthday. Your colleagues buy you a cake. The numbers of candles on the cake is provided (x). Please note this is not reality, and your age can be anywhere up to 1,000. Yes, you would look a mess.
As a surprise, your colleagues have arranged f... | {"functional": "_inputs = [[900, 'abcdef'], [56, 'ifkhchlhfd'], [256, 'aaaaaddddr'], [333, 'jfmgklfhglbe'], [12, 'jaam'], [808, 'alfbpmmpz'], [660, 'zyxsqwh'], [651, 'hmgoltyy'], [349, 'nxls'], [958, 'hovzfsxbmwu'], [301, 'doda'], [383, 'zwwl'], [871, 'gnlyvknjga'], [583, 'slhacx'], [0, 'jpipe']]\n_outputs = [['That wa... | 296 | 374 |
coding | Solve the programming task below in a Python markdown code block.
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.
Let us define a function f(r, c) as follows:
- f(r,c) := (The number of paths from the point (0, 0) ... | {"inputs": ["1 1 4 2", "1 1 0 2", "1 1 2 2", "1 1 2 2\n", "3 3 3 3\n", "252 5 944 30", "268 5 944 30", "268 3 944 30"], "outputs": ["48\n", "0\n", "14", "14\n", "20\n", "111503270\n", "684252700\n", "914919249\n"]} | 398 | 154 |
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.
Bob has received a binary string of length N transmitted by Alice. He knows that due to errors in transmission, up to K bits might have been corrupted (and hence flipped). However, he also knows that the string Alice had intended to transmit was not peri... | {"inputs": ["3 \n5 0 \n00000 \n3 1 \n001 \n3 3 \n101\n"], "outputs": ["0\n3\n6\n"]} | 373 | 56 |
coding | Solve the programming task below in a Python markdown code block.
# Task
A common way for prisoners to communicate secret messages with each other is to encrypt them. One such encryption algorithm goes as follows.
You take the message and place it inside an `nx6` matrix (adjust the number of rows depending on the me... | {"functional": "_inputs = [['Attack at noon or we are done for'], [\"Let's kill them all\"], ['Meet me behind the kitchen tomorrow at seven in the evening']]\n_outputs = [['A.ow.f tanedo tt..or a.oan. cnrre. ko.e..'], [\"Lkhl eie. tlm. 'l.. s.a. .tl.\"], ['Men.eoaete e.dknrtnhn eb.i.r..ei tetttosi.n .hhcoweneg miehm.v.... | 280 | 255 |
coding | Solve the programming task below in a Python markdown code block.
You will be given an array of positive integers. The array should be sorted by the amount of distinct perfect squares and reversed, that can be generated from each number permuting its digits.
E.g.: ```arr = [715, 112, 136, 169, 144]```
```
Number P... | {"functional": "_inputs = [[[715, 112, 136, 169, 144]], [[234, 61, 16, 441, 144, 728]]]\n_outputs = [[[169, 144, 112, 136, 715]], [[144, 441, 16, 61, 234, 728]]]\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)... | 585 | 257 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an n x n integer matrix grid.
Generate an integer matrix maxLocal of size (n - 2) x (n - 2) such that:
maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 ... | {"functional": "def check(candidate):\n assert candidate(grid = [[9,9,8,1],[5,6,2,6],[8,2,6,4],[6,2,2,2]]) == [[9,9],[8,6]]\n assert candidate(grid = [[1,1,1,1,1],[1,1,1,1,1],[1,1,2,1,1],[1,1,1,1,1],[1,1,1,1,1]]) == [[2,2,2],[2,2,2],[2,2,2]]\n\n\ncheck(Solution().largestLocal)"} | 150 | 148 |
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 nums consisting of non-negative powers of 2, and an integer target.
In one operation, you must apply the following changes to the array:
Choose any element of the array nums[i] such th... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,8], target = 7) == 1\n assert candidate(nums = [1,32,1,2], target = 12) == 2\n assert candidate(nums = [1,32,1], target = 35) == -1\n\n\ncheck(Solution().minOperations)"} | 198 | 88 |
coding | Solve the programming task below in a Python markdown code block.
Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties:
In one second we can add an arbitrary (possibly negati... | {"inputs": ["1\n0\n", "1\n8\n", "1\n5\n", "1\n0\n", "1\n5\n", "1\n8\n", "1\n1\n", "1\n9\n"], "outputs": ["0\n", "1\n", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n"]} | 363 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of size N. In one operation, you can:
Choose an index i (1≤ i ≤ N) and increase A_{i} by 1.
Find the minimum number of operations required to convert the array A into a *permutation* of size N. If it is impossible to do so, prin... | {"inputs": ["4\n4\n3 1 1 2\n3\n0 3 3\n3\n3 2 1\n3\n2 0 1\n"], "outputs": ["3\n-1\n0\n3"]} | 718 | 54 |
coding | Solve the programming task below in a Python markdown code block.
This is a rather simple problem to describe. You will be given three numbers $S, P$ and $k$. Your task is to find if there are integers $n_1, n_2,...,n_k$ such that $n_1 + n_2 +...+ n_k = S$, $n_1 \cdot n_2 \cdot ... \cdot n_k = P$. If such integers exis... | {"inputs": ["11 48 3", "11 100 3"], "outputs": ["3 4 4", "NO"]} | 373 | 35 |
coding | Solve the programming task below in a Python markdown code block.
The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each per... | {"inputs": ["1\n50\n", "1\n50\n", "2\n25 25\n", "2\n50 25\n", "2\n50 25\n", "2\n25 25\n", "2\n25 100\n", "2\n25 100\n"], "outputs": ["NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n"]} | 288 | 114 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
Consider the following algorithm, which generates a (not necessarily uniformly) random permutation of numbers $1$ through $N$:
P := [1, 2, ..., N]
fo... | {"inputs": ["2"], "outputs": ["1 2\n2 1"]} | 400 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to find the first element of an array that is not consecutive.
By not consecutive we mean not exactly 1 larger than the previous element of the array.
E.g. If we have an array `[1,2,3,4,6,7,8]` then `1` then `2` then `3` then `4` are all c... | {"functional": "_inputs = [[[1, 2, 3, 4, 6, 7, 8]], [[1, 2, 3, 4, 5, 6, 7, 8]], [[4, 6, 7, 8, 9, 11]], [[4, 5, 6, 7, 8, 9, 11]], [[31, 32]], [[-3, -2, 0, 1]], [[-5, -4, -3, -1]]]\n_outputs = [[6], [None], [6], [11], [None], [0], [-1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstanc... | 466 | 292 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.
Two arrays nums1 and nums2 are said to be distinct if:
They are of... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,3,2,2], k = 2, p = 2) == 11\n assert candidate(nums = [1,2,3,4], k = 4, p = 1) == 10\n\n\ncheck(Solution().countDistinct)"} | 144 | 79 |
coding | Solve the programming task below in a Python markdown code block.
There are N cities in a row. The i-th city from the left has a sadness of A_{i}.
In an attempt to reduce the sadness of the cities, you can send [blimps] from the left of city 1 that move rightwards (i.e, a blimp crosses cities 1, 2, \ldots in order)
Y... | {"inputs": ["3\n4 4 4\n1 5 4 4\n5 4 3\n1 4 3 3 5\n4 3 1\n3 1 3 9"], "outputs": ["2\n2\n3\n"]} | 734 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Here we have a function that help us spam our hearty laughter. But is not working! I need you to find out why...
Expected results:
```python
spam(1) ==> "hue"
spam(6) ==> "huehuehuehuehuehue"
spam(14) ==> "huehuehuehuehuehuehuehuehuehuehuehuehuehue"
... | {"functional": "_inputs = [[1], [6], [14]]\n_outputs = [['hue'], ['huehuehuehuehuehue'], ['huehuehuehuehuehuehuehuehuehuehuehuehuehue']]\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, (l... | 112 | 185 |
coding | Solve the programming task below in a Python markdown code block.
Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.
First of all, Vlad assigned indiv... | {"inputs": ["1\n0\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "2\n5 1\n", "2\n5 1\n", "2\n5 0\n"], "outputs": ["0\n", "0\n", "1\n", "2\n", "3\n", "5\n", "5\n", "5\n"]} | 428 | 92 |
coding | Solve the programming task below in a Python markdown code block.
You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding).
If th... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n4\n", "2\n1 2\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 266 | 88 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array.
Return the length of ... | {"functional": "def check(candidate):\n assert candidate(nums = [3,1,4,2], p = 6) == 1\n assert candidate(nums = [6,3,5,2], p = 9) == 2\n assert candidate(nums = [1,2,3], p = 3) == 0\n assert candidate(nums = [1,2,3], p = 7) == -1\n assert candidate(nums = [1000000000,1000000000,1000000000], p = 3) == 0\... | 130 | 156 |
coding | Solve the programming task below in a Python markdown code block.
You are given two arrays $a$ and $b$, both of length $n$.
Let's define a function $f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$.
Your task is to reorder the elements (choose an arbitrary order of elements) of the array $b$ to minimize the value... | {"inputs": ["2\n1 3\n4 2\n", "2\n1 3\n4 1\n", "2\n1 5\n4 1\n", "2\n1 9\n4 1\n", "2\n1 9\n4 2\n", "2\n1 9\n4 0\n", "2\n2 9\n4 0\n", "2\n1 3\n4 2\n"], "outputs": ["20\n", "14\n", "18\n", "26\n", "44\n", "8\n", "16\n", "20\n"]} | 462 | 141 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well.
Chef prepared a problem. The admin has rated this problem for x points.
A problem is called :
1) Easy if 1 ≤ x < 100
2) Medium if 100 ≤ x < 200
3) Hard if 200 ≤ x ≤ 300
... | {"inputs": ["3\n50\n172\n201\n"], "outputs": ["Easy\nMedium\nHard\n"]} | 381 | 29 |
coding | Solve the programming task below in a Python markdown code block.
Akshat has X rupees to spend in the current month. His daily expenditure is Y rupees, i.e., he spends Y rupees each day.
Given that the current month has 30 days, find out if Akshat has enough money to meet his daily expenditures for this month.
-----... | {"inputs": ["3\n1000 10\n250 50\n1500 50\n"], "outputs": ["YES\nNO\nYES\n"]} | 445 | 41 |
coding | Solve the programming task below in a Python markdown code block.
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upw... | {"inputs": ["3\n2 1\n1 0\n0 1\n", "3\n2 1\n1 0\n0 1\n", "5\n0 0\n0 1\n0 2\n0 3\n0 4\n", "5\n0 0\n0 1\n0 2\n0 3\n0 4\n", "2\n72098079 0\n72098078 1\n", "2\n73639551 1\n73639551 0\n", "2\n72098079 0\n72098078 1\n", "2\n73639551 1\n73639551 0\n"], "outputs": ["19\n", "19\n", "2930\n", "2930\n", "2\n", "1\n", "2\n", "1\n"]... | 568 | 230 |
coding | Solve the programming task below in a Python markdown code block.
Let's call a number a binary decimal if it's a positive integer and all digits in its decimal notation are either $0$ or $1$. For example, $1\,010\,111$ is a binary decimal, while $10\,201$ and $787\,788$ are not.
Given a number $n$, you are asked to re... | {"inputs": ["1\n1\n", "3\n121\n5\n1000000000\n"], "outputs": ["1\n", "2\n5\n1\n"]} | 365 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Ayrat has number n, represented as it's prime factorization p_{i} of size m, i.e. n = p_1·p_2·...·p_{m}. Ayrat got secret information that that the product of all divisors of n taken modulo 10^9 + 7 is the password to the secret data base. Now he wants t... | {"inputs": ["2\n2 3\n", "2\n2 5\n", "2\n2 2\n", "2\n3 2\n", "2\n3 3\n", "2\n3 5\n", "2\n5 5\n", "2\n5 3\n"], "outputs": ["36\n", "100\n", "8\n", "36\n", "27\n", "225\n", "125\n", "225\n"]} | 341 | 113 |
coding | Solve the programming task below in a Python markdown code block.
You are currently in the United States of America. The main currency here is known as the United States Dollar (USD). You are planning to travel to another country for vacation, so you make it today's goal to convert your USD (all bills, no cents) into t... | {"functional": "_inputs = [[7, 'Armenian Dram'], [322, 'Armenian Dram'], [25, 'Bangladeshi Taka'], [730, 'Bangladeshi Taka'], [37, 'Croatian Kuna'], [40, 'Croatian Kuna'], [197, 'Czech Koruna'], [333, 'Czech Koruna'], [768, 'Dominican Peso'], [983, 'Dominican Peso']]\n_outputs = [['You now have 3346 of Armenian Dram.']... | 531 | 418 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order.
Please complete the following python code precisely:
```python
class Solution:
def original... | {"functional": "def check(candidate):\n assert candidate(s = \"owoztneoer\") == \"012\"\n assert candidate(s = \"fviefuro\") == \"45\"\n\n\ncheck(Solution().originalDigits)"} | 72 | 54 |
coding | Solve the programming task below in a Python markdown code block.
Mike and Joe are playing a game with some stones. Specifically, they have $n$ piles of stones of sizes $a_1, a_2, \ldots, a_n$. These piles are arranged in a circle.
The game goes as follows. Players take turns removing some positive number of stones fr... | {"inputs": ["1\n1\n1\n", "1\n1\n1000000000\n", "2\n1\n37\n2\n100 100\n", "1\n2\n1000000000 999999999\n", "1\n50\n260939408 52936453 298470524 981491199 699765 834662291 553329721 651730905 665925345 395625534 162042985 788733611 54572656 795877605 826562363 882540598 190947839 644851021 335204703 226590818 150893107 90... | 408 | 597 |
coding | Solve the programming task below in a Python markdown code block.
In Group C of the 3rd year, we decided to use the "class flag" used at the sports festival on November 10, 2007 at future class reunions. So, in order to decide which students to keep the "class flag", I decided to play the following game using a large a... | {"inputs": ["50\n0\n25\n9", "50\n0\n164\n9", "50\n0\n25\n14", "50\n0\n35\n14", "50\n0\n35\n18", "50\n8\n3308\n3", "50\n8\n5734\n3", "50\n8\n5734\n4"], "outputs": ["3C11\n3C39\n3C25\n3C09\n", "3C11\n3C39\n3C08\n3C09\n", "3C11\n3C39\n3C25\n3C14\n", "3C11\n3C39\n3C35\n3C14\n", "3C11\n3C39\n3C35\n3C18\n", "3C11\n3C08\n3C32... | 423 | 280 |
coding | Solve the programming task below in a Python markdown code block.
The number 105 is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
-----Constraints-----
- N is an integer between 1 and ... | {"inputs": ["0", "1", "2", "3", "6", "9", "5", "8"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 147 | 62 |
coding | Solve the programming task below in a Python markdown code block.
A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.
For example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci ... | {"inputs": ["atcoddrregularcontest", "ssetabcrdpuflrrdaemtn", "nstcebmrmrteqbfcaress", "rdscrblracsfldraqdqso", "jrpddbrrqrrm_qnfsecec", "cenesebp_mrrprraddprj", "qsadmbdbqok^r`qtmore_", "atooddrregularccntest"], "outputs": ["b\n", "g\n", "d\n", "e\n", "a\n", "f\n", "c\n", "b\n"]} | 228 | 128 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times:
Choose two different indices i and j where 0 <= i, j < n.
Simultaneously, rep... | {"functional": "def check(candidate):\n assert candidate(s = \"1010\", target = \"0110\") == True\n assert candidate(s = \"11\", target = \"00\") == False\n\n\ncheck(Solution().makeStringsEqual)"} | 240 | 60 |
coding | Solve the programming task below in a Python markdown code block.
Vasya's older brother, Petya, attends an algorithm course in his school. Today he learned about matchings in graphs. Formally, a set of edges in a graph is called a matching if no pair of distinct edges in the set shares a common endpoint.
Petya instantl... | {"inputs": ["3\n3 3\n1 2\n1 3\n2 3\n4 2\n1 2\n3 4\n5 0"], "outputs": ["3\n1\n0"]} | 597 | 48 |
coding | Solve the programming task below in a Python markdown code block.
Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change.
You have... | {"inputs": ["2\n2\n", "1\n1\n", "9\n9\n", "5\n5\n", "5\n5\n", "1\n1\n", "9\n9\n", "2\n2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 229 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Marcin is a coach in his university. There are $n$ students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integ... | {"inputs": ["1\n0\n1\n", "1\n0\n0\n", "1\n1\n0\n", "1\n1\n1\n", "1\n2\n0\n", "1\n2\n1\n", "1\n2\n2\n", "1\n1\n2\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 608 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:
The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left o... | {"functional": "def check(candidate):\n assert candidate(start = \"_L__R__R_\", target = \"L______RR\") == True\n assert candidate(start = \"R_L_\", target = \"__LR\") == False\n assert candidate(start = \"_R\", target = \"R_\") == False\n\n\ncheck(Solution().canChange)"} | 193 | 81 |
coding | Solve the programming task below in a Python markdown code block.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmet... | {"inputs": ["|+|=|\n", "|+|=|\n", "||+|=|\n", "|+||=|\n", "|+|=||\n", "|+||=|\n", "||+|=|\n", "|+||=|\n"], "outputs": ["Impossible\n", "Impossible\n", "|+|=||\n", "|+|=||\n", "|+|=||\n", "|+|=||\n", "|+|=||\n", "|+|=||\n"]} | 534 | 111 |
coding | Solve the programming task below in a Python markdown code block.
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera... | {"inputs": ["1\n2\n", "1\n1\n", "1\n0\n", "1\n4\n", "1\n7\n", "1\n5\n", "1\n10\n", "1\n-1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 473 | 88 |
coding | Solve the programming task below in a Python markdown code block.
A common problem in number theory is to find x given a such that:
a * x = 1 mod [n]
Then x is called the inverse of a modulo n.
Your goal is to code a function inverseMod wich take a and n as parameters and return x.
You may be interested by these ... | {"functional": "_inputs = [[2, 5], [48, 101], [7, 733], [48, 733], [2, 733], [229, 101], [229, 103], [229, 105], [5, 5], [61965, 17408], [101014, 125445], [156435434, 3543432125]]\n_outputs = [[3], [40], [419], [168], [367], [15], [9], [94], [None], [None], [7969], [1056765589]]\nimport math\ndef _deep_eq(a, b, tol=1e-... | 195 | 335 |
coding | Solve the programming task below in a Python markdown code block.
The Fibonacci numbers are the numbers in the following integer sequence (Fn):
>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...
such as
>F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
Given a number, say prod (for product), we search two Fib... | {"functional": "_inputs = [[4895], [5895], [74049690], [84049690], [193864606], [447577], [602070], [602070602070], [1120149658760], [256319508074468182850], [203023208030065646654504166904697594722575], [203023208030065646654504166904697594722576], [0], [1], [2], [3], [4], [5], [6], [7], [105]]\n_outputs = [[[55, 89, ... | 636 | 705 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer X.
Find the largest perfect power that is at most X.
Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
-----Constraints-----
-... | {"inputs": ["7", "8", "2", "3", "6", "4", "5", "9"], "outputs": ["4\n", "8\n", "1\n", "1\n", "4\n", "4\n", "4\n", "9\n"]} | 170 | 62 |
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.
The low score of nums is the minimum absolute difference between any two integers.
The high score of nums is the maximum absolute difference between any two integers.
The score of... | {"functional": "def check(candidate):\n assert candidate(nums = [1,4,3]) == 0\n assert candidate(nums = [1,4,7,8,5]) == 3\n\n\ncheck(Solution().minimizeSum)"} | 111 | 56 |
coding | Solve the programming task below in a Python markdown code block.
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.
In this problem, you are given... | {"inputs": ["E F", "A A", "E B", "D F", "A C", "E A", "E E", "A D"], "outputs": ["<\n", "=\n", ">\n", "<\n", "<\n", ">\n", "=\n", "<\n"]} | 215 | 71 |
coding | Solve the programming task below in a Python markdown code block.
You are a given an array $a$ of length $n$. Find a subarray $a[l..r]$ with length at least $k$ with the largest median.
A median in an array of length $n$ is an element which occupies position number $\lfloor \frac{n + 1}{2} \rfloor$ after we sort the e... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "2 2\n2 2\n", "2 1\n2 2\n", "2 2\n2 2\n", "2 1\n2 2\n", "4 2\n1 2 3 4\n", "4 2\n1 2 3 4\n"], "outputs": ["1", "1", "2", "2", "2", "2", "3", "\n3"]} | 442 | 115 |
coding | Solve the programming task below in a Python markdown code block.
We have a grid with (2^N - 1) rows and (2^M-1) columns. You are asked to write 0 or 1 in each of these squares. Let a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left.
For a quadruple of integers (... | {"inputs": ["1 1", "2 2", "2 1", "3 2", "4 1", "3 3", "5 1", "1 3"], "outputs": ["1\n", "111\n101\n111\n", "1\n1\n1\n", "111\n101\n111\n101\n111\n101\n111\n", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "1111111\n1010101\n1111111\n1011101\n1111111\n1010101\n1111111\n", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\... | 448 | 266 |
coding | Solve the programming task below in a Python markdown code block.
Given an Array and an Example-Array to sort to, write a function that sorts the Array following the Example-Array.
Assume Example Array catalogs all elements possibly seen in the input Array. However, the input Array does not necessarily have to have al... | {"functional": "_inputs = [[[1, 2, 3, 4, 5], [2, 3, 4, 1, 5]], [[1, 2, 3, 3, 3, 4, 5], [2, 3, 4, 1, 5]], [[1, 2, 3, 3, 3, 5], [2, 3, 4, 1, 5]], [[1, 2, 3, 3, 3, 5], [3, 4, 5, 6, 9, 11, 12, 13, 1, 7, 8, 2, 10]], [['a', 'a', 'b', 'f', 'd', 'a'], ['c', 'a', 'd', 'b', 'e', 'f']]]\n_outputs = [[[2, 3, 4, 1, 5]], [[2, 3, 3, ... | 144 | 436 |
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 nums of size n representing the cost of collecting different chocolates. The cost of collecting the chocolate at the index i is nums[i]. Each chocolate is of a different type, a... | {"functional": "def check(candidate):\n assert candidate(nums = [20,1,15], x = 5) == 13\n assert candidate(nums = [1,2,3], x = 4) == 6\n\n\ncheck(Solution().minCost)"} | 178 | 64 |
coding | Solve the programming task below in a Python markdown code block.
On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off... | {"inputs": ["2\n", "1\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["0 2\n", "0 1\n", "0 2\n", "0 2\n", "0 2\n", "1 2\n", "2 2\n", "2 3\n"]} | 232 | 86 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b.
A node a is an ancestor of b if either: any child of a is eq... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([8,3,10,1,6,None,14,None,None,4,7,13])) == 7\n assert candidate(root = tree_node([1,None,2,None,0,3])) == 3\n\n\ncheck(Solution().maxAncestorDiff)"} | 173 | 79 |
coding | Solve the programming task below in a Python markdown code block.
Given are two strings S and T.
Let us change some of the characters in S so that T will be a substring of S.
At least how many characters do we need to change?
Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but ... | {"inputs": ["cabacc\nabb", "ccbaac\naac", "caacbc\nbba", "ccabac\nabb", "ccabac\nbba", "ccabac\ncba", "ccabac\ncaa", "ccbaac\ncaa"], "outputs": ["1\n", "0\n", "2\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 226 | 96 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend fo... | {"functional": "def check(candidate):\n assert candidate(n = 5, k = 2) == [4,5]\n assert candidate(n = 4, k = 4) == [2,3,4]\n\n\ncheck(Solution().circularGameLosers)"} | 331 | 64 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths.
Each video clip is described by an array clips where... | {"functional": "def check(candidate):\n assert candidate(clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10) == 3\n assert candidate(clips = [[0,1],[1,2]], time = 5) == -1\n assert candidate(clips = [[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]], time =... | 204 | 167 |
coding | Solve the programming task below in a Python markdown code block.
Mr. Chef is the manager of the Code cinemas and after a long break, the theatres are now open to the public again. To compensate for the loss in revenue due to Covid-19, Mr. Chef wants to maximize the profits for every show from now on and at the same ti... | {"inputs": ["3\n1 5\n3 3\n4 4"], "outputs": ["3\n4\n4"]} | 484 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Serena is interested in only red and yellow roses. She is arranging flowers in some fashion to be presented at her friend's birthday. Her friend loves only red and yellow roses(but mostly red ones). The flowers can be arranged only in the following three... | {"inputs": ["47\nRRYRRY\nRRRR\nYYRWBR\nR\nRY\nRRY\nW\nYRY\nRGGGGGGGGG\nRYYRYYRYY\nRYYY\nRR\nRYRYRYRYR\nRRRRGRRR\nRRYRRYRYY\nYYY\nBBBB\nRRRYYY\nRRRRY\nYRRRR\nRRYYRYYYR\nRYYYRYYYR\nRYYBYYRYY\nRRRRRRRRR\nRYYYYYYYY\nYYYYYYYYY\nRYRYYRYYR\nYYR\nRP\nRYYYY\nRRYYY\nRYY\nRYRYYRY\nRYRYYY\nRYRYY\nY\nRRYY\nRYRRRRYYY\nRYYRYYRY\nRYRY... | 337 | 303 |
coding | Solve the programming task below in a Python markdown code block.
Given: an array containing hashes of names
Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.
Example:
``` ruby
list([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Mag... | {"functional": "_inputs = [[[{'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'}, {'name': 'Homer'}, {'name': 'Marge'}]], [[{'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'}]], [[{'name': 'Bart'}, {'name': 'Lisa'}]], [[{'name': 'Bart'}]], [[]]]\n_outputs = [['Bart, Lisa, Maggie, Homer & Marge'], ['Bart, Lisa & ... | 440 | 268 |
coding | Solve the programming task below in a Python markdown code block.
You have a digit sequence S of length 4. You are wondering which of the following formats S is in:
- YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order
- MMYY... | {"inputs": ["3367", "2206", "1291", "1211", "2352", "2340", "2265", "2454"], "outputs": ["NA\n", "YYMM\n", "MMYY\n", "AMBIGUOUS\n", "NA\n", "NA\n", "NA\n", "NA\n"]} | 248 | 91 |
coding | Solve the programming task below in a Python markdown code block.
Given a [tree] containing N nodes.
Each node can be coloured using exactly one of the C colours. Find the number of colourings of the tree such that:
All nodes in a path of length at most two have distinct colours.
As the answer can be huge, print it m... | {"inputs": ["3 3\n1 2\n1 3\n"], "outputs": ["6\n"]} | 466 | 24 |
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.
To decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament.
There are 2^k players in this tournament, numbered 0 through 2^k-1. Each player has his/her favorite hand, which he/she will use in every match.
A string s ... | {"inputs": ["1 1\nP\n", "1 1\nR\n", "1 1\nS\n", "3 2\nRPS\n", "1 100\nS\n", "11 1\nRPSSPRSPPRS\n", "15 87\nRPPRPRRRPPSPRPP\n", "19 2\nSSSPRPRPSSRPPSRRSRR\n"], "outputs": ["P\n", "R\n", "S\n", "P\n", "S\n", "P\n", "S\n", "S\n"]} | 656 | 132 |
coding | Solve the programming task below in a Python markdown code block.
You will be given a string S of length 3 representing the weather forecast for three days in the past.
The i-th character (1 \leq i \leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.
You w... | {"inputs": ["CSS\nBSR", "SRR\nSSR", "SSR\nRTS", "STR\nSTR", "RSR\nSSS", "SSC\nBSR", "RSR\nSSR", "SSR\nRSS"], "outputs": ["1\n", "2\n", "0\n", "3\n", "1\n", "1\n", "2\n", "1\n"]} | 301 | 90 |
coding | Solve the programming task below in a Python markdown code block.
The name of our college is "Government College of Engineering and Textile Technology Berhampore". There is another college named "Government College of Engineering and Textile Technology Serampore". As the names are quite similar, those who are unaware o... | {"inputs": ["3\nGovernment clg Berhampore\nSeRaMporE textile college\nGirls college Kolkata"], "outputs": ["GCETTB\nGCETTS\nOthers"]} | 268 | 40 |
coding | Solve the programming task below in a Python markdown code block.
Hint
In solving this problem, the following may be referred to. Shows how to convert an integer value to a string. Assign value as a string to str.
For C
include <stdio.h>
int main () {
int value = 123; // Convert this value to a string
char str [6]... | {"inputs": ["1 10\n1 2 3 4 7 6 7 8 9 10", "5 7\n8 4 5 3 1 6 9 10 11 2", "5 7\n8 3 5 3 1 6 9 10 11 2", "5 7\n8 1 5 3 1 6 9 10 11 2", "6 7\n8 1 5 3 1 6 9 10 11 2", "6 7\n3 2 5 3 1 6 18 10 8 2", "3 4\n3 4 5 3 5 11 17 2 5 1", "3 6\n3 4 5 3 5 11 17 2 5 1"], "outputs": ["0\n", "34444\n", "14444\n", "11111\n", "111111\n", "14... | 609 | 280 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.
Please complete the following python code precisely:
```python
class Solution:
def threeC... | {"functional": "def check(candidate):\n assert candidate(arr = [2,6,4,1]) == False\n assert candidate(arr = [1,2,34,3,4,5,7,23,12]) == True\n\n\ncheck(Solution().threeConsecutiveOdds)"} | 77 | 69 |
coding | Solve the programming task below in a Python markdown code block.
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=... | {"inputs": ["6 2\n3 4", "5 3\n1 2 4"], "outputs": ["4", "3"]} | 381 | 32 |
coding | Solve the programming task below in a Python markdown code block.
DZY has a sequence a, consisting of n integers.
We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such... | {"inputs": ["1\n3\n", "1\n1\n", "1\n4\n", "1\n42\n", "1\n19\n", "2\n1 2\n", "2\n1 1\n", "2\n1 4\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "2\n"]} | 257 | 94 |
coding | Solve the programming task below in a Python markdown code block.
The only difference between this problem and D2 is the bound on the size of the tree.
You are given an unrooted tree with $n$ vertices. There is some hidden vertex $x$ in that tree that you are trying to find.
To do this, you may ask $k$ queries $v_1, ... | {"inputs": ["3\n1\n2\n1 2\n10\n2 4\n2 1\n5 7\n3 10\n8 6\n6 1\n1 3\n4 7\n9 6\n"], "outputs": ["0\n1\n2\n"]} | 547 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Consider the following numbers (where `n!` is `factorial(n)`):
```
u1 = (1 / 1!) * (1!)
u2 = (1 / 2!) * (1! + 2!)
u3 = (1 / 3!) * (1! + 2! + 3!)
...
un = (1 / n!) * (1! + 2! + 3! + ... + n!)
```
Which will win: `1 / n!` or `(1! + 2! + 3! + ... + n!)`?
... | {"functional": "_inputs = [[5], [6], [7], [8], [20], [30], [50], [113], [200], [523], [1011], [10110]]\n_outputs = [[1.275], [1.2125], [1.173214], [1.146651], [1.052786], [1.034525], [1.020416], [1.008929], [1.005025], [1.001915], [1.00099], [1.000098]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, ... | 358 | 314 |
coding | Solve the programming task below in a Python markdown code block.
# Task
You are given an array `a` of positive integers a. You may choose some integer `X` and update `a` several times, where to update means to perform the following operations:
```
pick a contiguous subarray of length not greater than the given k;
rep... | {"functional": "_inputs = [[[1, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1], 2], [[5, 2, 3, 5, 2, 2, 3, 5, 1, 2, 5, 1, 2, 5, 3], 7], [[1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1], 9]]\n_outputs = [[4], [2], [1]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(... | 487 | 284 |
coding | Solve the programming task below in a Python markdown code block.
Modify the `kebabize` function so that it converts a camel case string into a kebab case.
Notes:
- the returned string should only contain lowercase letters
Also feel free to reuse/extend the following starter code:
```python
def kebabize(string):
``` | {"functional": "_inputs = [['myCamelCasedString'], ['myCamelHas3Humps'], ['SOS'], ['42'], ['CodeWars']]\n_outputs = [['my-camel-cased-string'], ['my-camel-has-humps'], ['s-o-s'], [''], ['code-wars']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.i... | 70 | 207 |
coding | Solve the programming task below in a Python markdown code block.
-----Problem Statement-----
Harry Potter has one biscuit and zero rupee in his pocket. He will perform the following operations exactly $K$ times in total, in the order he likes:
- Hit his pocket, which magically increases the number of biscuits by one.
... | {"inputs": ["4 2 6"], "outputs": ["7"]} | 317 | 16 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will sort elements in an array by decreasing frequency of elements. If two elements have the same frequency, sort them by increasing value.
More examples in test cases.
Good luck!
Please also try [Simple time difference](https://w... | {"functional": "_inputs = [[[2, 3, 5, 3, 7, 9, 5, 3, 7]], [[1, 2, 3, 0, 5, 0, 1, 6, 8, 8, 6, 9, 1]], [[5, 9, 6, 9, 6, 5, 9, 9, 4, 4]], [[4, 4, 2, 5, 1, 1, 3, 3, 2, 8]], [[4, 9, 5, 0, 7, 3, 8, 4, 9, 0]]]\n_outputs = [[[3, 3, 3, 5, 5, 7, 7, 2, 9]], [[1, 1, 1, 0, 0, 6, 6, 8, 8, 2, 3, 5, 9]], [[9, 9, 9, 9, 4, 4, 5, 5, 6, 6... | 115 | 460 |
coding | Solve the programming task below in a Python markdown code block.
After Misha's birthday he had many large numbers left, scattered across the room. Now it's time to clean up and Misha needs to put them in a basket. He ordered this task to his pet robot that agreed to complete the task at certain conditions. Before the ... | {"inputs": ["2\n5\n5\n", "2\n3\n5\n", "2\n6\n5\n", "2\n7\n5\n", "2\n7\n6\n", "2\n7\n9\n", "2\n5\n5\n", "2\n7\n12\n"], "outputs": ["0\n1 0\n", "0\n0\n", "0\n0\n", "0\n0\n", "0\n0\n", "0\n0\n", "0\n1 0\n", "0\n0\n"]} | 464 | 123 |
coding | Solve the programming task below in a Python markdown code block.
Chef considers an array *good* if it has no subarray of size less than N such that the [GCD] of all the elements of the subarray is equal to 1.
Chef has an array A of size N with him. He wants to convert it into a *good* array by applying a specific op... | {"inputs": ["3\n3\n3 2 6\n4\n3 2 4 8\n4\n6 15 9 18\n "], "outputs": ["1\n2 3\n-1\n0\n"]} | 661 | 54 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root node of a binary tree, your task is to create a string representation of the tree following a specific set of formatting rules. The representation should be based on a preorder traversal of the binary t... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,3,4])) == \"1(2(4))(3)\"\n assert candidate(root = tree_node([1,2,3,None,4])) == \"1(2()(4))(3)\"\n\n\ncheck(Solution().tree2str)"} | 400 | 77 |
coding | Solve the programming task below in a Python markdown code block.
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum num... | {"inputs": ["ab\n", "bb\n", "ba\n", "ab\n", "aab\n", "abb\n", "bab\n", "bba\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "3\n", "2\n", "1\n", "0\n"]} | 246 | 71 |
coding | Solve the programming task below in a Python markdown code block.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exactly one e... | {"inputs": ["1\n4\n", "1\n2\n", "1\n5\n", "1\n1\n", "1\n3\n", "1\n8\n", "2\n1 3\n", "2\n2 1\n"], "outputs": ["1 ", "1 ", "1 ", "2 ", "1\n", "1\n", "1 1 ", "1 1 "]} | 319 | 89 |
coding | Solve the programming task below in a Python markdown code block.
Given are a sequence of N integers A_1, A_2, \ldots, A_N and a positive integer S.
For a pair of integers (L, R) such that 1\leq L \leq R \leq N, let us define f(L, R) as follows:
- f(L, R) is the number of sequences of integers (x_1, x_2, \ldots , x_... | {"inputs": ["3 4\n2 2 6", "3 4\n2 2 2", "3 4\n1 2 1", "3 4\n1 3 1", "3 5\n2 2 3", "3 4\n2 2 4", "3 4\n2 2 4\n", "5 7\n2 6 1 9 5"], "outputs": ["2\n", "5\n", "1\n", "4\n", "3\n", "5", "5\n", "7\n"]} | 461 | 130 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith person of height hi with exactly ki other people in... | {"functional": "def check(candidate):\n assert candidate(people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]) == [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]]\n assert candidate(people = [[6,0],[5,0],[4,0],[3,2],[2,2],[1,4]]) == [[4,0],[5,0],[2,2],[3,2],[1,4],[6,0]]\n\n\ncheck(Solution().reconstructQueue)"} | 175 | 138 |
coding | Solve the programming task below in a Python markdown code block.
Note : Issues Fixed with python 2.7.6 , Use any one you like :D , ( Thanks to
Time , time , time . Your task is to write a function that will return the degrees on a analog clock from a digital time that is passed in as parameter . The digital time is ... | {"functional": "_inputs = [['01:01'], ['00:00'], ['01:03'], ['01:30'], ['12:05'], ['26:78'], ['16:25'], ['17:09'], ['19:00'], ['20:34'], ['23:20'], ['24:00'], ['-09:00']]\n_outputs = [['30:6'], ['360:360'], ['30:18'], ['30:180'], ['360:30'], ['Check your time !'], ['120:150'], ['150:54'], ['210:360'], ['240:204'], ['33... | 414 | 339 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ throug... | {"inputs": ["3\n1 0\n2\n1\n2 1\n1 3\n1 1\n5 10\n1 2 3 4 5\n10 11 12 13 15\n"], "outputs": ["2\n2\n-1\n"]} | 757 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other.
Example
$s=mom$
The list of all ... | {"inputs": ["1\ncdcd\n", "2\nabba\nabcd\n", "2\nifailuhkqq\nkkkk\n"], "outputs": ["5\n", "4\n0\n", "3\n10\n"]} | 711 | 53 |
coding | Solve the programming task below in a Python markdown code block.
Vanja and Miksi have already finished everything for this year at their university, so they decided to spend their free time playing a game with a binary sequence $A_1, A_2, \dots, A_N$ (i.e. a sequence containing only integers $0$ and $1$).
At the begin... | {"inputs": ["2\n2 1\n1 0\n3 5\n0 1 0"], "outputs": ["1\n2"]} | 566 | 32 |
coding | Solve the programming task below in a Python markdown code block.
M-kun has the following three cards:
* A red card with the integer A.
* A green card with the integer B.
* A blue card with the integer C.
He is a genius magician who can do the following operation at most K times:
* Choose one of the three cards an... | {"inputs": ["7 4 4\n3", "4 2 5\n3", "7 4 4\n5", "4 2 5\n6", "7 2 4\n5", "4 2 3\n6", "7 2 4\n9", "1 2 3\n6"], "outputs": ["Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]} | 249 | 110 |
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. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.
For example, if nums = [1, 2, 3, 4]:
[2, 3], [1, 2, 3], and ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,4]) == 6\n assert candidate(nums = [4,2,3,15]) == 5\n\n\ncheck(Solution().numberOfGoodSubsets)"} | 243 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has a grid consisting of three squares numbered 1, 2 and 3.
In each square, either 0 or 1 is written. The number written in Square i is s_i.
Snuke will place a marble on each square that says 1.
Find the number of squares on which Snuke will place ... | {"inputs": ["101\n", "000\n"], "outputs": ["2\n", "0\n"]} | 170 | 26 |
coding | Solve the programming task below in a Python markdown code block.
"Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, t... | {"inputs": ["1\n2\n", "1\n1\n", "2\n2 3\n", "2\n1 1\n", "2\n1 2\n", "2\n3 4\n", "2\n3 3\n", "2\n1 4\n"], "outputs": ["1\n", "0\n", "1\n", "1\n", "0\n", "2\n", "2\n", "1\n"]} | 380 | 98 |
coding | Solve the programming task below in a Python markdown code block.
Heidi found out that the Daleks have created a network of bidirectional Time Corridors connecting different destinations (at different times!). She suspects that they are planning another invasion on the entire Space and Time. In order to counter the inv... | {"inputs": ["2 1\n1 2 944277353\n", "3 3\n1 2 8\n2 3 3\n3 1 2\n", "3 3\n1 2 8\n2 3 3\n3 1 4\n", "10 10\n9 1 0\n9 4 0\n5 2 0\n8 10 0\n8 3 0\n10 4 0\n1 2 0\n5 6 0\n7 3 0\n6 7 0\n", "10 10\n9 1 0\n9 4 0\n3 2 0\n8 10 0\n8 3 0\n10 4 0\n1 2 0\n5 6 0\n7 3 0\n6 7 0\n", "10 10\n9 1 0\n9 4 0\n3 2 0\n8 10 0\n8 3 0\n10 4 0\n1 2 0\... | 717 | 535 |
coding | Solve the programming task below in a Python markdown code block.
You are given three integers in the range [0-99]. You must determine if any ordering of the numbers forms a date from the 20th century.
- If no ordering forms a date, return the string `"invalid"`.
- If multiple distinct orderings form dates, return th... | {"functional": "_inputs = [['[[2, 3, 4, 2, 3, 4]]', '[[1, 2, 3, 4, 2, 3, 4]]', '[[1, 1, 1, 1, 1, 1, 1, 1]]', '[[]]', '[[7]]', '[[1, 2, 3, 4]]']]\n_outputs = [['invalid']]\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... | 328 | 242 |
coding | Solve the programming task below in a Python markdown code block.
An array $a_1, a_2, \ldots, a_n$ is good if and only if for every subsegment $1 \leq l \leq r \leq n$, the following holds: $a_l + a_{l + 1} + \ldots + a_r = \frac{1}{2}(a_l + a_r) \cdot (r - l + 1)$.
You are given an array of integers $a_1, a_2, \ldots... | {"inputs": ["5\n4\n1 2 3 4\n4\n1 1 2 2\n2\n0 -1\n6\n3 -2 4 -1 -4 0\n1\n-100\n"], "outputs": ["0\n2\n0\n3\n0\n"]} | 496 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).
You are given an integer $n$. You need to find two integers $l$ and $r$ such that $-10^{18} \le l < r \le 10^{18}$ and $l ... | {"inputs": ["7\n2\n4\n7\n3\n111\n6\n56293238153\n", "7\n1\n2\n6\n2\n101\n2\n390536414718\n", "7\n1\n2\n6\n2\n001\n2\n390536414718\n", "7\n1\n2\n6\n2\n001\n2\n133532318784\n", "7\n1\n2\n4\n2\n001\n2\n133532318784\n", "7\n1\n2\n8\n2\n001\n2\n133532318784\n", "7\n1\n2\n8\n4\n001\n2\n133532318784\n", "7\n2\n2\n8\n4\n001\n2... | 507 | 718 |
coding | Solve the programming task below in a Python markdown code block.
A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.
The fare is constructed in th... | {"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n4\n", "1\n7\n", "1\n9\n", "1\n5\n"], "outputs": ["20\n", "20\n", "20\n", "20\n", "20\n", "20\n", "20\n", "20\n"]} | 608 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Polycarp found the string $s$ and the permutation $p$. Their lengths turned out to be the same and equal to $n$.
A permutation of $n$ elements — is an array of length $n$, in which every integer from $1$ to $n$ occurs exactly once. For example, $[1, 2, ... | {"inputs": ["1\n12\nzsmlzcqpszjy\n2 3 4 5 6 7 8 9 10 11 12 1\n", "3\n5\nababa\n3 4 5 2 1\n5\nababa\n2 1 4 5 3\n10\ncodeforces\n8 6 1 7 5 2 9 3 10 4\n", "1\n26\nofnbnccxwsnaxyjwnmefjhkwmi\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1\n", "1\n78\naaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqq... | 653 | 497 |
coding | Solve the programming task below in a Python markdown code block.
After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boys... | {"inputs": ["3 0 3\n1\n2\n3\n", "3 1 3\n2\n2\n3\n", "3 1 3\n1\n2\n3\n", "4 0 4\n1\n2\n3\n4\n", "4 0 4\n1\n2\n3\n2\n", "4 0 4\n1\n2\n3\n3\n", "5 2 5\n2\n2\n3\n4\n5\n", "5 2 5\n1\n2\n3\n4\n5\n"], "outputs": ["...", "..X", "..X\n", "....\n", "....", "....", "...XX", "...XX\n"]} | 725 | 159 |
coding | Solve the programming task below in a Python markdown code block.
Did you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eagerly waiting for the user reviews i... | {"inputs": ["2\nP 1\nP 2\n2\nP 2\nM -2\n0", "2\nP 1\nP 2\n\n2\nP 0\nM -2\n\n0", "2\nP 1\nP 4\n\n2\nP 0\nM -2\n\n0", "2\nQ 2\nP 4\n\n0\nP 0\nM -2\n\n0", "2\nP 1\nP 5\n\n2\nQ 0\nM -2\n\n0", "2\nQ 2\nP 6\n\n0\nP 0\nL -4\n\n2", "2\nQ 2\nP 5\n\n0\nP 1\nL -4\n\n2", "2\nQ 2\nP 8\n\n0\nP 1\nM -2\n\n1"], "outputs": ["1\n1", "1\... | 618 | 243 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
In the world of Dota2, there are two parties: the Radiant and the Dire.
The Dota2 senate consists of senators coming from two parties. Now the Senate wants to decide on a change in the Dota2 game. The voting for this ... | {"functional": "def check(candidate):\n assert candidate(senate = \"RD\") == \"Radiant\"\n assert candidate(senate = \"RDD\") == \"Dire\"\n\n\ncheck(Solution().predictPartyVictory)"} | 317 | 50 |
coding | Solve the programming task below in a Python markdown code block.
Chef is looking to buy a TV and has shortlisted two models. The first one costs A rupees, while the second one costs B rupees.
Since there is a huge sale coming up on Chefzon, Chef can get a flat discount of C rupees on the first TV, and a flat discount... | {"inputs": ["3\n85 75 35 20\n100 99 0 0\n30 40 0 10\n"], "outputs": ["First\nSecond\nAny\n"]} | 576 | 52 |
coding | Solve the programming task below in a Python markdown code block.
An electronics shop sells red and blue lamps. A red lamp costs X rupees and a blue lamp costs Y rupees.
Chef is going to buy exactly N lamps from this shop. Find the minimum amount of money Chef needs to pay such that at least K of the lamps bought are ... | {"inputs": ["4\n2 2 5 1\n4 1 3 1\n3 0 4 7\n5 2 3 4\n"], "outputs": ["10\n6\n12\n15\n"]} | 364 | 55 |
coding | Solve the programming task below in a Python markdown code block.
Bear Limak has a sequence of N non-negative integers A1, A2, ..., AN. He defines the score of a segment (consecutive subsequence) as its sum of elements modulo P (not necessarily prime). Find the maximum score of a non-empty segment, and also find the nu... | {"inputs": ["4\n2 3\n1 2\n3 5\n2 4 3\n3 100\n1 3 5\n4 3\n1 2 3 4"], "outputs": ["2 1\n4 2\n9 1\n2 2"]} | 530 | 68 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.