problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.
Please complete the following python code precisely:
```python
class Solution:
def f... | {"functional": "def check(candidate):\n assert candidate(arr = [5,5,4], k = 1) == 1\n assert candidate(arr = [4,3,1,1,3,3,2], k = 3) == 2\n\n\ncheck(Solution().findLeastNumOfUniqueInts)"} | coding | 85 |
Solve the programming task below in a Python markdown code block.
# Task
Initially a number `1` is written on a board. It is possible to do the following operations with it:
```
multiply the number by 3;
increase the number by 5.```
Your task is to determine that using this two operations step by step, is it possible ... | {"functional": "_inputs = [[1], [2], [3], [4], [5], [6], [100], [101], [12345], [54321]]\n_outputs = [[True], [False], [True], [False], [False], [True], [False], [True], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, ... | coding | 414 |
Solve the programming task below in a Python markdown code block.
Given two positive numbers B and C, what is the minimum positive value of A, such that A \cdot B is divisible by C.
Here, A \cdot B denotes the value obtained when A is multiplied by B.
------ Input Format ------
- The first line will contain an int... | {"inputs": ["2\n2 4\n8 12"], "outputs": ["2\n3"]} | coding | 341 |
Solve the programming task below in a Python markdown code block.
How many licks does it take to get to the tootsie roll center of a tootsie pop?
A group of engineering students from Purdue University reported that its licking machine, modeled after a human tongue, took an average of 364 licks to get to the center of ... | {"functional": "_inputs = [[{'freezing temps': 10, 'clear skies': -2}], [{'happiness': -5, 'clear skies': -2}], [{}], [{'dragons': 100, 'evil wizards': 110, 'trolls': 50}], [{'white magic': -250}]]\n_outputs = [['It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing t... | coding | 571 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as '#'.
For example, the abo... | {"functional": "def check(candidate):\n assert candidate(preorder = \"9,3,4,#,#,1,#,#,2,#,6,#,#\") == True\n assert candidate(preorder = \"1,#\") == False\n assert candidate(preorder = \"9,#,#,1\") == False\n\n\ncheck(Solution().isValidSerialization)"} | coding | 221 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.
Among all possible paths starting from the top-left corner ... | {"functional": "def check(candidate):\n assert candidate(grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]) == -1\n assert candidate(grid = [[1,-2,1],[1,-2,1],[3,-4,1]]) == 8\n assert candidate(grid = [[1,3],[0,-4]]) == 0\n\n\ncheck(Solution().maxProductPath)"} | coding | 194 |
Solve the programming task below in a Python markdown code block.
*This kata is inspired by [Project Euler Problem #387](https://projecteuler.net/problem=387)*
---
A [Harshad number](https://en.wikipedia.org/wiki/Harshad_number) (or Niven number) is a number that is divisible by the sum of its digits. A *right trunca... | {"functional": "_inputs = [[0, 20], [30, 100], [90, 200], [200, 210], [1000, 2000], [2200, 2300], [9000002182976, 9000195371842]]\n_outputs = [[[10, 12, 18, 20]], [[30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100]], [[90, 100, 102, 108, 120, 126, 180, 200]], [[200, 201, 204, 207, 209, 210]], [[1000,... | coding | 735 |
Solve the programming task below in a Python markdown code block.
# Your Task
You have a Petri dish with bacteria, and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them.
You know that you have `n` bacteria in the Petri dish and size ... | {"functional": "_inputs = [[[101, 53, 42, 102, 101, 55, 54], 1], [[20, 15, 10, 15, 20, 25], 5], [[5, 3, 1, 5], 1]]\n_outputs = [[3], [1], [4]]\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... | coding | 564 |
Solve the programming task below in a Python markdown code block.
Chef is playing a game with his childhood friend. He gave his friend a list of N numbers named $a_1, a_2 .... a_N$ (Note: All numbers are unique). Adjust the numbers in the following order:
$(i)$ swap every alternate number with it's succeeding number (... | {"inputs": ["1\n10\n5 15 1 66 55 32 40 22 34 11\n38"], "outputs": ["35 41"]} | coding | 523 |
Solve the programming task below in a Python markdown code block.
Your task is very simple. Given an input string s, case\_sensitive(s), check whether all letters are lowercase or not. Return True/False and a list of all the entries that are not lowercase in order of their appearance in s.
For example, case\_sensitive... | {"functional": "_inputs = [['asd'], ['cellS'], ['z'], ['']]\n_outputs = [[[True, []]], [[False, ['S']]], [[True, []]], [[True, []]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list,... | coding | 150 |
Solve the programming task below in a Python markdown code block.
Math geeks and computer nerds love to anthropomorphize numbers and assign emotions and personalities to them. Thus there is defined the concept of a "happy" number. A happy number is defined as an integer in which the following sequence ends with the num... | {"functional": "_inputs = [[10], [50], [100]]\n_outputs = [[[1, 7, 10]], [[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49]], [[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math... | coding | 539 |
Solve the programming task below in a Python markdown code block.
For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.
Constraints
* $p1$ and $p2$ are different
* The circle and line have at least one cross point
* $1 \leq q \leq 1,000$
* $-10,000 \leq cx, cy, x1, y1, x2, y2 \leq ... | {"inputs": ["2 0 1\n2\n0 1 4 1\n3 0 3 3", "2 0 2\n2\n0 1 4 1\n3 0 3 3", "2 0 2\n2\n0 1 4 2\n3 0 3 3", "2 0 2\n2\n0 1 4 2\n3 0 5 3", "2 0 2\n1\n0 1 4 2\n3 0 5 3", "2 0 2\n1\n0 1 4 0\n3 0 5 3", "2 0 2\n1\n0 1 8 0\n1 0 5 3", "2 0 2\n1\n0 2 8 0\n1 0 5 3"], "outputs": ["2.00000000 1.00000000 2.00000000 1.00000000\n3.0000000... | coding | 536 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities.
There are m friends numbered from 0 to m - 1 who are traveling through the country. Each one o... | {"functional": "def check(candidate):\n assert candidate(n = 5, paths = [[0,1,2,3,4],\n [2,3,4],\n [4,0,1,2,3]]) == 2\n assert candidate(n = 3, paths = [[0],[1],[2]]) == 0\n assert candidate(n = 5, paths = [[0,1,2,3,4],\n [4,3,2,1,0]]) == 1\n\n\ncheck... | coding | 232 |
Solve the programming task below in a Python markdown code block.
In this kata you will be given a sequence of the dimensions of rectangles ( sequence with width and length ) and circles ( radius - just a number ).
Your task is to return a new sequence of dimensions, sorted ascending by area.
For example,
```python... | {"functional": "_inputs = [[[]]]\n_outputs = [[[]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all(_deep_eq... | coding | 224 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse.
A point of the cheese with index i (0-indexed) is:
reward1[i] if the first mouse eats it.
reward2[i] if th... | {"functional": "def check(candidate):\n assert candidate(reward1 = [1,1,3,4], reward2 = [4,4,1,1], k = 2) == 15\n assert candidate(reward1 = [1,1], reward2 = [1,1], k = 2) == 2\n\n\ncheck(Solution().miceAndCheese)"} | coding | 164 |
Solve the programming task below in a Python markdown code block.
Given are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.
Operation: Choose one character of S and replace it with a different character.
-----Constraints-----
- S and... | {"inputs": ["apple\nelppa", "abcdd\nbcdea", "elppa\nelppa", "elppa\nelppb", "elpap\nelppb", "ddc`a\nbbcfa", "ddcba\nbcdea", "cdcba\nbcdea"], "outputs": ["4\n", "5\n", "0\n", "1\n", "2\n", "3\n", "4\n", "4\n"]} | coding | 203 |
Solve the programming task below in a Python markdown code block.
Given is a rooted tree with N vertices numbered 1 to N.
The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.
Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.... | {"inputs": ["4 3\n1 2\n4 3\n1 4\n2 7\n1 000\n3 1", "4 3\n1 2\n2 3\n2 4\n2 4\n2 100\n3 1", "2 3\n1 2\n2 4\n1 4\n1 6\n2 100\n1 1", "4 3\n1 2\n2 3\n2 4\n2 4\n2 100\n3 0", "4 3\n1 2\n2 3\n2 4\n2 4\n2 110\n3 0", "2 3\n1 2\n2 4\n1 4\n1 3\n2 100\n1 1", "4 3\n1 2\n2 3\n2 4\n2 4\n2 101\n3 1", "4 3\n1 2\n4 3\n1 4\n2 2\n2 000\n3 ... | coding | 640 |
Solve the programming task below in a Python markdown code block.
A binary string is a string that consists of characters $0$ and $1$.
Let $\operatorname{MEX}$ of a binary string be the smallest digit among $0$, $1$, or $2$ that does not occur in the string. For example, $\operatorname{MEX}$ of $001011$ is $2$, becaus... | {"inputs": ["6\n1\n1001\n01100\n111\n0000\n01010\n", "6\n1\n1001\n01100\n101\n0000\n01010\n", "6\n1\n1111\n01100\n101\n1000\n11010\n", "6\n1\n1010\n11100\n100\n0000\n01010\n", "6\n0\n1011\n01100\n010\n0000\n01010\n", "6\n0\n1001\n01100\n110\n0010\n01010\n", "6\n0\n1001\n01100\n111\n0010\n01010\n", "6\n1\n0010\n01100\n1... | coding | 552 |
Solve the programming task below in a Python markdown code block.
C: Prayer (Pray)
Some twins are famous for praying before the contest.
There are four integers $ H, W, X, Y $, and it seems unlucky if $ H \ times W $ and $ x + y $ are both odd numbers.
input
Four integers $ H, W, X, Y $ are given, separated by spac... | {"inputs": ["3 5 2 4", "3 9 1 4", "1 6 1 1", "1 6 0 1", "1 6 0 0", "1 3 0 1", "1 0 0 1", "0 0 0 1"], "outputs": ["Yes\n", "No\n", "Yes\n", "Yes\n", "Yes\n", "No\n", "Yes\n", "Yes\n"]} | coding | 273 |
Solve the programming task below in a Python markdown code block.
There are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.
Person i gives A_i testimonies. The j-th testimony by Person i is represented by... | {"inputs": ["1\n0\n", "2\n1\n2 0\n1\n1 1", "2\n1\n2 0\n0\n1 0", "2\n1\n2 0\n0\n2 0", "2\n1\n2 0\n0\n0 0", "2\n1\n2 0\n0\n0 1", "2\n1\n2 1\n1\n1 1", "2\n1\n2 1\n1\n1 0"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "2\n", "1\n"]} | coding | 449 |
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 positive integers nums. Find the number of triplets (i, j, k) that meet the following conditions:
0 <= i < j < k < nums.length
nums[i], nums[j], and nums[k] are pairwise distinct.
... | {"functional": "def check(candidate):\n assert candidate(nums = [4,4,2,4,3]) == 3\n assert candidate(nums = [1,1,1,1,1]) == 0\n\n\ncheck(Solution().unequalTriplets)"} | coding | 146 |
Solve the programming task below in a Python markdown code block.
In this kata you must take an input string, reverse the order of the words, and reverse the order of the letters within the words.
But, as a bonus, every test input will end with a punctuation mark (! ? .) and the output should be returned with the mark... | {"functional": "_inputs = [['an Easy one?'], ['a small lOan OF 1,000,000 $!'], ['<?> &!.\".'], ['b3tTer p4ss thIS 0ne.'], ['']]\n_outputs = [['eno ysaE na?'], ['$ 000,000,1 FO naOl llams a!'], ['\".!& >?<.'], ['en0 SIht ss4p reTt3b.'], ['']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or is... | coding | 185 |
Solve the programming task below in a Python markdown code block.
Problem
There are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called "U & U". "U & U" has a common score for $ 2 $ teams, and the goal is to work ... | {"inputs": ["6 5", "5 9", "7 9", "1 1", "1 2", "1 3", "2 3", "3 3"], "outputs": ["2\n", "3\n", "3\n", "2\n", "1\n", "1\n", "3\n", "2\n"]} | coding | 574 |
Solve the programming task below in a Python markdown code block.
The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS activation cod... | {"inputs": ["12345\n", "13542\n", "71232\n", "11111\n", "10000\n", "99999\n", "91537\n", "70809\n"], "outputs": ["71232", "84443", "10151", "36551", "00000", "99999", "27651", "00000"]} | coding | 358 |
Solve the programming task below in a Python markdown code block.
Alice and Bob are decorating a Christmas Tree.
Alice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.
In Bob's opinion, a Christmas Tree... | {"inputs": ["1 2 3\n", "9 5 5\n", "1 3 4\n", "6 5 7\n", "1 5 4\n", "3 2 4\n", "3 3 5\n", "3 2 3\n"], "outputs": ["6", "12", "6", "15", "6", "6", "9", "6"]} | coding | 513 |
Solve the programming task below in a Python markdown code block.
Freddy has a really fat left pinky finger, and every time Freddy tries to type an ```A```, he accidentally hits the CapsLock key!
Given a string that Freddy wants to type, emulate the keyboard misses where each ```A``` supposedly pressed is replaced wit... | {"functional": "_inputs = [['aAaaaaAaaaAAaAa'], ['The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the bl... | coding | 554 |
Solve the programming task below in a Python markdown code block.
You are given a chessboard of size 1 × n. It is guaranteed that n is even. The chessboard is painted like this: "BWBW...BW".
Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the ... | {"inputs": ["2\n2\n", "2\n2\n", "2\n1\n", "6\n1 2 6\n", "6\n1 5 6\n", "6\n1 4 5\n", "6\n3 5 6\n", "6\n3 4 5\n"], "outputs": ["0\n", "0\n", "0\n", "2\n", "2\n", "1\n", "2\n", "2\n"]} | coding | 465 |
Solve the programming task below in a Python markdown code block.
You are standing on top of an amazing Himalayan mountain. The view is absolutely breathtaking! you want to take a picture on your phone, but... your memory is full again! ok, time to sort through your shuffled photos and make some space...
Given a galle... | {"functional": "_inputs = [[['2016.img1', '2016.img2', '2016.img3', '2016.img4', '2016.img5']], [['2016.img4', '2016.img5', '2016.img1', '2016.img3', '2016.img2']], [['2012.img2', '2016.img1', '2016.img3', '2016.img4', '2016.img5']], [['2016.img1', '2013.img3', '2016.img2', '2015.img3', '2012.img7', '2016.img4', '2013.... | coding | 275 |
Solve the programming task below in a Python markdown code block.
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.
This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The p... | {"inputs": ["3\n", "8\n", "2\n", "1\n", "8\n", "1\n", "2\n", "7\n"], "outputs": ["3\n", "8\n", "2\n", "1\n", "8\n", "1\n", "2\n", "7\n"]} | coding | 239 |
Solve the programming task below in a Python markdown code block.
Our master carpenter is designing a condominium called Bange Hills Mansion. The condominium is constructed by stacking up floors of the same height. The height of each floor is designed so that the total height of the stacked floors coincides with the pr... | {"inputs": ["101 2 5", "100 2 5", "111 2 5", "000 2 5", "010 2 8", "000 2 8", "101 2 8", "100 2 8"], "outputs": ["0\n", "3\n", "1\n", "4\n", "2\n", "7\n", "0\n", "3\n"]} | coding | 283 |
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. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non... | {"functional": "def check(candidate):\n assert candidate(nums = [2,4,1,1,6,5]) == 3\n assert candidate(nums = [6,6,5,5,4,1]) == 0\n\n\ncheck(Solution().countHillValley)"} | coding | 179 |
Solve the programming task below in a Python markdown code block.
The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:
The MEX of [2, 2, 1] is 0 because 0 does not belong to the array.
The MEX of [3, 1, 0, 1] is 2 because 0 and 1 belong to the arr... | {"inputs": ["4\n2\n0 0 0 1\n2\n0 0 1 1\n3\n1 3 2 3 3 2\n3\n0 0 1 1 1 2\n"], "outputs": ["NO\nYES\nYES\nNO\n"]} | coding | 632 |
Solve the programming task below in a Python markdown code block.
Shortest Common Non-Subsequence
A subsequence of a sequence $P$ is a sequence that can be derived from the original sequence $P$ by picking up some or no elements of $P$ preserving the order. For example, "ICPC" is a subsequence of "MICROPROCESSOR".
A ... | {"inputs": ["0101\n1101001", "0101\n1100000", "0101\n1101000", "0101\n0001000", "0101\n0011001", "0101\n0110001", "0101\n1111001", "0101\n1001001"], "outputs": ["0000\n", "111\n", "0001\n", "110\n", "1000\n", "0010\n", "000\n", "0110\n"]} | coding | 448 |
Solve the programming task below in a Python markdown code block.
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high.
At the beginning o... | {"inputs": ["2 2 5 4\n", "1 4 1 5\n", "1 1 1 1\n", "1 1 2 2\n", "2 3 4 5\n", "3 1 3 1\n", "5 4 1 4\n", "5 5 2 1\n"], "outputs": ["4\n", "0\n", "1\n", "1\n", "3\n", "3\n", "1\n", "2\n"]} | coding | 390 |
Solve the programming task below in a Python markdown code block.
Tonmoy has a special torch. The torch has 4 levels numbered 1 to 4 and 2 states (\texttt{On} and \texttt{Off}). Levels 1, 2, and 3 correspond to the \texttt{On} state while level 4 corresponds to the \texttt{Off} state.
The levels of the torch can be c... | {"inputs": ["3\n4 0\n0 1\n3 1"], "outputs": ["Off\nOn\nAmbiguous"]} | coding | 633 |
Solve the programming task below in a Python markdown code block.
You are given an array A of size N. Output the maximum value of A[i]%A[j] (ie. A[i] mod A[j]) over all 1 ≤ i, j ≤ N.
------ Input ------
First line of input contains T, the number of testcases.
The first line of each test case contains N, the number o... | {"inputs": ["1\n2\n1 2"], "outputs": ["1"]} | coding | 215 |
Solve the programming task below in a Python markdown code block.
A nested list (or *array* in JavaScript) is a list that apears as a value inside another list,
```python
[item, item, [item, item], item]
```
in the above list, [item, item] is a nested list.
Your goal is to write a function that determines the dep... | {"functional": "_inputs = [[[1, [2, [3, [4, [5, [6], 5], 4], 3], 2], 1]], [[True]], [[]], [[2, 'yes', [True, False]]], [[2.0, [2, 0], 3.7, [3, 7], 6.7, [6, 7]]], [[[[[]]], [[[]]]]], [[True, False, True, [False], True]], [[[], [], [[], []]]], [[77]], [[2, 'yes', [True, [False]]]], [[77, [77]]], [[[77], 77, [[77]]]]]\n_o... | coding | 256 |
Solve the programming task below in a Python markdown code block.
Your task is to make two functions, ```max``` and ```min``` (`maximum` and `minimum` in PHP and Python) that take a(n) array/vector of integers ```list``` as input and outputs, respectively, the largest and lowest number in that array/vector.
#Examples
... | {"functional": "_inputs = [[[-52, 56, 30, 29, -54, 0, -110]], [[42, 54, 65, 87, 0]], [[1, 2, 3, 4, 5, 10]], [[-1, -2, -3, -4, -5, -10]], [[9]]]\n_outputs = [[-110], [0], [1], [-10], [9]]\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, ... | coding | 219 |
Solve the programming task below in a Python markdown code block.
Blob is a computer science student. He recently got an internship from Chef's enterprise. Along with the programming he has various other skills too like graphic designing, digital marketing and social media management. Looking at his skills Chef has pro... | {"inputs": ["6\n3 9 10 1 30 40"], "outputs": ["46"]} | coding | 221 |
Solve the programming task below in a Python markdown code block.
There were initially X million people in a town, out of which Y million people left the town and Z million people immigrated to this town.
Determine the final population of town in millions.
------ Input Format ------
- The first line of input will ... | {"inputs": ["4\n3 1 2\n2 2 2\n4 1 8\n10 1 10\n"], "outputs": ["4\n2\n11\n19\n"]} | coding | 315 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diago... | {"functional": "def check(candidate):\n assert candidate(mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]) == [[1,1,1,1],[1,2,2,2],[1,2,3,3]]\n assert candidate(mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]) == [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[... | coding | 157 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums and two integers indexDiff and valueDiff.
Find a pair of indices (i, j) such that:
i != j,
abs(i - j) <= indexDiff.
abs(nums[i] - nums[j]) <= valueDiff, and
Return true if such pa... | {"functional": "def check(candidate):\n assert candidate(nums = [1,2,3,1], indexDiff = 3, valueDiff = 0) == True\n assert candidate(nums = [1,5,9,1,5,9], indexDiff = 2, valueDiff = 3) == False\n\n\ncheck(Solution().containsNearbyAlmostDuplicate)"} | coding | 127 |
Solve the programming task below in a Python markdown code block.
You have a fence consisting of $n$ vertical boards. The width of each board is $1$. The height of the $i$-th board is $a_i$. You think that the fence is great if there is no pair of adjacent boards having the same height. More formally, the fence is grea... | {"inputs": ["3\n3\n2 4\n2 1\n3 5\n3\n2 3\n2 2\n2 6\n4\n1 7\n3 3\n2 6\n1000000000 2\n", "3\n3\n2 4\n2 0\n3 5\n3\n2 3\n2 2\n2 6\n4\n1 7\n3 3\n2 6\n1000000000 4\n", "3\n3\n2 4\n2 1\n0 5\n3\n2 3\n2 2\n1 6\n4\n1 7\n3 3\n2 6\n1000000000 2\n", "3\n3\n2 4\n2 0\n3 5\n3\n2 3\n2 2\n2 6\n4\n1 7\n3 3\n3 6\n1000000000 4\n", "3\n3\n2... | coding | 605 |
Solve the programming task below in a Python markdown code block.
Compute A \times B, truncate its fractional part, and print the result as an integer.
-----Constraints-----
- 0 \leq A \leq 10^{15}
- 0 \leq B < 10
- A is an integer.
- B is a number with two digits after the decimal point.
-----Input-----
Input is... | {"inputs": ["2 0.01", "4 1.10", "2 1.10", "3 1.10", "1 0.01", "1 0.01\n", "0 9.98\n", "74 1.10"], "outputs": ["0\n", "4\n", "2\n", "3\n", "0", "0\n", "0\n", "81\n"]} | coding | 169 |
Solve the programming task below in a Python markdown code block.
Morning desert sun horizon
Rise above the sands of time...
Fates Warning, "Exodus"
After crossing the Windswept Wastes, Ori has finally reached the Windtorn Ruins to find the Heart of the Forest! However, the ancient repository containing this pricele... | {"inputs": ["1\n10\ngepardotop\n", "1\n10\ngepardotpp\n", "1\n10\npptodrapeg\n", "1\n10\npotodrapeg\n", "1\n10\negpardotpp\n", "1\n10\nppotdsaoeg\n", "1\n10\ngtpardoeop\n", "1\n10\nptpodrapeg\n"], "outputs": ["27\n", "27\n", "26\n", "18\n", "36\n", "17\n", "24\n", "19\n"]} | coding | 697 |
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... | coding | 328 |
Solve the programming task below in a Python markdown code block.
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.
Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbe... | {"inputs": ["7\n4\n0\n6\n1\n11010\n-1", "7\n4\n0\n0\n1\n11010\n-1", "7\n0\n0\n0\n6\n10000\n-1", "7\n4\n0\n0\n2\n11010\n-1", "7\n0\n0\n0\n6\n11000\n-1", "7\n0\n0\n0\n7\n11000\n-1", "7\n0\n0\n1\n7\n11000\n-1", "7\n2\n0\n7\n6\n11010\n-1"], "outputs": ["13\n10\n0\n12\n1\n2230002\n", "13\n10\n0\n0\n1\n2230002\n", "13\n0\n0\... | coding | 502 |
Solve the programming task below in a Python markdown code block.
A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system.
You are given user's friends' opinions about a list of items. You are also given a thresho... | {"inputs": ["1 3 1\nYYN\n", "1 3 1\nYYN\n", "3 1 1\nN\nY\nN\n", "3 1 1\nN\nY\nN\n", "2 4 2\nNYNY\nNYNY\n", "2 4 2\nNYNY\nNYNY\n", "2 4 2\nYNNY\nNYNY\n", "2 4 1\nYNNY\nNYNY\n"], "outputs": ["2\n", "2\n", "1\n", "1\n", "2\n", "2\n", "1\n", "3\n"]} | coding | 263 |
Solve the programming task below in a Python markdown code block.
You are given a sequence of positive integers of length N, A=a_1,a_2,…,a_{N}, and an integer K.
How many contiguous subsequences of A satisfy the following condition?
- (Condition) The sum of the elements in the contiguous subsequence is at least K.
We ... | {"inputs": ["1 4\n3\n", "1 64\n64\n", "1 33\n34\n", "2 2\n3 5\n", "3 5\n3 3 3\n", "4 10\n6 1 2 7\n", "8 29\n6 10 9 7 5 3 2 6\n", "6 231759\n58478 68246 31455 68061 22344 58784\n"], "outputs": ["0\n", "1\n", "1\n", "3\n", "3\n", "2\n", "10\n", "3\n"]} | coding | 297 |
Solve the programming task below in a Python markdown code block.
### Count the number of Duplicates
Write a function that will return the count of **distinct case-insensitive** alphabetic characters and numeric digits that occur more than
once in the input string.
The input string can be assumed to contain only alp... | {"functional": "_inputs = [[''], ['abcde'], ['abcdeaa'], ['abcdeaB'], ['Indivisibilities']]\n_outputs = [[0], [0], [1], [2], [2]]\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, tu... | coding | 256 |
Solve the programming task below in a Python markdown code block.
There is a haunted town called HauntedLand. The structure of HauntedLand can be thought of as a grid of size n * m. There is a house in each cell of the grid. Some people have fled from their houses because they were haunted. '.' represents a haunted hou... | {"inputs": ["2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*.."], "outputs": ["1\n2"]} | coding | 555 |
Solve the programming task below in a Python markdown code block.
You have $n$ barrels lined up in a row, numbered from left to right from one. Initially, the $i$-th barrel contains $a_i$ liters of water.
You can pour water from one barrel to another. In one act of pouring, you can choose two different barrels $x$ and... | {"inputs": ["2\n4 1\n5 5 5 5\n3 2\n0 0 0\n", "2\n4 2\n5 5 5 5\n3 2\n0 0 0\n", "2\n4 2\n5 5 5 5\n3 2\n0 0 1\n", "2\n4 3\n5 5 2 5\n3 2\n0 1 0\n", "2\n4 3\n5 5 2 1\n3 2\n0 1 0\n", "2\n4 3\n5 1 2 1\n3 2\n0 1 0\n", "2\n4 2\n2 5 5 0\n3 2\n0 0 0\n", "2\n4 3\n5 1 2 2\n3 2\n0 1 0\n"], "outputs": ["10\n0\n", "15\n0\n", "15\n1\n"... | coding | 525 |
Solve the programming task below in a Python markdown code block.
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.
If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and ... | {"inputs": ["0 2 6", "3 1 0", "1 2 6", "0 0 7", "3 2 6", "3 1 3", "3 2 6\n", "3 1 3\n"], "outputs": ["4\n", "0\n", "3\n", "7\n", "1", "0", "1\n", "0\n"]} | coding | 246 |
Solve the programming task below in a Python markdown code block.
There are 10 problems in a contest. You know that the score of each problem is either 1 or 100 points.
Chef came to know the total score of a participant and he is wondering how many problems were actually solved by that participant.
Given the total sc... | {"inputs": ["5\n103\n0\n6\n142\n1000\n"], "outputs": ["4\n0\n6\n-1\n10\n"]} | coding | 382 |
Solve the programming task below in a Python markdown code block.
Alice likes all the numbers which are divisible by A. Bob does not like the numbers which are divisible by B and likes all the remaining numbers. Determine the smallest number greater than or equal to N which is liked by both Alice and Bob. Output -1 if ... | {"inputs": ["3\n5 2 11\n4 3 24\n7 7 100\n"], "outputs": ["15\n28\n-1\n"]} | coding | 352 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the largest digit in both numbers is equal.
For example, 2373 is made up of three distinct digits: 2, 3, a... | {"functional": "def check(candidate):\n assert candidate(nums = [51,71,17,24,42]) == 88\n assert candidate(nums = [1,2,3,4]) == -1\n\n\ncheck(Solution().maxSum)"} | coding | 129 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the head of a linked list, rotate the list to the right by k places.
Please complete the following python code precisely:
```python
# Definition for singly-linked list.
# class ListNode:
# def __init__(sel... | {"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,2,3,4,5]), k = 2), list_node([4,5,1,2,3]))\n assert is_same_list(candidate(head = list_node([0,1,2]), k = 4), list_node([2,0,1]))\n\n\ncheck(Solution().rotateRight)"} | coding | 114 |
Solve the programming task below in a Python markdown code block.
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... ... | {"inputs": ["1\n1\n", "1\n1\n", "1\n0\n", "1\n10\n", "1\n11\n", "1\n-1\n", "1\n17\n", "1\n10\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | coding | 467 |
Solve the programming task below in a Python markdown code block.
Vova plans to go to the conference by train. Initially, the train is at the point $1$ and the destination point of the path is the point $L$. The speed of the train is $1$ length unit per minute (i.e. at the first minute the train is at the point $1$, at... | {"inputs": ["1\n8 5 1 5\n", "1\n2 5 1 1\n", "1\n3 4 3 3\n", "1\n2 5 1 1\n", "1\n3 4 3 3\n", "1\n8 5 1 5\n", "1\n1 5 1 1\n", "1\n8 4 1 5\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n"]} | coding | 681 |
Solve the programming task below in a Python markdown code block.
Mislove had an array $a_1$, $a_2$, $\cdots$, $a_n$ of $n$ positive integers, but he has lost it. He only remembers the following facts about it:
The number of different numbers in the array is not less than $l$ and is not greater than $r$;
For each... | {"inputs": ["4 2 2\n", "5 1 5\n", "1 1 1\n", "1 1 1\n", "2 1 1\n", "2 1 2\n", "2 2 2\n", "3 1 2\n"], "outputs": ["5 7\n", "5 31\n", "1 1\n", "1 1\n", "2 2\n", "2 3\n", "3 3\n", "3 5\n"]} | coding | 561 |
Solve the programming task below in a Python markdown code block.
Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. T... | {"inputs": ["1\n3\n", "1\n5\n", "1\n2\n", "1\n1\n", "1\n10\n", "1\n10\n", "2\n1 2\n", "2\n2 3\n"], "outputs": ["3\n", "5\n", "2\n", "1\n", "10\n", "10\n", "6\n", "10\n"]} | coding | 534 |
Solve the programming task below in a Python markdown code block.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numb... | {"inputs": ["1\n55 7\n", "1\n86 7\n", "1\n86 9\n", "1\n86 4\n", "1\n86 3\n", "1\n86 0\n", "1\n49 0\n", "1\n55 60\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0"]} | coding | 627 |
Solve the programming task below in a Python markdown code block.
A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself.
The total income A of his kingdom during 0-th year is known, as well as the total income B during n-th... | {"inputs": ["1 1 4\n", "0 3 6\n", "3 0 4\n", "1 1 5\n", "0 1 2\n", "0 1 4\n", "3 0 6\n", "1 1 9\n"], "outputs": ["-1\n", "No solution\n", "0\n", "1\n", "No solution\n", "No solution\n", "0\n", "1\n"]} | coding | 329 |
Solve the programming task below in a Python markdown code block.
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the end of her... | {"inputs": ["1\nm\n", "1\nm\n", "1\nl\n", "1\nk\n", "1\nn\n", "1\nj\n", "1\nMiao.\n", "1\nLalA.\n"], "outputs": ["OMG>.< I don't know!\n", "OMG>.< I don't know!\n", "OMG>.< I don't know!\n", "OMG>.< I don't know!\n", "OMG>.< I don't know!\n", "OMG>.< I don't know!\n", "OMG>.< I don't know!\n", "OMG>.< I don't know!\n"]... | coding | 357 |
Solve the programming task below in a Python markdown code block.
For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n.
For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it e... | {"inputs": ["1 0\n", "2 0\n", "3 0\n", "1 1\n", "2 1\n", "3 1\n", "4 1\n", "5 1\n"], "outputs": ["1\n", "2\n", "3\n", "10\n", "10\n", "30\n", "20\n", "10\n"]} | coding | 251 |
Solve the programming task below in a Python markdown code block.
# Solve For X
You will be given an equation as a string and you will need to [solve for X](https://www.mathplacementreview.com/algebra/basic-algebra.php#solve-for-a-variable) and return x's value. For example:
```python
solve_for_x('x - 5 = 20') # sho... | {"functional": "_inputs = [['x - 5 = 20'], ['5 * x + 5 = 30'], ['20 = 5 * x - 5'], ['24 = 4 + 5 * x'], ['x = 5'], ['x * 100 = 700'], ['2 * x + 5 = 105'], ['2 * x = 198'], ['x - 100 + 2 - 50 = 52'], ['x / 3 = 33'], ['x + 80 = 20'], ['x + 20 = -60'], ['5 * x + 20 - x = 60'], ['x + x + 6 = 10'], ['5 * x = x + 8'], ['x = x... | coding | 236 |
Solve the programming task below in a Python markdown code block.
Write a function that takes a positive integer and returns the next smaller positive integer containing the same digits.
For example:
```python
next_smaller(21) == 12
next_smaller(531) == 513
next_smaller(2071) == 2017
```
Return -1 (for `Haskell`: re... | {"functional": "_inputs = [[21], [907], [531], [1027], [441], [123456798], [513], [351], [315], [153], [135], [100], [2071], [1207], [414], [123456789], [29009], [1234567908], [9999999999], [59884848483559], [1023456789], [51226262651257], [202233445566], [506789]]\n_outputs = [[12], [790], [513], [-1], [414], [1234567... | coding | 341 |
Solve the programming task below in a Python markdown code block.
Gordon Ramsay shouts. He shouts and swears. There may be something wrong with him.
Anyway, you will be given a string of four words. Your job is to turn them in to Gordon language.
Rules:
Obviously the words should be Caps,
Every word should end with... | {"functional": "_inputs = [['What feck damn cake'], ['are you stu pid'], ['i am a chef'], ['dont you talk tome'], ['how dare you feck']]\n_outputs = [['WH@T!!!! F*CK!!!! D@MN!!!! C@K*!!!!'], ['@R*!!!! Y**!!!! ST*!!!! P*D!!!!'], ['*!!!! @M!!!! @!!!! CH*F!!!!'], ['D*NT!!!! Y**!!!! T@LK!!!! T*M*!!!!'], ['H*W!!!! D@R*!!!! ... | coding | 115 |
Solve the programming task below in a Python markdown code block.
You are given n points on a plane. All points are different.
Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC.
The groups of three points are considered unordered, that is, if point B is the m... | {"inputs": ["3\n3 3\n1 2\n1 1\n", "3\n3 3\n0 2\n1 1\n", "3\n1 1\n4 2\n3 3\n", "3\n2 3\n0 2\n1 1\n", "3\n1 1\n4 3\n3 3\n", "3\n2 3\n0 2\n2 1\n", "3\n1 1\n5 2\n3 3\n", "3\n2 3\n0 0\n2 1\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | coding | 237 |
Solve the programming task below in a Python markdown code block.
Our Chef is very happy that his son was selected for training in one of the finest culinary schools of the world.
So he and his wife decide to buy a gift for the kid as a token of appreciation.
Unfortunately, the Chef hasn't been doing good business late... | {"inputs": ["2 2\n9 7\n10 8", "2 2\n9 7\n8 10", "2 2\n10 7\n3 0", "2 2\n9 7\n3 10", "2 2\n2 7\n10 8", "2 2\n9 7\n6 10", "2 2\n9 7\n6 16", "2 2\n11 4\n6 2"], "outputs": ["8\n", "GUESS\n", "7\n", "GUESS\n", "8\n", "GUESS\n", "GUESS\n", "4\n"]} | coding | 661 |
Solve the programming task below in a Python markdown code block.
Chef has a new customer and he wants to prepare his order as soon as possible. While preparing, he sees that the mint sauce is finished. He has to run upstairs to get it from other kitchen. Chef is currently on the X^{th} stair. He has to climb all the w... | {"inputs": ["4\n2 10\n5 12\n34 43\n57 63"], "outputs": ["6\n5\n6\n4"]} | coding | 611 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:
Every adjacent pair of words differs by a single letter.
... | {"functional": "def check(candidate):\n assert candidate(beginWord = \"hit\", endWord = \"cog\", wordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\",\"cog\"]) == 5\n assert candidate(beginWord = \"hit\", endWord = \"cog\", wordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]) == 0\n\n\ncheck(Solution().ladderLeng... | coding | 180 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given integers height and width which specify the dimensions of a brick wall you are building. You are also given a 0-indexed array of unique integers bricks, where the ith brick has a height of 1 and a width ... | {"functional": "def check(candidate):\n assert candidate(height = 2, width = 3, bricks = [1,2]) == 2\n assert candidate(height = 1, width = 1, bricks = [5]) == 0\n\n\ncheck(Solution().buildWall)"} | coding | 195 |
Solve the programming task below in a Python markdown code block.
You are given three integers A, B and C.
Determine whether C is not less than A and not greater than B.
-----Constraints-----
- -100≤A,B,C≤100
- A, B and C are all integers.
-----Input-----
Input is given from Standard Input in the following format:... | {"inputs": ["7 5 4", "2 0 2", "1 0 2", "7 5 3", "1 1 2", "7 3 3", "1 1 0", "7 1 3"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | coding | 144 |
Solve the programming task below in a Python markdown code block.
You will be given an array that contains two strings. Your job is to create a function that will take those two strings and transpose them, so that the strings go from top to bottom instead of left to right.
A few things to note:
1. There should be one ... | {"functional": "_inputs = [[['Hello', 'World']], [['joey', 'louise']], [['a', 'cat']], [['cat', '']], [['!a!a!', '?b?b']]]\n_outputs = [['H W\\ne o\\nl r\\nl l\\no d'], ['j l\\no o\\ne u\\ny i\\n s\\n e'], ['a c\\n a\\n t'], ['c \\na \\nt '], ['! ?\\na b\\n! ?\\na b\\n! ']]\nimport math\ndef _deep_eq(a, b, tol=... | coding | 142 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5 of the actual answer will be accepted.
Please complete the following python code prec... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([3,9,20,None,None,15,7])) == [3.00000,14.50000,11.00000]\n assert candidate(root = tree_node([3,9,20,15,7])) == [3.00000,14.50000,11.00000]\n\n\ncheck(Solution().averageOfLevels)"} | coding | 142 |
Solve the programming task below in a Python markdown code block.
Recently, the Fair Nut has written $k$ strings of length $n$, consisting of letters "a" and "b". He calculated $c$ — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.
Then, he lost hi... | {"inputs": ["1 1\na\na\n", "1 1\na\na\n", "2 4\naa\nbb\n", "2 4\nab\nbb\n", "2 4\nba\nbb\n", "2 5\nab\nbb\n", "2 4\naa\nbb\n", "3 3\naba\nbba\n"], "outputs": ["1", "1\n", "6\n", "5\n", "3\n", "5\n", "6\n", "8\n"]} | coding | 503 |
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"]} | coding | 365 |
Solve the programming task below in a Python markdown code block.
Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service.
You need to consider the following ratings:
- Terrible: tip 0%
- Poor: tip 5%
- Good: tip 10%
- Great: tip 15%
- Excellent: tip 20%... | {"functional": "_inputs = [[30, 'poor'], [20, 'Excellent'], [20, 'hi'], [107.65, 'GReat'], [20, 'great!']]\n_outputs = [[2], [4], ['Rating not recognised'], [17], ['Rating not recognised']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, ... | coding | 192 |
Solve the programming task below in a Python markdown code block.
**Principal Diagonal** -- The principal diagonal in a matrix identifies those elements of the matrix running from North-West to South-East.
**Secondary Diagonal** -- the secondary diagonal of a matrix identifies those elements of the matrix running from... | {"functional": "_inputs = [[[[2, 2, 2], [4, 2, 6], [8, 8, 2]]], [[[7, 2, 2], [4, 2, 6], [1, 8, 1]]], [[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], [[[1, 2, 2, 5, 1], [4, 1, 6, 1, 1], [1, 8, 5, 6, 2], [1, 5, 2, 1, 2], [1, 8, 2, 6, 1]]], [[[88, 2, 2, 5, 1, 1, 2, 2, 5, 1], [4, 1, 6, 1, 1, 1, 2, 2, 7, 1], [1, 8, 1, 6, 2, 1, 2, 1, 5... | coding | 229 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time... | {"functional": "def check(candidate):\n assert candidate(people = [1,2], limit = 3) == 1\n assert candidate(people = [3,2,2,1], limit = 3) == 3\n assert candidate(people = [3,5,3,4], limit = 5) == 4\n\n\ncheck(Solution().numRescueBoats)"} | coding | 128 |
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"]} | coding | 365 |
Solve the programming task below in a Python markdown code block.
There are three airports A, B and C, and flights between each pair of airports in both directions.
A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C a... | {"inputs": ["3 1 3", "2 3 4", "3 1 2", "3 1 0", "1 1 3", "3 0 0", "1 6 5", "1 6 6"], "outputs": ["4\n", "5\n", "3\n", "1\n", "2\n", "0\n", "6\n", "7\n"]} | coding | 361 |
Solve the programming task below in a Python markdown code block.
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.
The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.
Here, a self-loop is an edge where a_i ... | {"inputs": ["3 2\n1 2 1\n2 3 1\n", "3 3\n1 2 1\n1 3 1\n2 3 3\n", "15 14\n1 2 522\n2 3 575\n3 4 426\n4 5 445\n5 6 772\n6 7 81\n7 8 447\n8 9 629\n9 10 497\n10 11 202\n11 12 775\n12 13 325\n13 14 982\n14 15 784\n", "33 35\n29 1 166\n29 2 587\n29 3 954\n29 4 139\n29 5 62\n29 6 259\n29 7 194\n29 8 877\n29 9 588\n29 10 318\n... | coding | 591 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings.
Return the maximum number of copies of target that can be formed by taking letters from s and ... | {"functional": "def check(candidate):\n assert candidate(s = \"ilovecodingonleetcode\", target = \"code\") == 2\n assert candidate(s = \"abcba\", target = \"abc\") == 1\n assert candidate(s = \"abbaccaddaeea\", target = \"aaaaa\") == 1\n\n\ncheck(Solution().rearrangeCharacters)"} | coding | 103 |
Solve the programming task below in a Python markdown code block.
You are given two integers $a$ and $b$.
In one move, you can choose some integer $k$ from $1$ to $10$ and add it to $a$ or subtract it from $a$. In other words, you choose an integer $k \in [1; 10]$ and perform $a := a + k$ or $a := a - k$. You may use ... | {"inputs": ["1\n5 5\n", "1\n5 5\n", "1\n7 5\n", "1\n2 5\n", "1\n2 9\n", "1\n2 6\n", "1\n0 6\n", "1\n12 5\n"], "outputs": ["0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | coding | 454 |
Solve the programming task below in a Python markdown code block.
B: Hokkaido University Hard
Note
Please note that the question settings are the same as question A, except for the constraints.
story
Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a... | {"inputs": ["3 3\nB.B\nB..\n.BB", "2 3\nB.B\nB..\n.BB", "1 3\nB-B\n..B\n.BA", "1 1\nB-B\n..B\n.BA", "1 3\nBB.\nB..\n.AA", "3 3\nB.B\nB..\nBB.", "3 3\nB.B\nC..\nBB.", "3 3\nB/B\nC..\nBB."], "outputs": ["4\n", "3\n", "2\n", "0\n", "1\n", "4\n", "4\n", "4\n"]} | coding | 555 |
Solve the programming task below in a Python markdown code block.
Chef is setting up a perfect bath for himself. He has X litres of hot water and Y litres of cold water.
The initial temperature of water in his bathtub is A degrees. On mixing water, the temperature of the bathtub changes as following:
The temperature... | {"inputs": ["4\n24 25 2 0\n37 37 2 9\n30 20 10 9\n30 31 0 20\n"], "outputs": ["YES\nYES\nNO\nNO\n"]} | coding | 581 |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is instructor of the famous course "Introduction to Algorithms" in a famous univerisity. There are n students in his class. There is not enough space in the class room, ... | {"inputs": ["4\n><\n*><*\n><><\n*><><><*"], "outputs": ["0\n0\n1\n2"]} | coding | 562 |
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\n0\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n7\n", "1\n3\n", "1\n6\n"], "outputs": ["20\n", "20\n", "20\n", "20\n", "20\n", "20\n", "20\n", "20\n"]} | coding | 619 |
Solve the programming task below in a Python markdown code block.
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.
There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.
F... | {"inputs": ["4\n2 3 9 9", "4\n4 4 8 9", "4\n0 4 8 9", "4\n2 3 7 9", "4\n2 3 7 9\n", "4\n2 3 13 9", "4\n4 4 13 9", "4\n0 4 8 18"], "outputs": ["7\n", "5\n", "9\n", "7", "7\n", "11\n", "9\n", "18\n"]} | coding | 237 |
Solve the programming task below in a Python markdown code block.
Chef wants to serve mankind by making people immortal by preparing a dish, a dish of life - a dish with the best taste in the universe, one with the smell and splash of fresh water flowing down the springs of the mountain, one with the smell of the best ... | {"inputs": ["3\n3 4\n3 1 2 3\n2 1 3\n2 1 2\n2 3\n3 1 2 3\n2 1 3\n2 3\n2 1 2\n2 1 3"], "outputs": ["sad\nsome\nall"]} | coding | 636 |
Solve the programming task below in a Python markdown code block.
Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much.
A song is a sequence of notes. Dima and Inna want to play each... | {"inputs": ["1\n2\n5\n", "1\n1\n5\n", "1\n2\n5\n", "2\n1 1\n2 1\n", "2\n1 1\n2 1\n", "3\n1 1 2\n2 2 3\n", "3\n1 2 2\n2 2 3\n", "3\n1 2 1\n2 2 3\n"], "outputs": ["-1\n", "-1\n", "-1\n", "0\n", "0\n", "4\n", "4\n", "1\n"]} | coding | 548 |
Solve the programming task below in a Python markdown code block.
Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$.
You are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \le x < y \le r$ and $l \le LCM... | {"inputs": ["1\n411 2649\n", "1\n542 9298\n", "1\n248 2649\n", "1\n431 2649\n", "1\n431 4578\n", "1\n2465 5273\n", "1\n1025 9298\n", "1\n4695 6427\n"], "outputs": ["411 822\n", "542 1084\n", "248 496\n", "431 862\n", "431 862\n", "2465 4930\n", "1025 2050\n", "-1 -1\n"]} | coding | 316 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You have prepared four problems. The difficulty levels of the problems are A_{1}, A_{2}, A_{3}, A_{4} respectively. A problem set comprises at least two probl... | {"inputs": ["3\n1 4 3 2\n4 5 5 5\n2 2 2 2"], "outputs": ["2\n1\n0"]} | coding | 445 |
Solve the programming task below in a Python markdown code block.
If the strings are consecutive, you can replace the characters with a rule to shorten the string. For example, for the string AAAA, the expression @ 4A will compress one character. Create a program that restores the character string compressed by this ru... | {"inputs": ["ab@5C1@8050\n@99,1=1@90", "ab@5C2@8050\n@99,1=1@90", "ab@5C2?8050\n@99,1=1@90", "ab@5C1@8050\nA99+1=1@90", "ab@5C2@8050\n@89,1=1@90", "ab@5C2?8050\n@91,1=9@90", "`b@5C1@8050\nA99+1=1@90", "ab@5C3@8050\n@89,1=1@90"], "outputs": ["abCCCCC10000000050\n999999999,1=1000000000", "abCCCCC20000000050\n999999999,1=... | coding | 238 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There are n 1-indexed robots, each having a position on a line, health, and movement direction.
You are given 0-indexed integer arrays positions, healths, and a string directions (directions[i] is either 'L' for left ... | {"functional": "def check(candidate):\n assert candidate(positions = [5,4,3,2,1], healths = [2,17,9,15,10], directions = \"RRRRR\") == [2,17,9,15,10]\n assert candidate(positions = [3,5,2,6], healths = [10,10,15,12], directions = \"RLRL\") == [14]\n assert candidate(positions = [1,2,5,6], healths = [10,10,11,1... | coding | 317 |
Solve the programming task below in a Python markdown code block.
Nezzar has $n$ balls, numbered with integers $1, 2, \ldots, n$. Numbers $a_1, a_2, \ldots, a_n$ are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means that $a_i \leq a_{i+1}$ for all $1 \leq i < n$.
Nezzar ... | {"inputs": ["5\n6\n1 1 1 2 3 4\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n1 2 3\n1\n1\n", "5\n6\n1 1 1 2 3 4\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n2 2 3\n1\n1\n", "5\n6\n1 1 1 2 3 3\n5\n1 1 2 2 3\n4\n1 2 2 2\n3\n2 2 3\n1\n1\n", "5\n6\n1 1 2 2 3 3\n5\n1 1 2 2 3\n4\n1 2 2 2\n3\n2 2 3\n1\n1\n", "5\n6\n1 1 1 2 3 6\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\... | coding | 454 |
Solve the programming task below in a Python markdown code block.
Chef has a stick of length N.
He can break the stick into 2 or more parts such that the [parity] of length of each part is same. For example, a stick of length 11 can be broken into three sticks of lengths \{3, 3, 5\} since each part is odd, but it cann... | {"inputs": ["3\n6 1\n3 2\n4 3\n"], "outputs": ["YES\nNO\nYES\n"]} | coding | 442 |
Solve the programming task below in a Python markdown code block.
Little Elephant likes lemonade.
When Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all.
There are n rooms (numbered from 0 to n-1), each contains ... | {"inputs": ["2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 3 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 2 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 2 0 2 0 0\n1 7\n3 9 4 5\n7 2 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1... | coding | 426 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.