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.
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for ... | {"inputs": ["1\n0\n", "1\n1\n", "2\n00\n", "2\n10\n", "2\n11\n", "2\n01\n", "3\n101\n", "3\n001\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "2\n", "2\n", "3\n", "3\n"]} | 506 | 94 |
coding | Solve the programming task below in a Python markdown code block.
A few years ago, Aaron left his old school and registered at another due to security reasons. Now he wishes to find Jane, one of his schoolmates and good friends.
There are `n` schools numbered from 1 to `n`. One can travel between each pair of schools ... | {"functional": "_inputs = [[2], [10]]\n_outputs = [[0], [4]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n return all... | 169 | 162 |
coding | Solve the programming task below in a Python markdown code block.
Chef Ada is preparing $N$ dishes (numbered $1$ through $N$). For each valid $i$, it takes $C_i$ minutes to prepare the $i$-th dish. The dishes can be prepared in any order.
Ada has a kitchen with two identical burners. For each valid $i$, to prepare the ... | {"inputs": ["3\n3\n2 2 2\n3\n1 2 3\n4\n2 3 4 5"], "outputs": ["4\n3\n7"]} | 570 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares an... | {"inputs": ["0\n0\n", "0\nX\n", "X\n0\n", "X\nX\n", "X\n0\n", "0\nX\n", "X\nX\n", "0\n0\n"], "outputs": ["0", "0", "0", "0", "0\n", "0\n", "0\n", "0\n"]} | 405 | 82 |
coding | Solve the programming task below in a Python markdown code block.
It’s still hot every day, but September has already come. It’s autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. It’s autumn indeed.
When two red dragonflies’ positional information as measur... | {"inputs": ["0 0", "50 0", "58 0", "26 0", "50 6", "84 6", "6 -1", "84 0"], "outputs": ["0\n", "50\n", "58\n", "26\n", "44\n", "78\n", "7\n", "84\n"]} | 207 | 90 |
coding | Solve the programming task below in a Python markdown code block.
Spring has come, and the management of the AvtoBus bus fleet has given the order to replace winter tires with summer tires on all buses.
You own a small bus service business and you have just received an order to replace $n$ tires. You know that the bus... | {"inputs": ["1\n25000\n", "4\n4\n7\n24\n998244353998244352\n"], "outputs": ["4167 6250\n", "1 1\n-1\n4 6\n166374058999707392 249561088499561088\n"]} | 542 | 109 |
coding | Solve the programming task below in a Python markdown code block.
problem
A mysterious $ X $ [cm] plant grows in one place. This plant has the following mysterious properties.
* Say "nobiro" to this plant and it will grow $ A $ [cm].
* Say "tidime" to this plant and it will grow $ B $ [cm].
* If you say "karero" to t... | {"inputs": ["8 48 5\n0\norioan\nnnciro\ndmifit", "7 48 5\n0\norioan\nnncior\ndmifit", "9 30 9\n0\nnoairo\noribon\nmidite", "4 30 5\n0\nnoairo\nnobiro\ntieimd", "3 30 5\n0\nnoairo\nnobiro\ntidime", "5 48 5\n0\norioan\nnncios\ndmifiu", "25 9 5\n0\norioan\nnobiro\nuifimd", "1 41 1\n0\norioan\nnncior\ndmifit"], "outputs": ... | 253 | 207 |
coding | Solve the programming task below in a Python markdown code block.
An eviternity number is a number which:
* contains only digits 8, 5 and 3, and
* the count of the digit `8` >= count of digit `5` >= count of digit `3`.
The first few eviternity numbers are as follows.
```Haskell
[8, 58, 85, 88, 358, 385, 538, 583, 5... | {"functional": "_inputs = [[0, 100], [0, 1000], [0, 10000], [0, 100000], [0, 500000], [90, 139701], [61, 56976]]\n_outputs = [[4], [14], [37], [103], [148], [99], [53]]\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_t... | 319 | 249 |
coding | Solve the programming task below in a Python markdown code block.
There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.
(Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi remembers (x_... | {"inputs": ["2 1 6 6", "2 2 6 6", "2 2 6 2", "2 2 6 1", "3 2 6 2", "6 2 6 2", "6 2 6 3", "2 2 6 3"], "outputs": ["1 10 -3 5\n", "2 10 -2 6\n", "6 6 2 6\n", "7 5 3 6\n", "6 5 3 5\n", "6 2 6 2\n", "5 3 5 2\n", "5 7 1 6\n"]} | 386 | 160 |
coding | Solve the programming task below in a Python markdown code block.
For encrypting strings this region of chars is given (in this order!):
* all letters (ascending, first all UpperCase, then all LowerCase)
* all digits (ascending)
* the following chars: `.,:;-?! '()$%&"`
These are 77 chars! (This region is zero-based.... | {"functional": "_inputs = [[\"$-Wy,dM79H'i'o$n0C&I.ZTcMJw5vPlZc Hn!krhlaa:khV mkL;gvtP-S7Rt1Vp2RV:wV9VuhO Iz3dqb.U0w\"], ['5MyQa9p0riYplZc'], [\"5MyQa79H'ijQaw!Ns6jVtpmnlZ.V6p\"], [''], [None]]\n_outputs = [['Do the kata \"Kobayashi-Maru-Test!\" Endless fun and excitement when finding a solution!'], ['This is a test!']... | 508 | 307 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?
Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:
- Whe... | {"inputs": ["3", "2", "1", "0", "1\n", "60", "91", "79"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 222 | 66 |
coding | Solve the programming task below in a Python markdown code block.
We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`.
Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times:
* Among the occurrences of `ST` in X as (c... | {"inputs": ["STTTSS", "SSSTTT", "TTTSSS", "TSTSST", "SSTTTS", "TSSTST", "STTSST", "TSSSTT"], "outputs": ["4\n", "0\n", "6\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 216 | 81 |
coding | Solve the programming task below in a Python markdown code block.
We’ve all seen katas that ask for conversion from snake-case to camel-case, from camel-case to snake-case, or from camel-case to kebab-case — the possibilities are endless.
But if we don’t know the case our inputs are in, these are not very helpful.
##... | {"functional": "_inputs = [['hello-world'], ['hello-to-the-world'], ['hello_world'], ['hello_to_the_world'], ['helloWorld'], ['helloToTheWorld'], ['hello-World'], ['hello-To-The-World'], ['good-Night'], ['he--llo'], ['good-night'], ['good_night'], ['goodNight'], ['hello_World'], ['hello_To_The_World'], ['he_lloWorld'],... | 557 | 320 |
coding | Solve the programming task below in a Python markdown code block.
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.
T... | {"inputs": ["5\n2 1 8 15 3\n", "5\n0 1 8 15 3\n", "5\n1 1 8 15 3\n", "5\n1 2 8 15 3\n", "5\n1 2 9 15 3\n", "5\n1 2 9 15 4\n", "5\n0 2 9 15 4\n", "5\n15 1 8 15 3\n"], "outputs": ["0 -1 1 0 -1 ", "-1 -1 1 0 -1 ", "-1 -1 1 0 -1 ", "-1 -1 1 0 -1 ", "-1 -1 1 0 -1 ", "-1 -1 1 0 -1 ", "-1 -1 1 0 -1 ", "3 -1 1 0 -1 "]} | 438 | 216 |
coding | Solve the programming task below in a Python markdown code block.
Write a program to take two numbers as input and print their difference if the first number is greater than the second number otherwise$otherwise$ print their sum.
-----Input:-----
- First line will contain the first number (N1$N1$)
- Second line will c... | {"inputs": ["82\n28"], "outputs": ["54"]} | 226 | 17 |
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.
# Task
Given an array of 2^(k) integers (for some integer `k`), perform the following operations until the array contains only one element:
```
On the 1st, 3rd, 5th, etc.
iterations (1-based) replace each pair of consecutive elements with their sum;
On... | {"functional": "_inputs = [[[1, 2, 3, 4, 5, 6, 7, 8]], [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], [[3, 3, 5, 5]]]\n_outputs = [[186], [64], [60]]\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 i... | 310 | 245 |
coding | Solve the programming task below in a Python markdown code block.
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr c... | {"inputs": ["9 4 3\n", "1 0 0\n", "6 5 5\n", "5 4 0\n", "9 4 4\n", "6 0 5\n", "3 0 1\n", "9 3 4\n"], "outputs": ["4", "1", "1", "1", "5\n", "6\n", "2\n", "5\n"]} | 178 | 98 |
coding | Solve the programming task below in a Python markdown code block.
There is a directed graph with N vertices numbered 1 to N and M edges.
The i-th edge is directed from Vertex A_i to Vertex B_i, and there are C_i coins placed along that edge.
Additionally, there is a button on Vertex N.
We will play a game on this graph... | {"inputs": ["2 1 0\n1 2 1\n", "2 2 0\n1 2 1\n1 1 1\n", "2 2 1\n1 2 1\n2 2 1\n", "2 2 0\n1 2 1\n1 2 2\n", "2 2 1\n2 1 2\n1 2 1\n", "2 1 10\n1 2 100\n2 2 100", "2 1 13\n1 2 100\n4 2 100", "2 1 13\n1 2 101\n4 2 100"], "outputs": ["1\n", "-1\n", "0\n", "2\n", "-1\n", "90\n", "87\n", "88\n"]} | 672 | 207 |
coding | Solve the programming task below in a Python markdown code block.
You are given a book with $n$ chapters.
Each chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list... | {"inputs": ["5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1\n1 2\n1 3\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 3\n0\n0\n2 3 2\n5\n1 2\n1 3\n1 4\n1 5\n0\n"], "outputs": ["2\n-1\n1\n2\n5\n"]} | 708 | 123 |
coding | Solve the programming task below in a Python markdown code block.
The new £5 notes have been recently released in the UK and they've certainly became a sensation! Even those of us who haven't been carrying any cash around for a while, having given in to the convenience of cards, suddenly like to have some of these in t... | {"functional": "_inputs = [[2000, [500, 160, 400]], [1260, [500, 50, 100]], [3600, [1800, 350, 460, 500, 15]], [1995, [1500, 19, 44]], [10000, [1800, 500, 1200, 655, 150]], [2300, [590, 1500, 45, 655, 150]], [5300, [1190, 1010, 1045, 55, 10, 19, 55]], [2000, [500, 495, 100, 900]], [2000, [500, 496, 100, 900]], [2000, [... | 201 | 465 |
coding | Solve the programming task below in a Python markdown code block.
One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from aliens! The scientists now want to ... | {"inputs": ["01\naaaaaa\n", "01\naabaaa\n", "01\naabbaa\n", "01\nbabbaa\n", "01\ncabbaa\n", "01\nbacbaa\n", "01\naacbaa\n", "01\naacaaa\n"], "outputs": ["4\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n"]} | 552 | 108 |
coding | Solve the programming task below in a Python markdown code block.
Everyone Knows AdFly and their Sister Sites.
If we see the Page Source of an ad.fly site we can see this perticular line:
Believe it or not This is actually the Encoded url which you would skip to.
The Algorithm is as Follows:
```
1) The ysmm value is ... | {"functional": "_inputs = [['O=T0ZToPdRHJRmwdcOz1oGvTL22lFzkRZhih5GsbezSw9kndbvyR50wYawHIAF/SdhT1'], ['N=z0dDoMdyHIRmwac1zMolvWLz2RFmkMZiiZ5HsZeySw9kndbvyR50wYawHIAF/SdhT1'], ['lololol']]\n_outputs = [['http://yahoo.com'], ['http://google.com'], ['Invalid']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstanc... | 326 | 266 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array prices where prices[i] is the price of a given stock on the ith day.
Find the maximum profit you can achieve. You may complete at most two transactions.
Note: You may not engage in multiple tran... | {"functional": "def check(candidate):\n assert candidate(prices = [3,3,5,0,0,3,1,4]) == 6\n assert candidate(prices = [1,2,3,4,5]) == 4\n assert candidate(prices = [7,6,4,3,1] ) == 0 \n assert candidate(prices = [1]) == 0\n\n\ncheck(Solution().maxProfit)"} | 110 | 103 |
coding | Solve the programming task below in a Python markdown code block.
We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after the merging step it will become "aba".
Given a string, you have to find two values: the number... | {"inputs": ["a\n", "a\n", "b\n", "bb\n", "aa\n", "bb\n", "ab\n", "ba\n"], "outputs": ["0 1\n", "0 1\n", "0 1\n", "1 2\n", "1 2\n", "1 2\n", "0 2\n", "0 2\n"]} | 434 | 86 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Below we will define what and n-interesting polygon is and your task is to find its area for a given n.
A 1-interesting polygon is just a square with a side of length 1. An n-interesting polygon is obtained by taking the n - 1-interesting polyg... | {"functional": "_inputs = [[2], [3], [1], [5]]\n_outputs = [[5], [13], [1], [41]]\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 Fals... | 249 | 174 |
coding | Solve the programming task below in a Python markdown code block.
There is an integer array $\boldsymbol{d}$ which does not contain more than two elements of the same value. How many distinct ascending triples ($d[i]<d[j]<d[k],i<j<k$) are present?
Input format
The first line contains an integer, $N$, denoting the n... | {"inputs": ["6\n1 1 2 2 3 4\n"], "outputs": ["4\n"]} | 267 | 26 |
coding | Solve the programming task below in a Python markdown code block.
There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if h... | {"inputs": ["3 2 1 2\n6 2 2\n", "3 2 1 2\n3 1 2\n", "3 2 1 2\n6 3 2\n", "3 2 1 2\n3 6 3\n", "3 2 0 2\n3 3 9\n", "3 2 0 2\n4 5 1\n", "3 2 0 2\n1 3 2\n", "3 2 1 2\n5 9 3\n"], "outputs": ["0\n", "6\n", "3\n", "6\n", "0\n", "3\n", "3\n", "9\n"]} | 535 | 166 |
coding | Solve the programming task below in a Python markdown code block.
*This kata is inspired by [Project Euler Problem #387](https://projecteuler.net/problem=387)*
---
A [Harshad number](https://en.wikipedia.org/wiki/Harshad_number) (or Niven number) is a number that is divisible by the sum of its digits. A *right trunca... | {"functional": "_inputs = [[0, 20], [30, 100], [90, 200], [200, 210], [1000, 2000], [2200, 2300], [9000002182976, 9000195371842]]\n_outputs = [[[10, 12, 18, 20]], [[30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100]], [[90, 100, 102, 108, 120, 126, 180, 200]], [[200, 201, 204, 207, 209, 210]], [[1000,... | 735 | 503 |
coding | Solve the programming task below in a Python markdown code block.
It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows.
* 3 Play the game.
* The person who gets 11 points f... | {"inputs": ["AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0", "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBABBBB\n0", "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABAABBA... | 453 | 680 |
coding | Solve the programming task below in a Python markdown code block.
Make a program that filters a list of strings and returns a list with only your friends name in it.
If a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not...
Ex: Input = ["Ryan", ... | {"functional": "_inputs = [[['Ryan', 'Kieran', 'Mark']], [['Ryan', 'Jimmy', '123', '4', 'Cool Man']], [['Jimm', 'Cari', 'aret', 'truehdnviegkwgvke', 'sixtyiscooooool']], [['Love', 'Your', 'Face', '1']], [['Hell', 'Is', 'a', 'badd', 'word']], [['Issa', 'Issac', 'Issacs', 'ISISS']], [['Robot', 'Your', 'MOMOMOMO']], [['Yo... | 132 | 378 |
coding | Solve the programming task below in a Python markdown code block.
There are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.
The color of the i-th square from the left is black if the i-th character of S is `B`, and white if that character is `W... | {"inputs": ["2\nBWWB", "4\nBWWWBBWB", "4\nBWBBWBWW", "4\nBWBBWBWX", "4\nBWBBWCWW", "4\nBWABWCWW", "4\nBWABVCWW", "4\nBBAWVCWW"], "outputs": ["4", "288\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 363 | 103 |
coding | Solve the programming task below in a Python markdown code block.
Read problem statements in [Vietnamese],
[Bengali], [Mandarin Chinese], and [Russian] as well.
Chefland has 2 different types of coconut, type A and type B. Type A contains only x_{a} milliliters of coconut water and type B contains only x_{b} grams of... | {"inputs": ["3\n100 400 1000 1200\n100 450 1000 1350\n150 400 1200 1200"], "outputs": ["13\n13\n11"]} | 686 | 73 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.
Return the number of ways to color the grid with n... | {"functional": "def check(candidate):\n assert candidate(m = 1, n = 1) == 3\n assert candidate(m = 1, n = 2) == 6\n assert candidate(m = 5, n = 5) == 580986\n\n\ncheck(Solution().colorTheGrid)"} | 130 | 76 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Please complete the following python code precisely:
```python
class So... | {"functional": "def check(candidate):\n assert candidate(strs = [\"flower\",\"flow\",\"flight\"]) == \"fl\"\n assert candidate(strs = [\"dog\",\"racecar\",\"car\"]) == \"\"\n\n\ncheck(Solution().longestCommonPrefix)"} | 78 | 61 |
coding | Solve the programming task below in a Python markdown code block.
Chef loves to play with arrays by himself. Today, he has an array A consisting of N distinct integers. He wants to perform the following operation on his array A.
- Select a pair of adjacent integers and remove the larger one of these two. This decrease... | {"inputs": ["2\n2\n3 4\n3\n4 2 5", "2\n2\n3 4\n3\n4 2 9", "2\n2\n3 4\n3\n0 2 5", "2\n2\n0 4\n3\n4 0 9", "2\n2\n0 4\n3\n7 2 9", "2\n2\n0 4\n3\n4 1 9", "2\n2\n1 4\n3\n4 2 9", "2\n2\n1 4\n3\n3 0 4"], "outputs": ["3\n4", "3\n4\n", "3\n0\n", "0\n0\n", "0\n4\n", "0\n2\n", "1\n4\n", "1\n0\n"]} | 361 | 189 |
coding | Solve the programming task below in a Python markdown code block.
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selectio... | {"inputs": ["3 8\n9 6 9", "3 8\n6 6 6", "3 8\n9 9 9", "3 8\n6 6 9", "3 8\n15 6 9", "3 8\n15 3 9", "3 8\n15 2 9", "1 11\n2 0 7"], "outputs": ["1\n", "0\n", "0\n", "0", "0\n", "0\n", "0\n", "0\n"]} | 334 | 129 |
coding | Solve the programming task below in a Python markdown code block.
We will define Ginkgo numbers and multiplication on Ginkgo numbers.
A Ginkgo number is a pair <m, n> where m and n are integers. For example, <1, 1>, <-2, 1> and <-3,-1> are Ginkgo numbers.
The multiplication on Ginkgo numbers is defined by <m, n> * <x... | {"inputs": ["8\n2 0\n1 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 0\n2 0", "8\n10 -1\n0 2\n0 3\n4 0\n2 -25\n-4 0\n-2 0\n2 0", "8\n10 -1\n0 2\n0 3\n8 0\n2 -23\n-4 0\n-2 1\n2 0", "8\n2 0\n1 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 0\n2 -1", "8\n10 -1\n0 2\n0 3\n4 1\n2 -23\n-4 0\n-2 0\n2 0", "8\n4 0\n0 2\n-3 1\n4 2\n0 -32\n-4 0\n-3 0\n2 -1", "8\... | 635 | 462 |
coding | Solve the programming task below in a Python markdown code block.
Complete the `greatestProduct` method so that it'll find the greatest product of five consecutive digits in the given string of digits.
For example:
The input string always has more than five digits.
Adapted from Project Euler.
Also feel free to reuse... | {"functional": "_inputs = [['123834539327238239583'], ['395831238345393272382'], ['92494737828244222221111111532909999'], ['02494037820244202221011110532909999']]\n_outputs = [[3240], [3240], [5292], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return m... | 81 | 290 |
coding | Solve the programming task below in a Python markdown code block.
Given two integers `a` and `b`, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return `a` or `b`.
**Note:** `a` and `b` are not ordered!
## Examples
```python
g... | {"functional": "_inputs = [[0, 1], [1, 2], [5, -1], [505, 4], [321, 123], [0, -1], [-50, 0], [-1, -5], [-5, -5], [-505, 4], [-321, 123], [0, 0], [-5, -1], [5, 1], [-17, -17], [17, 17]]\n_outputs = [[1], [3], [14], [127759], [44178], [-1], [-1275], [-15], [-5], [-127755], [-44055], [0], [-15], [15], [-17], [17]]\nimport... | 378 | 336 |
coding | Solve the programming task below in a Python markdown code block.
You are given an $array$ of size $N$ and an integer $K$ ( $N > 1 , K > 0$ ).
Each element in the array can be incremented by $K$ or decremented by $K$ $at$ $most$ $once$.
So there will be $3^n$ possible combinations of final array. (As there are 3 optio... | {"inputs": ["2\n4 3\n4 2 5 1\n3 5\n2 5 3"], "outputs": ["10\n13"]} | 335 | 38 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A password is said to be strong if it satisfies all the following criteria:
It has at least 8 characters.
It contains at least one lowercase letter.
It contains at least one uppercase letter.
It contains at least one... | {"functional": "def check(candidate):\n assert candidate(password = \"IloveLe3tcode!\") == True\n assert candidate(password = \"Me+You--IsMyDream\") == False\n assert candidate(password = \"1aB!\") == False\n\n\ncheck(Solution().strongPasswordCheckerII)"} | 173 | 69 |
coding | Solve the programming task below in a Python markdown code block.
Chef is multi-talented. He has developed a cure for coronavirus called COVAC-19. Now that everyone in the world is infected, it is time to distribute it throughout the world efficiently to wipe out coronavirus from the Earth. Chef just cooks the cure, yo... | {"inputs": ["3\n5 5\n1 2 3 4 5\n5 1\n40 30 20 10 50\n3 10\n20 1 110"], "outputs": ["5\n9\n6"]} | 633 | 63 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.
For each string in targetWords, check if it is possible to choose a string from startWo... | {"functional": "def check(candidate):\n assert candidate(startWords = [\"ant\",\"act\",\"tack\"], targetWords = [\"tack\",\"act\",\"acti\"]) == 2\n assert candidate(startWords = [\"ab\",\"a\"], targetWords = [\"abc\",\"abcd\"]) == 1\n\n\ncheck(Solution().wordCount)"} | 311 | 80 |
coding | Solve the programming task below in a Python markdown code block.
We define the score of permutations of combinations, of an integer number (the function to obtain this value:```sc_perm_comb```) as the total sum of all the numbers obtained from the permutations of all the possible combinations of its digits.
For exampl... | {"functional": "_inputs = [[348], [340], [333], [6], [0]]\n_outputs = [[3675], [1631], [369], [6], [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_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) ... | 359 | 193 |
coding | Solve the programming task below in a Python markdown code block.
# Task
A robot is standing at the `(0, 0)` point of the Cartesian plane and is oriented towards the vertical (y) axis in the direction of increasing y values (in other words, he's facing up, or north). The robot executes several commands each of which i... | {"functional": "_inputs = [[[4, 4, 3, 2, 2, 3]], [[7, 5, 4, 5, 2, 3]], [[10, 3, 10, 2, 5, 1, 2]], [[11, 8, 6, 6, 4, 3, 7, 2, 1]], [[5, 5, 5, 5]], [[34241, 23434, 2341]], [[9348, 2188, 9348]]]\n_outputs = [[True], [True], [False], [True], [True], [False], [False]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isin... | 349 | 306 |
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 n villages in a line in an area. There are two kinds of tribes A and B that reside there. A village can be either empty or occupied by one of the tribes. An empty v... | {"inputs": ["4\nA..A..B...B\n..A..\nA....A\n..B..B..B.."], "outputs": ["4 5\n1 0\n6 0\n0 7"]} | 334 | 50 |
coding | Solve the programming task below in a Python markdown code block.
=====Problem Statement=====
We have seen that lists are mutable (they can be changed), and tuples are immutable (they cannot be changed).
Let's try to understand this with an example.
You are given an immutable string, and you want to make changes to i... | {"functional": "_inputs = [['abracadabra', 5, 'k']]\n_outputs = ['abrackdabra']\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\... | 400 | 165 |
coding | Solve the programming task below in a Python markdown code block.
You start with a value in dollar form, e.g. $5.00. You must convert this value to a string in which the value is said, like '5 dollars' for example. This should account for ones, cents, zeroes, and negative values. Here are some examples:
```python
dolla... | {"functional": "_inputs = [['$20.18'], ['$5.62'], ['$83.47'], ['$16.93'], ['$0.00'], ['$0.01'], ['$0.63'], ['$0.28'], ['$1.00'], ['$2.00'], ['$31.00'], ['$45.00'], ['$-5843.21'], ['$-45.32'], ['$-2.63'], ['$-234.48']]\n_outputs = [['20 dollars and 18 cents.'], ['5 dollars and 62 cents.'], ['83 dollars and 47 cents.'], ... | 227 | 382 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
We distribute some number of candies, to a row of n = num_people people in the following way:
We then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last per... | {"functional": "def check(candidate):\n assert candidate(candies = 7, num_people = 4) == [1,2,3,1]\n assert candidate(candies = 10, num_people = 3) == [5,2,3]\n\n\ncheck(Solution().distributeCandies)"} | 244 | 75 |
coding | Solve the programming task below in a Python markdown code block.
You are given a string $t$ consisting of $n$ lowercase Latin letters and an integer number $k$.
Let's define a substring of some string $s$ with indices from $l$ to $r$ as $s[l \dots r]$.
Your task is to construct such string $s$ of minimum possible le... | {"inputs": ["1 1\na\n", "1 1\na\n", "1 50\nq\n", "2 4\naa\n", "2 2\noo\n", "2 2\naa\n", "2 1\naa\n", "2 2\nab\n"], "outputs": ["a\n", "a\n", "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n", "aaaaa\n", "ooo\n", "aaa\n", "aa\n", "abab\n"]} | 299 | 129 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a bookstore owner that has a store open for n minutes. You are given an integer array customers of length n where customers[i] is the number of the customers that enter the store at the start of the ith minut... | {"functional": "def check(candidate):\n assert candidate(customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3) == 16\n assert candidate(customers = [1], grumpy = [0], minutes = 1) == 1\n\n\ncheck(Solution().maxSatisfied)"} | 225 | 97 |
coding | Solve the programming task below in a Python markdown code block.
Chef published a blog post, and is now receiving many queries about it. On day $i$, he receives $Q_i$ queries. But Chef can answer at most $k$ queries in a single day.
Chef always answers the maximum number of questions that he can on any given day (not... | {"inputs": ["2\n6 5\n10 5 5 3 2 1\n1 1\n100"], "outputs": ["6\n101"]} | 709 | 41 |
coding | Solve the programming task below in a Python markdown code block.
You have two arrays of integers, $V=\{V_1,V_2,\ldots,V_N\}$ and $P=\{P_1,P_2,\ldots,P_N\}$, where both have $N$ number of elements. Consider the following function:
score = 0
int Go(step, energy) {
if (step == N) {
score += V[step];
... | {"inputs": ["4\n4 2\n0 2\n4 0\n3 4\n"], "outputs": ["7\n"]} | 456 | 30 |
coding | Solve the programming task below in a Python markdown code block.
There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perform th... | {"inputs": ["3\n1 2\n1 3", "3\n0 2\n2 3", "3\n1 1\n2 3", "3\n1 1\n2 2", "3\n1 2\n2 3", "4\n1 2\n2 3\n2 3", "4\n1 2\n1 3\n2 4", "4\n1 2\n2 3\n2 2"], "outputs": ["First\n", "First\n", "First\n", "First\n", "First", "First\n", "Second\n", "First\n"]} | 375 | 137 |
coding | Solve the programming task below in a Python markdown code block.
This is a very simply formulated task. Let's call an integer number `N` 'green' if `N²` ends with all of the digits of `N`. Some examples:
`5` is green, because `5² = 25` and `25` ends with `5`.
`11` is not green, because `11² = 121` and `121` does not... | {"functional": "_inputs = [[1], [2], [3], [4], [12], [13], [100], [110]]\n_outputs = [[1], [5], [6], [25], [2890625], [7109376], [6188999442576576769103890995893380022607743740081787109376], [9580863811000557423423230896109004106619977392256259918212890625]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstanc... | 303 | 335 |
coding | Solve the programming task below in a Python markdown code block.
There is a grid with $n$ rows and $m$ columns. Some cells are colored black, and the rest of the cells are colored white.
In one operation, you can select some black cell and do exactly one of the following:
color all cells in its row black, or
color ... | {"inputs": ["1\n3 3 1 1\nWWW\nWWW\nWWB\n", "1\n4 4 1 4\nWWWW\nWWWW\nWBWW\nWWWW\n", "9\n3 5 1 4\nWBWWW\nBBBWB\nWWBBB\n4 3 2 1\nBWW\nBBW\nWBB\nWWB\n2 3 2 2\nWWW\nWWW\n2 2 1 1\nWW\nWB\n5 9 5 9\nWWWWWWWWW\nWBWBWBBBW\nWBBBWWBWW\nWBWBWBBBW\nWWWWWWWWW\n1 1 1 1\nB\n1 1 1 1\nW\n1 2 1 1\nWB\n2 1 1 1\nW\nB\n"], "outputs": ["2\n",... | 709 | 225 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.
You are given a string keysPressed of length n, where keysPressed[i] was the ith key pressed in the testing sequence, and... | {"functional": "def check(candidate):\n assert candidate(releaseTimes = [9,29,49,50], keysPressed = \"cbcd\") == \"c\"\n assert candidate(releaseTimes = [12,23,36,46,62], keysPressed = \"spuda\") == \"a\"\n\n\ncheck(Solution().slowestKey)"} | 281 | 86 |
coding | Solve the programming task below in a Python markdown code block.
## Emotional Sort ( ︶︿︶)
You'll have a function called "**sortEmotions**" that will return an array of **emotions** sorted. It has two parameters, the first parameter called "**arr**" will expect an array of **emotions** where an **emotion** will be one... | {"functional": "_inputs = [[[':D', 'T_T', ':D', ':('], True], [['T_T', ':D', ':(', ':('], True], [[':)', 'T_T', ':)', ':D', ':D'], True], [[':D', 'T_T', ':D', ':('], False], [['T_T', ':D', ':(', ':('], False], [[':)', 'T_T', ':)', ':D', ':D'], False], [[], False], [[], True]]\n_outputs = [[[':D', ':D', ':(', 'T_T']], [... | 439 | 334 |
coding | Solve the programming task below in a Python markdown code block.
You have a multiset containing several integers. Initially, it contains $a_1$ elements equal to $1$, $a_2$ elements equal to $2$, ..., $a_n$ elements equal to $n$.
You may apply two types of operations: choose two integers $l$ and $r$ ($l \le r$), then... | {"inputs": ["1\n1\n", "1\n0\n", "1\n0\n", "1\n1\n", "1\n2\n", "1\n3\n", "1\n4\n", "1\n6\n"], "outputs": ["1\n", "0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 336 | 86 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit.
Return the minimum number of elements you need to add to make the sum of the ... | {"functional": "def check(candidate):\n assert candidate(nums = [1,-1,1], limit = 3, goal = -4) == 2\n assert candidate(nums = [1,-10,9,1], limit = 100, goal = 0) == 1\n\n\ncheck(Solution().minElements)"} | 138 | 76 |
coding | Solve the programming task below in a Python markdown code block.
This is the performance version of [this kata](https://www.codewars.com/kata/59afff65f1c8274f270020f5).
---
Imagine two rings with numbers on them. The inner ring spins clockwise and the outer ring spins anti-clockwise. We start with both rings aligned... | {"functional": "_inputs = [[5, 5], [2, 10], [10, 2], [7, 9], [1, 1], [16777216, 14348907]]\n_outputs = [[3], [13], [10], [4], [1], [23951671]]\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... | 431 | 230 |
coding | Solve the programming task below in a Python markdown code block.
Chef's current score is X. Each second, Chef will find the smallest [prime factor] of his score and add it to his score.
Determine the minimum time in seconds, after which his score becomes ≥ Y.
------ Input Format ------
- The first line of input wi... | {"inputs": ["4\n2 23\n9 20\n5 100\n6 89\n"], "outputs": ["11\n5\n46\n42\n"]} | 546 | 44 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Sereja is hosting his birthday dinner. He invited his N close friends. Let us number the people from 1 to N according to the order in which they arrive at the event. The dinner is being held in ... | {"inputs": ["3\n1\n0\n3\n0 0 0\n5\n0 1 2 1 4"], "outputs": ["0\n0\n3"]} | 594 | 40 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given positive integers n and target.
An array nums is beautiful if it meets the following conditions:
nums.length == n.
nums consists of pairwise distinct positive integers.
There doesn't exist two distinct ... | {"functional": "def check(candidate):\n assert candidate(n = 2, target = 3) == 4\n assert candidate(n = 3, target = 3) == 8\n assert candidate(n = 1, target = 1) == 1\n\n\ncheck(Solution().minimumPossibleSum)"} | 141 | 71 |
coding | Solve the programming task below in a Python markdown code block.
In this kata you will be given an **integer n**, which is the number of times that is thown a coin. You will have to return an array of string for all the possibilities (heads[H] and tails[T]). Examples:
```coin(1) should return {"H", "T"}```
```coin(2) ... | {"functional": "_inputs = [[1], [2], [3]]\n_outputs = [[['H', 'T']], [['HH', 'HT', 'TH', 'TT']], [['HHH', 'HHT', 'HTH', 'HTT', 'THH', 'THT', 'TTH', 'TTT']]]\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 ... | 275 | 209 |
coding | Solve the programming task below in a Python markdown code block.
Maya writes weekly articles to a well known magazine, but she is missing one word each time she is about to send the article to the editor. The article is not complete without this word. Maya has a friend, Dan, and he is very good with words, but he does... | {"functional": "_inputs = [[637], [7468], [49632], [1425], [6250], [12674], [4735], [7345], [3850], [2394], [2068], [137], [1065], [6509], [3549], [5394], [56124], [968], [103247], [67935], [7415], [2687], [261], [8054], [942547]]\n_outputs = [['aid'], ['dean'], ['email'], ['belt'], ['alto'], ['blade'], ['edit'], ['die... | 308 | 382 |
coding | Solve the programming task below in a Python markdown code block.
You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.
The boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c... | {"inputs": ["1\n4\n1 1\n1 1\n2 2\n3 4\n", "1\n4\n1 1\n1 1\n2 2\n3 4\n", "1\n4\n2 1\n1 1\n2 2\n3 4\n", "1\n4\n1 0\n1 2\n2 3\n3 4\n", "1\n4\n2 2\n1 1\n1 2\n3 8\n", "1\n4\n1 0\n2 2\n2 3\n3 0\n", "1\n4\n1 0\n1 1\n2 2\n3 6\n", "1\n4\n1 0\n1 4\n2 3\n3 4\n"], "outputs": ["4\n", "4\n", "4\n", "5\n", "8\n", "3\n", "6\n", "7\n"]... | 607 | 214 |
coding | Solve the programming task below in a Python markdown code block.
There are N positive integers written on a blackboard: A_1, ..., A_N.
Snuke can perform the following operation when all integers on the blackboard are even:
- Replace each integer X on the blackboard by X divided by 2.
Find the maximum possible number ... | {"inputs": ["3\n4 7 31", "3\n4 7 52", "3\n7 7 52", "3\n7 7 25", "3\n7 13 5", "3\n7 13 8", "3\n6 12 31", "3\n4 12 31"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 311 | 120 |
coding | Solve the programming task below in a Python markdown code block.
Takahashi and Aoki are going to together construct a sequence of integers.
First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:
- The length of a is N.
- Each element in a is an integer between 1 and K, in... | {"inputs": ["1 5", "2 2", "2 4", "2 0", "4 4", "6 4", "2 3", "2 6"], "outputs": ["5\n", "2\n", "4\n", "0\n", "28\n", "184\n", "3\n", "6\n"]} | 317 | 81 |
coding | Solve the programming task below in a Python markdown code block.
"I'm a fan of anything that tries to replace actual human contact." - Sheldon.
After years of hard work, Sheldon was finally able to develop a formula which would diminish the real human contact.
He found k$k$ integers n1,n2...nk$n_1,n_2...n_k$ . Also ... | {"inputs": ["1\n1\n5"], "outputs": ["2"]} | 497 | 16 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef’s girlfriend's birthday is near, so he wants to surprise her by making a special cake for her. Chef knows that his girlfriend likes cherries on the cake, so he puts cher... | {"inputs": ["2\n4 5\nRGRGR\nGRGRG\nRGRGR\nGRGRG\n2 3\nRRG\nGGR"], "outputs": ["0\n8"]} | 444 | 44 |
coding | Solve the programming task below in a Python markdown code block.
We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).
Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?
We remind you that the distance... | {"inputs": ["4 5\n0 5\n-2 4\n3 4\n4 -4\n", "12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n", "20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n... | 365 | 371 |
coding | Solve the programming task below in a Python markdown code block.
Now that you have won Code Monk and been hired by HackerEarth as a software engineer, you have been assigned to work on their wildly popular programming contest website.
HackerEarth is expecting a lot of participants (P) in Code Monk next year, and they... | {"inputs": ["2\n19 57 3\n24 97 2", "4\n50 700 2\n19 57 3\n1 1000 2\n24 97 2"], "outputs": ["Case #1: 0\nCase #2: 2", "Case #1: 2\nCase #2: 0\nCase #3: 4\nCase #4: 2"]} | 559 | 106 |
coding | Solve the programming task below in a Python markdown code block.
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, an... | {"inputs": ["1 2", "0 0", "8 0", "1 7", "2 2", "0 -1", "54 8", "60 4"], "outputs": ["0\n", "4\n", "-12\n", "5", "0", "6\n", "312\n", "116\n"]} | 263 | 83 |
coding | Solve the programming task below in a Python markdown code block.
In the previous challenge, you wrote code to perform an Insertion Sort on an unsorted array. But how would you prove that the code is correct? I.e. how do you show that for any input your code will provide the right output?
Loop Invariant
In computer ... | {"inputs": ["6\n7 4 3 5 6 2\n"], "outputs": ["2 3 4 5 6 7\n"]} | 653 | 36 |
coding | Solve the programming task below in a Python markdown code block.
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequen... | {"inputs": ["3\naabce\nace\nabacaba\naax\nty\nyyt\n", "3\naabce\nace\nabbcaaa\naax\nty\nyyt\n", "3\naabcf\nace\nabbcaaa\naax\nty\nyyt\n", "3\necbaa\nace\nabbcaaa\naax\nty\nyyt\n", "3\nbaacf\nace\nabbcaaa\naax\nty\nyyt\n", "3\naabce\nace\nabacaba\naax\nty\nyyt\n", "11\na\naaaaaaaaaaa\ncba\nabcabcabcabcabcabcabc\nbvdhsdv... | 430 | 453 |
coding | Solve the programming task below in a Python markdown code block.
Daenerys Targaryen has been suggested by her counselors to leave the Meereen and start conquering other parts of the world. But she knows giving up on the people of Meereen means victory of slavery. Her plan is to start conquering rest of the world while... | {"inputs": ["3\n5 3\n1 2 3 4 5\n6 2\n4 4 4 4 4 4\n7 4\n10 10 10 10 50 60 70"], "outputs": ["VICTORY\nVICTORY\nDEFEAT"]} | 705 | 77 |
coding | Solve the programming task below in a Python markdown code block.
# Task
Given a square `matrix`, your task is to reverse the order of elements on both of its longest diagonals.
The longest diagonals of a square matrix are defined as follows:
* the first longest diagonal goes from the top left corner to the bottom ri... | {"functional": "_inputs = [[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], [[[239]]], [[[1, 10], [100, 1000]]], [[[43, 455, 32, 103], [102, 988, 298, 981], [309, 21, 53, 64], [2, 22, 35, 291]]]]\n_outputs = [[[[9, 2, 7], [4, 5, 6], [3, 8, 1]]], [[[239]]], [[[1000, 100], [10, 1]]], [[[291, 455, 32, 2], [102, 53, 21, 981], [309, 29... | 258 | 403 |
coding | Solve the programming task below in a Python markdown code block.
Given an array of numbers, return a string made up of four parts:
a) a four character 'word', made up of the characters derived from the first two and last two numbers in the array. order should be as read left to right (first, second, second last, last... | {"functional": "_inputs = [[[111, 112, 113, 114, 115, 113, 114, 110]], [[51, 62, 73, 84, 95, 100, 99, 126]], [[66, 101, 55, 111, 113]], [[78, 117, 110, 99, 104, 117, 107, 115, 120, 121, 125]], [[101, 48, 75, 105, 99, 107, 121, 122, 124]], [[80, 117, 115, 104, 65, 85, 112, 115, 66, 76, 62]], [[91, 100, 111, 121, 51, 62,... | 178 | 884 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer array nums, return the number of AND triples.
An AND triple is a triple of indices (i, j, k) such that:
0 <= i < nums.length
0 <= j < nums.length
0 <= k < nums.length
nums[i] & nums[j] & nums[k] == 0... | {"functional": "def check(candidate):\n assert candidate(nums = [2,1,3]) == 12\n assert candidate(nums = [0,0,0]) == 27\n\n\ncheck(Solution().countTriplets)"} | 125 | 54 |
coding | Solve the programming task below in a Python markdown code block.
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1).
You will travel to the bottom-right square, (2, N), by repeatedly moving ... | {"inputs": ["1\n2\n6", "1\n2\n7", "1\n2\n1", "1\n1\n1", "1\n8\n2", "1\n1\n0", "1\n0\n0", "1\n2\n3"], "outputs": ["8\n", "9\n", "3\n", "2\n", "10\n", "1\n", "0\n", "5"]} | 358 | 94 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
A valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
For example, "", "()", "(())()", and "(()(()))" are all vali... | {"functional": "def check(candidate):\n assert candidate(s = \"(()())(())\") == \"()()()\"\n assert candidate(s = \"(()())(())(()(()))\") == \"()()()()(())\"\n assert candidate(s = \"()()\") == \"\"\n\n\ncheck(Solution().removeOuterParentheses)"} | 197 | 75 |
coding | Solve the programming task below in a Python markdown code block.
You are currently studying the language $A j o b$ ( which means strange in English ) from a renowned professor. The language has infinite number of letters in its alphabet ( now you know, why it is called ajob ).
The professor taught you $N$ words, on... | {"inputs": ["3\n2 1 2\n2 1 5\n5 3 13\n", "5\n5 2 3\n6 5 11\n7 6 3\n6 5 7\n6 5 5\n"], "outputs": ["1\n3\n2\n", "2\n7\n2\n0\n2\n"]} | 571 | 84 |
coding | Solve the programming task below in a Python markdown code block.
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them by -1... | {"inputs": ["2\n-1 0 1\n", "2\n-1 -1 1\n", "2\n50 54 50\n", "2\n50 50 50\n", "3\n-1 1 1 1 1\n", "3\n-2 3 4 5 6\n", "3\n-2 3 0 5 6\n", "2\n-1 -112 -1\n"], "outputs": ["2\n", "3\n", "154\n", "150\n", "5\n", "20\n", "16\n", "112\n"]} | 287 | 152 |
coding | Solve the programming task below in a Python markdown code block.
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the... | {"inputs": ["5\n1 1 1 1 1\n1\n+ 1\n", "5\n1 1 1 2 1\n1\n+ 1\n", "5\n1 1 1 4 1\n1\n+ 1\n", "5\n1 1 1 8 1\n1\n+ 1\n", "10\n1 1 1 1 1 1 1 1 1 1\n1\n+ 1\n", "10\n1 1 1 1 1 1 1 1 1 1\n1\n+ 1\n", "10\n1 1 1 1 0 1 1 1 1 1\n1\n+ 1\n", "10\n1 2 1 1 0 1 1 1 1 1\n1\n+ 1\n"], "outputs": ["NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "Y... | 721 | 242 |
coding | Solve the programming task below in a Python markdown code block.
A person is getting ready to leave and needs a pair of matching socks. If there are $n$ colors of socks in the drawer, how many socks need to be removed to be certain of having a matching pair?
Example
$n=2$
There are $2$ colors of socks in the dr... | {"inputs": ["2\n1\n2\n"], "outputs": ["2\n3\n"]} | 308 | 20 |
coding | Solve the programming task below in a Python markdown code block.
Victor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points with coordinates (xv, yv) and (xp... | {"inputs": ["0 0\n5 0\n1 0 2 0\n3 0 4 0\n", "0 0\n2 0\n0 2 2 2\n1 1 1 0\n", "0 0\n3 0\n0 2 2 2\n1 0 2 0\n", "0 0\n3 0\n1 0 2 0\n0 2 2 2\n", "0 1\n5 0\n1 0 2 0\n3 0 4 0\n", "0 0\n3 0\n0 2 2 2\n1 1 1 0\n", "0 0\n4 0\n0 2 2 2\n1 0 2 0\n", "0 0\n2 0\n1 1 1 -1\n0 2 2 2\n"], "outputs": ["NO", "NO", "YES", "YES", "YES\n", "NO... | 661 | 241 |
coding | Solve the programming task below in a Python markdown code block.
Chef wants to buy a new phone, but he is not willing to spend a lot of money. Instead, he checks the price of his chosen model everyday and waits for the price to drop to an acceptable value. So far, he has observed the price for $N$ days (numbere $1$ th... | {"inputs": ["1\n7\n375 750 723 662 647 656 619"], "outputs": ["2"]} | 545 | 42 |
coding | Solve the programming task below in a Python markdown code block.
In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model soluti... | {"inputs": ["2\n0 1\n", "2\n0 1\n", "2\n0 2\n", "2\n73 37\n", "2\n73 37\n", "2\n129 37\n", "2\n129 16\n", "2\n129 20\n"], "outputs": ["1\n", "1\n", "2\n", "36\n", "36\n", "92\n", "113\n", "109\n"]} | 682 | 122 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array A of length N. Find the number of pairs of indices (i,j) such that
1 ≤ i < j ≤ N
A_{i} \cdot A_{j} > 0
------ Input Format ------
- The first line contains a single integer T - the number of test cases. Then the test cases follo... | {"inputs": ["3\n5\n1 -3 0 2 -1\n4\n-1 -1 -1 -1\n4\n0 1 2 3\n"], "outputs": ["2\n6\n3\n"]} | 395 | 51 |
coding | Solve the programming task below in a Python markdown code block.
Chefland has all the cities on a straight line. There are $N$ cities in Chefland numbered $1$ to $N$. City $i$ is located at coordinate $x_i$ on the x-axis. Guru wants to travel from city $A$ to city $B$. He starts at time t=0. He has following choices t... | {"inputs": ["1\n4 1 3 2 4 3 2 4\n1 2 3 4"], "outputs": ["6"]} | 503 | 36 |
coding | Solve the programming task below in a Python markdown code block.
Ela likes Chess a lot. During breaks, she usually challenges her co-worker in DTL to some chess games. She's not an expert at classic chess, but she's very interested in Chess variants, where she has to adapt to new rules and test her tactical mindset to... | {"inputs": ["1\n4\n4 1 4 2 3 1\n1 3\n", "1\n100000\n1 1 2 1 1 2\n26298 33691\n", "6\n8\n7 2 8 2 7 1\n5 1\n8\n2 2 1 2 2 1\n5 5\n8\n2 2 1 2 2 1\n6 6\n8\n1 1 1 2 2 1\n5 5\n8\n2 2 1 2 2 1\n8 8\n8\n8 8 8 7 7 8\n4 8\n", "3\n100000\n100000 100000 99999 100000 100000 99999\n69 100000\n100000\n2 100000 1 99999 1 100000\n100000 ... | 715 | 539 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 because the lexicographically smallest character is 'c', which has a... | {"functional": "def check(candidate):\n assert candidate(queries = [\"cbd\"], words = [\"zaaaz\"]) == [1]\n assert candidate(queries = [\"bbb\",\"cc\"], words = [\"a\",\"aa\",\"aaa\",\"aaaa\"]) == [1,2]\n\n\ncheck(Solution().numSmallerByFrequency)"} | 181 | 80 |
coding | Solve the programming task below in a Python markdown code block.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left. An 'R' indicates he should move one unit right. A 'U' indicates he s... | {"inputs": ["R\n", "R\n", "LR\n", "UL\n", "UD\n", "LU\n", "RR\n", "LR\n"], "outputs": ["-1\n", "-1\n", "0\n", "1\n", "0\n", "1\n", "1\n", "0\n"]} | 415 | 71 |
coding | Solve the programming task below in a Python markdown code block.
Using his tip-top physique, Kim has now climbed up the mountain where the base is located. Kim has found the door to the (supposedly) super secret base. Well, it is super secret, but obviously no match for Kim's talents.
The door is guarded by a row of ... | {"inputs": ["3\n4\n3 5 3 4\n2\n5 7\n1\n4"], "outputs": ["3\n0\n0"]} | 751 | 36 |
coding | Solve the programming task below in a Python markdown code block.
This challenge is only forPython 2.
input()
In Python 2, the expression input() is equivalent to eval(raw _input(prompt)).
Code
>>> input()
1+2
3
>>> company = 'HackerRank'
>>> website = 'www.hackerrank.com'
>>> input()
'The company name: '+compan... | {"inputs": ["1 4\nx**3 + x**2 + x + 1\n"], "outputs": ["True\n"]} | 317 | 29 |
coding | Solve the programming task below in a Python markdown code block.
Alice and Bob play the following game.They choose a number N to play with.The runs are as follows :
1.Bob plays first and the two players alternate.
2.In his/her turn ,a player can subtract from N any prime number(including 1) less than N.The numbe... | {"inputs": ["2\n1\n2"], "outputs": ["ALICE\nBOB"]} | 273 | 20 |
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 integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.
To gain points, you must pick one cell in each row. Picking the ... | {"functional": "def check(candidate):\n assert candidate(points = [[1,2,3],[1,5,1],[3,1,1]]) == 9\n assert candidate(points = [[1,5],[2,3],[4,2]]) == 11\n\n\ncheck(Solution().maxPoints)"} | 231 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.
In one operation, select any index i such that 0 < i < words.length and words[i - 1] and words[i] are anagrams, and d... | {"functional": "def check(candidate):\n assert candidate(words = [\"abba\",\"baba\",\"bbaa\",\"cd\",\"cd\"]) == [\"abba\",\"cd\"]\n assert candidate(words = [\"a\",\"b\",\"c\",\"d\",\"e\"]) == [\"a\",\"b\",\"c\",\"d\",\"e\"]\n\n\ncheck(Solution().removeAnagrams)"} | 202 | 85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.