task_type stringclasses 4
values | problem stringlengths 14 5.23k | solution stringlengths 1 8.29k | problem_tokens int64 9 1.02k | solution_tokens int64 1 1.98k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territory of any of them. In addition, it was decided that... | {"inputs": ["1 3\n231\n", "1 3\n231\n", "1 4\n12#3\n", "1 4\n12#3\n", "1 4\n3#21\n", "1 4\n3#12\n", "1 5\n1#2#3\n", "3 1\n3\n1\n2\n"], "outputs": ["0\n", "0\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "0\n"]} | 523 | 126 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A = [1, 2, 3, ..., n]:
How many sequences ($S_{1}$) can you get after exact k adjacent swaps on A?
How many sequences ($S_{2}$) can you get after at most k swaps on A?
An adjacent swap can be made between two elements of... | {"inputs": ["3 2\n"], "outputs": ["3 6\n"]} | 392 | 18 |
coding | Solve the programming task below in a Python markdown code block.
In 17th century our Chef was a Wizard. He asked his small son "Anshu" to bring him the secret of the Magical Mountain. The boy after travelling a lot reached the Mountain.
The description of the Mountain was as follows:
- Mountain contains N magical sto... | {"inputs": ["1\n5\n1 2\n1 3\n2 4\n2 5"], "outputs": ["1 2 3 4 5"]} | 475 | 38 |
coding | Solve the programming task below in a Python markdown code block.
find the sum of the even fibonacci numbers till the given number(it is the value not index).
INPUT:
T test cases
next T lines consists of a number n.
OUTPUT:
Output the sum value.
0<t<10
2<n<10^20
Example:
if n=10
the numbers which are less than 10 are... | {"inputs": ["5\n14576\n145786\n1254478\n147852\n125478", "10\n457866622145522214789856\n321245663325\n12254\n14221\n14256\n145\n256\n125\n1254785632145632145\n14789666620000000"], "outputs": ["14328\n60696\n1089154\n60696\n60696", "390887039715493615101718\n112925716858\n14328\n14328\n14328\n188\n188\n44\n8899897080023... | 125 | 292 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Mr.Odd is my friend. Some of his common dialogues are “Am I looking odd?” , “It’s looking very odd” etc. Actually “odd” is his favorite word.
In this valentine when he went to meet his girlfriend. But he forgot to take gift. Because of this he ... | {"functional": "_inputs = [['oudddbo'], ['ouddddbo'], ['ooudddbd'], ['qoddoldfoodgodnooofostorodrnvdmddddeidfoi']]\n_outputs = [[1], [1], [2], [6]]\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 isins... | 271 | 198 |
coding | Solve the programming task below in a Python markdown code block.
People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (= 172), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ..., and 289-credit coins, ... | {"inputs": ["2\n4\n1\n0", "2\n2\n6\n0", "2\n0\n6\n0", "2\n7\n0\n0", "2\n2\n1\n0", "2\n1\n8\n0", "2\n4\n6\n0", "2\n0\n8\n0"], "outputs": ["1\n2\n1\n", "1\n1\n2\n", "1\n", "1\n2\n", "1\n1\n1\n", "1\n1\n3\n", "1\n2\n2\n", "1\n"]} | 277 | 132 |
coding | Solve the programming task below in a Python markdown code block.
Write a program that prints a chessboard with N rows and M columns with the following rules:
The top left cell must be an asterisk (*)
Any cell touching (left, right, up or down) a cell with an asterisk must be a dot (.)
Any cell touching (left, right, u... | {"functional": "_inputs = [['0 0'], ['1 0'], ['0 1'], ['2 2'], ['3 3'], ['5 2'], ['8 8']]\n_outputs = [[''], [''], [''], ['*.\\n.*'], ['*.*\\n.*.\\n*.*'], ['*.\\n.*\\n*.\\n.*\\n*.'], ['*.*.*.*.\\n.*.*.*.*\\n*.*.*.*.\\n.*.*.*.*\\n*.*.*.*.\\n.*.*.*.*\\n*.*.*.*.\\n.*.*.*.*']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n ... | 261 | 275 |
coding | Solve the programming task below in a Python markdown code block.
The eval() expression is a very powerful built-in function of Python. It helps in evaluating an expression. The expression can be a Python statement, or a code object.
For example:
>>> eval("9 + 5")
14
>>> x = 2
>>> eval("x + 3")
5
Here, eval() ca... | {"inputs": ["print(2 + 3)\n"], "outputs": ["5\n"]} | 214 | 20 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 109 + 7.
A subsequence of a string is obtained by deleting zero or more ch... | {"functional": "def check(candidate):\n assert candidate(s = 'bccb') == 6\n assert candidate(s = 'abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba') == 104860361\n\n\ncheck(Solution().countPalindromicSubsequences)"} | 156 | 80 |
coding | Solve the programming task below in a Python markdown code block.
You are given three positive integers $a$, $b$, $c$ ($a < b < c$). You have to find three positive integers $x$, $y$, $z$ such that:
$$x mod y = a,$$ $$y mod z = b,$$ $$z mod x = c.$$
Here $p mod q$ denotes the remainder from dividing $p$ by $q$. It is... | {"inputs": ["1\n1 2 2002\n", "1\n1 2 1000000\n", "1\n1 2 100000000\n", "4\n1 3 4\n127 234 421\n2 7 8\n59 94 388\n"], "outputs": ["2005 2004 2002\n", "1000003 1000002 1000000\n", "100000003 100000002 100000000\n", "8 7 4\n782 655 421\n17 15 8\n541 482 388\n"]} | 413 | 206 |
coding | Solve the programming task below in a Python markdown code block.
You are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following:
Hello firstname lastname! You just delved into python.
Function Description
Complete the print_full_name function in th... | {"inputs": ["Ross\nTaylor\n"], "outputs": ["Hello Ross Taylor! You just delved into python.\n"]} | 223 | 26 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is a private detective. He was asked to investigate a case of murder in the city of Frangton.
Chef arrived in Frangton to find out that the mafia was involved in the cas... | {"inputs": ["6\n0 1 1 2 2 3"], "outputs": ["4 5 6"]} | 455 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Devu has an array A consisting of N positive integers. He would like to perform following operation on array.
- Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same).
Remove both... | {"inputs": ["1 2\n1\n1\n2", "1 1\n1\n0\n0", "1 1\n0\n0\n0", "1 2\n1\n1\n0", "1 2\n1\n0\n0", "0 2\n0\n0\n0", "1 2\n1\n1\n2", "1 1\n0\n-1\n0"], "outputs": ["Yes\nNo", "No\n", "Yes\n", "Yes\nNo\n", "No\nNo\n", "Yes\nYes\n", "Yes\nNo\n", "No\n"]} | 511 | 136 |
coding | Solve the programming task below in a Python markdown code block.
On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off... | {"inputs": ["2\n", "1\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["0 2\n", "0 1\n", "0 2\n", "0 2\n", "0 2\n", "1 2\n", "2 2\n", "2 3\n"]} | 232 | 86 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:
Every element less than pivot appears before every element greater than pivot.
Every... | {"functional": "def check(candidate):\n assert candidate(nums = [9,12,5,10,14,3,10], pivot = 10) == [9,5,3,10,10,12,14]\n assert candidate(nums = [-3,4,3,2], pivot = 2) == [-3,2,4,3]\n\n\ncheck(Solution().pivotArray)"} | 223 | 100 |
coding | Solve the programming task below in a Python markdown code block.
Let $s$ be a string of lowercase Latin letters. Its price is the sum of the indices of letters (an integer between 1 and 26) that are included in it. For example, the price of the string abca is $1+2+3+1=7$.
The string $w$ and the integer $p$ are given.... | {"inputs": ["1\nvdjisjifreo\n39\n", "5\nabca\n2\nabca\n6\ncodeforces\n1\ncodeforces\n10\ncodeforces\n100\n"], "outputs": ["diife\n", "aa\naba\n\ncdc\ncodeforces\n"]} | 510 | 73 |
coding | Solve the programming task below in a Python markdown code block.
In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organiz... | {"inputs": ["2\n5 7\n", "2\n2 1\n", "2\n1 2\n", "2\n1 2\n", "2\n2 1\n", "2\n1 3\n", "2\n2 0\n", "2\n2 7\n"], "outputs": ["2 5\n", "1 1\n", "2 1\n", "2 1\n", "1 1\n", "2 1\n", "1 0\n", "2 2\n"]} | 322 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a 0-indexed integer array nums of size n containing all numbers from 1 to n, return the number of increasing quadruplets.
A quadruplet (i, j, k, l) is increasing if:
0 <= i < j < k < l < n, and
nums[i] < nums[k... | {"functional": "def check(candidate):\n assert candidate(nums = [1,3,2,4,5]) == 2\n assert candidate(nums = [1,2,3,4]) == 0\n\n\ncheck(Solution().countQuadruplets)"} | 127 | 60 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums and an integer k, return the number of good subarrays of nums.
A subarray arr is good if it there are at least k pairs of indices (i, j) such that i < j and arr[i] == arr[j].
A subarray is ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,1,1,1,1], k = 10) == 1\n assert candidate(nums = [3,1,4,3,2,2,4], k = 2) == 4\n\n\ncheck(Solution().countGood)"} | 121 | 74 |
coding | Solve the programming task below in a Python markdown code block.
A bracketed sequence is called correct (regular) if by inserting "+" and "1" you can get a well-formed mathematical expression from it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not.
The teacher... | {"inputs": ["1\n(\n", "1\n)\n", "2\n((\n", "2\n)(\n", "2\n()\n", "2\n))\n", "3\n(()\n", "4\n))))\n"], "outputs": ["-1\n", "-1\n", "-1\n", "2\n", "0\n", "-1\n", "-1\n", "-1\n"]} | 521 | 92 |
coding | Solve the programming task below in a Python markdown code block.
## Description
Your job is to create a simple password validation function, as seen on many websites.
The rules for a valid password are as follows:
- There needs to be at least 1 uppercase letter.
- There needs to be at least 1 lowercase letter.
- The... | {"functional": "_inputs = [['Abcd1234'], ['Abcd123'], ['abcd1234'], ['AbcdefGhijKlmnopQRsTuvwxyZ1234567890'], ['ABCD1234'], ['Ab1!@#$%^&*()-_+={}[]|\\\\:;?/>.<,'], ['!@#$%^&*()-_+={}[]|\\\\:;?/>.<,'], [''], [' aA1----'], ['4aA1----']]\n_outputs = [[True], [False], [False], [True], [False], [True], [False], [False], [Tr... | 168 | 293 |
coding | Solve the programming task below in a Python markdown code block.
The most dangerous cyborg Jenish is finally entrapped on a narrow bridge over a valley. The bridge is $N$ meters long. For convenience, position $i$ represents a portion of bridge between whose left border is at distance $i-1$ meters from left end and ri... | {"inputs": ["3\n4 8\n5 1 4 2\n3 4\n3 1 2\n2 7\n5 5"], "outputs": ["YES\nYES\nNO"]} | 721 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Consider a sequence made up of the consecutive prime numbers. This infinite sequence would start with:
```python
"2357111317192329313741434753596167717379..."
```
You will be given two numbers: `a` and `b`, and your task will be to return `b` elements ... | {"functional": "_inputs = [[2, 2], [10, 5], [10, 3], [20, 9], [30, 12], [40, 8], [50, 6], [10000, 5], [20000, 5]]\n_outputs = [['57'], ['19232'], ['192'], ['414347535'], ['616771737983'], ['83899710'], ['031071'], ['02192'], ['09334']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstan... | 235 | 290 |
coding | Solve the programming task below in a Python markdown code block.
Snuke lives at position x on a number line.
On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B.
Find out which store is closer t... | {"inputs": ["5 1 7", "1 3 1", "1 3 0", "0 2 7", "6 1 7", "8 1 7", "4 2 9", "2 3 0"], "outputs": ["B\n", "B\n", "B\n", "A\n", "B\n", "B\n", "A\n", "A\n"]} | 266 | 94 |
coding | Solve the programming task below in a Python markdown code block.
Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.
He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a s... | {"inputs": ["3\n4\n11\n6\n", "3\n6\n5\n46\n", "3\n6\n11\n6\n", "3\n28\n1\n62\n", "3\n6\n17\n46\n", "3\n9\n24\n21\n", "3\n7\n24\n21\n", "3\n30\n11\n6\n"], "outputs": ["NO\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nNO\n"]} | 290 | 163 |
coding | Solve the programming task below in a Python markdown code block.
Chef bought N items from a shop. Although it is hard to carry all these items in hand, so Chef has to buy some polybags to store these items.
1 polybag can contain at most 10 items. What is the minimum number of polybags needed by Chef?
------ Input Fo... | {"inputs": ["3\n20\n24\n99\n"], "outputs": ["2\n3\n10\n"]} | 279 | 28 |
coding | Solve the programming task below in a Python markdown code block.
Connect the countless points with lines, till we reach the faraway yonder.
There are n points on a coordinate plane, the i-th of which being (i, y_{i}).
Determine whether it's possible to draw two parallel and non-overlapping lines, such that every poi... | {"inputs": ["4\n1 0 3 0\n", "4\n1 0 1 4\n", "4\n0 0 4 0\n", "4\n0 0 1 3\n", "4\n1 3 4 4\n", "4\n2 2 4 5\n", "4\n1 3 3 6\n", "4\n1 3 4 4\n"], "outputs": ["No\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "No\n", "Yes\n"]} | 424 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Division of Big Integers
Given two integers $A$ and $B$, compute the quotient, $\frac{A}{B}$. Round down to the nearest decimal.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the quotient in a line.
... | {"inputs": ["9 6", "2 1", "1 4", "2 4", "2 2", "5 3", "5 6", "9 8"], "outputs": ["1\n", "2\n", "0\n", "0\n", "1\n", "1\n", "0\n", "1\n"]} | 205 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.
-----Constraints-----
- 1 \leq N \leq 10^9
- N is an integer.
-----Input-----
Input is given from Standard Input ... | {"inputs": ["7", "2", "0", "70", "12", "16", "26", "38"], "outputs": ["4\n", "1\n", "0\n", "64\n", "9\n", "16\n", "25\n", "36\n"]} | 131 | 71 |
coding | Solve the programming task below in a Python markdown code block.
Error Handling is very important in coding and seems to be overlooked or not implemented properly.
#Task
Your task is to implement a function which takes a string as input and return an object containing the properties
vowels and consonants. The vowels... | {"functional": "_inputs = [['Test'], ['Here is some text'], ['To be a Codewarrior or not to be'], ['To Kata or not to Kata'], ['aeiou'], ['TEst'], ['HEre Is sOme text'], [['To Kata or not to Kata']], [None], ['Test '], ['Here is some text '], [' '], [{'jjjjj': 'jjjjj'}]]\n_outputs... | 350 | 446 |
coding | Solve the programming task below in a Python markdown code block.
The Little Elephant loves numbers.
He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations... | {"inputs": ["2\n", "3\n", "9\n", "4\n", "5\n", "6\n", "7\n", "8\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 133 | 70 |
coding | Solve the programming task below in a Python markdown code block.
Students are taught to add multi-digit numbers from right-to-left one digit at a time.
Many find the "carry" operation - in which 1 is carried from one digit position
to be added to the next - to be a significant challenge. Your job is to
count the numb... | {"inputs": ["3\n123 456\n555 555\n123 594", "3\n5555555555 5555555555\n1111111111 1111111111\n5111111111 5111111111"], "outputs": ["No carry operation\n3 carry operations\n1 carry operation", "10 carry operations\nNo carry operation\n1 carry operation"]} | 264 | 129 |
coding | Solve the programming task below in a Python markdown code block.
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.
From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized.
If there are multiple pairs th... | {"inputs": ["2\n010 0", "2\n001 0", "2\n101 0", "2\n111 0", "2\n110 0", "2\n110 1", "2\n100 1", "2\n010 1"], "outputs": ["10 0\n", "1 0\n", "101 0\n", "111 0\n", "110 0\n", "110 1\n", "100 1\n", "10 1\n"]} | 391 | 138 |
coding | Solve the programming task below in a Python markdown code block.
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $n$ positions to install lamps, they correspond to the integer numbers fr... | {"inputs": ["2 1 1\n1\n1\n", "3 1 1\n2\n1\n", "3 1 1\n2\n1\n", "2 1 1\n1\n1\n", "3 1 1\n2\n0\n", "3 1 0\n2\n0\n", "2 1 2\n1\n1 2\n", "3 1 2\n2\n1 1\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "2\n", "2\n"]} | 644 | 139 |
coding | Solve the programming task below in a Python markdown code block.
Mehta is a very lazy boy. He always sleeps in Maths class. One day his teacher catches him sleeping and tells him that she would mark him absent for the whole semester. While she pretends to be strict, she is actually very kind-hearted. So she wants to g... | {"inputs": ["4\n2\n8\n36\n900\n"], "outputs": ["0\n1/3\n1/8\n3/26\n"]} | 535 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Toby has found a game to entertain himself.The game is like this:
You are in a coordinate system initially at (0,0) and you are given a sequence of steps which lead to your destination.The steps are given in the form of directions: ’U’ ,’D’ , ’L’ and ‘R... | {"inputs": ["3\n7\nULUDLLU\n4\nRUUR\n4\nLRLR"], "outputs": ["2\n0\n4"]} | 518 | 33 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Vietnamese], and [Russian] as well.
Chef has an array A of length N.
Since Chef's favorite number is 3, he wants to make all numbers in the array a multiple of 3.
Chef can do the following operation:
Select any ... | {"inputs": ["3\n3\n1 2 3\n4\n6 3 9 12\n2\n4 3\n"], "outputs": ["1\n0\n-1\n"]} | 455 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef has a string $S$. He also has another string $P$, called *pattern*. He wants to find the pattern in $S$, but that might be impossible. Therefore... | {"inputs": ["3\nakramkeeanany\naka\nsupahotboy\nbohoty\ndaehabshatorawy\nbadawy"], "outputs": ["aaakaeekmnnry\nabohotypsu\naabadawyehhorst"]} | 479 | 57 |
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.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Finish the solution so that it returns the sum of all the multiples of 3 or 5 **below** the number passed in.
> Note: If ... | {"functional": "_inputs = [[10], [20], [0], [1], [200]]\n_outputs = [[23], [78], [0], [0], [9168]]\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) != le... | 161 | 186 |
coding | Solve the programming task below in a Python markdown code block.
Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!
He decided to visit all n cities of Persia to find t... | {"inputs": ["1\n", "2\n2 1 5\n", "2\n2 1 89\n", "2\n2 1 17\n", "2\n2 1 140\n", "3\n1 2 0\n2 3 0\n", "3\n1 2 3\n2 3 5\n", "3\n1 2 3\n2 3 3\n"], "outputs": ["0", "5", "89", "17\n", "140\n", "0", "8\n", "6\n"]} | 377 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.
Let's call a positive number special if it can be written as a sum of different non-negative... | {"inputs": ["3\n6 7\n2 6\n9 255\n", "3\n1 2\n2 6\n7 433\n", "3\n6 7\n2 6\n9 205\n", "3\n1 2\n2 6\n7 749\n", "3\n0 4\n2 6\n39 564\n", "3\n0 8\n0 6\n105 46\n", "3\n1 7\n0 6\n35 564\n", "3\n0 4\n0 6\n39 564\n"], "outputs": ["43\n6\n5380840\n", "1\n6\n6607553\n", "43\n6\n5315221\n", "1\n6\n41311999\n", "0\n6\n452236824\n",... | 347 | 277 |
coding | Solve the programming task below in a Python markdown code block.
Vasya decided to go to the grocery store. He found in his wallet $a$ coins of $1$ burle and $b$ coins of $2$ burles. He does not yet know the total cost of all goods, so help him find out $s$ ($s > 0$): the minimum positive integer amount of money he can... | {"inputs": ["1\n69 74\n", "1\n99 101\n", "1\n3947394 7\n", "1\n3534 1834\n", "1\n9999999 0\n", "1\n12345 12345\n", "1\n112311 11332\n", "1\n1223111 133212\n"], "outputs": ["218\n", "302\n", "3947409\n", "7203\n", "10000000\n", "37036\n", "134976\n", "1489536\n"]} | 567 | 188 |
coding | Solve the programming task below in a Python markdown code block.
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $... | {"inputs": ["1 1\n", "2 1\n", "1 1\n", "2 1\n", "8 5\n", "11 3\n", "11 6\n", "14 5\n"], "outputs": ["1\n", "2\n", "1\n", "2\n", "2\n", "5\n", "4\n", "6\n"]} | 599 | 89 |
coding | Solve the programming task below in a Python markdown code block.
Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index `0` will be considered even.
For example, `capitalize("abcdef") = ['AbCdEf', 'aBcDeF']`. See test cases for more examples.
The ... | {"functional": "_inputs = [['abcdef'], ['codewars'], ['abracadabra'], ['codewarriors'], ['indexinglessons'], ['codingisafunactivity']]\n_outputs = [[['AbCdEf', 'aBcDeF']], [['CoDeWaRs', 'cOdEwArS']], [['AbRaCaDaBrA', 'aBrAcAdAbRa']], [['CoDeWaRrIoRs', 'cOdEwArRiOrS']], [['InDeXiNgLeSsOnS', 'iNdExInGlEsSoNs']], [['CoDiN... | 192 | 291 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai an... | {"functional": "def check(candidate):\n assert candidate(n = 6, edges = [[0,1],[0,2],[1,3],[1,4],[2,5]], values = [2,8,3,6,2,5]) == 24\n assert candidate(n = 3, edges = [[0,1],[1,2]], values = [4,6,1]) == 0\n\n\ncheck(Solution().maxXor)"} | 253 | 103 |
coding | Solve the programming task below in a Python markdown code block.
What's in a name?
..Or rather, what's a name in? For us, a particular string is where we are looking for a name.
Task
Test whether or not the string contains all of the letters which spell a given name, in order.
The format
A function passing two stri... | {"functional": "_inputs = [['Across the rivers', 'chris'], ['Next to a lake', 'chris'], ['Under a sea', 'chris'], ['A crew that boards the ship', 'chris'], ['A live son', 'Allison'], ['Just enough nice friends', 'Jennifer'], ['thomas', 'Thomas'], ['pippippi', 'Pippi'], ['pipipp', 'Pippi'], ['ppipip', 'Pippi']]\n_output... | 385 | 270 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed integer array nums consisting of 3 * n elements.
You are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal... | {"functional": "def check(candidate):\n assert candidate(nums = [3,1,2]) == -1\n assert candidate(nums = [7,9,5,8,1,3]) == 1\n\n\ncheck(Solution().minimumDifference)"} | 211 | 57 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef has decided to start a new firm called PatentChef. However, he's stuck with some big legal issues. Their firm has received offers from a lot of companies, so Chef told h... | {"inputs": ["2\n4 4 2 4\nEEOO\n4 3 1 4\nEEOO"], "outputs": ["yes\nno"]} | 714 | 38 |
coding | Solve the programming task below in a Python markdown code block.
Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks... | {"inputs": ["1\n4 1\n0011\n0011\n1 4\n", "1\n4 1\n0011\n0111\n1 4\n", "1\n4 1\n0011\n0011\n4 4\n", "1\n4 1\n0011\n0110\n1 4\n", "1\n4 1\n0011\n0011\n2 4\n", "1\n4 1\n0011\n0100\n1 4\n", "1\n4 1\n0011\n0100\n2 4\n", "1\n4 1\n0011\n0001\n4 4\n"], "outputs": ["NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n"... | 676 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p_1, p_2, ..., p_{n}], where p_{i} denotes the n... | {"inputs": ["5 5\n5 4 3 2 1\n1 5 3\n1 3 1\n2 4 3\n4 4 4\n2 5 3\n", "5 5\n5 4 3 2 1\n1 5 3\n1 5 1\n2 4 3\n4 4 4\n2 5 3\n", "5 5\n5 4 3 2 1\n1 5 4\n1 3 1\n2 4 3\n4 4 4\n2 5 3\n", "5 5\n5 4 3 2 1\n1 5 3\n1 3 1\n2 4 3\n3 4 4\n2 5 3\n", "5 5\n5 4 6 2 1\n1 5 4\n1 3 1\n2 4 3\n4 4 4\n2 5 3\n", "5 5\n8 4 3 2 1\n1 5 3\n1 3 1\n2 ... | 686 | 470 |
coding | Solve the programming task below in a Python markdown code block.
Let's define a multiplication operation between a string $a$ and a positive integer $x$: $a \cdot x$ is the string that is a result of writing $x$ copies of $a$ one after another. For example, "abc" $\cdot~2~=$ "abcabc", "a" $\cdot~5~=$ "aaaaa".
A strin... | {"inputs": ["1\nabababababbb\nab\n", "1\nabababababbb\nab\n", "1\nabababababbb\naa\n", "1\nabababacabbb\naa\n", "1\nabababacabbb\nba\n", "1\nabababacabbb\nab\n", "1\nbbbacabababa\naa\n", "1\nbbbacbbababa\naa\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n"]} | 459 | 141 |
coding | Solve the programming task below in a Python markdown code block.
There is an infinitely long street that runs west to east, which we consider as a number line.
There are N roadworks scheduled on this street.
The i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.
Q people are standi... | {"inputs": ["4 5\n0 4 1\n8 13 1\n2 48 9\n3 4 2\n1\n0\n2\n3\n5\n8", "4 5\n0 4 1\n8 13 1\n2 48 9\n3 4 2\n1\n0\n2\n0\n5\n8", "4 5\n0 4 1\n8 13 1\n2 48 4\n3 4 2\n1\n0\n2\n0\n5\n8", "4 2\n0 4 1\n8 21 1\n2 48 4\n3 5 2\n1\n0\n2\n0\n5\n8", "4 5\n2 4 2\n8 13 1\n17 6 6\n5 7 2\n1\n1\n2\n3\n8\n8", "4 5\n2 4 2\n8 13 1\n17 6 6\n5 7 ... | 509 | 441 |
coding | Solve the programming task below in a Python markdown code block.
Chef recently took a course in linear algebra and learned about linear combinations of vectors. Therefore, in order to test his intelligence, Raj gave him a "fuzzy" problem to solve.
A sequence of integers $B_1, B_2, \ldots, B_M$ generates an integer $K$... | {"inputs": ["2\n2 4\n3\n1\n2\n8"], "outputs": ["0\n2\n3"]} | 614 | 28 |
coding | Solve the programming task below in a Python markdown code block.
You will be given an array which lists the current inventory of stock in your store and another array which lists the new inventory being delivered to your store today.
Your task is to write a function that returns the updated list of your current inven... | {"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(_dee... | 242 | 155 |
coding | Solve the programming task below in a Python markdown code block.
Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.
You are given $n$ operations which... | {"inputs": ["1\n+\n", "1\n-\n", "1\n-\n", "1\n+\n", "2\n-+\n", "2\n++\n", "2\n+-\n", "2\n--\n"], "outputs": ["1", "0", "0\n", "1\n", "1", "2", "0", "0"]} | 545 | 84 |
coding | Solve the programming task below in a Python markdown code block.
There are N boxes arranged in a row.
Initially, the i-th box from the left contains a_i candies.
Snuke can perform the following operation any number of times:
- Choose a box containing at least one candy, and eat one of the candies in the chosen box.
H... | {"inputs": ["2 0\n7 5", "2 0\n1 5", "2 1\n1 2", "2 0\n5 9", "2 0\n1 0", "2 0\n1 9", "2 0\n4 0", "2 0\n1 2"], "outputs": ["12\n", "6\n", "2\n", "14\n", "1\n", "10\n", "4\n", "3\n"]} | 231 | 113 |
coding | Solve the programming task below in a Python markdown code block.
Given is an integer S.
Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.
The answer can be very large, so output it modulo 10^9 + 7.
-----Constraints-----
- 1 \leq S \leq 2000
- All... | {"inputs": ["3", "1", "8", "9", "6", "7", "2", "7\n"], "outputs": ["1\n", "0\n", "4\n", "6\n", "2\n", "3", "0", "3\n"]} | 154 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Russian] and [Mandarin Chinese].
Value of an array A of length L is defined as the sum of (A_{i} \oplus i) for all 0 ≤ i < L, where \oplus denotes [bitwise xor operation]. Note that array indices start from zero.
You are gi... | {"inputs": ["3\n2 0\n2 1\n10 100"], "outputs": ["0\n6\n204600"]} | 658 | 36 |
coding | Solve the programming task below in a Python markdown code block.
A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.
Catacombs consist of several rooms and bidirectional passages between some pairs of them. ... | {"inputs": ["1\n0\n", "1\n0\n", "2\n0 0\n", "2\n0 1\n", "2\n0 1\n", "2\n0 0\n", "5\n0 1 0 1 3\n", "5\n0 1 0 1 0\n"], "outputs": ["1\n", "1\n", "2\n", "1\n", "1\n", "2\n", "3\n", "4\n"]} | 490 | 110 |
coding | Solve the programming task below in a Python markdown code block.
You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both lang... | {"inputs": ["1 1\na c\na\n", "1 1\na c\na\n", "1 1\namit am\namit\n", "1 1\namit am\namit\n", "1 1\namit ma\namit\n", "1 1\namit la\namit\n", "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll\n", "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll\n"], "outputs": ["a\n", "a "... | 562 | 210 |
coding | Solve the programming task below in a Python markdown code block.
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha.
So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. Fo... | {"inputs": ["2 4\n1 2 1\n2 3 2\n", "2 2\n1 1 1\n1 1 1\n", "2 2\n2 2 1\n3 3 2\n", "2 4\n1 2 5\n1 3 5\n", "2 4\n1 2 5\n1 3 5\n", "2 2\n1 1 1\n1 1 1\n", "2 2\n2 2 1\n3 3 2\n", "2 4\n1 2 1\n2 3 2\n"], "outputs": ["-1\n", "-1\n", "3\n", "-1\n", "-1", "-1", "3", "-1"]} | 617 | 179 |
coding | Solve the programming task below in a Python markdown code block.
Fennec and Snuke are playing a board game.
On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeated... | {"inputs": ["4\n1 4\n4 3\n2 3", "4\n1 2\n4 2\n2 3", "4\n1 4\n4 3\n2 1", "4\n1 4\n4 3\n2 2", "4\n1 4\n4 2\n2 2", "4\n1 3\n4 2\n2 3", "4\n1 4\n4 2\n4 2", "4\n1 3\n4 2\n2 1"], "outputs": ["Snuke\n", "Fennec\n", "Snuke\n", "Snuke\n", "Snuke\n", "Snuke\n", "Snuke\n", "Fennec\n"]} | 411 | 174 |
coding | Solve the programming task below in a Python markdown code block.
You have a stripe of checkered paper of length $n$. Each cell is either white or black.
What is the minimum number of cells that must be recolored from white to black in order to have a segment of $k$ consecutive black cells on the stripe?
If the input... | {"inputs": ["1\n20 2\nWWWBBBWBWBWBWBWBWBWB\n", "4\n5 3\nBBWBW\n5 5\nBBWBW\n5 1\nBBWBW\n1 1\nW\n"], "outputs": ["0\n", "1\n2\n0\n1\n"]} | 489 | 74 |
coding | Solve the programming task below in a Python markdown code block.
Consider a matrix where each cell contains either a $0$ or a $1$. Any cell containing a $1$ is called a filled cell. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally. In the following grid, a... | {"inputs": ["4\n4\n1 1 0 0\n0 1 1 0\n0 0 1 0\n1 0 0 0\n"], "outputs": ["5\n"]} | 540 | 48 |
coding | Solve the programming task below in a Python markdown code block.
You are given undirected weighted graph. Find the length of the shortest cycle which starts from the vertex 1 and passes throught all the edges at least once. Graph may contain multiply edges between a pair of vertices and loops (edges from the vertex to... | {"inputs": ["2 0\n", "1 0\n", "5 0\n", "3 0\n", "6 0\n", "15 0\n", "2 1\n1 1 3\n", "7 1\n3 4 4\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "3\n", "-1\n"]} | 230 | 99 |
coding | Solve the programming task below in a Python markdown code block.
Recall that a permutation of length $n$ is an array where each element from $1$ to $n$ occurs exactly once.
For a fixed positive integer $d$, let's define the cost of the permutation $p$ of length $n$ as the number of indices $i$ $(1 \le i < n)$ such th... | {"inputs": ["2\n2\n3\n"], "outputs": ["2\n1 2 \n2\n1 2 3 \n"]} | 396 | 32 |
coding | Solve the programming task below in a Python markdown code block.
Chef is the event manager of his college. He has been assigned the task to manage the upcoming tech fest. There are $K$ rooms where the event can take place, and at a particular time only one event can be organized in a room for a particular time interva... | {"inputs": ["1\n4 2\n1 10 1\n10 20 2\n15 50 2\n20 30 2"], "outputs": ["3"]} | 468 | 47 |
coding | Solve the programming task below in a Python markdown code block.
A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least x points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results have... | {"inputs": ["1 100\n56\n44\n", "3 2\n6 4 0\n0 0 7\n", "2 50\n67 33\n12 4\n", "3 3\n1 50 2\n2 2 1\n", "2 50\n25 24\n26 26\n", "2 50\n25 25\n24 26\n", "3 10\n9 9 0\n0 0 7\n", "3 3\n1 50 2\n2 2 2\n"], "outputs": ["1 1\n", "1 3\n", "1 1\n", "1 3\n", "1 2\n", "1 1\n", "1 1\n", "1 3\n"]} | 682 | 199 |
coding | Solve the programming task below in a Python markdown code block.
The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
The calendar is so beautiful that she wants to know what is the next ... | {"inputs": ["2016\n", "2000\n", "1000\n", "1900\n", "1899\n", "1004\n", "2100\n", "1313\n"], "outputs": ["2044\n", "2028\n", "1006\n", "1906\n", "1905\n", "1032\n", "2106\n", "1319\n"]} | 274 | 118 |
coding | Solve the programming task below in a Python markdown code block.
A matrix B (consisting of integers) of dimension N × N is said to be good if there exists an array A (consisting of integers) such that B[i][j] = |A[i] - A[j]|, where |x| denotes absolute value of integer x.
You are given a partially filled matrix B of ... | {"inputs": ["4\n2 2\n1 1 0\n1 2 1\n2 3\n1 1 0\n1 2 1\n2 1 0\n3 2\n2 2 0\n2 3 1\n3 3\n1 2 1\n2 3 1\n1 3 1"], "outputs": ["yes\nno\nyes\nno"]} | 574 | 94 |
coding | Solve the programming task below in a Python markdown code block.
In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left.
NOTE: String letters are case... | {"inputs": ["ABCDCDC\nCDC\n"], "outputs": ["2\n"]} | 292 | 18 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer $n$. Check if $n$ has an odd divisor, greater than one (does there exist such a number $x$ ($x > 1$) that $n$ is divisible by $x$ and $x$ is odd).
For example, if $n=6$, then there is $x=3$. If $n=4$, then such a number does not... | {"inputs": ["2\n4\n54\n", "2\n7\n30\n", "2\n5\n30\n", "2\n3\n30\n", "2\n3\n57\n", "2\n7\n46\n", "2\n5\n54\n", "2\n5\n48\n"], "outputs": ["NO\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n", "YES\nYES\n"]} | 331 | 126 |
coding | Solve the programming task below in a Python markdown code block.
Recently, chef Ciel often hears about lucky numbers.
Everybody knows that lucky numbers are positive integers
whose decimal representation contains only the lucky digits 4 and 7.
For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Ciel de... | {"inputs": ["6\nmlik 64\nCsel'i nriDk 24\nfhT crruy 1nd noitide 94654\nrcie temelo 85855\nunagi 1\n The first dao tasl letters acn ea b soacd 564", "6\nmlik 64\nCsel'i nriDk 24\nfhT crruy 1nd noitide 94654\nrcie temelo 85855\nunagi 1\n The first dao tasl letters abn ea b soacd 564", "6\nmlik 64\nCsel'i ... | 616 | 627 |
coding | Solve the programming task below in a Python markdown code block.
Our friendly friend Pete is really a nice person, but he tends to be rather... Inappropriate.
And possibly loud, if given enough ethanol and free rein, so we ask you to write a function that should take its not always "clean" speech and cover as much as... | {"functional": "_inputs = [['I want to punch someone in the face'], ['uh!'], ['What the hell am I doing here? And where is my wallet? PETE SMASH!'], ['I want to punch someone in the face', ['someone', 'face']], ['I want to punch someone in the face', ['drink', 'job', 'girls']]]\n_outputs = [['I w**t to p***h s*****e in... | 413 | 315 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
What is the maximum number of squares of size 2x2 that can be fit in a right angled isosceles triangle of base B.
One side of the square must be parallel to the base of the isosceles tr... | {"inputs": ["11\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11"], "outputs": ["0\n0\n0\n1\n1\n3\n3\n6\n6\n10\n10"]} | 215 | 59 |
coding | Solve the programming task below in a Python markdown code block.
We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s_1, s_2, ..., s_{k}. After that, in each of these strings we swapped exactly two characters (the characters we swapped could b... | {"inputs": ["1 2\nyu\n", "1 2\nyu\n", "1 3\nvts\n", "1 3\nvts\n", "2 2\nnm\nnm\n", "2 2\nab\ncd\n", "2 2\nac\nca\n", "2 2\nnm\nnm\n"], "outputs": ["uy\n", "uy\n", "tvs\n", "tvs\n", "mn\n", "-1\n", "-1\n", "mn\n"]} | 448 | 115 |
coding | Solve the programming task below in a Python markdown code block.
There are 2 trains A and B and N stations in a line from 1 to N in order. There is also an array P of length N-1 such that P_{i} (1≤ i < N) denotes the amount of time any train takes to go from the i-th station to the (i+1)-th station.
Initially, both ... | {"inputs": ["3\n2\n4\n3\n3 5\n4\n5 2 6\n"], "outputs": ["8\n13\n19\n"]} | 567 | 38 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.
An array is called good if the parity of each index matches the parity of the element at that index. More formally, ... | {"inputs": ["7\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n", "7\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n", "4\n4\n3 2 7 6\n3\n6 4 4\n1\n7\n7\n7 7 2 2 2 3 2\n", "4\n4\n6 2 7 6\n3\n6 4 4\n1\n7\n7\n6 7 4 2 2 3 2\n", "4\n4\n6 2 7 6\n3\n6 4 4\n1\n8\n7\n6 7 4 2 2 0 2\n", "4\n4\n6 2 7 1\n3\n6 2 4\n1\n8\n7\n6 7 4 2 2 0 2\n"... | 621 | 427 |
coding | Solve the programming task below in a Python markdown code block.
Kulyash believes in equality.
Given an integer N, output a binary string of length N such that:
The count of 01 [subsequences] in the string is equal to the count of 10 subsequences;
The string has at least one occurrence of 0 as well as 1.
If multip... | {"inputs": ["2\n4\n3\n"], "outputs": ["1001\n010\n"]} | 316 | 25 |
coding | Solve the programming task below in a Python markdown code block.
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column f... | {"inputs": ["2 1\nb\na\n", "2 1\nb\na\n", "2 1\nc\na\n", "2 1\nc\nb\n", "2 2\nfb\nye\n", "2 2\nfb\nye\n", "2 2\nbf\nye\n", "2 3\naxc\nbxa\n"], "outputs": ["1\n", "1", "1\n", "1\n", "0\n", "0", "0\n", "0\n"]} | 378 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, return the number of distinct non-empty subsequences of s. Since the answer may be very large, return it modulo 109 + 7.
A subsequence of a string is a new string that is formed from the original str... | {"functional": "def check(candidate):\n assert candidate(s = \"abc\") == 7\n assert candidate(s = \"aba\") == 6\n assert candidate(s = \"aaa\") == 3\n\n\ncheck(Solution().distinctSubseqII)"} | 146 | 57 |
coding | Solve the programming task below in a Python markdown code block.
The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Valid decimal values for RGB are 0 - 255. Any values that fall out of that range must be rounded to the closest ... | {"functional": "_inputs = [[0, 0, 0], [1, 2, 3], [255, 255, 255], [254, 253, 252], [-20, 275, 125]]\n_outputs = [['000000'], ['010203'], ['FFFFFF'], ['FEFDFC'], ['00FF7D']]\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, a... | 241 | 241 |
coding | Solve the programming task below in a Python markdown code block.
Write a method that takes one argument as name and then greets that name, capitalized and ends with an exclamation point.
Example:
```
"riley" --> "Hello Riley!"
"JACK" --> "Hello Jack!"
```
Also feel free to reuse/extend the following starter code:
`... | {"functional": "_inputs = [['riley'], ['molly'], ['BILLY']]\n_outputs = [['Hello Riley!'], ['Hello Molly!'], ['Hello Billy!']]\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... | 83 | 176 |
coding | Solve the programming task below in a Python markdown code block.
Contest T-shirts
Segtree has $ M $ contest T-shirts.
He decided to spend $ N $ days on the contest T-shirt alone, and told $ i = 1, 2, 3, \ dots, N $ "$ A_i $ T-shirt on the $ i $ day." I made a plan for $ N $ to wear.
However, if you keep the current... | {"inputs": ["2 0\n2 2 1", "2 0\n2 0 1", "2 0\n2 0 0", "2 0\n1 0 0", "4 0\n1 0 0", "0 0\n2 2 1", "2 1\n2 0 1", "3 0\n2 0 0"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 350 | 126 |
coding | Solve the programming task below in a Python markdown code block.
A Little Elephant and his friends from the Zoo of Lviv like candies very much.
There are N elephants in the Zoo. The elephant with number K (1 ≤ K ≤ N) will be happy if he receives at least A_{K} candies. There are C candies in all in the Zoo.
The Zoo ... | {"inputs": ["2\n2 3\n1 1\n3 7\n4 2 2", "2\n2 1\n1 1\n3 7\n4 2 2", "2\n2 1\n1 2\n3 7\n0 2 2", "2\n2 2\n1 1\n3 3\n4 1 6", "2\n2 2\n1 1\n3 3\n0 0 3", "2\n2 1\n1 2\n3 7\n4 2 2", "2\n2 1\n2 2\n3 7\n0 2 2", "2\n2 0\n1 1\n3 7\n4 2 2"], "outputs": ["Yes\nNo", "No\nNo\n", "No\nYes\n", "Yes\nNo\n", "Yes\nYes\n", "No\nNo\n", "No\... | 485 | 221 |
coding | Solve the programming task below in a Python markdown code block.
Chef Two and Chef Ten are playing a game with a number $X$. In one turn, they can multiply $X$ by $2$. The goal of the game is to make $X$ divisible by $10$.
Help the Chefs find the smallest number of turns necessary to win the game (it may be possible t... | {"inputs": ["3\n10\n25\n1"], "outputs": ["0\n1\n-1"]} | 261 | 25 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloon... | {"inputs": ["5 3 \n1 2 3 4 5\n1 2 3 4 5"], "outputs": ["15"]} | 623 | 36 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return 0 if the sum of the digits of the minimum integer in nums is odd, or 1 otherwise.
Please complete the following python code precisely:
```python
class Solution:
def sumOfDigit... | {"functional": "def check(candidate):\n assert candidate([34,23,1,24,75,33,54,8]) == 0\n assert candidate([99,77,33,66,55]) == 1\n\n\ncheck(Solution().sumOfDigits)"} | 78 | 73 |
coding | Solve the programming task below in a Python markdown code block.
Burenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions ($\frac{a}{b}$ and $\frac{c}{d}$) with integer numerators and denominators. Then children are commanded to play with their fractions.
Burenka is a... | {"inputs": ["1\n1 2 3 4\n", "1\n2 1 4 3\n", "1\n1 2 3 1\n", "1\n5 8 1 2\n", "1\n3 1 5 1\n", "1\n2 3 3 5\n", "1\n5 3 4 3\n", "1\n3 5 1 7\n"], "outputs": ["2\n", "2\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 522 | 134 |
coding | Solve the programming task below in a Python markdown code block.
Construct an N \times M matrix with entries having positive integers such that:
If M > 1, i^{th} row is strictly increasing from left to right with a fixed common difference d_{i} for all 1≤ i ≤ N.
If N > 1, j^{th} column is strictly increasing from top... | {"inputs": ["3\n3 3\n1 2\n1 1\n"], "outputs": ["1 2 3\n3 6 9\n5 10 15\n1 2\n1\n"]} | 488 | 50 |
coding | Solve the programming task below in a Python markdown code block.
For the human eye, primary colours are red, green, and blue.
Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and... | {"inputs": ["4\n1 0 1\n3 3 0\n1 1 1\n0 0 0\n"], "outputs": ["2\n3\n3\n0"]} | 512 | 43 |
coding | Solve the programming task below in a Python markdown code block.
Lately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia.
The game is played by two people taking turns, where Mr. Chanek takes... | {"inputs": ["2\n5\n6\n", "2\n6\n6\n", "2\n3\n6\n", "2\n4\n6\n", "2\n1\n6\n", "2\n7\n3\n", "2\n8\n3\n", "2\n5\n1\n"], "outputs": ["2\n4\n", "4\n4\n", "2\n4\n", "3\n4\n", "1\n4\n", "3\n2\n", "5\n2\n", "2\n1\n"]} | 394 | 118 |
coding | Solve the programming task below in a Python markdown code block.
You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.
You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one t... | {"inputs": ["1\n1\n100\n", "1\n1\n100\n", "1\n100000000\n1\n", "1\n100000000\n1\n", "5\n5 4 3 7 3\n7 7 14 57 94\n", "5\n5 4 3 7 3\n7 7 14 57 94\n", "5\n5 4 3 7 3\n7 7 14 57 61\n", "5\n5 4 3 7 3\n7 1 14 57 61\n"], "outputs": ["10\n", "10\n", "100000000000\n", "100000000000\n", "89\n", "89\n", "112\n", "118\n"]} | 613 | 228 |
coding | Solve the programming task below in a Python markdown code block.
Chef loves saving money and he trusts none other bank than State Bank of Chefland. Unsurprisingly, the employees like giving a hard time to their customers. But instead of asking them to stand them in long queues, they have weird way of accepting money.
... | {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n1\n1 2\n3\n1 2 4\n7\n1 2 4 8\n15"]} | 632 | 47 |
coding | Solve the programming task below in a Python markdown code block.
Your teacher gave you an assignment — given an integer N, construct a binary string B = b_{1b}_2b_{3}\ldots b_{N} of length N such that:
\max(b_{i}, b_{i+1}) = 1
for every i from 1 to N-1.
What is the minimum number of 1's such a binary string can con... | {"inputs": ["6\n6\n8\n2\n3\n5\n100"], "outputs": ["3\n4\n1\n1\n2\n50"]} | 482 | 37 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1:
Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by ... | {"functional": "def check(candidate):\n assert candidate(nums1 = [4,3,1,4], nums2 = [1,3,7,1], k = 3) == 2\n assert candidate(nums1 = [3,8,5,2], nums2 = [2,4,1,6], k = 1) == -1\n\n\ncheck(Solution().minOperations)"} | 202 | 91 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows
... | {"functional": "def check(candidate):\n assert candidate(arr = [4,2,1,3]) == [[1,2],[2,3],[3,4]]\n assert candidate(arr = [1,3,6,10,15]) == [[1,3]]\n assert candidate(arr = [3,8,-10,23,19,-4,-14,27]) == [[-14,-10],[19,23],[23,27]]\n\n\ncheck(Solution().minimumAbsDifference)"} | 123 | 126 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer $N$. Consider set $S=\{0,\:1,\ldots,\:2^N-1\}$. How many subsets $A\subset S$ with $\bigoplus_{x\in A}x=0$ ($\theta$ denotes xor operation) are there?
Print your answer modulo $(10^9+7)$.
Note that the xorsum of an empty set... | {"inputs": ["2\n1\n2\n"], "outputs": ["2\n4\n"]} | 302 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Consider the following pseudocode, run on an array $A=[a_0,a_1,...,a_{n-1}]$ of length $n$:
rep := 0
while A not empty:
B := []
for x in A, y in A:
if x != y: append absolute_value(x - y) to B
A := B
rep := rep + 1
Given the val... | {"inputs": ["3\n1 3 4\n"], "outputs": ["4\n"]} | 438 | 20 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.