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
Divyam is teaching his student Amit about palindromes. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. For example,... | {"inputs": ["2\naaa\naca"], "outputs": ["4\n2"]} | 392 | 18 |
coding | Solve the programming task below in a Python markdown code block.
Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a_1, a_2, ..., a_{n} megabytes. The file size is equal to m megabytes.
Find the minimum number of USB flash drives needed to write Sean's file,... | {"inputs": ["1\n1\n1\n", "1\n1\n1\n", "2\n5\n5\n10\n", "2\n5\n5\n10\n", "3\n5\n2\n1\n3\n", "3\n6\n2\n3\n2\n", "3\n5\n2\n1\n5\n", "2\n5\n10\n10\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "2\n", "3\n", "1\n", "1\n"]} | 342 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size $n \times m$ cells on a map (rows of grid are numbered from $1$ to $n$ from north to south, and columns are numbered from $... | {"inputs": ["3 4 3 3\n4 4 0 5\n", "1 1 1 1\n1 3 4 7\n", "1 1 1 1\n1 3 4 7\n", "3 4 3 3\n4 4 0 5\n", "3 4 2 1\n1 2 3 59\n", "3 4 2 1\n2 2 3 59\n", "3 4 2 1\n2 4 3 59\n", "3 4 2 1\n2 4 0 59\n"], "outputs": ["2\n", "1\n", "1\n", "2\n", "111\n", "153\n", "44\n", "172\n"]} | 751 | 193 |
coding | Solve the programming task below in a Python markdown code block.
Given a string consisting of only numbers from 0 to 9, consider the operation of creating a new string from that string according to the following rules. Read the given string one character at a time from the left end. Go, if the same number a continues ... | {"inputs": ["5\n6\n5\n1\n0", "5\n4\n3\n1\n0", "5\n7\n5\n1\n0", "5\n4\n0\n1\n0", "5\n9\n5\n8\n0", "5\n7\n4\n1\n0", "5\n3\n4\n1\n0", "5\n3\n8\n1\n0"], "outputs": ["1113122116\n312211\n", "1113122114\n1211\n", "1113122117\n312211\n", "1113122114\n", "1113122119\n1113122118\n", "1113122117\n111221\n", "1113122113\n111221\n... | 418 | 257 |
coding | Solve the programming task below in a Python markdown code block.
Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows,
To decide the amount of beverage they plan to consume, say X.
Then order for a random... | {"inputs": ["4\n4 3 25 5\n33", "4\n55 45 2 23\n58", "7\n2 5 4 9 7 33 6\n44", "6\n45 55 5 7 23 4\n107", "8\n4 8 9 7 45 6 3 27\n56", "8\n4 8 9 7 45 6 3 27\n156"], "outputs": ["True", "False", "True", "True", "True", "False"]} | 370 | 148 |
coding | Solve the programming task below in a Python markdown code block.
Dilku and Bhopu live in Artland. Dilku loves Bhopu and he writes a message : “iloveyou”
on paper and wishes to send it to Bhopu. As Dilku is busy making an artwork, he asks his friend Raj to send the message to Bhopu. However Raj has a condition that he ... | {"inputs": ["iloveyou", "ulrvysioqjifo", "abcvleouioydef"], "outputs": ["happy", "sad", "happy"]} | 301 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Let's consider all integers in the range from $1$ to $n$ (inclusive).
Among all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find the maximum value of $\mathrm{gcd}(a, b)$, wh... | {"inputs": ["2\n3\n5\n", "2\n6\n5\n", "2\n9\n5\n", "2\n3\n9\n", "2\n6\n7\n", "2\n9\n7\n", "2\n3\n5\n", "2\n10\n7\n"], "outputs": ["1\n2\n", "3\n2\n", "4\n2\n", "1\n4\n", "3\n3\n", "4\n3\n", "1\n2\n", "5\n3\n"]} | 335 | 119 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well.
Chef is a great mechanic. As the cost of petrol is increasing day by day he decided to build a water car to take his girlfriend Natasha on a date. Water car has great build qual... | {"inputs": ["3\n3 1\n4 2\n4 3\n"], "outputs": ["3 3\n6 4\n6 3\n"]} | 554 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Subodh is having N branches, where each branches have positive integral student. A minimize operation is performed on the branch such that all of them are reduced by the minimum number student in a branch.
Suppose we have 5 branches and all of them have... | {"inputs": ["6\n5 4 4 2 2 8", "1000\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | 278 | 2,042 |
coding | Solve the programming task below in a Python markdown code block.
An array is said to be `hollow` if it contains `3` or more `0`s in the middle that are preceded and followed by the same number of non-zero elements. Furthermore, all the zeroes in the array must be in the middle of the array.
Write a function named `i... | {"functional": "_inputs = [[[-1, 0, 0, 0, 3]], [[1, 0, 0, 0, 0]]]\n_outputs = [[True], [False]]\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... | 133 | 186 |
coding | Solve the programming task below in a Python markdown code block.
Chef has finally got the chance of his lifetime to drive in the F1 tournament. But, there is one problem. Chef did not know about the [107% rule] and now he is worried whether he will be allowed to race in the main event or not.
Given the fastest finish... | {"inputs": ["4\n1 2\n15 16\n15 17\n100 107\n"], "outputs": ["NO\nYES\nNO\nYES\n"]} | 595 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Recently Johnny have learned bogosort sorting algorithm. He thought that it is too ineffective. So he decided to improve it. As you may know this algorithm shuffles the sequence randomly until it is sorted. Johnny decided that we don't need to shuffle th... | {"inputs": ["3\n2\n3\n7", "3\n4\n7\n3", "3\n2\n2\n8", "3\n3\n3\n7", "3\n4\n6\n8", "3\n3\n3\n5", "3\n4\n3\n5", "3\n2\n6\n7"], "outputs": ["2\n10/3\n8810/693\n", "5\n8810/693\n10/3\n", "2\n2\n439331/27027\n", "10/3\n10/3\n8810/693\n", "5\n1826/189\n439331/27027\n", "10/3\n10/3\n149/21\n", "5\n10/3\n149/21\n", "2\n1826/18... | 380 | 237 |
coding | Solve the programming task below in a Python markdown code block.
Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems.
Let's suppose that your task is to build a square city. The world map uses the Cartesian coordin... | {"inputs": ["2\n0 0\n2 2\n", "2\n0 0\n0 3\n", "2\n0 1\n1 0\n", "2\n0 1\n1 0\n", "2\n0 0\n2 8\n", "2\n0 0\n2 4\n", "2\n0 0\n0 1\n", "2\n0 0\n2 2\n"], "outputs": ["4\n", "9\n", "1\n", "1\n", "64\n", "16\n", "1\n", "4\n"]} | 317 | 136 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e. it translates to a sequence of valid UTF-8 encoded characters).
A character in UTF8 can be from 1 to 4 bytes long, s... | {"functional": "def check(candidate):\n assert candidate(data = [197,130,1]) == True\n assert candidate(data = [235,140,4]) == False\n\n\ncheck(Solution().validUtf8)"} | 350 | 58 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the head of a linked list, remove the nth node from the end of the list and return its head.
Please complete the following python code precisely:
```python
# Definition for singly-linked list.
# class ListNode... | {"functional": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1,2,3,4,5]), n = 2), list_node([1,2,3,5]))\n assert is_same_list(candidate(head = list_node([1]), n = 1), list_node([]))\n assert is_same_list(candidate(head = list_node([1,2]), n = 1), list_node([1]))\n\n\ncheck(Solution()... | 121 | 112 |
coding | Solve the programming task below in a Python markdown code block.
Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.
........#
........#
........#
........#
Constraints
* 3 ≤ H ≤ 300
* 3 ≤ W ≤ 300
Input
T... | {"inputs": ["3 4\n5 7\n3 3\n0 0", "3 6\n5 6\n3 3\n0 0", "3 4\n5 0\n3 3\n0 0", "3 4\n5 3\n3 3\n0 0", "3 4\n8 0\n3 3\n0 0", "5 4\n8 0\n3 3\n0 0", "5 4\n8 0\n3 6\n0 0", "3 4\n5 6\n5 3\n0 0"], "outputs": ["####\n#..#\n####\n\n#######\n#.....#\n#.....#\n#.....#\n#######\n\n###\n#.#\n###\n\n", "######\n#....#\n######\n\n####... | 196 | 509 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a string of size $N$ which consists only lowercase English alphabet. The chef doesn't like the consonant alphabet at all. So he is thinking of changing every single consonant alphabet to any vowel alphabet. There is some cost for performing this... | {"inputs": ["2\naeiou\ndbcc"], "outputs": ["0\n6"]} | 345 | 20 |
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, determine if it is a valid binary search tree (BST).
A valid BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.
The right su... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([2,1,3])) == True\n assert candidate(root = tree_node([5,1,4,None,None,3,6])) == False\n\n\ncheck(Solution().isValidBST)"} | 178 | 59 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
There are $N$ seats in a row. You are given a string $S$ with length $N$; for each valid $i$, the $i$-th character of $S$ is '0' if the $i$-th seat is empty o... | {"inputs": ["4\n000\n010\n101\n01011011011110"], "outputs": ["0\n1\n2\n4"]} | 481 | 45 |
coding | Solve the programming task below in a Python markdown code block.
Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether S... | {"inputs": ["4 0", "1 2", "7 0", "0 2", "5 0", "0 8", "0 6", "0 0"], "outputs": ["Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n", "Possible\n"]} | 205 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Write a function getMean that takes as parameters an array (arr) and 2 integers (x and y). The function should return the mean between the mean of the the first x elements of the array and the mean of the last y elements of the array.
The mean should be... | {"functional": "_inputs = [[[1, 3, 2, 4], 2, 3], [[1, 3, 2], 2, 2], [[1, 3, 2, 4], 1, 2], [[1, 3, 2, 4], 2, 8], [[1, -1, 2, -1], 2, 3]]\n_outputs = [[2.5], [2.25], [-1], [-1], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_to... | 274 | 255 |
coding | Solve the programming task below in a Python markdown code block.
For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:
* push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.
* randomAccess($p$): Print el... | {"inputs": ["11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n1 1", "11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n2 1", "11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n2 1", "11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n2 0\n2 1", "11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1... | 416 | 540 |
coding | Solve the programming task below in a Python markdown code block.
Problem
There are coins with front and back sides and dice with rolls from $ 1 $ to $ N $. Gacho decided to play the following games using these.
The game starts with a score of $ 0 $ and proceeds as follows.
1. Roll the dice $ 1 $ and add the number... | {"inputs": ["2 2 2", "2 2 4", "2 2 7", "9 9 3", "2 2 15", "2 1 15", "1 4 56", "1 4 85"], "outputs": ["329420637\n", "159719097\n", "903411140\n", "184782344\n", "224604980\n", "1\n", "701294609\n", "808453146\n"]} | 557 | 154 |
coding | Solve the programming task below in a Python markdown code block.
Write a program that reads two numbers $X$ and $K$. The program first finds the factors of $X$ and then gives the sum of $K$th power of every factor. The program also finds the factor of $k$ and outputs the sum of $X$ times of every factor.
-----Input:... | {"inputs": ["1\n8 6"], "outputs": ["266304 88"]} | 318 | 24 |
coding | Solve the programming task below in a Python markdown code block.
Ksusha the Squirrel is standing at the beginning of a straight road, divided into n sectors. The sectors are numbered 1 to n, from left to right. Initially, Ksusha stands in sector 1.
Ksusha wants to walk to the end of the road, that is, get to sector ... | {"inputs": ["2 1\n..\n", "2 1\n..\n", "2 2\n..\n", "2 2\n..\n", "2 4\n..\n", "2 8\n..\n", "2 1\n..\n", "3 1\n.#.\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "NO\n"]} | 345 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_... | {"inputs": ["10\n1 1000000000\n2 146085669\n9 805629\n4 9999997\n5 999996\n6 99995\n9 18320\n8 993\n9 157\n7 2\n", "10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 56682\n9 99995\n5 18320\n8 993\n9 92\n7 1\n", "10\n1 1000000000\n2 146085669\n6 805629\n4 9999997\n5 999996\n6 99995\n9 18320\n8 993\n9 157\n7 2\n",... | 404 | 955 |
coding | Solve the programming task below in a Python markdown code block.
Emma is really fond of integers and loves playing with them. Her friends were jealous, and to test her, one of them gave her a problem.
Emma is given a list ${A}$ of $N$ integers and is asked a set of ${Q}$ queries. Each query is denoted by an integer ... | {"inputs": ["3\n1 2 2\n1\n2\n", "3\n1 2 3\n2\n1\n2\n"], "outputs": ["8\n", "6\n11\n"]} | 566 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in mandarin chinese, russian and vietnamese as well.
There are two players A, B playing a game. Player A has a string s with him, and player B has string t with him. Both s and t consist only of lower case English letters and a... | {"inputs": ["3\nab\nab\naba\ncde\nab\ncd"], "outputs": ["B\nA\nB"]} | 657 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $26$ buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunction... | {"inputs": ["1\nqw\n", "1\nqw\n", "1\npw\n", "1\npx\n", "1\nqx\n", "1\nwq\n", "1\nvp\n", "1\nvo\n"], "outputs": ["qw\n", "qw\n", "pw\n", "px\n", "qx\n", "qw\n", "pv\n", "ov\n"]} | 506 | 87 |
coding | Solve the programming task below in a Python markdown code block.
The cows have just learned what a primitive root is! Given a prime p, a primitive root $\operatorname{mod} p$ is an integer x (1 ≤ x < p) such that none of integers x - 1, x^2 - 1, ..., x^{p} - 2 - 1 are divisible by p, but x^{p} - 1 - 1 is.
Unfortunat... | {"inputs": ["3\n", "5\n", "7\n", "2\n", "2\n", "7\n", "5\n", "3\n"], "outputs": ["1\n", "2\n", "2\n", "1\n", "1", "2", "2", "1"]} | 251 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to cho... | {"inputs": ["1\n1\n", "1\n2\n", "1\n3\n", "1\n5\n", "1\n9\n", "1\n18\n", "2\n1 1\n", "2\n1 2\n"], "outputs": ["1", "1\n", "1\n", "1\n", "1\n", "1\n", "1", "2"]} | 409 | 88 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).
Please complete the following ... | {"functional": "def check(candidate):\n assert candidate(text = \"abcabcabc\") == 3\n assert candidate(text = \"leetcodeleetcode\") == 2\n\n\ncheck(Solution().distinctEchoSubstrings)"} | 93 | 48 |
coding | 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... | 236 | 432 |
coding | Solve the programming task below in a Python markdown code block.
Chef has recently moved into an apartment. It takes 30 minutes for Chef to reach office from the apartment.
Chef left for the office X minutes before Chef was supposed to reach. Determine whether or not Chef will be able to reach on time.
------ Input... | {"inputs": ["6\n30\n60\n14\n29\n31\n42\n"], "outputs": ["YES\nYES\nNO\nNO\nYES\nYES\n"]} | 291 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.
Chef is planning to setup a secure password for his Codechef account. For a password to be secure the following conditions should be satisfied:
1) ... | {"inputs": ["3\n#cookOff#P1\nU@code4CHEFINA\ngR3@tPWD"], "outputs": ["NO\nYES\nNO"]} | 485 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array arr of distinct integers and an integer k.
A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], t... | {"functional": "def check(candidate):\n assert candidate(arr = [2,1,3,5,4,6,7], k = 2) == 5\n assert candidate(arr = [3,2,1], k = 10) == 3\n assert candidate(arr = [1,9,8,2,3,7,6,4,5], k = 7) == 9\n assert candidate(arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000) == 99\n\n\ncheck(Solution().getWinner)... | 165 | 157 |
coding | Solve the programming task below in a Python markdown code block.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another stri... | {"inputs": ["1\nz\n", "2\naz\n", "2\naa\n", "2\nba\n", "2\nbb\n", "2\nbc\n", "2\nca\n", "2\nab\n"], "outputs": ["z", "az", "aa", "ab\n", "bb\n", "bc\n", "ac\n", "ab\n"]} | 517 | 83 |
coding | Solve the programming task below in a Python markdown code block.
Your coworker was supposed to write a simple helper function to capitalize a string (that contains a single word) before they went on vacation.
Unfortunately, they have now left and the code they gave you doesn't work. Fix the helper function they wrote... | {"functional": "_inputs = [['word'], ['i'], ['glasswear']]\n_outputs = [['Word'], ['I'], ['Glasswear']]\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) ... | 148 | 169 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.
The employees are numbered from 0 to n... | {"functional": "def check(candidate):\n assert candidate(favorite = [2,2,1,2]) == 3\n assert candidate(favorite = [1,2,0]) == 3\n assert candidate(favorite = [3,0,1,4,1]) == 4\n\n\ncheck(Solution().maximumInvitations)"} | 172 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A with N integers. You have to tell Chef whether this array is closed under multiplication.
We say that an array is closed under multiplication if... | {"inputs": ["3\n3\n1 0 3\n3\n1 -1 -1\n3\n1 3 3"], "outputs": ["1\n1\n0\n"]} | 729 | 41 |
coding | Solve the programming task below in a Python markdown code block.
One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.
Let's think about a scene in real life: there are lots of people waiting in front of the elevator, each person wa... | {"inputs": ["1 1\n2\n", "1 1\n2\n", "2 1\n2 2\n", "2 2\n2 2\n", "2 2\n2 2\n", "2 1\n2 2\n", "2 2\n3 2\n", "2 3\n6 2\n"], "outputs": ["2\n", "2\n", "4\n", "2\n", "2\n", "4\n", "4\n", "10\n"]} | 530 | 115 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game on a matrix, consisting of $2$ rows and $m$ columns. The cell in the $i$-th row in the $j$-th column contains $a_{i, j}$ coins in it.
Initially, both Alice and Bob are standing in a cell $(1, 1)$. They are going to perfo... | {"inputs": ["3\n3\n1 3 7\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n7\n", "3\n3\n1 3 7\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n4\n", "3\n3\n1 3 7\n3 5 1\n3\n0 3 9\n3 1 1\n1\n3\n5\n", "3\n3\n1 3 7\n3 2 0\n3\n1 3 9\n3 2 0\n1\n3\n7\n", "3\n3\n1 3 7\n3 5 1\n3\n1 3 6\n3 5 1\n1\n4\n4\n", "3\n3\n0 3 6\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n4\n", "3\n3\n0... | 551 | 374 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of size N. Let us list down all the subarrays of the given array. There will be a total of N * (N + 1) / 2 subarrays of the given array. Let us sort each of the subarrays in descending order of the numbers in it.
Now you want t... | {"inputs": ["1\n4 2\n3 1 2 4\n1\n5"], "outputs": ["4\n3"]} | 476 | 30 |
coding | Solve the programming task below in a Python markdown code block.
There are total $N$ cars in a sequence with $ith$ car being assigned with an alphabet equivalent to the $ith$ alphabet of string $S$ . Chef has been assigned a task to calculate the total number of cars with alphabet having a unique even value in the giv... | {"inputs": ["bbccdd\n5\n1 2\n3 4\n5 6\n1 6\n2 5"], "outputs": ["1\n0\n1\n2\n2"]} | 357 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Chef is given a binary string A of length N. He can perform the following operation on A any number of times:
Choose L and R (1 ≤ L ≤ R ≤ N), such that, in the [substring] A[L,R], the number of 1s is equal to the number of 0s and reverse the substring A[... | {"inputs": ["2\n5\n01100\n4\n0000\n"], "outputs": ["00011\n0000"]} | 474 | 37 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a ... | {"functional": "def check(candidate):\n assert candidate(n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = \"abaedcd\") == [2,1,1,1,1,1,1]\n assert candidate(n = 4, edges = [[0,1],[1,2],[0,3]], labels = \"bbbb\") == [4,2,1,1]\n assert candidate(n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = \"... | 232 | 164 |
coding | Solve the programming task below in a Python markdown code block.
Reve has two integers $n$ and $k$.
Let $p$ be a permutation$^\dagger$ of length $n$. Let $c$ be an array of length $n - k + 1$ such that $$c_i = \max(p_i, \dots, p_{i+k-1}) + \min(p_i, \dots, p_{i+k-1}).$$ Let the cost of the permutation $p$ be the maxi... | {"inputs": ["3\n5 3\n5 1\n6 6\n"], "outputs": ["5 4 1 3 2\n1 2 3 4 5\n6 5 4 3 2 1\n"]} | 615 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Hackerland is a one-dimensional city with houses aligned at integral locations along a road. The Mayor wants to install radio transmitters on the roofs of the city's houses. Each transmitter has a fixed range meaning it can transmit a signal to all house... | {"inputs": ["5 1 \n1 2 3 4 5\n", "8 2\n7 2 4 6 5 9 12 11 \n"], "outputs": ["2\n", "3\n"]} | 645 | 56 |
coding | Solve the programming task below in a Python markdown code block.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to f... | {"inputs": ["1\n", "5\n", "6\n", "4\n", "7\n", "8\n", "3\n", "2\n"], "outputs": ["-1\n", "10080", "100170", "1050", "1000020", "10000200", "210\n", "-1\n"]} | 216 | 93 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters... | {"functional": "def check(candidate):\n assert candidate(s = \"abc\", t = \"ahbgdc\") == True\n assert candidate(s = \"axc\", t = \"ahbgdc\") == False\n\n\ncheck(Solution().isSubsequence)"} | 135 | 57 |
coding | Solve the programming task below in a Python markdown code block.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend ... | {"inputs": ["1\n100000\n", "1\n100000\n", "6\n1 1 1 2 2 2\n", "6\n6 1 2 1 6 2\n", "6\n1 2 1 2 2 2\n", "6\n1 2 1 4 2 2\n", "6\n1 3 1 4 2 2\n", "6\n0 3 1 4 2 2\n"], "outputs": ["1", "1\n", "5", "5\n", "5\n", "5\n", "5\n", "6\n"]} | 698 | 154 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Zanka finds fun in everyday simple things. One fine day he got interested in a very trivial sequence. Given a natural number $k$, he considers the sequence $A... | {"inputs": ["1\n1"], "outputs": ["6"]} | 422 | 14 |
coding | Solve the programming task below in a Python markdown code block.
Write a function with the signature shown below:
```python
def is_int_array(arr):
return True
```
* returns `true / True` if every element in an array is an integer or a float with no decimals.
* returns `true / True` if array is empty.
* returns... | {"functional": "_inputs = [[[]], [[1, 2, 3, 4]], [[-11, -12, -13, -14]], [[1.0, 2.0, 3.0]], [[1, 2, None]], [None], [''], [[None]], [[1.0, 2.0, 3.0001]], [['-1']]]\n_outputs = [[True], [True], [True], [True], [False], [False], [False], [False], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isins... | 110 | 265 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Borys are playing tennis.
A tennis match consists of games. In each game, one of the players is serving and the other one is receiving.
Players serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vic... | {"inputs": ["3\n2 1\n1 1\n0 5\n", "2\n99999 0\n0 99999\n", "2\n99999 1\n1 99999\n", "2\n99998 1\n1 99998\n", "2\n0 100000\n100000 0\n"], "outputs": ["4\n0 1 2 3\n2\n0 2\n2\n2 3\n", "2\n49999 50000\n2\n49999 50000\n", "2\n49999 50001\n2\n49999 50001\n", "4\n49998 49999 50000 50001\n4\n49998 49999 50000 50001\n", "1\n500... | 706 | 260 |
coding | Solve the programming task below in a Python markdown code block.
Tonio has a keyboard with only two letters, "V" and "K".
One day, he has typed out a string s with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to max... | {"inputs": ["V\n", "K\n", "K\n", "V\n", "VK\n", "VV\n", "KV\n", "KK\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "1\n", "1\n", "0\n", "1\n"]} | 393 | 70 |
coding | Solve the programming task below in a Python markdown code block.
You are planning the next FIFA World Cup and you are counting the number of highways that need to be built to connect the cities with the venue.
Your country has $n$ cities and all cities lie on a single straight road called “Highway Road”. If you want... | {"inputs": ["1\n4 2\n"], "outputs": ["13\n"]} | 526 | 19 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a positive integer n which is the number of nodes of a 0-indexed directed weighted graph and a 0-indexed 2D array edges where edges[i] = [ui, vi, wi] indicates that there is an edge from node ui to node ... | {"functional": "def check(candidate):\n assert candidate(n = 4, edges = [[0,1,1],[1,2,3],[2,3,2],[0,3,4]], s = 0, marked = [2,3]) == 4\n assert candidate(n = 5, edges = [[0,1,2],[0,2,4],[1,3,1],[2,3,3],[3,4,2]], s = 1, marked = [0,4]) == 3\n assert candidate(n = 4, edges = [[0,1,1],[1,2,3],[2,3,2]], s = 3, mar... | 186 | 172 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).
Print the string S after lowercasing the K-th character in it.
-----Constraints-----
- 1 ≤ N ≤ 50
- 1 ≤ K ≤ N
- S is a string of len... | {"inputs": ["1 1\nA\n", "3 2\nABC", "3 2\nACC", "3 2\nBCC", "3 2\nCBA", "3 2\nBDC", "6 2\nCCA", "3 2\nCDB"], "outputs": ["a\n", "AbC\n", "AcC\n", "BcC\n", "CbA\n", "BdC\n", "CcA\n", "CdB\n"]} | 149 | 108 |
coding | Solve the programming task below in a Python markdown code block.
Recently a top secret mission to Mars has taken place. As a result, scientists managed to obtain some information about the Martian DNA. Now we know that any Martian DNA contains at most m different nucleotides, numbered from 1 to m. Special characterist... | {"inputs": ["3 3 0\n", "5000 3 0\n", "6984 3 0\n", "6984 4 0\n", "2 1 1\naa\n", "100000 52 0\n", "100000 34 0\n", "3 4 2\nab\nba\n"], "outputs": ["27\n", "22443616\n", "170353494", "63989708", "0\n", "378241178\n", "486606280", "50"]} | 634 | 165 |
coding | Solve the programming task below in a Python markdown code block.
Go around the Labyrinth
Explorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not. The... | {"inputs": ["3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n.....\n.....\n3 8\n..#.....\n........\n.....#..\n3 5\n..#..\n-....\n..#..\n4 4\n....\n....\n..##\n..#.\n0 0", "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n../..\n.....\n3 8\n..#.....\n........\n..#.....\n3 5\n..#..\n....-\n..#..\n4 4\n....\n....\n..##\n..#.\n... | 690 | 793 |
coding | Solve the programming task below in a Python markdown code block.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i... | {"inputs": ["3\n2 3 5\n3 7 1", "3\n1 3 3\n2 2 1", "3\n1 6 5\n0 1 3", "3\n2 1 5\n3 7 1", "3\n1 6 3\n2 2 1", "3\n0 1 5\n3 7 1", "3\n1 6 3\n2 1 1", "3\n0 1 5\n3 4 1"], "outputs": ["-1\n", "2\n", "0\n", "-1\n", "2\n", "-1\n", "2\n", "-1\n"]} | 727 | 159 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an m x n binary matrix image where 0 represents a white pixel and 1 represents a black pixel.
The black pixels are connected (i.e., there is only one black region). Pixels are connected horizontally and ... | {"functional": "def check(candidate):\n assert candidate(image = [[\"0\",\"0\",\"1\",\"0\"],[\"0\",\"1\",\"1\",\"0\"],[\"0\",\"1\",\"0\",\"0\"]], x = 0, y = 2) == 6\n assert candidate(image = [[\"1\"]], x = 0, y = 0) == 1\n\n\ncheck(Solution().minArea)"} | 155 | 93 |
coding | Solve the programming task below in a Python markdown code block.
A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the store.
Berland h... | {"inputs": ["5 1 1\n", "2 2 2\n", "4 1 2\n", "4 2 2\n", "4 4 2\n", "4 1 1\n", "3 3 2\n", "2 2 5\n"], "outputs": ["2\n1 5\n", "5\n1 1 2 3 4\n", "4\n1 1 4 5\n", "4\n1 1 4 5\n", "5\n1 1 4 5 8\n", "2\n1 4\n", "5\n1 1 3 4 6\n", "11\n1 1 1 1 1 2 3 3 3 3 4\n"]} | 595 | 179 |
coding | Solve the programming task below in a Python markdown code block.
There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.
Adjacent ... | {"inputs": ["1\nq\n", "5\naaaab", "5\naa`ab", "5\naa``b", "5\nba_`a", "5\nbaaaa", "5\naa_`b", "5\nca_`a"], "outputs": ["1\n", "2\n", "4\n", "3\n", "5\n", "2\n", "4\n", "5\n"]} | 213 | 94 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ... \times N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors.
-----Note-----
W... | {"inputs": ["4", "3", "2", "6", "1", "8", "0", "5"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 237 | 62 |
coding | Solve the programming task below in a Python markdown code block.
You are given a positive integer L in base two.
How many pairs of non-negative integers (a, b) satisfy the following conditions?
- a + b \leq L
- a + b = a \mbox{ XOR } b
Since there can be extremely many such pairs, print the count modulo 10^9 + 7.
W... | {"inputs": ["1\n", "10\n", "1111111111111111111\n", "11100000110100000010101101011111001100000\n", "110011111011111010101111000110101110110100001011011011111100101001110010\n", "10010011010011000011011110000011000000000011011110101001100000100101011101111111010001\n", "11000000000011110101111101010111101010011110011010... | 352 | 416 |
coding | Solve the programming task below in a Python markdown code block.
Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise.
Format:
* Optional `-` or `+`
* Base prefix `0b` (binary), `0x` (hexadecimal), `0o` (octal), or in cas... | {"functional": "_inputs = [['123'], ['0x123'], ['0o123'], ['0123'], ['123 '], [' 123'], ['0b1010'], ['+123'], ['-123'], ['0B1010'], ['0b12'], ['-0x123'], ['-0o123'], ['-0123'], ['123\\n'], ['\\n123'], ['-0b1010'], ['0xDEADbeef'], ['0X123'], ['0O123'], ['0o18']]\n_outputs = [[123], [291], [83], [123], [None], [None], [1... | 163 | 377 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.
Return any possible rearrangement of s or return "" if not possible.
Please complete the following python code pr... | {"functional": "def check(candidate):\n assert candidate(s = \"aab\") == \"aba\"\n assert candidate(s = \"aaab\") == \"\"\n\n\ncheck(Solution().reorganizeString)"} | 85 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Your task is to write a function which counts the number of squares contained in an ASCII art picture.
The input pictures contain rectangles---some of them squares---drawn with the characters `-`, `|`, and `+`, where `-` and `|` are used to represent ho... | {"functional": "_inputs = [[['+--+ +----+', '| | | | +-+', '| | +----+ | |', '+--+ +-+']], [['+-----+', '| |', '+-----+']], [['+---+', '| |', '| +-+-+', '| | | |', '+-+-+ |', ' | |', ' +---+']], [['+-+-+', '| | |', '+-+-+', '| | |', '+-+-+']], [['+---+', '| |', '| |', '| |', '| ... | 431 | 1,319 |
coding | Solve the programming task below in a Python markdown code block.
You are given two arrays $a$ and $b$ of length $n$. Array $a$ contains each odd integer from $1$ to $2n$ in an arbitrary order, and array $b$ contains each even integer from $1$ to $2n$ in an arbitrary order.
You can perform the following operation on t... | {"inputs": ["3\n2\n3 1\n4 2\n3\n5 3 1\n2 4 6\n5\n7 5 9 1 3\n2 4 6 10 8\n"], "outputs": ["0\n2\n3\n"]} | 710 | 65 |
coding | Solve the programming task below in a Python markdown code block.
We have N strings of lowercase English letters: S_1, S_2, \cdots, S_N.
Takahashi wants to make a string that is a palindrome by choosing one or more of these strings - the same string can be chosen more than once - and concatenating them in some order of... | {"inputs": ["1\nx 1\n", "2\nabc 1\nab 0", "2\nabc 1\nba 0", "2\nabc 2\nab 0", "2\nabc 2\nba 0", "2\nbac 2\nba 0", "2\nbac 2\nab 0", "2\ncab 2\nab 0"], "outputs": ["1\n", "-1\n", "1\n", "-1\n", "2\n", "-1\n", "2\n", "-1\n"]} | 399 | 124 |
coding | Solve the programming task below in a Python markdown code block.
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.
Obs. i is said to be good when its ... | {"inputs": ["4 3\n1 2 3 4\n1 3\n3 3\n2 4", "4 2\n2 4 3 5\n1 3\n3 3\n2 4", "4 0\n2 4 3 5\n1 3\n3 3\n4 4", "4 3\n1 6 3 3\n1 3\n2 2\n3 4", "4 3\n1 2 3 5\n1 3\n3 3\n2 4", "4 3\n1 4 3 5\n1 3\n3 3\n2 4", "4 3\n2 4 3 5\n1 3\n3 3\n2 4", "4 2\n2 4 3 5\n1 3\n3 1\n2 4"], "outputs": ["1\n", "2\n", "4\n", "0\n", "1\n", "1\n", "1\n"... | 539 | 238 |
coding | Solve the programming task below in a Python markdown code block.
Gru has a string $S$ of length $N$, consisting of only characters $a$ and $b$ for banana and $P$ points to spend.
Now Gru wants to replace and/or re-arrange characters of this given string to get the lexicographically smallest string possible. For this, ... | {"inputs": ["1\n3 3\nbba"], "outputs": ["aab"]} | 389 | 19 |
coding | Solve the programming task below in a Python markdown code block.
A young boy John is playing with eight triangular panels. These panels are all regular triangles of the same size, each painted in a single color; John is forming various octahedra with them.
While he enjoys his playing, his father is wondering how many... | {"inputs": ["blue blue blue blue bluf blue blue blue\nred blue blue blue blue blue blue blue\nred red blue blue blue blue blue blue", "blue blue blue blue bluf clue blue blue\nred blue blue blue blue blue blue blue\nred red blue blue blue blue blue blue", "blue blue blue blue bluf cleu blue blue\nred blue blue blue blu... | 261 | 349 |
coding | Solve the programming task below in a Python markdown code block.
Easy and hard versions are actually different problems, so we advise you to read both statements carefully.
You are given a weighted rooted tree, vertex 1 is the root of this tree. Also, each edge has its own cost.
A tree is a connected graph without c... | {"inputs": ["4\n4 7\n2 1 4 2\n3 2 4 1\n4 1 2 2\n3 20\n2 1 8 1\n3 1 0 2\n5 50\n1 3 100 1\n1 5 6 2\n2 4 123 2\n5 4 55 1\n2 100\n1 2 954 1\n", "4\n4 2\n2 1 4 2\n3 2 4 1\n4 1 2 2\n3 20\n2 1 8 1\n3 1 0 2\n5 50\n1 3 100 1\n1 5 6 2\n2 4 123 2\n5 4 55 1\n2 100\n1 2 954 1\n", "4\n4 7\n2 1 4 2\n3 2 4 1\n4 1 1 2\n3 20\n2 1 8 1\n3... | 734 | 986 |
coding | Solve the programming task below in a Python markdown code block.
Do you remember how Kai constructed the word "eternity" using pieces of ice as components?
Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to construct his favourite number t. He realized that digits 6... | {"inputs": ["1\n1\n", "5\n2\n", "5\n2\n", "1\n1\n", "11\n1\n", "11\n1\n", "7\n777\n", "25\n52\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "0\n", "0\n", "3\n", "1\n"]} | 296 | 92 |
coding | Solve the programming task below in a Python markdown code block.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels o... | {"inputs": ["2 2 0\n", "0 0 1\n", "0 1 0\n", "1 4 3\n", "3 2 0\n", "1 4 4\n", "1 0 0\n", "5 0 5\n"], "outputs": [" 2\n", " 0\n", " 0\n... | 422 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Let \mathrm{popcount}(n) be the number of `1`s in the binary representation of n. For example, \mathrm{popcount}(3) = 2, \mathrm{popcount}(7) = 3, and \mathrm{popcount}(0) = 0.
Let f(n) be the number of times the following operation will be done when we... | {"inputs": ["3\n111", "3\n110", "3\n101", "3\n100", "3\n001", "3\n011", "23\n00110111001011011001111", "23\n00110111001011011101111"], "outputs": ["2\n2\n1\n", "1\n1\n2\n", "1\n2\n1\n", "0\n1\n2\n", "2\n2\n0\n", "2\n1\n1", "3\n3\n2\n2\n3\n3\n2\n3\n3\n3\n2\n2\n3\n2\n2\n2\n2\n3\n2\n3\n3\n3\n2\n", "4\n4\n3\n3\n4\n3\n3\n3\... | 456 | 247 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$.
Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at ... | {"inputs": ["3\n5\n3 1 5 2 3\n4\n17 8 19 45\n8\n265 265 265 265 265 265 265 265\n"], "outputs": ["6\n63\n0\n"]} | 695 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi loves numbers divisible by 2.
You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.
Here, the number of times an ... | {"inputs": ["3", "4", "2", "6", "5", "9", "8", "1"], "outputs": ["2\n", "4\n", "2\n", "4\n", "4\n", "8\n", "8\n", "1"]} | 227 | 61 |
coding | Solve the programming task below in a Python markdown code block.
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line co... | {"inputs": ["2 2 1\n1 0\n", "2 2 0\n1 0\n", "2 2 1\n1 0\n", "2 2 0\n1 0\n", "2 2 0\n2 0\n", "2 4 0\n2 0\n", "2 4 0\n0 0\n", "2 5 0\n0 0\n"], "outputs": ["1", "0", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n"]} | 409 | 132 |
coding | Solve the programming task below in a Python markdown code block.
In this Kata, you will be given a string and your task will be to return a list of ints detailing the count of uppercase letters, lowercase, numbers and special characters, as follows.
```Haskell
Solve("*'&ABCDabcde12345") = [4,5,5,3].
--the order is: ... | {"functional": "_inputs = [['Codewars@codewars123.com'], ['bgA5<1d-tOwUZTS8yQ'], ['P*K4%>mQUDaG$h=cx2?.Czt7!Zn16p@5H'], [\"RYT'>s&gO-.CM9AKeH?,5317tWGpS<*x2ukXZD\"], ['$Cnl)Sr<7bBW-&qLHI!mY41ODe'], ['@mw>0=QD-iAx!rp9TaG?o&M%l$34L.nbft']]\n_outputs = [[[1, 18, 3, 2]], [[7, 6, 3, 2]], [[9, 9, 6, 9]], [[15, 8, 6, 9]], [[1... | 129 | 365 |
coding | Solve the programming task below in a Python markdown code block.
Little Petya often visits his grandmother in the countryside. The grandmother has a large vertical garden, which can be represented as a set of `n` rectangles of varying height. Due to the newest irrigation system we can create artificial rain above them... | {"functional": "_inputs = [[[2]], [[1, 2, 1, 2, 1]], [[4, 2, 3, 3, 2]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]], [[1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]], [[1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1]], [[1, 1, 1, 2, 1, 2, 10, 2, 3, 3]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... | 357 | 1,532 |
coding | Solve the programming task below in a Python markdown code block.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater numb... | {"inputs": ["12\n010\n27\n68\n0", "12\n010\n44\n68\n0", "12\n010\n8\n118\n0", "12\n100\n88\n50\n0", "12\n100\n71\n28\n0", "12\n100\n24\n28\n0", "12\n100\n24\n34\n0", "12\n100\n24\n52\n0"], "outputs": ["5 7\n5 7\n17 19\n59 61\n", "5 7\n5 7\n41 43\n59 61\n", "5 7\n5 7\n5 7\n107 109\n", "5 7\n71 73\n71 73\n41 43\n", "5 7\... | 244 | 320 |
coding | 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"]} | 548 | 135 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.
You are given a string moves that represe... | {"functional": "def check(candidate):\n assert candidate(moves = \"UD\") == True\n assert candidate(moves = \"LL\") == False\n\n\ncheck(Solution().judgeCircle)"} | 228 | 43 |
coding | Solve the programming task below in a Python markdown code block.
write me a function `stringy` that takes a `size` and returns a `string` of alternating `'1s'` and `'0s'`.
the string should start with a `1`.
a string with `size` 6 should return :`'101010'`.
with `size` 4 should return : `'1010'`.
with `size` 12 sh... | {"functional": "_inputs = [[3], [5], [12], [26], [28]]\n_outputs = [['101'], ['10101'], ['101010101010'], ['10101010101010101010101010'], ['1010101010101010101010101010']]\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, ab... | 151 | 250 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a string word that consists of digits and lowercase English letters.
You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123 34 8 34". Notice that you a... | {"functional": "def check(candidate):\n assert candidate(word = \"a123bc34d8ef34\") == 3\n assert candidate(word = \"leet1234code234\") == 2\n assert candidate(word = \"a1b01c001\") == 1\n\n\ncheck(Solution().numDifferentIntegers)"} | 174 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not.
You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem pr... | {"inputs": ["001011", "100000", "011011", "100100", "111011", "111111", "101100", "110100"], "outputs": ["3\n", "1\n", "4\n", "2\n", "5\n", "6\n", "3\n", "3\n"]} | 213 | 102 |
coding | Solve the programming task below in a Python markdown code block.
There is a deck of $n$ cards. The $i$-th card has a number $a_i$ on the front and a number $b_i$ on the back. Every integer between $1$ and $2n$ appears exactly once on the cards.
A deck is called sorted if the front values are in increasing order and t... | {"inputs": ["1\n1 2\n", "1\n1 2\n", "1\n2 1\n", "2\n1 2\n3 4\n", "2\n2 1\n3 4\n", "2\n1 2\n3 4\n", "3\n1 2\n3 6\n4 5\n", "3\n3 5\n4 1\n2 6\n"], "outputs": ["0\n", "0\n", "0\n", "-1\n", "-1\n", "\n-1\n", "-1\n", "0\n"]} | 486 | 132 |
coding | Solve the programming task below in a Python markdown code block.
Chef's daily routine is very simple. He starts his day with cooking food, then he eats the food and finally proceeds for sleeping thus ending his day. Chef carries a robot as his personal assistant whose job is to log the activities of Chef at various in... | {"inputs": ["5\nCES\nCS\nCCC\nSC\nECCC"], "outputs": ["yes\nyes\nyes\nno\nno"]} | 471 | 31 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$. You may perform the following operation any number of times: select any two adjacent elements... | {"inputs": ["4\n2\n7 4\n3\n1 2 2\n5\n5 5 5 5 5\n8\n7 2 4 1 6 8 3 9"], "outputs": ["No\nYes\nNo\nYes"]} | 667 | 62 |
coding | Solve the programming task below in a Python markdown code block.
Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.
From the window in your room, you see the sequence of n hills, where i-th of them has height a_{i}. The Innopolis administration wants t... | {"inputs": ["1\n10\n", "1\n10\n", "1\n11\n", "2\n2 2\n", "2\n2 2\n", "2\n4 2\n", "3\n1 2 3\n", "2\n1 100\n"], "outputs": ["0 \n", "0 ", "0\n", "1 \n", "1 ", "0\n", "0 2 \n", "0 \n"]} | 620 | 107 |
coding | Solve the programming task below in a Python markdown code block.
Chef has an array A of size N and an integer K. He can perform the following operation on A any number of times:
Select any K distinct indices i_{1}, i_{2}, \ldots, i_{K} and increment the array elements at these K indices by 1.
Formally, set A_{i_{j}}... | {"inputs": ["4\n5 3\n2 4 5 4 2\n6 1\n4 5 5 4 6 4\n6 2\n4 5 5 4 6 4\n4 2\n1 2 3 3\n"], "outputs": ["YES\nYES\nYES\nNO\n"]} | 728 | 78 |
coding | Solve the programming task below in a Python markdown code block.
You've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in a faraway place called Naha.
You immediately decided to take a vacation and visit Coronavirus-chan. Y... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "3 2\n1 3 1\n", "3 6\n3 3 3\n", "3 3\n1 1 1\n", "3 2\n3 3 3\n", "3 2\n3 4 3\n", "3 2\n1 1 2\n"], "outputs": ["1", "1\n", "5", "12", "3\n", "5\n", "7\n", "3\n"]} | 721 | 124 |
coding | Solve the programming task below in a Python markdown code block.
Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, NOT stri... | {"functional": "_inputs = [[2, 2], [3, 3], [3, 4], [4, 4], [2, 5]]\n_outputs = [[[[1, 2], [2, 4]]], [[[1, 2, 3], [2, 4, 6], [3, 6, 9]]], [[[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]], [[[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]]], [[[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]]]]\nimport math\ndef _deep_eq(a, b, t... | 168 | 344 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.
The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.
These buttons are numbered 1 through N.
When Button i is lighten up and you press it, the... | {"inputs": ["3\n3\n1\n3", "3\n2\n2\n1", "3\n3\n2\n3", "3\n1\n2\n6", "3\n3\n2\n1", "3\n1\n1\n6", "3\n1\n2\n1", "3\n1\n0\n6"], "outputs": ["-1\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 279 | 111 |
coding | Solve the programming task below in a Python markdown code block.
# Story
John found a path to a treasure, and while searching for its precise location he wrote a list of directions using symbols `"^"`, `"v"`, `"<"`, `">"` which mean `north`, `east`, `west`, and `east` accordingly. On his way John had to try many diff... | {"functional": "_inputs = [['<>>'], [''], ['v>^<'], ['>>>>'], ['^>>>>v'], ['<^^>v<^^^'], ['<^>>v<'], ['<^<<^^>>vv<<<>^^^v^'], ['v<<<<<^^^^^v>v>v>v>v>>'], ['>^>^>^>^>^>^>v>v>v>v>v>v>v>v<'], ['^^^>>>>>>^^^<<<vvv<<<vvv'], ['^^^>>>>>>^^^<<<vvv<<<vv'], ['>vv<<<^^^^>>>>>vvvvvv<<<<<<^^^^^^^^>>>>vv'], ['>vv<<<^^^^>>>>>vvvvvv<<... | 381 | 500 |
coding | Solve the programming task below in a Python markdown code block.
Dexter, being irritated by DD, gave her a lucrative game to play to keep her busy.
There are $N$ bags numbered $1$ to $N$. The $i_{th}$ bag contains $A_i$ coins. The bags are placed in a circular order such that the $N_{th}$ bag is adjacent to the $1^{st... | {"inputs": ["1\n5 3\n8 6 9 4 10"], "outputs": ["24"]} | 389 | 28 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have some apples and a basket that can carry up to 5000 units of weight.
Given an integer array weight where weight[i] is the weight of the ith apple, return the maximum number of apples you can put in the basket.... | {"functional": "def check(candidate):\n assert candidate(weight = [100,200,150,1000]) == 4\n assert candidate(weight = [900,950,800,1000,700,800]) == 5\n\n\ncheck(Solution().maxNumberOfApples)"} | 101 | 83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.