info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4\\nabab\\naabb\\n\", \"1\\na\\nb\\n\", \"8\\nbabbaabb\\nabababaa\\n\", \"2\\nbb\\nbb\\n\", \"10\\naaaaabbbbb\\nababaaaaab\\n\", \"10\\nbbbbbbbbbb\\naaaaaaaaaa\\n\", \"6\\naaaaaa\\naabaaa\\n\", \"1\\nb\\nb\\n\", \"5\\nbaaaa\\nabaaa\\n\", \"10\\naabaaaaaab\\nbaaaaaabbb\\n\", \"100\\nbbbabbabab... | Monocarp has got two strings $s$ and $t$ having equal length. Both strings consist of lowercase Latin letters "a" and "b".
Monocarp wants to make these two strings $s$ and $t$ equal to each other. He can do the following operation any number of times: choose an index $pos_1$ in the string $s$, choose an index $pos_2$... | 0 |
{"tests": "{\"inputs\": [[[6, 2, 3, 4, 5]], [[14, 32, 3, 5, 5]], [[1, 2, 3, 4, 5]], [[\"Banana\", \"Orange\", \"Apple\", \"Mango\", 0, 2, 2]], [[\"C\", \"W\", \"W\", \"W\", 1, 2, 0]], [[\"Hackathon\", \"Katathon\", \"Code\", \"CodeWars\", \"Laptop\", \"Macbook\", \"JavaScript\", 1, 5, 2]], [[66, \"t\", 101, 0, 1, 1]], ... | Simple enough this one - you will be given an array. The values in the array will either be numbers or strings, or a mix of both. You will not get an empty array, nor a sparse one.
Your job is to return a single array that has first the numbers sorted in ascending order, followed by the strings sorted in alphabetic or... | 0.125 |
{"tests": "{\"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, [50... | 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 their purses and pockets. But how many of them could you get with w... | 0 |
{"tests": "{\"inputs\": [\"3\\n6\\n3 7 1 4 2 4\\n5\\n5 4 3 2 1\\n5\\n4 3 2 2 3\", \"3\\n6\\n3 7 1 4 2 4\\n5\\n5 4 3 2 1\\n5\\n4 3 1 2 3\", \"3\\n6\\n3 1 1 4 2 4\\n5\\n5 4 3 2 1\\n5\\n4 3 1 2 3\", \"3\\n6\\n3 1 1 4 2 4\\n5\\n2 4 3 2 1\\n5\\n4 3 1 2 3\", \"3\\n6\\n1 1 0 4 2 4\\n5\\n4 4 3 2 1\\n5\\n4 0 1 2 3\", \"3\\n6\\n... | Who's interested in football?
Rayne Wooney has been one of the top players for his football club for the last few years. But unfortunately, he got injured during a game a few months back and has been out of play ever since.
He's got proper treatment and is eager to go out and play for his team again. Before doing that,... | 0.875 |
{"tests": "{\"inputs\": [\"5 6\\n1 2 0 2 0\\n2 4\\n3 3\\n1 5\\n1 2\\n1 5\\n2 3\\n\", \"5 3\\n4 2 1 3 2\\n3 5\\n4 2\\n2 5\\n\", \"78 36\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\\n1 52\\n2 6\\n9 43\\n10 52... | The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 3\\n\", \"5\\n6 6 9 15 21\\n\", \"2\\n3 6\\n\", \"3\\n3 9 15\\n\", \"4\\n3 6 9 12\\n\", \"4\\n3 3 3 3\\n\", \"2\\n78 26\\n\", \"9\\n57 30 28 81 88 32 3 42 25\\n\", \"5\\n3 3 3 3 3\\n\", \"2\\n9 9\\n\", \"4\\n2 3 9 13\\n\", \"4\\n92 46 3 21\\n\", \"3\\n3 12 4\\n\", \"3\\n3 9 12\\n\", \"2... | Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful. In one move he can choose an index i (1 ≤ i < n), delete numbers ai, ai + 1 a... | 0 |
{"tests": "{\"inputs\": [\"2\\n0 23\\n3\\n1 1\\n2 1\\n3 1\\n0\", \"2\\n0 23\\n3\\n1 1\\n1 1\\n3 1\\n0\", \"2\\n1 23\\n3\\n1 1\\n4 1\\n3 1\\n0\", \"2\\n1 23\\n3\\n2 1\\n10 1\\n3 1\\n0\", \"2\\n0 23\\n3\\n1 1\\n2 1\\n3 2\\n0\", \"2\\n0 23\\n3\\n1 1\\n1 0\\n3 1\\n0\", \"2\\n0 23\\n3\\n1 2\\n1 0\\n3 1\\n0\", \"2\\n0 23\\n3... | Peter is a person with erratic sleep habits. He goes to sleep at twelve o'lock every midnight. He gets up just after one hour of sleep on some days; he may even sleep for twenty-three hours on other days. His sleeping duration changes in a cycle, where he always sleeps for only one hour on the first day of the cycle.
... | 0 |
{"tests": "{\"inputs\": [[\"codwars.com\"], [\"http://codwars.com\"], [\"http://kcodwars.com\"], [\"https://www.codwars.com\"], [\"https://www.codwars.com/kata\"], [\"codewars.com.codwars.com\"], [\"https://www.codwars.com/kata?this=is&a=querystring\"], [\"https://this.is.an.unneccesarily.long.subdomain.codwars.com/kat... | A marine themed rival site to Codewars has started. Codwars is advertising their website all over the internet using subdomains to hide or obfuscate their domain to trick people into clicking on their site.
Your task is to write a function that accepts a URL as a string and determines if it would result in an http req... | 0 |
{"tests": "{\"inputs\": [\"1\\n2\\n\", \"3\\n1 1 1\\n\", \"1\\n983155795040951739\\n\", \"2\\n467131402341701583 956277077729692725\\n\", \"10\\n217673221404542171 806579927281665969 500754531396239406 214319484250163112 328494187336342674 427465830578952934 951554014286436941 664022909283791499 653206814724654845 6670... | As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup. [Image]
Then at one turn Barney swaps the cup in the midd... | 0 |
{"tests": "{\"inputs\": [[[[2, 5], [3, 6]], [[5, 2], [3, 6]]], [[[2, 5], [3, 6]], [[6, 3], [5, 2]]], [[[2, 5], [3, 6]], [[6, 3], [2, 5]]], [[[2, 5], [3, 5], [6, 2]], [[2, 6], [5, 3], [2, 5]]], [[[2, 5], [3, 5], [6, 2]], [[3, 5], [6, 2], [5, 2]]], [[], []], [[[2, 3], [3, 4]], [[4, 3], [2, 4]]], [[[2, 3], [3, 2]], [[2, 3... | Given two arrays, the purpose of this Kata is to check if these two arrays are the same. "The same" in this Kata means the two arrays contains arrays of 2 numbers which are same and not necessarily sorted the same way. i.e. [[2,5], [3,6]] is same as [[5,2], [3,6]] or [[6,3], [5,2]] or [[6,3], [2,5]] etc
[[2,5], [3,6]]... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n1 4 6\", \"8\\n1 4 3 4 6 8 12 12\", \"10\\n356822 296174 484500 710640 610703 888250 259161 609120 592348 713644\", \"3\\n2 3 6\", \"8\\n1 8 3 4 6 8 12 12\", \"10\\n356822 296174 484500 710640 231537 888250 259161 609120 592348 713644\", \"3\\n2 1 6\", \"8\\n1 8 3 4 6 11 12 12\", \"10\\n3... | We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}.
Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b):
* \sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j)
Since the answer may be enormous, compute it modulo 998244353.
Constraints
* 1 \leq N \leq 200000
... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n3 3\\n3 5 8\\n4 3\\n5 8 10 12\\n5 3\\n3 2 8 17 15\", \"3\\n3 3\\n3 5 8\\n4 3\\n5 8 11 12\\n5 3\\n3 2 8 17 15\", \"3\\n3 3\\n3 5 8\\n4 3\\n5 8 11 12\\n5 6\\n3 2 8 17 15\", \"3\\n3 3\\n3 4 8\\n4 3\\n5 8 11 12\\n5 6\\n3 2 8 17 15\", \"3\\n3 3\\n3 5 8\\n4 3\\n3 8 10 12\\n5 3\\n3 2 8 17 15\", ... | Read problems statements in Mandarin Chinese and Russian as well.
Given an array of N numbers, a pair of numbers is called good if difference between the two numbers is strictly less than D.
Find out maximum possible sum of all good disjoint pairs that can be made from these numbers.
Sum of X pairs is the sum of all ... | 0 |
{"tests": "{\"inputs\": [[[\"a\", \"a\", \"b\", \"b\", \"c\", \"a\", \"b\", \"c\"]], [[\"a\", \"a\", \"a\", \"b\", \"b\", \"b\", \"c\", \"c\", \"c\"]], [[null, \"a\", \"a\"]], [[\"foo\"]], [[\"\"]], [[]]], \"outputs\": [[[[\"a\", 2], [\"b\", 2], [\"c\", 1], [\"a\", 1], [\"b\", 1], [\"c\", 1]]], [[[\"a\", 3], [\"b\", 3]... | Implement a function which behaves like the 'uniq -c' command in UNIX.
It takes as input a sequence and returns a sequence in which all duplicate elements following each other have been reduced to one instance together with the number of times a duplicate elements occurred in the original array.
Example:
```python
... | 0 |
{"tests": "{\"inputs\": [\"2 81\\n\", \"2 3\\n\", \"4 27\\n\", \"7 90\\n\", \"331358794 820674098\\n\", \"234899623 6561\\n\", \"422262807 3\\n\", \"528551307 729\\n\", \"108260816 609551797\\n\", \"969271595 9\\n\", \"296519935 960061928\\n\", \"596386879 356583466\\n\", \"3 3\\n\", \"3 60\\n\", \"4 81\\n\", \"3 27\\n... | An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the... | 0 |
{"tests": "{\"inputs\": [\"11\\n0\\n1\\n-2\\n0\\n-4\\n1\\n-1\\n2\\n0\\n0\\n0\", \"12\\n0\\n0\\n7\\n0\\n2\\n0\\n0\\n3\\n-5\\n-2\\n1\\n0\", \"8\\n0\\n4\\n-1\\n1\\n0\\n-2\\n0\\n0\", \"12\\n0\\n-1\\n7\\n0\\n2\\n0\\n0\\n3\\n-5\\n-2\\n1\\n0\", \"8\\n0\\n4\\n-2\\n1\\n0\\n-2\\n0\\n0\", \"12\\n0\\n-1\\n7\\n0\\n2\\n0\\n-1\\n3\\n... | All space-time unified dimension sugoroku tournament. You are representing the Earth in the 21st century in the tournament, which decides only one Sugoroku absolute champion out of more than 500 trillion participants.
The challenge you are currently challenging is one-dimensional sugoroku with yourself as a frame. Sta... | 0 |
{"tests": "{\"inputs\": [[2, 7], [3, 10], [7, 17], [10, 50], [37, 200], [7, 100]], \"outputs\": [[6], [9], [14], [50], [185], [98]]}", "source": "taco"} | # Task
**_Given_** a **_Divisor and a Bound_** , *Find the largest integer N* , Such That ,
# Conditions :
* **_N_** is *divisible by divisor*
* **_N_** is *less than or equal to bound*
* **_N_** is *greater than 0*.
___
# Notes
* The **_parameters (divisor, bound)_** passed to the function are *only posit... | 0 |
{"tests": "{\"inputs\": [\"2\\n\\n3 4\\n2 3 2 1\\n1 0\\n0 0\\n\\n5 5\\n1 2 1 3 1\\n3 0\\n0 0\\n2 1\\n4 0\\n\", \"4\\n\\n2 1\\n42\\n0 0\\n\\n2 1\\n2\\n0 0\\n\\n2 1\\n42\\n1 0\\n\\n2 1\\n2\\n1 0\\n\", \"5\\n\\n3 3\\n1 1 1\\n0 0\\n0 1\\n\\n3 3\\n1 1 1\\n1 0\\n2 1\\n\\n3 3\\n1 1 1\\n1 0\\n0 1\\n\\n3 3\\n1 1 1\\n0 0\\n1 0\\... | Polycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sitting on seat m, that means, he will be the m-th person to get food.
The flight menu has k dishes in t... | 0 |
{"tests": "{\"inputs\": [\"10\\n0 5\\n1 0\\n2 3\\n3 2\\n4 6\\n5 9\\n6 1\\n7 8\\n8 4\\n9 7\\n\", \"10\\n-7 6\\n-16 11\\n-9 -5\\n3 4\\n-8 12\\n-17 6\\n2 -1\\n-5 15\\n-7 4\\n-6 -2\\n\", \"8\\n11 -3\\n12 -5\\n10 -6\\n9 -4\\n8 -8\\n6 -7\\n7 -10\\n5 -9\\n\", \"8\\n-10000 4285\\n-7143 -10000\\n-4286 -1429\\n-1429 -7143\\n1428... | You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.
Multiset is a set where equal elements are allowed.
Multiset is called symmetric, if there is a point P on t... | 0 |
{"tests": "{\"inputs\": [[\"2\", \"5 2\", \"8 4 5 2 10\", \"8 3\", \"1 1 1 1 1 1 1 1\"], \"2\\n5 2\\n3 4 5 2 10\\n8 3\\n1 1 1 1 1 1 1 1\", \"2\\n5 2\\n3 2 5 0 10\\n8 3\\n1 1 1 1 1 1 1 1\", \"2\\n5 2\\n3 2 5 0 10\\n8 3\\n1 0 1 1 1 1 1 1\", \"2\\n5 2\\n8 4 5 2 10\\n8 3\\n1 1 1 1 1 1 0 1\", \"2\\n5 2\\n3 4 5 2 10\\n8 3\\n... | Chef has gone shopping with his 5-year old son. They have bought N items so far. The items are numbered from 1 to N, and the item i weighs Wi grams.
Chef's son insists on helping his father in carrying the items. He wants his dad to give him a few items. Chef does not want to burden his son. But he won't stop botherin... | 0 |
{"tests": "{\"inputs\": [\"5\\nWWVWWWWWWW\", \"4\\nBWWWBBWB\", \"5\\nWWVWWWWWWX\", \"5\\nWWVWWWXWWX\", \"5\\nWWVVWWXWWX\", \"5\\nWXWWWWWWWW\", \"5\\nWWVWWXWWWW\", \"4\\nBWBBWBWW\", \"5\\nWWVWWWWVWX\", \"5\\nWWVVWWXXWX\", \"5\\nWWWWWWWWXW\", \"5\\nWWWWXWWVWW\", \"4\\nBWBBWBWX\", \"5\\nWVVVWWXXWX\", \"5\\nWWWWWVWWXW\", \... | 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`.
You will perform the following operation exactly N times: choo... | 0 |
{"tests": "{\"inputs\": [\"aaaaa\\naa\\n\", \"axbaxxb\\nab\\n\", \"aabb\\nab\\n\", \"aaaaaaaaaaaaaaa\\na\\n\", \"aaaaaaaaaaa\\nb\\n\", \"ababababababababa\\naba\\n\", \"axxbaxxbaxxb\\nab\\n\", \"axaxxbaxabxbaxxbxb\\nab\\n\", \"ababcc\\nabc\\n\", \"a\\na\\n\", \"a\\nb\\n\", \"a\\naa\\n\", \"a\\nab\\n\", \"a\\nbbbbbbbbbb... | Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates $\operatorname{occ}(s^{\prime}, p)$ that is defined as the maximal number of non-overlapping substrings equal to p that can be found in s'. He wants to make this number as big... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 3\\n1 3\\n3 8\\n\", \"3\\n1 3\\n2 4\\n5 7\\n\", \"1\\n0 1000000000000000000\\n\", \"1\\n0 1000000000000000000\\n\", \"3\\n1 3\\n2 4\\n3 7\\n\", \"1\\n1 1000000000000000000\\n\", \"3\\n0 3\\n1 1\\n3 8\\n\", \"3\\n1 3\\n2 4\\n3 14\\n\", \"3\\n1 5\\n2 4\\n3 14\\n\", \"3\\n0 3\\n2 3\\n3 8\\... | You are given $n$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.
Your task is the following: for every $k \in [1..n]$, calculate the number of points with in... | 0.625 |
{"tests": "{\"inputs\": [\")?(??((???????()?(?????????)??(????????((?)?????)????)??????(?????)?)?????)??????(??()??????)????????)?)()??????????????())????????(???)??)????????????????????(?????)??)???)??(???????????????)???)??)?\\n\", \"??\\n\", \"(?\\n\", \"))((()(()((((()))())()())((())())(((()()(())))))((())()()(()()... | As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him.
<image>
Thus, he came up with a puz... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n1 3\\n5 8\\n2 5\\n3 19\\n56678 164422\\n\", \"6\\n1 4\\n1 4\\n4 5\\n631059 999974\\n1 2\\n1 2\\n\", \"17\\n1 3\\n2 4\\n3 5\\n2 3\\n1 2\\n2 5\\n3 5\\n1 2\\n1 5\\n1 2\\n3 4\\n281794 563452\\n1 3\\n1 3\\n1 2\\n218235 436471\\n1 5\\n\", \"1\\n999999 1000000\\n\", \"14\\n1 2\\n51649 234369\\n3... | Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | 0.25 |
{"tests": "{\"inputs\": [\"0 1\", \"4 5\", \"6 5\", \"0 2\", \"4 1\", \"-1 1\", \"6 9\", \"0 8\", \"8 1\", \"6 3\", \"0 9\", \"1 8\", \"11 1\", \"8 3\", \"0 12\", \"1 10\", \"19 1\", \"8 2\", \"0 6\", \"2 8\", \"9 1\", \"0 11\", \"-1 11\", \"1 11\", \"-2 11\", \"0 4\", \"-3 11\", \"2 14\", \"-3 4\", \"-2 1\", \"-3 7\",... | Problem
There are n vertices that are not connected to any of the vertices.
An undirected side is stretched between each vertex.
Find out how many sides can be stretched when the diameter is set to d.
The diameter represents the largest of the shortest distances between two vertices.
Here, the shortest distance is the... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n0 0 0\\n0 1 0\\n0 0 0\\n\", \"4 3\\n0 0 0\\n0 0 1\\n1 0 0\\n0 0 0\\n\", \"50 4\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 1 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 ... | Simon has a rectangular table consisting of n rows and m columns. Simon numbered the rows of the table from top to bottom starting from one and the columns — from left to right starting from one. We'll represent the cell on the x-th row and the y-th column as a pair of numbers (x, y). The table corners are cells: (1, 1... | 0.125 |
{"tests": "{\"inputs\": [\"20\\n2 1\\n3 1\\n4 2\\n5 2\\n6 3\\n7 1\\n8 6\\n9 2\\n10 3\\n11 6\\n12 2\\n13 3\\n14 2\\n15 1\\n16 8\\n17 15\\n18 2\\n19 14\\n20 14\\n0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1\\n0 1 0 1 1 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0\\n\", \"30\\n2 1\\n3 2\\n4 3\\n5 3\\n6 5\\n7 3\\n8 3\\n9 2\\n10 3\\n11 2\\n12 ... | Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees.
The game is played on a tree having n nodes, numbered from 1 to n. Each node i has an initial value initi, which ... | 0 |
{"tests": "{\"inputs\": [\"7 4\\n1 2 3 3 1 4 3\\n3 1\\n2 3\\n2 4\\n\", \"10 5\\n3 1 5 3 1 5 1 2 4 2\\n4 5\\n4 3\\n4 2\\n4 1\\n\", \"10 10\\n2 10 8 7 9 3 4 6 5 1\\n10 4\\n10 1\\n10 6\\n10 8\\n10 2\\n10 9\\n10 7\\n10 3\\n10 5\\n\", \"2 2\\n1 2\\n2 1\\n\", \"10 10\\n2 10 8 7 9 3 4 6 5 1\\n10 4\\n10 1\\n10 6\\n10 8\\n10 2\... | You have a set of $n$ discs, the $i$-th disc has radius $i$. Initially, these discs are split among $m$ towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order of their radii from bottom to top.
You would like to assemble one tower containing all of those discs. To do ... | 0 |
{"tests": "{\"inputs\": [\"ccpa\", \"cnbc\", \"emec\", \"ccoa\", \"aocc\", \"pcca\", \"ccao\", \"pcda\", \"ccbo\", \"qcda\", \"ccbn\", \"qbda\", \"adbq\", \"dnbc\", \"dobc\", \"dobd\", \"cobd\", \"dboc\", \"cbod\", \"cboe\", \"eobc\", \"cobe\", \"boce\", \"bode\", \"edob\", \"edoc\", \"code\", \"coee\", \"ocde\", \"edc... | G: Palindromic Subsequences
problem
Given a string S consisting only of lowercase letters, find out how many subsequences of this string S are not necessarily continuous and are palindromes.
Here, a subsequence that is not necessarily continuous with S is an arbitrary selection of one or more characters | S | charac... | 0.125 |
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5], 2], [[1, 2, 3, 4, 5], 3], [[15], 3], [[1, 2, 3, 4], 1], [[1, 2, 3, 4, 5, 6], 20], [[32, 45, 43, 23, 54, 23, 54, 34], 2], [[32, 45, 43, 23, 54, 23, 54, 34], 0], [[3, 234, 25, 345, 45, 34, 234, 235, 345], 3], [[3, 234, 25, 345, 45, 34, 234, 235, 345, 34, 534, 45, 645, 645, 645, ... | *Inspired by the [Fold an Array](https://www.codewars.com/kata/fold-an-array) kata. This one is sort of similar but a little different.*
---
## Task
You will receive an array as parameter that contains 1 or more integers and a number `n`.
Here is a little visualization of the process:
* Step 1: Split the array in t... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n101\\n001\\n110\\n\", \"7 15\\n000100001010010\\n100111010110001\\n101101111100100\\n010000111111010\\n111010010100001\\n000011001111101\\n111111011010011\\n\", \"1 1\\n0\\n\", \"1 1\\n1\\n\", \"2 58\\n1100001110010010100001000000000110110001101001100010101110\\n111011001010111100111001... | A binary matrix is called good if every even length square sub-matrix has an odd number of ones.
Given a binary matrix $a$ consisting of $n$ rows and $m$ columns, determine the minimum number of cells you need to change to make it good, or report that there is no way to make it good at all.
All the terms above have... | 0.125 |
{"tests": "{\"inputs\": [\"-13 3\\n\", \"1 -33\\n\", \"13 3\\n\", \"36 80\\n\", \"50 -24\\n\", \"-76 39\\n\", \"-96 -16\\n\", \"91 0\\n\", \"0 15\\n\", \"0 0\\n\", \"100 100\\n\", \"10 1\\n\"], \"outputs\": [\"-10\\n\", \"34\\n\", \"39\\n\", \"2880\\n\", \"74\\n\", \"-37\\n\", \"1536\\n\", \"91\\n\", \"15\\n\", \"0\\n\... | We have two integers: A and B.
Print the largest number among A + B, A - B, and A \times B.
-----Constraints-----
- All values in input are integers.
- -100 \leq A,\ B \leq 100
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
Print the largest number among A + B, A -... | 0.875 |
{"tests": "{\"inputs\": [[\"abcdef\", 5], [\"\", 5], [\"abcd\", 1], [\"0abc\", 2], [\"ab\", 255], [\"ab\", 256], [\"abcde\", 32], [\"tcddoadepwweasresd\", 77098]], \"outputs\": [[\"df\"], [\"\"], [\"d\"], [\"b\"], [\"ab\"], [\"\"], [\"\"], [\"codewars\"]]}", "source": "taco"} | # Introduction
A grille cipher was a technique for encrypting a plaintext by writing it onto a sheet of paper through a pierced sheet (of paper or cardboard or similar). The earliest known description is due to the polymath Girolamo Cardano in 1550. His proposal was for a rectangular stencil allowing single letters, ... | 0 |
{"tests": "{\"inputs\": [\"10\\nonetwonetwooneooonetwooo\\ntwo\\none\\ntwooooo\\nttttwo\\nttwwoo\\nooone\\nonnne\\noneeeee\\noneeeeeeetwooooo\\n\", \"4\\nonetwone\\ntestme\\noneoneone\\ntwotwo\\n\", \"1\\nzzzone\\n\", \"10\\nonetwonetwooneooonetwooo\\ntwo\\none\\ntwooooo\\nttttwo\\nttwwoo\\nooone\\nonnne\\nonedeee\\non... | You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j ... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2 10\\n1 3 15\\n2 3 5\\n2 4 3\\n3 4 10\\n2\\n1 4 10 LoveLetter\\n2 3 13 Greetings\\n3 3\\n1 2 1\\n2 3 1\\n3 1 1\\n3\\n1 2 1 BusinessMailC\\n2 3 1 BusinessMailB\\n3 1 1 BusinessMailA\\n0 0\", \"4 5\\n1 2 10\\n2 3 15\\n2 3 5\\n2 4 3\\n3 4 10\\n2\\n1 4 10 LoveLetter\\n2 3 13 Greetings\\n... | The postal system in the area where Masa lives has changed a bit. In this area, each post office is numbered consecutively from 1 to a different number, and mail delivered to a post office is intended from that post office via several post offices. Delivered to the post office. Mail "forwarding" is only done between sp... | 0 |
{"tests": "{\"inputs\": [\"10 4\\n8 4\\n9 8\\n2 8\\n8 1\\n\", \"9 10\\n6 4\\n7 5\\n9 3\\n7 6\\n4 8\\n4 2\\n9 8\\n1 3\\n5 1\\n4 7\\n\", \"10 10\\n10 6\\n9 4\\n7 8\\n1 5\\n3 10\\n2 1\\n4 9\\n5 2\\n10 3\\n6 3\\n\", \"8 12\\n6 1\\n7 5\\n2 5\\n4 1\\n6 3\\n4 3\\n5 7\\n1 3\\n5 2\\n2 7\\n4 6\\n7 2\\n\", \"3 6\\n1 2\\n1 3\\n2 1... | Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.
Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha... | 0 |
{"tests": "{\"inputs\": [\"Z:1\\n\", \"123:A\\n\", \"N:7\\n\", \"00001:00001\\n\", \"1:11\\n\", \"000G6:000GD\\n\", \"0:1N\\n\", \"Z:2\\n\", \"0:Z\\n\", \"Z:00\\n\", \"0:1A\\n\", \"000Z:000Z\\n\", \"0Z:01\\n\", \"A:10\\n\", \"00Z:01\\n\", \"0033:00202\\n\", \"000B3:00098\\n\", \"00Z:03\\n\", \"01B:4A\\n\", \"0011:124\\... | Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extraterrestrial civilizations are forbidden. It was very unfair to Petya as he adored... | 0.125 |
{"tests": "{\"inputs\": [[\"Hello\"], [\"CCCC\"], [\"tes3t5\"], [\"ay\"], [\"\"], [\"YA\"], [\"123\"], [\"ya1\"], [\"yaYAya\"], [\"YayayA\"]], \"outputs\": [[\"ellohay\"], [\"ccccay\"], [null], [\"ayway\"], [null], [\"ayay\"], [null], [null], [\"ayayayay\"], [\"ayayayay\"]]}", "source": "taco"} | Pig Latin is an English language game where the goal is to hide the meaning of a word from people not aware of the rules.
So, the goal of this kata is to wite a function that encodes a single word string to pig latin.
The rules themselves are rather easy:
1) The word starts with a vowel(a,e,i,o,u) -> return the orig... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0 1 1\\n1 1 2 2\\n3 0 4 1\\n\", \"3\\n0 0 1 1\\n0 1 1 2\\n1 0 2 1\\n\", \"4\\n0 0 5 5\\n0 0 4 4\\n1 1 4 4\\n1 1 4 4\\n\", \"5\\n0 0 10 8\\n1 2 6 7\\n2 3 5 6\\n3 4 4 5\\n8 1 9 2\\n\", \"4\\n6 77 44 98\\n4 3 84 92\\n8 23 66 89\\n28 39 80 83\\n\", \"10\\n-44 -47 -17 5\\n-40 -21 46 22\\n-45... | You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | 0 |
{"tests": "{\"inputs\": [\"3 2 50\\n1\\n2\\n3\\n4 4 65\\n1\\n2\\n3\\n0\\n3 1 10\\n8\\n1\\n1\\n0 0 0\", \"3 2 50\\n1\\n2\\n3\\n4 4 65\\n1\\n2\\n3\\n0\\n3 1 10\\n8\\n2\\n1\\n0 0 0\", \"3 2 50\\n1\\n2\\n1\\n4 4 65\\n1\\n2\\n3\\n0\\n3 1 10\\n8\\n2\\n1\\n0 0 0\", \"3 2 50\\n1\\n2\\n3\\n4 4 65\\n1\\n2\\n3\\n0\\n3 1 10\\n8\\n... | Princess'Gamble
Princess gambling
English text is not available in this practice contest.
One day, a brave princess in a poor country's tomboy broke the walls of her room, escaped from the castle, and entered the gambling hall where horse racing and other gambling were held. However, the princess who had never gambl... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n1 1 5 5\\n1 2\\n4 1\\n3 3\\n\", \"84 5\\n67 59 41 2\\n39 56\\n7 2\\n15 3\\n74 18\\n22 7\\n\", \"88294752 4\\n35290308 52335089 69408342 32650662\\n53981397 84728746\\n56670292 81664574\\n16110353 77620219\\n45476005 495904\\n\", \"41323044 1\\n28208465 38217978 31290636 25974675\\n39500... | Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of $n \times n$ square blocks. Yura needs to move from the block with coordinates $(s_x,s_y)... | 0 |
{"tests": "{\"inputs\": [\"6 3\\n2 2 6\\n\", \"6 3\\n1 2 2\\n\", \"5 3\\n3 2 2\\n\", \"2 2\\n1 2\\n\", \"100 3\\n45 10 45\\n\", \"10000 3\\n3376 5122 6812\\n\", \"100000 10\\n31191 100000 99999 99999 99997 100000 99996 99994 99995 99993\\n\", \"2000 100\\n5 128 1368 1679 1265 313 1854 1512 1924 338 38 1971 238 1262 183... | Dreamoon likes coloring cells very much.
There is a row of n cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 1 to n.
You are given an integer m and m integers l_1, l_2, …, l_m (1 ≤ l_i ≤ n)
Dreamoon will perform m operations.
In i-th operation, Dreamoon will choose a number ... | 0 |
{"tests": "{\"inputs\": [[\"Code Wars\"], [\"does\"], [\"your\"], [\"solution\"], [\"work\"], [\"for\"], [\"these\"], [\"words\"], [\"DOES\"], [\"YOUR\"], [\"SOLUTION\"], [\"WORK\"], [\"FOR\"], [\"THESE\"], [\"WORDS\"], [\"Does\"], [\"Your\"], [\"Solution\"], [\"Work\"], [\"For\"], [\"These\"], [\"Words\"], [\"A\"], [\... | # Background
My TV remote control has arrow buttons and an `OK` button.
I can use these to move a "cursor" on a logical screen keyboard to type words...
# Keyboard
The screen "keyboard" layout looks like this
#tvkb {
width : 400px;
border: 5px solid gray; border-collapse: collapse;
}
#tvkb td {
... | 0 |
{"tests": "{\"inputs\": [\"7\\nNNESWW\\nSWSWSW\\n\", \"3\\nNN\\nSS\\n\", \"3\\nES\\nNW\\n\", \"5\\nWSSE\\nWNNE\\n\", \"2\\nE\\nE\\n\", \"2\\nW\\nS\\n\", \"2\\nS\\nN\\n\", \"100\\nWNWWSWWSESWWWSSSSWSSEENWNWWWWNNENESWSESSENEENNWWWWWSSWSWSENESWNEENESWWNNEESESWSEEENWWNWNNWWNNWWWWSW\\nEESEESSENWNWWWNWWNWWNWWSWNNWNWNWSWNNEEN... | In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.
One example of a grid path is (0, 0) → (0, 1) → (0, 2) → (1, 2... | 0 |
{"tests": "{\"inputs\": [\"5\\n3\\n-2 4 3\\n5\\n1 1 1 1 1\\n5\\n-2 4 7 -6 4\\n9\\n9 7 -4 -2 2 -3 9 -4 -5\\n9\\n-4 1 9 4 8 9 5 1 -9\\n\", \"5\\n3\\n-2 4 3\\n5\\n1 1 1 1 1\\n5\\n-2 4 7 -6 4\\n9\\n9 7 -4 -2 2 -3 9 -4 -5\\n9\\n-4 1 9 4 8 9 5 1 -15\\n\", \"5\\n3\\n-2 4 3\\n5\\n1 1 1 1 1\\n5\\n-2 4 7 -6 4\\n9\\n9 7 -4 -2 1 -... | You are given n integers a_1, a_2, ..., a_n, where n is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following conditions hold:
1. At least (n - 1)/(2) of the adjacent differences a_{i + 1} - a_i for i = 1, 2, ..., n - 1 are grea... | 0 |
{"tests": "{\"inputs\": [\"10\\n1 2 3 4 5 6 7 8 9 10\\n\", \"10\\n10 9 8 7 6 5 4 3 2 1\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 1 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 7... | Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n0 2\\n2 0\\n3 5\\n5 3\\n\", \"10\\n1 0\\n1 -3\\n1 5\\n1 -2\\n1 5\\n1 -2\\n1 -2\\n1 -2\\n1 -2\\n1 -2\\n\", \"60\\n-20 179\\n-68 0\\n-110 68\\n-22 177\\n47 140\\n-49 -4\\n-106 38\\n-23 22\\n20 193\\n47 173\\n-23 22\\n-100 32\\n-97 29\\n47 124\\n-49 -4\\n20 193\\n-20 179\\n-50 149\\n-59 -7\\... | The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them.
For that a young player Vasya decided to make the shepherd run round the cows a... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\\n\", \"10 100000\\n1 2 3 4 5 6 7 8 9 10\\n\", \"2 100\\n1 2\\n\", \"10 100000\\n1 1 2 2 3 3 4 4 5 5\\n\", \"5 100000\\n1 1 1 1 1\\n\", \"1 0\\n1\\n\", \"2 1\\n1 1\\n\", \"2 1\\n2 2\\n\", \"86 95031\\n1 1 2 1 1 2 1 1 1 1 2 2 2 1 1 1 2 2 1 2 1 1 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 2 2 1 ... | When Darth Vader gets bored, he sits down on the sofa, closes his eyes and thinks of an infinite rooted tree where each node has exactly n sons, at that for each node, the distance between it an its i-th left child equals to d_{i}. The Sith Lord loves counting the number of nodes in the tree that are at a distance at m... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n5\\n2\\n1\\n4\\n3\\n\", \"4\\n3\\n2\\n4\\n1\\n\", \"7\\n3\\n2\\n1\\n6\\n5\\n4\\n7\\n\", \"6\\n5\\n3\\n4\\n1\\n2\\n6\\n\", \"6\\n5\\n3\\n8\\n1\\n2\\n6\", \"4\\n3\\n2\\n3\\n1\", \"6\\n5\\n3\\n8\\n1\\n2\\n3\", \"4\\n3\\n2\\n2\\n1\", \"6\\n4\\n3\\n8\\n1\\n2\\n3\", \"4\\n3\\n1\\n2\\n1\", \"4\\... | You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the state where p_i=i for every i can be reached by performing the following operation any number of times:
- Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three.
----... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 3 2 1 2\\n1 2\\n1 3\\n1 4\\n6 6 1 2 5\\n1 2\\n6 5\\n2 3\\n3 4\\n4 5\\n9 3 9 2 5\\n1 2\\n1 6\\n1 9\\n1 3\\n9 5\\n7 9\\n4 8\\n4 3\\n11 8 11 3 3\\n1 2\\n11 9\\n4 9\\n6 5\\n2 10\\n3 2\\n5 9\\n8 3\\n7 4\\n7 10\\n\", \"1\\n5 5 4 3 4\\n1 2\\n4 1\\n5 1\\n5 3\\n\", \"10\\n10 9 10 6 6\\n6 1\\n7 6... | Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of $n$ vertices numbered from $1$ to $n$. Recall that a tree on $n$ vertices is an undirected, connected graph with $n-1$ edges.
Initially, Alice is located at vertex $a$, and Bob at vertex $b$. They take turns alternately, and Alice makes... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n1 1\\n1 1\\n2 2\\n3 3\\n4 4\\n\", \"5 5\\n4 1\\n4 2\\n4 3\\n4 4\\n4 5\\n\", \"2 2\\n1 1\\n2 10\\n\", \"10 1\\n1 732\\n1 649\\n1 821\\n1 756\\n1 377\\n1 216\\n1 733\\n1 420\\n1 857\\n1 193\\n\", \"26 5\\n2 377\\n3 103\\n1 547\\n2 700\\n3 616\\n5 363\\n2 316\\n5 260\\n3 385\\n2 460\\n4 20... | Polycarp is making a quest for his friends. He has already made n tasks, for each task the boy evaluated how interesting it is as an integer q_{i}, and the time t_{i} in minutes needed to complete the task.
An interesting feature of his quest is: each participant should get the task that is best suited for him, depen... | 0 |
{"tests": "{\"inputs\": [\"9\\nabacbecfd\\n\", \"8\\naaabbcbb\\n\", \"7\\nabcdedc\\n\", \"5\\nabcde\\n\", \"200\\nraaaaabbbccccccccccdddddeeeeeeeeeeeeeeffffffffffggggggggghhhhhiiiiiiiiijjjjkkkkkkkkkkllllllllmmmmmmmmnnnnnnnooooooooppppppqqqqqqqqqqrrrrrrrrssssttttttttttuuuuuuuuvvvvvvwwwwwwxxxxxxxyyyyyyyzzzzzzzzzzzz\\n\",... | This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.
You are given a string $s$ consisting of $n$ lowercase Latin letters.
You have to color all its characters one of the ... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n0 0\\n3 -1\\n5 2\\n1 4\\n0 3\\n3\\n3\\n4\\n5\", \"5\\n1 0\\n3 -1\\n5 2\\n1 1\\n0 3\\n3\\n3\\n4\\n5\", \"5\\n0 0\\n2 0\\n5 2\\n1 4\\n0 3\\n3\\n3\\n4\\n5\", \"5\\n1 0\\n3 -1\\n5 2\\n1 1\\n0 3\\n3\\n3\\n4\\n4\", \"5\\n0 0\\n2 0\\n5 1\\n1 4\\n0 3\\n3\\n3\\n4\\n5\", \"5\\n1 0\\n3 0\\n5 2\\n1 1... | Let's write a program related to an unsolved math problem called "Happy End Problem". Create a program to find the smallest convex polygon formed by connecting exactly k points from the N points given on the plane. However, after being given the coordinates of N points, the question is given the number k of the angles ... | 0 |
{"tests": "{\"inputs\": [\"BBBWW\\n\", \"WWWWWW\\n\", \"WBWBWBWBWB\\n\", \"WWWXWW\", \"WBWBWBBBWW\", \"BWBBW\", \"WXWXWW\", \"WWBBCWBWBV\", \"XWBBCWBWBV\", \"XWVBCWBWCB\", \"WWBBB\", \"XWVWVX\", \"WWBBBWBWBW\", \"WBBWB\", \"WXVXWW\", \"WWBBBWBWBV\", \"WBBXB\", \"WWXVXW\", \"BXBBW\", \"WWXUXW\", \"BXBWB\", \"WXUXWW\", \... | Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones b... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n-3 1 1\\n2 -4 1\\n2 1 -1\\n3\\n-4 1 1\\n1 1 -6\\n1 -5 3\\n4\\n-8 6 -2 1\\n2 -7 -2 1\\n1 -1 1 1\\n1 1 1 -5\\n6\\n2 2 3 -7 3 2\\n1 -10 1 1 3 2\\n2 6 5 2 -6 0\\n3 4 -23 2 2 5\\n3 3 -6 2 3 7\\n-7 2 3 2 -5 -13\\n6\\n2 2 3 -7 3 2\\n1 -10 1 1 3 2\\n2 6 5 2 -6 1\\n3 4 -23 2 2 5\\n3 3 -6 2 3 7\\n-... | Let's solve the puzzle by programming.
The numbers n x n are arranged in a grid pattern. Some of the numbers are circled and we will call them the starting point. The rules of the puzzle are as follows:
* Draw one line that goes vertically and horizontally from each starting point (cannot be drawn diagonally).
* Exte... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"1\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"99\\n\", \"999\\n\", \"9999\\n\", \"99999\\n\", \"999999\\n\", \"524287\\n\", \"131071\\n\", \"178481\\n\", \"524288\\n\", \"1000000\\n\", \"3\\n\", \"1\\n\", \"9999\\n\", \"5\\n\", \"999999\\... | Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it doesn’t matter which pl... | 0.125 |
{"tests": "{\"inputs\": [[[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"], 3, 2, \"c\"], [[\"c\", \"b\", \"c\", \"d\", \"e\", \"f\"], 3, 2, \"c\"], [[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"], 3, 2, \"g\"], [[\"a\", \"b\", \"c\", \"c\", \"e\", \"c\"], 7, 1, \"c\"], [[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"], 1, 2, \"b\"], ... | # Let's watch a parade!
## Brief
You're going to watch a parade, but you only care about one of the groups marching. The parade passes through the street where your house is. Your house is at number `location` of the street. Write a function `parade_time` that will tell you the times when you need to appear to see all ... | 0 |
{"tests": "{\"inputs\": [[[]], [[[1]]], [[[0, 1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3, 4, 5, 6]]], [[[1], [2], [3], [4], [5], [6]]], [[[\"a\", \"b\", \"c\"], [\"d\", \"e\", \"f\"]]], [[[true, false, true], [false, true, false]]], [[[]]], [[[], [], [], [], [], []]]], \"outputs\": [[[]], [[[1]]], [[[0], [1]]], [[[1, 4... | Transpose means is to interchange rows and columns of a two-dimensional array matrix.
[A^(T)]ij=[A]ji
ie:
Formally, the i th row, j th column element of AT is the j th row, i th column element of A:
Example :
```
[[1,2,3],[4,5,6]].transpose() //should return [[1,4],[2,5],[3,6]]
```
Write a prototype transpose to... | 0 |
{"tests": "{\"inputs\": [\"4\\n2\\n1 0\\n2\\n0 0\\n4\\n0 1 1 1\\n4\\n1 1 0 0\\n\", \"4\\n2\\n1 0\\n2\\n0 0\\n4\\n0 1 1 1\\n4\\n1 1 0 0\\n\", \"4\\n2\\n1 0\\n2\\n0 0\\n4\\n0 1 1 0\\n4\\n1 1 0 0\\n\", \"4\\n2\\n1 0\\n2\\n0 0\\n4\\n0 1 1 0\\n4\\n1 1 1 0\\n\", \"4\\n2\\n1 1\\n2\\n0 0\\n4\\n0 1 1 1\\n4\\n1 1 0 0\\n\", \"4\\... | Alexandra has an even-length array $a$, consisting of $0$s and $1$s. The elements of the array are enumerated from $1$ to $n$. She wants to remove at most $\frac{n}{2}$ elements (where $n$ — length of array) in the way that alternating sum of the array will be equal $0$ (i.e. $a_1 - a_2 + a_3 - a_4 + \dotsc = 0$). In o... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n1 2 3 4 5\\n\", \"5 1\\n-4 -5 -3 -2 -1\\n\", \"10 2\\n10 9 1 -9 -7 -9 3 8 -10 5\\n\", \"10 4\\n-8 -1 2 -3 9 -8 4 -3 5 9\\n\", \"1 1\\n504262064\\n\", \"3 3\\n-54481850 -878017339 -486296116\\n\", \"2 2\\n-333653905 224013643\\n\", \"14 2\\n-14 84 44 46 -75 -75 77 -49 44 -82 -74 -51 -9 -... | You are given an array a_1, a_2, ..., a_{n} consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k obtained minimums. What is the maximum possible integer you can ge... | 0 |
{"tests": "{\"inputs\": [\"8 4 1\\n3 3\", \"10 6 10\\n10 4\\n4 4\\n5 1\\n4 2\\n7 3\\n1 3\\n2 4\\n8 2\\n3 5\\n7 1\", \"10 6 10\\n10 4\\n4 4\\n5 1\\n6 2\\n7 3\\n1 3\\n2 4\\n8 2\\n7 5\\n7 1\", \"8 4 0\\n3 3\", \"3 4 0\\n5 3\", \"4 4 0\\n3 3\", \"8 2 0\\n3 3\", \"4 4 1\\n3 1\", \"10 6 10\\n10 4\\n4 2\\n5 1\\n4 2\\n7 3\\n1 ... | There is an Amidakuji that consists of w vertical bars and has a height (the number of steps to which horizontal bars can be added) of h. w is an even number. Of the candidates for the place to add the horizontal bar of this Amidakuji, the ath from the top and the bth from the left are called (a, b). (When a horizontal... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 7 8 8\\n7\\n4 2 5 2 6 2 7\\n\", \"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 7 8 8\\n7\\n4 2 5 2 6 2 5\\n\", \"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 7 8 8\\n7\\n4 2 5 3 6 2 5\\n\", \"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 7 4 4 7 8 8\\n7\\n4 2 5 3 6 2 5\\n\", \"3\\n7... | You are given a sequence $a_1, a_2, \dots, a_n$, consisting of integers.
You can apply the following operation to this sequence: choose some integer $x$ and move all elements equal to $x$ either to the beginning, or to the end of $a$. Note that you have to move all these elements in one direction in one operation.
Fo... | 0.125 |
{"tests": "{\"inputs\": [\"7 1.0000\\n\", \"3 0.0000\\n\", \"3 1.0000\\n\", \"1000 0.0000\\n\", \"1000 1.0000\\n\", \"999 1.0000\\n\", \"38 0.2356\\n\", \"217 0.0744\\n\", \"847 0.3600\\n\", \"357 0.9853\\n\", \"440 0.9342\\n\", \"848 0.8576\\n\", \"141 0.0086\\n\", \"517 0.4859\\n\", \"937 0.8022\\n\", \"995 0.4480\\n... | Little Johnny Bubbles enjoys spending hours in front of his computer playing video games. His favorite game is Bubble Strike, fast-paced bubble shooting online game for two players.
Each game is set in one of the N maps, each having different terrain configuration. First phase of each game decides on which map the gam... | 0 |
{"tests": "{\"inputs\": [\"7\\n2 1 1\\n3 2 0\\n4 2 1\\n5 2 0\\n6 7 1\\n7 2 1\\n\", \"2\\n1 2 1\\n\", \"2\\n1 2 0\\n\", \"2\\n1 2 1\\n\", \"2\\n1 2 0\\n\", \"7\\n2 1 1\\n3 2 0\\n4 2 1\\n5 4 0\\n6 7 1\\n7 2 1\\n\", \"7\\n2 1 1\\n3 2 1\\n4 2 1\\n5 2 0\\n6 7 1\\n7 2 1\\n\", \"7\\n2 1 1\\n3 2 0\\n4 2 1\\n5 2 0\\n6 7 0\\n7 2... | You are given a tree (an undirected connected acyclic graph) consisting of $n$ vertices and $n - 1$ edges. A number is written on each edge, each number is either $0$ (let's call such edges $0$-edges) or $1$ (those are $1$-edges).
Let's call an ordered pair of vertices $(x, y)$ ($x \ne y$) valid if, while traversing t... | 0 |
{"tests": "{\"inputs\": [[[1, 3, 2]], [[1, 2, 3, 4, 5]], [[3, 4, 1, 2, 5]], [[10, 20, 40, 50, 30]], [[1, 10]], [[22, 33, 18, 9, 110, 4, 1, 88, 6, 50]]], \"outputs\": [[[3, 1, 2]], [[5, 4, 3, 2, 1]], [[3, 2, 5, 4, 1]], [[5, 4, 2, 1, 3]], [[2, 1]], [[5, 4, 6, 7, 1, 9, 10, 2, 8, 3]]]}", "source": "taco"} | You are given an array of unique numbers. The numbers represent points. The higher the number the higher the points.
In the array [1,3,2] 3 is the highest point value so it gets 1st place. 2 is the second highest so it gets second place. 1 is the 3rd highest so it gets 3rd place.
Your task is to return an array giv... | 0 |
{"tests": "{\"inputs\": [[\"00000001\", 8], [\"00000010\", 8], [\"01111110\", 8], [\"01111111\", 8], [\"11111111\", 8], [\"11111110\", 8], [\"10000010\", 8], [\"1000 0000\", 8], [\"1010 1010 0010 0010 1110 1010 0010 1110\", 32], [\"1000 0000 1110 1111 0011 0100 1100 1010\", 32], [\"10110001000100000101100011111000\", 3... | The goal is to write a pair of functions the first of which will take a string of binary along with a specification of bits, which will return a numeric, signed complement in two's complement format. The second will do the reverse. It will take in an integer along with a number of bits, and return a binary string.
ht... | 0 |
{"tests": "{\"inputs\": [\"2 3 1001 1000 1 1 1 2\", \"16 10 1 10 3 3 7 7\", \"2 3 1001 1000 1 2 1 2\", \"16 10 1 10 3 3 2 7\", \"2 3 1000 1000 1 2 1 2\", \"2 3 1000 1000 1 2 0 2\", \"2 3 1000 1010 1 2 0 2\", \"16 10 0 7 3 3 2 8\", \"2 2 1000 1000 1 1 1 2\", \"10 10 1 22 3 3 7 7\", \"10 10 1 10 3 3 7 3\", \"2 3 1001 100... | The fearless Ikta has finally hunted down the infamous Count Big Bridge! Count Bigbridge is now trapped in a rectangular room w meters wide and h meters deep, waiting for his end.
If you select a corner of the room and take the coordinate system so that the width direction is the x-axis and the depth direction is the ... | 0 |
{"tests": "{\"inputs\": [\"K3n5JwuWoJdFUVq8H5QldFqDD2B9yCUDFY1TTMN10\\n\", \"F646Pj3RlX5iZ9ei8oCh.IDjGCcvPQofAPCpNRwkBa6uido8w\\n\", \"uVVcZsrSe\\n\", \"rXoypUjrOofxvzuSUrNfhxn490ZBwQZ0mMHYFlY4DCNQW\\n\", \"F7\\n\", \"B9O9WWF\\n\", \"oZndfd2PbCT85u6081\\n\", \"A\\n\", \"D5LkqCdKJsy\\n\", \"XugVHXi3RqJWXaP9i6g.0fP\\n\",... | <image>
You can preview the image in better quality by the link: [http://assets.codeforces.com/files/656/without-text.png](//assets.codeforces.com/files/656/without-text.png)
Input
The only line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be an alphanumeric character o... | 0 |
{"tests": "{\"inputs\": [\"2 100\\n85 2 6\\n60 1 1\", \"10 1000\\n451 4593 6263\\n324 310 9662\\n378 1431 7068\\n71 1757 9218\\n204 3676 4328\\n840 6221 9080\\n684 1545 8511\\n709 5467 8674\\n862 6504 9835\\n283 4965 9980\", \"1 100000\\n31415 2718 1443\", \"2 100\\n85 2 11\\n60 1 1\", \"10 1000\\n451 4593 6263\\n324 3... | Takahashi and Aoki will take N exams numbered 1 to N. They have decided to compete in these exams. The winner will be determined as follows:
* For each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusive).
* Let A be \sum_{i=1}^{N} c_i \times (Takahashi's score on Exa... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"2\\n1 2\\n\", \"3\\n1 2 1\\n\", \"2\\n1 3\\n\", \"2\\n3 5\\n\", \"2\\n9 10\\n\", \"2\\n6 8\\n\", \"3\\n0 0 0\\n\", \"2\\n223 58\\n\", \"2\\n106 227\\n\", \"2\\n125 123\\n\", \"3\\n31 132 7\\n\", \"2\\n41 29\\n\", \"3\\n103 286 100\\n\", \"3\\n9 183 275\\n\", \"3\\n19 88 202\\n... | Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!
Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games.
BitLGM and Bi... | 0 |
{"tests": "{\"inputs\": [[\"Q♣\", \"3♣\", \"♦\"], [\"3♣\", \"Q♣\", \"♦\"], [\"5♥\", \"A♣\", \"♦\"], [\"8♠\", \"8♠\", \"♣\"], [\"2♦\", \"A♠\", \"♦\"], [\"A♠\", \"2♦\", \"♦\"], [\"joker\", \"joker\", \"♦\"], [\"joker\", \"10♣\", \"♠\"], [\"10♣\", \"joker\", \"♠\"]], \"outputs\": [[\"The first card won.\"], [\"The second ... | Lеt's create function to play cards. Our rules:
We have the preloaded `deck`:
```
deck = ['joker','2♣','3♣','4♣','5♣','6♣','7♣','8♣','9♣','10♣','J♣','Q♣','K♣','A♣',
'2♦','3♦','4♦','5♦','6♦','7♦','8♦','9♦','10♦','J♦','Q♦','K♦','A♦',
'2♥','3♥','4♥','5♥','6♥','7♥','8♥','9♥','10♥','J♥','Q♥... | 0 |
{"tests": "{\"inputs\": [[5, 5], [2, 10], [10, 2], [7, 9], [1, 1], [16777216, 14348907]], \"outputs\": [[3], [13], [10], [4], [1], [23951671]]}", "source": "taco"} | 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 on 0 at the top, and on each move we spin each ring by 1. How man... | 0 |
{"tests": "{\"inputs\": [\"8\\n00000000\\n80000000\\n00000080\\n00000040\\n000000c0\\n00000100\\n15330257\\n80000f70\", \"8\\n00000000\\n80000000\\n00000080\\n00000040\\n000000c0\\n00000100\\n21251916\\n80000f70\", \"8\\n00000100\\n80000000\\n00000080\\n00000040\\n000000c0\\n00000100\\n21251916\\n80000f70\", \"8\\n0000... | Consider a 32-bit real type with 7 bits from the right as the decimal part, the following 24 bits as the integer part, and the leftmost 1 bit as the sign part as shown below (b1, ..., b32). Represents 0 or 1).
<image>
To translate this format into a decimal representation that is easy for humans to understand, inter... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n5 7\\n8 14\\n3 9\", \"3 3\\n9 7\\n8 14\\n3 9\", \"3 3\\n9 7\\n8 14\\n3 5\", \"3 3\\n5 7\\n8 8\\n3 9\", \"100000 1\\n1 2\\n3 4\", \"3 3\\n9 5\\n5 14\\n3 5\", \"3 3\\n5 7\\n8 8\\n4 9\", \"3 3\\n9 5\\n7 14\\n3 5\", \"3 3\\n8 7\\n8 8\\n4 9\", \"2 3\\n9 7\\n8 4\\n3 9\", \"3 2\\n8 7\\n8 11\\n... | You are given an integer N. Consider an infinite N-ary tree as shown below:
<image>
Figure: an infinite N-ary tree for the case N = 3
As shown in the figure, each vertex is indexed with a unique positive integer, and for every positive integer there is a vertex indexed with it. The root of the tree has the index 1. ... | 0 |
{"tests": "{\"inputs\": [\"5\\n-X--X\", \"20\\nX-X-X--X--X-X--X--X-\", \"5\\n-X-X-\", \"20\\n-X--X--X-X-----XXX-X\", \"100\\n-X-X-X--X-X--X--X-X--X-X-X--X-X-X--X--X-X-X-X--X--X-X-X-X-X-X-X-X-X-X-X-X-X-X-X--X-X-X-X-X-X-X-X-X-X\", \"5\\nX-X--\", \"20\\n-X.-X--X-X-----XXX-X\", \"20\\nX-XXX-----X-X--X-.X-\", \"20\\nX-XYX--... | There is a very long bench. The bench is divided into M sections, where M is a very large integer.
Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action:
* We call a section comfortable if the section is currently unoccupied and is not adjacent to any occupied s... | 0 |
{"tests": "{\"inputs\": [\"58 5858758 7544547\\n6977 5621 6200 6790 7495 5511 6214 6771 6526 6557 5936 7020 6925 5462 7519 6166 5974 6839 6505 7113 5674 6729 6832 6735 5363 5817 6242 7465 7252 6427 7262 5885 6327 7046 6922 5607 7238 5471 7145 5822 5465 6369 6115 5694 6561 7330 7089 7397 7409 7093 7537 7279 7613 6764 73... | It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.
Unfortunately, Joe ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2\\n1 3\\n1 4\\n0 3 2 0\\n-3 4 5 -1\", \"4\\n1 2\\n2 3\\n1 4\\n0 3 2 0\\n-3 4 5 -1\", \"4\\n1 2\\n1 4\\n3 4\\n0 3 2 0\\n-3 4 5 -1\", \"4\\n1 2\\n1 3\\n1 4\\n0 4 2 0\\n-3 4 5 -1\", \"4\\n1 2\\n2 3\\n1 4\\n0 3 2 0\\n-3 2 5 -1\", \"4\\n1 2\\n1 3\\n3 4\\n0 3 2 0\\n-4 4 5 -1\", \"4\\n1 2\\n1... | Problem statement
There is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices.
Each vertex has a button, and the button at the $ i $ th vertex is called the button $ i $.
First, the beauty of the button $ i $ is $ a_i $.
Each time you press the button ... | 0 |
{"tests": "{\"inputs\": [\"4 1\\n1020\\n\", \"6 2\\n199119\\n\", \"5 2\\n99999\\n\", \"5 2\\n49792\\n\", \"4 2\\n2939\\n\", \"12 7\\n129679930099\\n\", \"6 2\\n199999\\n\", \"20 19\\n19999999999999999999\\n\", \"5 3\\n78989\\n\", \"10 3\\n9879879999\\n\", \"4 2\\n1102\\n\", \"5 3\\n12933\\n\", \"9 3\\n987987999\\n\", \... | You are given an integer x of n digits a_1, a_2, …, a_n, which make up its decimal notation in order from left to right.
Also, you are given a positive integer k < n.
Let's call integer b_1, b_2, …, b_m beautiful if b_i = b_{i+k} for each i, such that 1 ≤ i ≤ m - k.
You need to find the smallest beautiful integer y,... | 0 |
{"tests": "{\"inputs\": [\"1 7\\n0000000\\n\", \"2 5\\n0010010\\n0010010\\n\", \"3 5\\n0100001\\n1001001\\n1010011\\n\", \"10 0\\n0111010\\n1101111\\n1111011\\n0111010\\n1101011\\n1101011\\n1110111\\n1010010\\n1111111\\n0010010\\n\", \"10 10\\n0101111\\n0000000\\n1111011\\n1011011\\n1011011\\n1111011\\n0010010\\n101001... | Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer.
The poor boy was very upset because of that. He wa... | 0 |
{"tests": "{\"inputs\": [\"3\\n7 2 3 6\\n1 4\\n7 2 3 6\\n5 1\\n7 2 3 6\\n4 4\\n\", \"3\\n7 2 3 6\\n1 4\\n7 2 3 6\\n5 1\\n7 2 3 6\\n2 4\\n\", \"3\\n7 2 3 6\\n1 4\\n7 2 3 6\\n5 1\\n12 2 3 6\\n4 4\\n\", \"3\\n7 2 3 6\\n1 4\\n7 2 3 4\\n5 1\\n7 2 3 6\\n2 4\\n\", \"3\\n7 2 3 6\\n1 4\\n7 2 3 9\\n5 1\\n7 2 3 6\\n2 4\\n\", \"3\... | Consider a long corridor which can be divided into $n$ square cells of size $1 \times 1$. These cells are numbered from $1$ to $n$ from left to right.
There are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in the $a$-th cell, the guard is in the $b$-th cell ($a \ne b$).
One... | 0 |
{"tests": "{\"inputs\": [\"1 2 5\\n\", \"-1 4 15\\n\", \"0 -1 5\\n\", \"0 1 8\\n\", \"-134 -345 -134\\n\", \"-134 -345 -133\\n\", \"999999999 -1000000000 1000000000\\n\", \"0 0 0\\n\", \"0 0 1\\n\", \"-1000000000000000000 1 1000000000000000000\\n\", \"-3 26 -1\\n\", \"-25 4 -8\\n\", \"12 30 -8\\n\", \"-12 17 3\\n\", \"... | Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.
Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the number... | 0.125 |
{"tests": "{\"inputs\": [\"2 3 5\\n4 6\\n\", \"2 3 5\\n4 7\\n\", \"6 3 5\\n12 11 12 11 12 11\\n\", \"1 4 3\\n12\\n\", \"10 1 17\\n3 1 1 2 1 3 4 4 1 4\\n\", \"3 6 3\\n2 5 9\\n\", \"7 26 8\\n5 11 8 10 12 12 3\\n\", \"11 5 85\\n19 20 6 7 6 2 1 5 8 15 6\\n\", \"7 7 2\\n5 2 4 2 4 1 1\\n\", \"8 5 10\\n1 7 2 5 2 1 6 5\\n\", \... | На тренировку по подготовке к соревнованиям по программированию пришли n команд. Тренер для каждой команды подобрал тренировку, комплект задач для i-й команды занимает a_{i} страниц. В распоряжении тренера есть x листов бумаги, у которых обе стороны чистые, и y листов, у которых только одна сторона чистая. При печати у... | 0 |
{"tests": "{\"inputs\": [\"7 5\\n3 1 4 1 5 9 3\", \"15 10\\n1 5 6 10 11 11 11 20 21 25 25 26 99 83 99\", \"15 10\\n1 5 6 10 11 11 11 20 21 25 25 26 99 83 56\", \"15 10\\n1 5 6 10 11 11 11 20 21 25 25 26 99 124 99\", \"7 5\\n3 1 4 1 5 8 3\", \"15 10\\n1 5 6 10 11 11 11 20 21 1 25 26 99 124 99\", \"7 8\\n4 2 5 1 5 9 3\",... | Takahashi is playing with N cards.
The i-th card has an integer X_i on it.
Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:
* The integers on the two cards are the same.
* The sum of the integers on the two cards is a multiple of M.
Find the maximum numb... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 3 3 3\\n\", \"4\\n1 2 2 2\\n\", \"8\\n1 1 1 1 1 2 2 2\\n\", \"44\\n28 28 36 40 28 28 35 28 28 33 33 28 28 28 28 47 28 43 28 28 35 38 49 40 28 28 34 39 45 32 28 28 28 50 39 28 32 28 50 32 28 33 28 28\\n\", \"4\\n2 1 1 1\\n\", \"28\\n48 14 22 14 14 14 14 14 47 39 14 36 14 14 49 41 36 45 1... | Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stone... | 0 |
{"tests": "{\"inputs\": [\"5\\n2\\n3\\n3\\n5\\n6\", \"2\\n6\\n3\", \"2\\n6\\n2\", \"2\\n5\\n2\", \"2\\n1\\n2\", \"2\\n1\\n3\", \"5\\n2\\n3\\n5\\n5\\n6\", \"5\\n2\\n3\\n3\\n2\\n6\", \"2\\n8\\n3\", \"2\\n5\\n1\", \"2\\n14\\n2\", \"2\\n14\\n4\", \"2\\n3\\n2\", \"2\\n14\\n8\", \"2\\n15\\n2\", \"2\\n14\\n16\", \"2\\n11\\n2\... | There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color i. None of the sides were painted in multiple colors. Find the mi... | 0.125 |
{"tests": "{\"inputs\": [[1], [2], [3], [7], [17], [27], [0], [-89]], \"outputs\": [[\"1\"], [\"22\\n21\"], [\"333\\n322\\n321\"], [\"7777777\\n7666666\\n7655555\\n7654444\\n7654333\\n7654322\\n7654321\"], [\"77777777777777777\\n76666666666666666\\n76555555555555555\\n76544444444444444\\n76543333333333333\\n76543222222... | ## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto n number of rows.
* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.
### Rules/Note:
* The pattern should be created using only unit digits.
* If `n < 1` then it should return "" i.... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 100\\n2 1 10\\n\", \"1\\n9 2 8 6 5 9 4 7 1 3\\n\", \"3\\n3 1 3 2\\n3 5 4 6\\n2 8 7\\n\", \"3\\n3 1000 1000 1000\\n6 1000 1000 1000 1000 1000 1000\\n5 1000 1000 1000 1000 1000\\n\", \"1\\n1 1\\n\", \"5\\n1 3\\n1 2\\n1 8\\n1 1\\n1 4\\n\", \"3\\n5 1 2 3 4 5\\n4 1 2 3 4\\n8 1 2 3 4 5 6 7 8\... | Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.
The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any non-empty pile, and in Jiro's turn he takes a card from the bottom o... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n5960 3774 3598 3469 3424\", \"5 5\\n3949 3774 4045 3469 3424\", \"5 5\\n5960 3774 3598 2384 3424\", \"5 5\\n5960 3774 3598 610 3424\", \"5 5\\n5960 3170 3598 610 3424\", \"5 1\\n5960 3170 3598 610 3424\", \"5 5\\n3949 359 3598 3469 3424\", \"5 5\\n5960 3774 3598 4173 3424\", \"5 5\\n394... | Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤ 5
* a_i ≤ 7
Subtask 3 [140 points]
* There are no additional constraint... | 0 |
{"tests": "{\"inputs\": [[\"\"], [\"0\"], [\"1\"], [\"4\"], [\"15\"], [\"2rr\"], [\"1wbg\"], [\"1WWU\"], [\"0r\"], [\"2x\"], [\"2R\"], [\"2\\n\"], [\"\\n2\"], [\"1b\"], [\"1bb\"], [\"1bbb\"], [\"1bg\"], [\"1bgu\"], [\"1br\"], [\"1brg\"], [\"1g\"], [\"1gg\"], [\"1ggg\"], [\"1ggu\"], [\"1ggw\"], [\"1gu\"], [\"1guu\"], [\... | Implement `String#parse_mana_cost`, which parses [Magic: the Gathering mana costs](http://mtgsalvation.gamepedia.com/Mana_cost) expressed as a string and returns a `Hash` with keys being kinds of mana, and values being the numbers.
Don't include any mana types equal to zero.
Format is:
* optionally natural number re... | 0 |
{"tests": "{\"inputs\": [\"2\\n2\\nYNNNNYYY\\n2\\nNYNNYYNNNYNYYNNN\", \"2\\n2\\nYYZNNNNY\\n2\\nYYNNYNNNNYNYYNNN\", \"2\\n2\\nYYZNNNNY\\n4\\nNYNNYYNNNYNYYNNN\", \"2\\n2\\nYYZNNNNY\\n4\\nNNNYYNYNNNYYONYN\", \"2\\n2\\nYYZNYNNN\\n4\\nNNNYYNYNNNYYNNYN\", \"2\\n2\\nYNNNNYYY\\n3\\nNYNNYYNNNYNYYNNN\", \"2\\n2\\nNNNYNZYY\\n0\\n... | She is an extraordinary girl. She works for a library. Since she is young and cute, she is forced to do a lot of laborious jobs. The most annoying job for her is to put returned books into shelves, carrying them by a cart. The cart is large enough to carry many books, but too heavy for her. Since she is delicate, she w... | 0 |
{"tests": "{\"inputs\": [\"1\\n0\\n\", \"4\\n1 4 2 3\\n\", \"4\\n23 7 5 1\\n\", \"8\\n4 5 3 6 2 7 1 8\\n\", \"8\\n23 2 7 5 15 8 4 10\\n\", \"4\\n23 5 7 1\\n\", \"2\\n-1000000000 1000000000\\n\", \"4\\n2 4 2 3\\n\", \"4\\n23 7 1 1\\n\", \"8\\n23 2 7 5 15 8 4 19\\n\", \"4\\n15 5 7 1\\n\", \"2\\n-1000000000 1000000100\\n\... | In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonempty segment of consecutive children of a line. A group's sociability is the maxim... | 0 |
{"tests": "{\"inputs\": [\"6 5\\naabbaa\\nbaaaab\\naaaaa\\n\", \"5 4\\nazaza\\nzazaz\\nazaz\\n\", \"9 12\\nabcabcabc\\nxyzxyzxyz\\nabcabcayzxyz\\n\", \"1 2\\nt\\nt\\ntt\\n\", \"20 40\\nxxxxxxxxxxxxxxxxxxxx\\nxxxxxxxxxxxxxxxxxxxx\\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\n\", \"20 27\\nmmmmmmmmmmmmmmmmmmmm\\nmmmmmmmmm... | Vasya had three strings $a$, $b$ and $s$, which consist of lowercase English letters. The lengths of strings $a$ and $b$ are equal to $n$, the length of the string $s$ is equal to $m$.
Vasya decided to choose a substring of the string $a$, then choose a substring of the string $b$ and concatenate them. Formally, he c... | 0.75 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"199 200\\n\", \"1 1000000000000000000\\n\", \"3 1\\n\", \"21 8\\n\", \"18 55\\n\", \"1 2\\n\", \"2 1\\n\", \"1 3\\n\", \"2 3\\n\", \"1 4\\n\", \"5 2\\n\", \"2 5\\n\", \"4 5\\n\", \"3 5\\n\", \"13 4\\n\", \"21 17\\n\", \"5 8\\n\", \"13 21\\n\", \"74 99\\n\", \"2377 1055... | Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.
However, all Mike has is lots of identical resistors with unit resistance R_0 = 1. Elements with other resistance can be constructed from these resistors. In this problem, we will c... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n0 0\\n1 1\\n0 3\\n1 2\", \"4\\n0 0\\n0 2\\n0 4\\n2 0\\n\", \"3\\n-1 -1\\n1 0\\n3 1\", \"2\\n10000 10000\\n-10000 -10000\\n\", \"5\\n-8893 8986\\n-3629 9045\\n-7719 -6470\\n-258 4491\\n-6902 -6866\\n\", \"25\\n1964 -4517\\n5939 -4080\\n9503 -7541\\n-5037 -6950\\n-9914 5015\\n-435 7555\\n-9... | This problem is same as the next one, but has smaller constraints.
It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons... | 0.375 |
{"tests": "{\"inputs\": [\"20 20\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"10 4\\n0 1 4 2 7 0 10 0 5 8\\n\", \"10 7\\n10 8 6 5 0 0 0 4 3 9\\n\", \"10 1\\n8 7 0 2 0 10 0 0 3 5\\n\", \"10 7\\n7 9 2 10 0 0 0 3 5 1\\n\", \"10 2\\n10 0 9 0 0 4 2 6 8 0\\n\", \"10 2\\n0 7 0 10 8 0 4 2 3 0\\n\", \"10 4\\n0 1 4 2 3 0 10... | In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.
(Cultural note: standing in huge and disorganized queues for hours is a native ... | 0 |
{"tests": "{\"inputs\": [\"6 5\\n0 0 0 0 0\\n0 0 0 0 0\\n0 3 3 3 0\\n0 3 3 3 0\\n0 3 3 3 0\\n0 0 0 0 0\\n\", \"2 3\\n0 0 0\\n0 0 0\\n\", \"10 10\\n0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0\\n0 0 1585 1564 3603 1095 1364 1029 3189 1331\\n0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0... | A widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called "Guess That Car!".
The game show takes place on a giant parking lot, which is 4n meters long from north to south and 4m meters wide from west ... | 0.25 |
{"tests": "{\"inputs\": [\"300 10 8 5\\n50 5 2 1\\n70 5 2 0\\n75 1 1 0\\n100 3 1 0\\n150 2 2 0\\n240 5 5 7\\n50 1 1 0\\n60 2 2 0\\n70 2 3 0\\n90 1 3 0\\n120 3 5 0\\n140 4 1 0\\n150 2 4 1\\n180 3 5 4\\n15 2 2 1\\n20 2 2 1\\n25 2 2 0\\n60 1 1 0\\n120 5 5 4\\n15 5 4 1\\n20 5 4 0\\n40 1 1 0\\n40 2 2 0\\n120 2 3 4\\n30 1 1 ... | ICPC Ranking
Your mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings.
The log is a sequence of records of program submission in the order of submission. A record has four fields: elapsed time, team number, p... | 0.125 |
{"tests": "{\"inputs\": [\"100001 50000\", \"5 10\", \"0 2\", \"100001 27098\", \"5 7\", \"101001 27098\", \"6 7\", \"101000 27098\", \"3 7\", \"101000 9586\", \"3 10\", \"101000 14296\", \"2 10\", \"101000 4853\", \"101000 3325\", \"101001 3325\", \"101001 365\", \"101011 365\", \"101011 172\", \"101011 164\", \"10101... | We have a sequence of N integers: x=(x_0,x_1,\cdots,x_{N-1}). Initially, x_i=0 for each i (0 \leq i \leq N-1).
Snuke will perform the following operation exactly M times:
* Choose two distinct indices i, j (0 \leq i,j \leq N-1,\ i \neq j). Then, replace x_i with x_i+2 and x_j with x_j+1.
Find the number of differe... | 0 |
{"tests": "{\"inputs\": [[\"25abcd26\"], [\"18zyz14\"], [\"a1b2c3d4\"], [\"5a8p17\"], [\"w6aa4ct24m5\"], [\"17dh\"], [\"25gj8sk6r17\"], [\"18zzz14\"], [\"y17kg5et11\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"1a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z\"], [\"h15q4pc6yw23nmx19y\"], [\"p16k11o25x7... | In this Kata, you will create a function that converts a string with letters and numbers to the inverse of that string (with regards to Alpha and Numeric characters). So, e.g. the letter `a` will become `1` and number `1` will become `a`; `z` will become `26` and `26` will become `z`.
Example: `"a25bz"` would become `... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2\", \"2\\n2 -2\", \"2\\n2 -4\", \"2\\n2 -3\", \"2\\n2 -6\", \"2\\n2 -11\", \"2\\n2 -5\", \"2\\n2 -10\", \"2\\n2 -7\", \"2\\n2 -13\", \"2\\n2 -16\", \"2\\n2 -25\", \"2\\n2 -20\", \"2\\n2 -14\", \"2\\n2 -12\", \"2\\n2 -15\", \"2\\n2 -36\", \"2\\n2 -17\", \"2\\n2 -23\", \"2\\n2 -22\", \"2... | B: Parentheses Number
problem
Define the correct parenthesis string as follows:
* The empty string is the correct parenthesis string
* For the correct parenthesis string S, `(` S `)` is the correct parenthesis string
* For correct parentheses S, T ST is the correct parentheses
Here, the permutations are associate... | 0.125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.