info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"1 2\\n10 10\\n12 5\", \"100 1\\n111 101\\n102 1\", \"100 2\\n100 101\\n102 1\", \"1 1\\n1 20\\n12 5\", \"100 2\\n100 101\\n102 0\", \"1 1\\n2 20\\n12 5\", \"100 2\\n100 111\\n102 0\", \"1 1\\n0 20\\n12 5\", \"30901 15700\\n2647944172 11366428589\\n5864465524 4464634034\", \"1 -2\\n-2 1\\n1 3\...
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows towards the east: * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subse...
0
{"tests": "{\"inputs\": [\"4\\n3 9 1 -1\\n\", \"8\\n11 -1 13 19 24 7 17 5\\n\", \"8\\n-1 1 10 10 10 5 6 1\\n\", \"2\\n-1 1000000000\\n\", \"2\\n1000000000 -1\\n\", \"8\\n-1 8 8 8 1 1 1 1\\n\", \"16\\n-1 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2\\n\", \"4\\n1 -1 1 1\\n\", \"8\\n-1 2 2 2 2 1 1 1\\n\", \"32\\n8 4 1 -1 2 2 5 6 ...
You are organizing a boxing tournament, where $n$ boxers will participate ($n$ is a power of $2$), and your friend is one of them. All boxers have different strength from $1$ to $n$, and boxer $i$ wins in the match against boxer $j$ if and only if $i$ is stronger than $j$. The tournament will be organized as follows: ...
0
{"tests": "{\"inputs\": [\"4\\n63 63\\n12 34\\n17 29\\n58 91\\n\", \"1\\n0 0\\n\", \"6\\n42 60\\n78 107\\n6 38\\n58 81\\n70 105\\n70 105\\n\", \"2\\n50 67\\n54 64\\n\", \"6\\n99 100\\n65 65\\n34 34\\n16 18\\n65 67\\n88 88\\n\", \"3\\n5 6\\n1 3\\n1 4\\n\", \"2\\n1 2\\n1 3\\n\", \"3\\n1 5\\n1 2\\n4 5\\n\", \"3\\n1 10\\n5...
Luba needs your help again! Luba has n TV sets. She knows that i-th TV set will be working from moment of time li till moment ri, inclusive. Luba wants to switch off one of TV sets in order to free the socket. Let's call some TV set redundant if after switching it off the number of integer moments of time when at leas...
0
{"tests": "{\"inputs\": [\"4 0 4\\n1\\n2\\n3\\n4\\n\", \"15 10 15\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n\", \"7 4 7\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n\", \"10 2 10\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\", \"9 4 9\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"12 2 12\\n1\\n2\\n3\\n4\\n5\\n6...
After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boys have a chance to resolve the problem once and for all. Sasha se...
0
{"tests": "{\"inputs\": [\"6\\n8\\n1,2,2,2\\n1,3,4,3\\n1,4,4,2\\n2,5,3,2\\n3,4,4,2\\n3,6,1,2\\n4,6,1,1\\n5,6,2,2\\n2,4,50,30\", \"6\\n8\\n1,2,2,2\\n1,3,4,3\\n1,4,4,2\\n2,5,3,2\\n3,4,4,2\\n3,6,1,2\\n4,6,1,1\\n2,1,6,5\\n2,4,50,30\", \"6\\n8\\n1,2,2,2\\n0,3,4,3\\n2,4,4,1\\n2,5,3,2\\n3,4,2,4\\n3,6,1,2\\n4,6,1,1\\n5,6,2,2\\...
One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go to a dista...
0
{"tests": "{\"inputs\": [\"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 8\\n\", \"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 13\\n\", \"1 4\\n1 1 1 2\\n2 1 1 6\\n1 1 1 1\\n2 1 1 7\\n\", \"1 4\\n1 1 1 2\\n2 1 1 6\\n1 1 1 1\\n2 1 1 8\\n\", \"1 2\\n2 1 1 8\\n2 1 1 7\\n\", \"1 2\\n2 1 1 10\\n2 1 1 5\\n\", \...
Levko loves array a_1, a_2, ... , a_{n}, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from l_{i} to r_{i} by d_{i}. In other words, perform assignments a_{j} = a_{j...
0
{"tests": "{\"inputs\": [[[1, 2, 3]], [[-3, -2, -1]], [[-20, 0, 20]], [[-13, 4, 8]], [[1, 3, 2]], [[-2, -3, -1]], [[-20, 20, 0]], [[-13, 9, 8]], [[3, 6, 2]], [[3, 6, 2, 7, 3]], [[26, 32, -21, 45, 21]], [[14, 12, 17, 124, 1, -12, 21, -24]], [[]], [[25, 12, 7, 4, 2, -7, -12, -22]], [[324, 123, 36, 4, -1, -72, -123]], [[1...
In computer science and discrete mathematics, an [inversion](https://en.wikipedia.org/wiki/Inversion_%28discrete_mathematics%29) is a pair of places in a sequence where the elements in these places are out of their natural order. So, if we use ascending order for a group of numbers, then an inversion is when larger num...
0
{"tests": "{\"inputs\": [\"4\\n2 4 4 2\\n\", \"4\\n2 2 3 5\\n\", \"4\\n100003 100004 100005 100006\\n\", \"8\\n5 3 3 3 3 4 4 4\\n\", \"10\\n123 124 123 124 2 2 2 2 9 9\\n\", \"8\\n10 10 10 10 11 10 11 10\\n\", \"1\\n1000000\\n\", \"10\\n10519 10519 10520 10520 10520 10521 10521 10521 10522 10523\\n\", \"100\\n4116 4116...
In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length l_{i}. Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way that m...
0.125
{"tests": "{\"inputs\": [\"5\\n3 5\\n4 6\\n3 2\\n69 696\\n123456 654321\\n\", \"5\\n3 5\\n4 0\\n3 2\\n69 696\\n123456 654321\\n\", \"5\\n6 5\\n2 0\\n3 2\\n69 696\\n123456 654321\\n\", \"5\\n6 5\\n2 0\\n6 2\\n69 696\\n185099 654321\\n\", \"5\\n9 5\\n3 0\\n6 1\\n100 696\\n341251 1051160\\n\", \"5\\n14 1\\n3 0\\n1 3\\n100...
You are given two integers $n$ and $m$. Find the $\operatorname{MEX}$ of the sequence $n \oplus 0, n \oplus 1, \ldots, n \oplus m$. Here, $\oplus$ is the bitwise XOR operator . $\operatorname{MEX}$ of the sequence of non-negative integers is the smallest non-negative integer that doesn't appear in this sequence. For e...
0.75
{"tests": "{\"inputs\": [\"3\\nBBBGGGRRR\", \"3\\nRRRBGGBGB\", \"3\\nBRRGGGRBB\", \"5\\nBGRGRRBRGGRBBGB\", \"3\\nBGRGGRRBB\", \"5\\nBGBBRGGRGRRGRBB\", \"3\\nRGRBGRBGB\", \"5\\nBGRGRRBBGGRBRGB\", \"5\\nBRRBRGGBBGRGRGB\", \"5\\nBRRBRBGBGGRGRGB\", \"3\\nBBBGGRRGR\", \"5\\nBRRRRGBBGGGBGRB\", \"5\\nBRRGRBBBBGRGGRG\", \"5\\n...
We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls. Takahashi will distribute these 3N balls to N people so that each pe...
0
{"tests": "{\"inputs\": [\"2\\n1 5\\n3 3\\n\", \"3\\n6 5\\n-1 10\\n3 3\\n\", \"4\\n7 10\\n-10 3\\n4 3\\n-4 3\\n\", \"20\\n-8 1\\n26 4\\n0 5\\n9 1\\n19 4\\n22 20\\n28 27\\n11 8\\n-3 20\\n-25 17\\n10 4\\n-18 27\\n24 28\\n-11 19\\n2 27\\n-2 18\\n-1 12\\n-24 29\\n31 29\\n29 7\\n\", \"2\\n1 5\\n4 3\", \"3\\n6 5\\n-1 7\\n3 3...
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable. Takahashi, who is a misch...
0
{"tests": "{\"inputs\": [\"HEISEI 1 1 8\\nHEISEI 31 4 30\\nIESIEH 31 5 1\\nHEISEI 99 12 31\\nHEISEI 38 8 30\\nHEISEI 98 2 22\\nHEISEI 2 3 26\\nHEISEI 28 4 23\\n#\", \"HEISEI 1 1 8\\nHEISEI 31 4 30\\nIESIEH 31 5 1\\nHEISEI 99 12 31\\nHEISEI 38 8 30\\nHEISEI 98 2 22\\nHEISEI 3 3 26\\nHEISEI 28 4 23\\n#\", \"HEISEI 1 1 8\...
Revised The current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era. In the system developed by the ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG), the date uses the Japanese calendar (the Japa...
0.375
{"tests": "{\"inputs\": [\"5 8\\n2 5 3\\n4 1 3\\n3 4 7\\n3 1 9\\n1 2 6\\n5 3 7\\n2 4 7\\n4 5 9\\n\", \"10 15\\n6 5 805980\\n1 6 805980\\n7 8 805980\\n4 9 805980\\n4 1 805980\\n3 6 805980\\n6 9 805980\\n8 10 805980\\n3 1 805980\\n1 8 805980\\n8 4 805980\\n2 8 805980\\n2 10 805980\\n2 7 805980\\n2 9 805980\\n\", \"2 1\\n...
You are given a connected weighted undirected graph without any loops and multiple edges. Let us remind you that a graph's spanning tree is defined as an acyclic connected subgraph of the given graph that includes all of the graph's vertexes. The weight of a tree is defined as the sum of weights of the edges that the...
0
{"tests": "{\"inputs\": [\"5\\n1 2 3 2 1\\n\", \"3\\n10 6 8\\n\", \"7\\n1 2 1 2 1 2 1\\n\", \"7\\n1 2 1 2 1 3 1\\n\", \"1\\n1\\n\", \"5\\n1 1 4 2 2\\n\", \"6\\n1 3 4 3 5 4\\n\", \"100\\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 ...
This is an easier version of the problem. In this version $n \le 1000$ The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp...
0
{"tests": "{\"inputs\": [\"3 10 4\\n\", \"3 10 3\\n\", \"3 8 51\\n\", \"3 8 52\\n\", \"456947336 740144 45\\n\", \"33 232603 599417964\\n\", \"4363010 696782227 701145238\\n\", \"9295078 2 6\\n\", \"76079 281367 119938421\\n\", \"93647 7 451664565\\n\", \"5 18553 10908\\n\", \"6 52 30\\n\", \"6431 855039 352662\\n\", \...
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc. [Image] Barney woke up in the morning and wants to eat th...
0.375
{"tests": "{\"inputs\": [\"6\\n\", \"89\\n\", \"15\\n\", \"91\\n\", \"76\\n\", \"80\\n\", \"96\\n\", \"72\\n\", \"79\\n\", \"5\\n\", \"74\\n\", \"97\\n\", \"47\\n\", \"50\\n\", \"3\\n\", \"7\\n\", \"94\\n\", \"20\\n\", \"75\\n\", \"66\\n\", \"46\\n\", \"14\\n\", \"71\\n\", \"22\\n\", \"81\\n\", \"56\\n\", \"12\\n\", \"...
Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai, j. L...
0
{"tests": "{\"inputs\": [\"3 3\\n1 2 2\\n1 3 1\\n2 3 3\", \"4 3\\n1 2 1\\n1 3 1\\n2 3 3\", \"3 2\\n1 2 2\\n2 3 1\", \"3 2\\n1 3 2\\n2 3 1\", \"3 2\\n1 3 2\\n2 0 1\", \"3 2\\n1 2 2\\n2 0 1\", \"3 2\\n2 2 2\\n2 0 1\", \"3 2\\n1 1 1\\n2 3 1\", \"3 3\\n1 2 2\\n1 3 1\\n2 3 0\", \"3 2\\n1 3 2\\n2 1 1\", \"3 2\\n1 2 2\\n2 -1 ...
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b...
0.125
{"tests": "{\"inputs\": [\"4 2\\n1 2 -3 -4\\n\", \"4 3\\n-1 -2 -3 -4\\n\", \"2 1\\n-1 1000000000\\n\", \"10 10\\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\\n\", \"4 2\\n1 2 -3 0\", \"10 2\\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\", \"4 3\\n-1 -3 -3 -4\", \"3 1\\n-1 10000...
Given are N integers A_1,\ldots,A_N. We will choose exactly K of these elements. Find the maximum possible product of the chosen elements. Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive). -----Constraints----- - 1 \leq K \leq N \leq 2\times 10^5 - |A_i| \leq 10^9 -...
0.125
{"tests": "{\"inputs\": [[[true, true, false, true, false]], [[false, false, true, false, false]], [[false, false, false, false, false]], [[false, false, false, false, false, false]], [[false, false]], [[true, false]], [[false, false, false, true, false, false, false, true]], [[false, false, true, false, true, true, tr...
In a far away country called AlgoLandia, there are `N` islands numbered `1` to `N`. Each island is denoted by `k[i]`. King Algolas, king of AlgoLandia, built `N - 1` bridges in the country. A bridge is built between islands `k[i]` and `k[i+1]`. Bridges are two-ways and are expensive to build. The problem is that there...
0
{"tests": "{\"inputs\": [\"3\\n5\\n6\\n8\", \"2\\n10\\n4\", \"3\\n5\\n5\\n8\", \"2\\n10\\n6\", \"3\\n8\\n5\\n8\", \"2\\n10\\n2\", \"2\\n18\\n4\", \"2\\n34\\n4\", \"2\\n34\\n8\", \"2\\n35\\n15\", \"2\\n4\\n57\", \"2\\n4\\n43\", \"2\\n5\\n43\", \"2\\n5\\n62\", \"2\\n5\\n17\", \"2\\n10\\n31\", \"2\\n14\\n31\", \"2\\n15\\n...
A boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously. He noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explore this interesting phen...
0
{"tests": "{\"inputs\": [\"5 1 1\\n1 0 0 0 4\\n\", \"6 1 2\\n3 8 0 1 0 0\\n\", \"5 1 1\\n1 1 0 3 0\\n\", \"5 1 1\\n4 0 0 1 0\\n\", \"2 1 1\\n0 2\\n\", \"100 66 30\\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 25 27 15 53 29 56 30 24 50 39 39 46 4 14 44 16 55 48 15 5...
Instructors of Some Informatics School make students go to bed. The house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered from 1 to n. Initially,...
0
{"tests": "{\"inputs\": [\"2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\\n\", \"5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\\n\", \"2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1\\n\", \"3 4 2 3 5 5 6 6 4 5 4 6 5 1 1 1 6 2 1 3 3 2 4 2\\n\", \"5 5 2 5 3 3 2 6 6 4 2 4 6 1 4 3 1 6 2 1 3 4 5 1\\n\", \"6 6 1 2 6 1 1...
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2. It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation...
0
{"tests": "{\"inputs\": [\"3 3 4\\n...\\nR.L\\nR.U\\n\", \"2 2 2\\n..\\nRL\\n\", \"2 2 2\\n..\\nLR\\n\", \"3 4 8\\n....\\nRRLL\\nUUUU\\n\", \"2 2 2\\n..\\nUU\\n\", \"2 2 0\\n..\\n..\\n\", \"5 5 10\\n.....\\nRU.D.\\n..DLL\\n.D...\\nRL..L\\n\", \"5 6 20\\n......\\n.UURD.\\nLUD.RR\\nU.LDDD\\nDDLDDU\\n\", \"4 5 15\\n.....\...
Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all. [Image] The park can be represented as a rectangular n × m field. The park has k spiders, each spider at ...
0
{"tests": "{\"inputs\": [[1000, 10, 127, 14], [1000, 10, 0, 10], [25, 50, 120, 18], [35869784, 90, 100, 5], [1234567, 4, 3, 11], [100000000, 21, 5, 14], [0, 100, 10, 14], [250, 0, 5, 14], [100, 10, 0, 14], [500, 100, 10, 0]], \"outputs\": [[1120], [10000], [450], [84954920], [7760148], [1130769276], [0], [0], [1400], [...
You have recently discovered that horses travel in a unique pattern - they're either running (at top speed) or resting (standing still). Here's an example of how one particular horse might travel: ``` The horse Blaze can run at 14 metres/second for 60 seconds, but must then rest for 45 seconds. After 500 seconds Bla...
0.375
{"tests": "{\"inputs\": [\"3\\n-1 3\\n2 1\\n3 -2\\n\", \"4\\n1 4\\n2 1\\n3 3\\n4 2\\n\", \"10\\n19 -11\\n-3 -12\\n5 3\\n3 -15\\n8 -14\\n-9 -20\\n10 -9\\n0 2\\n-7 17\\n6 -6\\n\", \"3\\n-1 3\\n2 2\\n3 -2\", \"4\\n1 4\\n2 1\\n3 0\\n4 2\", \"4\\n1 4\\n2 1\\n3 0\\n4 0\", \"3\\n-2 5\\n2 -1\\n1 -2\", \"10\\n19 -11\\n-3 -12\\n...
We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates. For a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are parallel to the coordinate a...
0
{"tests": "{\"inputs\": [\"4\\ngarage for sa-le\\n\", \"4\\nEdu-ca-tion-al Ro-unds are so fun\\n\", \"1\\nj\\n\", \"10\\nb\\n\", \"1\\nQGVsfZevMD\\n\", \"1\\nqUOYCytbKgoGRgaqhjrohVRxKTKjjOUPPnEjiXJWlvpCyqiRzbnpyNqDylWverSTrcgZpEoDKhJCrOOvsuXHzkPtbXeKCKMwUTVk\\n\", \"100000\\nBGRHXGrqgjMxCBCdQTCpQyHNMkraTRxhyZBztkxXNFEK...
The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' in some words, their positions set word wrapping points. Word can include more th...
0
{"tests": "{\"inputs\": [[\"x = 12t + 18\", \"y = 8t + 7\"], [\"x = -12t + 18\", \"y = 8t + 7\"], [\"x = 12t + 18\", \"y = -8t + 7\"], [\"x = -12t + 18\", \"y = -8t + 7\"], [\"x = -t + 12\", \"y = 12t - 1\"], [\"x = -12t - 18\", \"y = 8t - 7\"], [\"x = -12t + 18\", \"y = 8t - 7\"], [\"x = -18t + 12\", \"y = 7t - 8\"], ...
### Task: Your job is to take a pair of parametric equations, passed in as strings, and convert them into a single rectangular equation by eliminating the parameter. Both parametric halves will represent linear equations of x as a function of time and y as a function of time respectively. The format of the final equ...
0
{"tests": "{\"inputs\": [\"4 4 2 1 4\\n1 2 2 1\\n2 3 2 1\\n3 4 5 1\\n2 4 4 2\\n3 1\\n3 6\\n10 5 3\\n\\n10\\n2 0 1 1 2\\n1\\n\\n1\\n4 5 2 4 1\\n4 3 10 1\\n3 2 2 1\\n3 4 1 2\\n3 2 5 2\\n2 1 10 1\\n3 3\\n20 30\\n3 2 1\\n5 10\\n3 2 1\\n5 5 2 1 5\\n1 2 10 2\\n1 3 20 2\\n2 4 20 1\\n3 4 10 1\\n4 5 20 1\\n2 2\\n20\\n4 1\\n20\\...
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1. <image> Figure D-1: A sample railway network Suppose you are going to station D from station A. Obviously, the path with the shortest distance is A->B->D. However, the path with the shortes...
0
{"tests": "{\"inputs\": [\"1\\n13\\n\", \"4\\n1 2 3 4\\n\", \"16\\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632652 639921017 582019792 143353286 537373229 944668919 758615621\\n\", \"16\\n521848329 105907607 414661942 473600423 264555612 186332345 774233687 736918178 ...
Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve. He's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to arrange all these numbers in the matrix (put each number in a single ...
0
{"tests": "{\"inputs\": [\"5 2\\n00100\\n\", \"6 1\\n000000\\n\", \"4 1\\n0011\\n\", \"12 6\\n000010000100\\n\", \"5 1\\n01010\\n\", \"5 4\\n10000\\n\", \"9 2\\n010111110\\n\", \"10 1\\n0011100011\\n\", \"14 2\\n00001101011000\\n\", \"5 3\\n10011\\n\", \"15 3\\n111111101111111\\n\", \"18 11\\n110111111111111111\\n\", \...
You work as a system administrator in a dormitory, which has $n$ rooms one after another along a straight hallway. Rooms are numbered from $1$ to $n$. You have to connect all $n$ rooms to the Internet. You can connect each room to the Internet directly, the cost of such connection for the $i$-th room is $i$ coins. ...
0.375
{"tests": "{\"inputs\": [[\"\"], [\"..........\"], [\"P..\"], [\"P....\"], [\"P......P......\"], [\"P.P..\"], [\"P.P.P....\"], [\".....P.P........P....\"], [\".....P......P.P..P....\"], [\"P.O....\"], [\"P......P.O....\"], [\"P..OP..P..\"], [\"P......P..OP..P...\"], [\"..P...O.....\"]], \"outputs\": [[\"\"], [\"0000000...
# Situation You have been hired by a company making electric garage doors. Accidents with the present product line have resulted in numerous damaged cars, broken limbs and several killed pets. Your mission is to write a safer version of their controller software. # Specification We always start with a closed door. The...
0
{"tests": "{\"inputs\": [\"3 3\\n1 2\\n2 3\\n3 1\\n2 1 3\\n\", \"3 3\\n1 2\\n2 3\\n3 1\\n1 1 1\\n\", \"5 3\\n1 2\\n2 3\\n4 5\\n2 1 2 2 1\\n\", \"1 0\\n1\\n\", \"10 20\\n8 9\\n2 1\\n8 4\\n3 4\\n4 6\\n10 3\\n7 8\\n2 3\\n10 7\\n10 9\\n3 6\\n3 5\\n9 1\\n10 2\\n5 8\\n8 3\\n8 1\\n7 5\\n9 2\\n6 8\\n2 4 3 2 2 4 3 1 3 1\\n\", \...
Today Johnny wants to increase his contribution. His plan assumes writing $n$ blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because otherwise, the reader...
0
{"tests": "{\"inputs\": [\"50 12346\\n376 144139\\n927438 667387\\n18 3312\\n9 3142\\n25 1299\\n111 33333\\n103 862150\\n6 1104\\n0 0\", \"50 12346\\n712 144139\\n927438 667387\\n23 3312\\n9 3142\\n25 1299\\n111 33333\\n103 862150\\n6 1104\\n0 0\", \"81 12346\\n376 144139\\n927438 927438\\n18 3312\\n9 3142\\n25 1299\\n...
You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics. * The shredder takes as ...
0.5
{"tests": "{\"inputs\": [\"2 2 3\\n1 2\\n2 2\\n2 1\\n\", \"1 5 3\\n1 3\\n1 1\\n1 5\\n\", \"4 3 6\\n1 2\\n1 3\\n2 2\\n2 3\\n3 1\\n3 3\\n\", \"20 20 80\\n5 3\\n13 13\\n8 5\\n2 9\\n12 16\\n1 11\\n15 11\\n3 20\\n10 7\\n5 4\\n11 2\\n5 20\\n14 8\\n5 1\\n8 13\\n11 5\\n19 2\\n15 12\\n12 7\\n16 5\\n17 3\\n12 2\\n17 16\\n12 3\\n...
Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m) in the table. Recently scientists discovered that for every four...
0
{"tests": "{\"inputs\": [\"20\\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\\n\", \"18\\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1\\n\", \"6\\n2 1 0 2 1 2\\n\", \"1\\n0\\n\", \"7\\n0 1 2 3 4 2 6\\n\", \"6\\n0 0 0 0 0 0\\n\", \"4\\n0 0 0 0\\n\", \"1\\n0\\n\", \"6\\n0 0 0 0 0 0\\n\", \"7\\n0 1 2 3 4 2 6\\n\", \"4\\n0 0 0 0\\n\", \...
Since Sonya has just learned the basics of matrices, she decided to play with them a little bit. Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The cells with equal numbers ...
0.5
{"tests": "{\"inputs\": [\"4\\n6\\n654321\\n4\\n1337\\n2\\n33\\n4\\n2122\\n\", \"1\\n4\\n3333\\n\", \"21\\n3\\n123\\n3\\n123\\n3\\n123\\n3\\n123\\n3\\n123\\n3\\n213\\n3\\n123\\n3\\n123\\n3\\n123\\n3\\n321\\n3\\n123\\n3\\n321\\n3\\n132\\n3\\n322\\n3\\n321\\n3\\n341\\n3\\n123\\n3\\n421\\n3\\n421\\n3\\n421\\n3\\n421\\n\",...
You are given a sequence $s$ consisting of $n$ digits from $1$ to $9$. You have to divide it into at least two segments (segment — is a consecutive sequence of elements) (in other words, you have to place separators between some digits of the sequence) in such a way that each element belongs to exactly one segment and...
0
{"tests": "{\"inputs\": [\"5 0\\n5 5 4 1 2\\n\", \"10 -10\\n5 5 1 7 4 1 2 4 9 2\\n\", \"10 0\\n5 5 1 7 4 1 2 4 9 2\\n\", \"10 -10\\n5 5 1 0 5 1 2 4 9 2\\n\", \"5 0\\n5 5 4 0 2\\n\", \"10 -10\\n5 5 1 7 4 1 0 4 9 2\\n\", \"10 -12\\n5 5 1 0 5 1 2 4 9 2\\n\", \"10 -10\\n5 5 1 0 4 1 0 4 9 2\\n\", \"10 0\\n5 9 1 12 0 2 2 4 1...
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the...
0
{"tests": "{\"inputs\": [\"4 3 2 2 -1 1\\n\", \"4 4 2 0 1 1\\n\", \"10 10 10 1 -1 0\\n\", \"1000000000 1000000000 1 1000000000 0 1\\n\", \"2 1 1 0 -1 -1\\n\", \"4 2 1 2 1 1\\n\", \"5 3 4 3 1 -1\\n\", \"15 9 1 1 1 1\\n\", \"15 9 1 1 -1 -1\\n\", \"15 9 2 1 1 1\\n\", \"15 9 2 1 -1 1\\n\", \"1000000000 999999999 999999998 ...
Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image] There is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. The ball starts moving along a line tha...
0
{"tests": "{\"inputs\": [\"5\\n3 2 2 2 1\\n\", \"5\\n1 1 1 1 1\\n\", \"3\\n3 3 3\\n\", \"1\\n1\\n\", \"10\\n9 8 7 7 6 4 3 2 1 1\\n\", \"10\\n99 83 62 53 47 33 24 15 10 9\\n\", \"100\\n100 100 99 98 97 92 92 92 92 91 89 87 87 87 86 85 84 82 82 81 81 80 79 78 78 77 77 76 76 74 72 71 71 70 69 66 64 63 63 62 60 59 59 59 55...
You are given a Young diagram. Given diagram is a histogram with $n$ columns of lengths $a_1, a_2, \ldots, a_n$ ($a_1 \geq a_2 \geq \ldots \geq a_n \geq 1$). [Image] Young diagram for $a=[3,2,2,2,1]$. Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a do...
0
{"tests": "{\"inputs\": [[\"HELLO WORLD\"], [\"SOS\"], [\"1836\"], [\"THE QUICK BROWN FOX\"], [\"JUMPED OVER THE\"], [\"LAZY DOG\"], [\"WOLFRAM ALPHA 1\"], [\"CodeWars Rocks\"], [\"\"], [\"Final basic test\"]], \"outputs\": [[\".... . .-.. .-.. --- .-- --- .-. .-.. -..\"], [\"... --- ...\"], [\".---- ---.. ...-- -......
Write a function that will encrypt a given sentence into International Morse Code, both the input and out puts will be strings. Characters should be separated by a single space. Words should be separated by a triple space. For example, "HELLO WORLD" should return -> ".... . .-.. .-.. --- .-- --- .-. .-.. -.." To f...
0
{"tests": "{\"inputs\": [\"111199\\n\", \"1000\\n\", \"10000\\n\", \"11\\n\", \"244\\n\", \"1000000000\\n\", \"14\\n\", \"55\\n\", \"2000\\n\", \"116\\n\", \"20\\n\", \"6\\n\", \"600000000\\n\", \"198\\n\", \"12\\n\", \"999999999\\n\", \"100\\n\", \"83\\n\", \"13\\n\", \"8\\n\", \"150\\n\", \"4\\n\", \"35\\n\", \"70900...
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as...
0
{"tests": "{\"inputs\": [[\"Hi, how are you today?\"], [\"I think it would be nice if we could all get along.\"], [\"Let's eat, Grandma!\"], [\"Woot woot woot woot woot woot!\"], [\"Hi, I can have cheeseburger?\"], [\"Sometimes I use ? in the middle of a sentence; is that ok?!\"], [\"Unto us a child is born.\"], [\"Wha...
The internet is a very confounding place for some adults. Tom has just joined an online forum and is trying to fit in with all the teens and tweens. It seems like they're speaking in another language! Help Tom fit in by translating his well-formatted English into n00b language. The following rules should be observed: ...
0
{"tests": "{\"inputs\": [\"5\\n1 5 8 123 7\\n123 7 5 1\\n5 1 7\\n\", \"6\\n1 4 3 3 5 7\\n3 7 5 4 3\\n4 3 7 5\\n\", \"3\\n1 2 3\\n3 2\\n2\\n\", \"10\\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 656422756 9301599 25720377\\n277246428 388684428 661369649 460626451 656422756 802090732 9301599 784...
A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix s...
0
{"tests": "{\"inputs\": [\"35 2 5 6 3\\n6 8 3 4 2 1 1 10 8 1 2 4 4 2 10 1 1 6 3 8 10 6 3 8 10 8 9 7 9 10 3 9 4 6 7\\n\", \"36 6 6 9 6\\n3 5 8 7 6 8 1 5 10 10 8 5 10 9 8 1 9 7 2 1 8 8 6 1 6 7 4 3 10 2 5 8 4 1 1 4\\n\", \"17 2 7 10 6\\n10 5 9 2 7 5 6 10 9 7 10 3 10 2 9 10 1\\n\", \"77 2 8 8 3\\n7 9 3 6 2 7 8 4 4 1 8 6 1 ...
Ziota found a video game called "Monster Invaders". Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns. For the sake of simplicity, we only consider two different types of monsters and three different types of guns. Namely, the two types of monsters are: *...
0
{"tests": "{\"inputs\": [\"4 6\\n7\\n2\\n3\\n5\", \"4 6\\n4\\n1\\n3\\n5\", \"1 6\\n4\\n2\\n3\\n1\", \"4 10\\n7\\n1\\n3\\n5\", \"4 11\\n5\\n2\\n3\\n5\", \"4 5\\n4\\n2\\n3\\n1\", \"1 6\\n3\\n2\\n3\\n1\", \"1 6\\n2\\n2\\n3\\n1\", \"4 9\\n7\\n2\\n3\\n5\", \"1 6\\n1\\n0\\n1\\n1\", \"4 11\\n5\\n2\\n1\\n5\", \"1 5\\n4\\n2\\n1...
problem There are fine icicles under the eaves of JOI's house in Canada. Because of this, JOI decided to investigate the icicles. There are N (2 ≤ N ≤ 100000 = 105) icicles under the eaves of JOI's house. These icicles are aligned and i cm (1 ≤ i ≤ N) from the left edge of the eaves. There are i-th icicles at the pos...
0
{"tests": "{\"inputs\": [\"3 3\\n\", \"1000000 1000000\\n\", \"1000000 500000\\n\", \"1 1\\n\", \"10 1\\n\", \"285042 201091\\n\", \"896437 604720\\n\", \"284114 73851\\n\", \"541826 316395\\n\", \"353093 96536\\n\", \"540898 158491\\n\", \"858309 773589\\n\", \"56322 42432\\n\", \"461466 56468\\n\", \"29102 1503\\n\",...
There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then board the pla...
0
{"tests": "{\"inputs\": [\"1 100\\n56\\n44\\n\", \"3 10\\n9 9 0\\n0 0 10\\n\", \"5 45\\n1 2 3 4 5\\n10 20 30 40 50\\n\", \"10 26872\\n84744 76378 25507 49544 44949 65159 78873 9386 2834 83577\\n43277 76228 210 44539 72154 22876 94528 90143 3059 2544\\n\", \"10 16\\n8 4 2 5 4 8 3 5 6 9\\n5 3 8 6 2 10 10 8 9 3\\n\", \"3 ...
A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least x points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results have only points, no names. The teacher has to know Vasya's chances. ...
0
{"tests": "{\"inputs\": [\"4\\n1 2 4 4\\n\", \"9\\n1 1 8 8 8 4 4 4 4\\n\", \"7\\n4 3 7 1 4 3 3\\n\", \"1\\n1\\n\", \"2\\n1 1\\n\", \"2\\n1 2\\n\", \"9\\n9 5 7 9 6 4 6 4 8\\n\", \"10\\n1 2 3 4 5 6 7 8 9 10\\n\", \"10\\n6 6 6 6 6 6 6 6 6 6\\n\", \"10\\n10 7 10 10 7 10 7 7 10 10\\n\", \"10\\n6 8 9 6 5 9 4 8 8 6\\n\", \"10...
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year... $n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo...
0.125
{"tests": "{\"inputs\": [\"5\\n\", \"113\\n\", \"1000000000\\n\", \"5432359\\n\", \"999999994\\n\", \"10\\n\", \"9\\n\", \"1\\n\", \"0\\n\", \"3\\n\", \"4\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"19\\n\", \"100\\n\", \"997\\n\", \"9994\\n\", \"10002\\n\", \"100000\\n\", \"99999\\n\", \"999999999\\n\", \"999999998\\n\", \"...
Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded. For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct. For given n find out to which integer will Vasy...
0.25
{"tests": "{\"inputs\": [\"3 143320251\", \"2 1660952267\", \"6 259722551\", \"1 81577459\", \"8 556099089\", \"0 4861465\", \"9 345897173\", \"157 925309799\", \"10 259722551\", \"4 1745284472\", \"5 394143938\", \"12 81577459\", \"13 255726765\", \"11 452537087\", \"134 925309799\", \"7 152253599\", \"16 346412399\",...
N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, y...
0
{"tests": "{\"inputs\": [\"2\\n0 0\\n\", \"5\\n0 1 1 0 4\\n\", \"31\\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 2 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23\\n\", \"2\\n0 1\", \"31\\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 3 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23\", \"5\\n0 1 1 0 3\", \"31\\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 3 3 6 12 10 12 16 5...
Snuke has a rooted tree with N+1 vertices. The vertices are numbered 0 through N, and Vertex 0 is the root of the tree. The parent of Vertex i (1 \leq i \leq N) is Vertex p_i. Besides this tree, Snuke also has an box which is initially empty and many marbles, and playing with them. The play begins with placing one marb...
0
{"tests": "{\"inputs\": [\"20\\n1 676\\n10 2\\n10 467\\n7 826\\n7 138\\n8 76\\n8 148\\n2 121\\n7 527\\n3 571\\n10 410\\n7 174\\n2 318\\n6 97\\n3 919\\n8 684\\n3 586\\n4 570\\n10 494\\n8 582\\n74\\n1 6 10 15 20 22 25 26 27 29 32 33 34 37 39 44 49 52 53 55 56 61 65 66 70 72 74 77 79 80 83 85 88 91 95 98 103 106 107 112 1...
Vasya plays the Geometry Horse. The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value. There are n types of geometric figures. The number of figures of type ki and figure cost ci is kno...
0
{"tests": "{\"inputs\": [\"10 2\\n7 6 18 6 16 18 1 17 17\\n6 9 3 10 9 1 10 1 5\\n\", \"10 1\\n3 2 3 1 3 3 1 4 1\\n1 2 3 4 4 1 2 1 3\\n\", \"10 2\\n7 6 18 6 16 18 1 17 17\\n6 17 3 10 9 1 10 1 5\\n\", \"10 1\\n3 0 3 1 3 3 1 4 1\\n1 2 3 4 4 1 2 1 3\\n\", \"10 2\\n7 6 18 6 16 18 2 17 17\\n6 17 3 10 9 1 10 1 5\\n\", \"10 1\...
You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor. Let: $a_i$ for all $i$ from $1$ to $n-1$ be the time required to go from the ...
0
{"tests": "{\"inputs\": [\"5 2\\n-1 -2 5 -4 8\\n\", \"7 6\\n-3 0 -1 -2 -2 -4 -1\\n\", \"4 1\\n3 -1 6 0\\n\", \"4 1\\n3 -2 6 0\\n\", \"5 2\\n-1 -2 5 -7 8\\n\", \"4 1\\n3 -2 1 0\\n\", \"5 2\\n0 -2 5 -7 8\\n\", \"4 1\\n2 -2 1 0\\n\", \"5 2\\n0 -2 1 -7 8\\n\", \"5 2\\n0 -2 2 -7 8\\n\", \"5 2\\n0 -2 2 -7 14\\n\", \"5 2\\n0 ...
You are given an array $a_1, a_2, \dots, a_n$ and an integer $k$. You are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let $f(i)$ be the index of subarray the $i$-th element belongs to. Subarrays are numbered from left to ri...
0.625
{"tests": "{\"inputs\": [\"4 8\\n7 12 8 9\", \"3 8\\n9 6 9\", \"33 3\\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3\", \"8 5\\n3 6 2 8 7 2 5 9\", \"3 8\\n15 6 9\", \"33 3\\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3\", \"8 5\\n3 6 2 8 7 2 5 16\", \"33 3\\n3 3 3 3 3 3 3 3 3 3 ...
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 selection? Constraints * 1 \leq N \leq 50 * 1 \leq A \leq 50 * 1 \leq x_...
0.75
{"tests": "{\"inputs\": [[[1, [1, 1]], [[2, 2], 2]], [[1, [1, 1]], [2, [2]]], [[[[], []]], [[[], []]]], [[[[], []]], [[1, 1]]], [[1, [[[1]]]], [2, [[[2]]]]], [[], 1], [[], {}], [[1, \"[\", \"]\"], [\"[\", \"]\", 1]]], \"outputs\": [[false], [false], [true], [false], [true], [false], [false], [true]]}", "source": "taco"...
Complete the function/method (depending on the language) to return `true`/`True` when its argument is an array that has the same nesting structures and same corresponding length of nested arrays as the first array. For example: ```python # should return True same_structure_as([ 1, 1, 1 ], [ 2, 2, 2 ] ) same_structure...
0
{"tests": "{\"inputs\": [\"2\\n3 1\", \"4\\n1 2 3 3\", \"2\\n4 1\", \"4\\n1 2 5 3\", \"2\\n3 0\", \"4\\n1 2 8 3\", \"4\\n1 0 12 4\", \"4\\n1 0 12 6\", \"4\\n1 0 1 6\", \"4\\n1 0 1 7\", \"4\\n1 0 11 4\", \"4\\n1 -1 12 11\", \"4\\n2 0 -1 25\", \"4\\n1 -2 12 11\", \"4\\n0 -1 0 36\", \"2\\n25 2\", \"4\\n-1 -1 0 36\", \"2\\...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Phantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offerings. One day, our Chefs decided to visit the park. There are tota...
0.125
{"tests": "{\"inputs\": [\"5 5\\n1 3\\n2 3\\n1 4\\n2 2\\n1 2\\n\", \"200000 0\\n\", \"176527 15\\n1 81279\\n2 22308\\n2 133061\\n1 80744\\n2 44603\\n1 170938\\n2 139754\\n2 15220\\n1 172794\\n1 159290\\n2 156968\\n1 56426\\n2 77429\\n1 97459\\n2 71282\\n\", \"2463 0\", \"176527 15\\n1 81279\\n2 22308\\n2 168987\\n1 807...
There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left. Each of the central (N-2) \times (N-2) squares in the grid has a black stone on it. Each of the 2N - 1 squares on the bottom side and the right side has a white stone on it. Q q...
0
{"tests": "{\"inputs\": [\"3\\n100000\\n30000\\n29639\", \"2\\n0\\n2\", \"2\\n1\\n0\", \"3\\n000000\\n30000\\n29639\", \"2\\n1\\n1\", \"3\\n000001\\n30000\\n29639\", \"2\\n2\\n1\", \"3\\n000011\\n30000\\n29639\", \"3\\n000010\\n30000\\n29639\", \"2\\n2\\n2\", \"3\\n100010\\n30000\\n29639\", \"2\\n2\\n3\", \"3\\n100010\...
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at ...
0
{"tests": "{\"inputs\": [[1024], [1306], [1999], [2427], [1048576], [2646798]], \"outputs\": [[\"Not !!\"], [\"Disarium !!\"], [\"Not !!\"], [\"Disarium !!\"], [\"Not !!\"], [\"Disarium !!\"]]}", "source": "taco"}
# Definition **_Disarium number_** is the number that *The sum of its digits powered with their respective positions is equal to the number itself*. ____ # Task **_Given_** a number, **_Find if it is Disarium or not_** . ____ # Warm-up (Highly recommended) # [Playing With Numbers Series](https://www.codewars.com...
0.875
{"tests": "{\"inputs\": [[\"123,.)(!?\", 10], [\"\", 10], [null, 10], [\" \", 10], [\"Hello world!\", 127], [\"eBIIL TLOIA!\", -127], [\"ksdjai8983hdk?}{\", 15], [\"Hello world!\", 0]], \"outputs\": [[\"123,.)(!?\"], [\"\"], [\"\"], [\"\"], [\"eBIIL TLOIA!\"], [\"Hello world!\"], [\"zHsypx8983wsz?}{\"], [\"Hello worl...
Let’s get to know our hero: Agent #134 - Mr. Slayer. He was sent by his CSV agency to Ancient Rome in order to resolve some important national issues. However, something incredible has happened - the enemies have taken Julius Caesar as a prisoner!!! Caesar, not a simple man as you know, managed to send cryptic messag...
0
{"tests": "{\"inputs\": [\"8\\n1 2 7 3 4 8 5 6\\n\", \"6\\n25 1 2 3 14 36\\n\", \"20\\n1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11\\n\", \"7\\n1 2 5 7 3 4 6\\n\", \"1\\n1000000000\\n\", \"1\\n1\\n\", \"2\\n1 2\\n\", \"2\\n2 1\\n\", \"22\\n22 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11 21\\n\", \"63\\n32 4...
For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations. Max is a young biologist. For $n$ days he watched a specific shark, and now he knows the distance the shark traveled in each of the days. All the d...
0
{"tests": "{\"inputs\": [\"5\\n5 4 3 2 1\\n5\\n7 7 7 7 7\\n10\\n186 8 42 24 154 40 10 56 122 141\\n0\", \"5\\n5 4 3 2 1\\n5\\n7 12 2 0 7\\n10\\n372 8 42 18 154 40 10 56 122 141\\n0\", \"5\\n5 4 3 4 1\\n5\\n7 11 7 7 14\\n0\\n186 8 42 24 154 21 10 56 122 72\\n0\", \"5\\n5 4 3 4 1\\n5\\n13 11 1 7 14\\n0\\n186 8 64 24 241 ...
A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for- mulas: <image> where S, A, C, and M are all parameters. In this problem, 0 ≤ S, A, C ≤ 15 and M = 256. Now suppose we have some input string I(⋅), where each character in the string is an integer between 0 and (M - ...
0
{"tests": "{\"inputs\": [\"2\\n1000 2**3*3**1\\n100000 11**2*2**4\", \"2\\n1000 2**3*3**1\\n100000 4**2*2**11\", \"2\\n1001 2**3*2**1\\n100000 4**2*2**11\", \"2\\n1000 2**3*3**1\\n101000 11**2*2**4\", \"2\\n1001 1**3*3**2\\n100000 4**2*2**11\", \"2\\n1001 1**3*3**2\\n100000 4**2*2**01\", \"2\\n1001 1**3*3**1\\n110000 1...
Read problems statements in Mandarin Chinese and Russian. Leonid is developing new programming language. The key feature of his language is fast multiplication and raising to a power operations. He is asking you to help with the following task. You have an expression S and positive integer M. S has the following str...
0
{"tests": "{\"inputs\": [\"4 2\\n1 -3\\n4 -2 3 2 -3\\n\", \"5 2\\n5 3 -2 1 -1 5\\n3 -5 2 5\\n\", \"7 2\\n3 -1 6 7\\n7 -5 4 2 4 7 -3 4\\n\", \"2 1\\n2 -2 2\\n\", \"7 7\\n1 -2\\n1 6\\n2 7 -6\\n2 -6 4\\n2 -4 -6\\n3 -5 7 -5\\n1 -6\\n\", \"100 50\\n2 62 -62\\n2 19 -19\\n2 38 -38\\n2 -84 84\\n2 -16 16\\n2 67 -67\\n2 41 -41\\...
Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them. There are n parallel universes participating in this event (n Ricks and n Mortys). I. e. each of n universes has one Rick and one...
0.375
{"tests": "{\"inputs\": [[6923522112], [692352217312], [\"x5810a78432\"], [36637640050], [12762438338], [\"03868894286\"], [10000000146], [19415235426], [16691067984], [72097107542], [57040492705]], \"outputs\": [[false], [false], [false], [true], [false], [false], [true], [true], [false], [true], [false]]}", "source":...
Every Turkish citizen has an identity number whose validity can be checked by these set of rules: - It is an 11 digit number - First digit can't be zero - Take the sum of 1st, 3rd, 5th, 7th and 9th digit and multiply it by 7. Then subtract the sum of 2nd, 4th, 6th and 8th digits from this value. Modulus 10 of the resu...
0
{"tests": "{\"inputs\": [\"6 1\\n\", \"6 2\\n\", \"60 5\\n\", \"2 4\\n\", \"12 3\\n\", \"55 5\\n\", \"935 9\\n\", \"1 10000\\n\", \"120 1\\n\", \"1000000000000000 10000\\n\", \"671058194037157 8673\\n\", \"900018062553298 4801\\n\", \"128973636102142 5521\\n\", \"999999999999993 8123\\n\", \"260858031033600 9696\\n\", ...
Makoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times: Suppose the number currently written on the blackboard is $v$. He will randomly pick one of the divisors of $v$ (possibly $1$ and $v$) and replace $v$ with this divisor. As Makoto uses his fam...
0.25
{"tests": "{\"inputs\": [\"1\\n1000000000 1000000000\\n\", \"1\\n1000010000 1000000000\\n\", \"4\\n4 8\\n4 2\\n420 420\\n83876 42068\\n\", \"1\\n1001010000 1000000000\\n\", \"1\\n1001010010 1000000000\\n\", \"1\\n1001010010 1000100000\\n\", \"1\\n1000010010 1000000000\\n\", \"1\\n1000010011 1000000000\\n\", \"1\\n10010...
YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints. Inp...
0
{"tests": "{\"inputs\": [\"1\\n5 1 3\\n\", \"1\\n6 3 4\\n\", \"25\\n5 1 1\\n5 2 3\\n5 5 5\\n5 5 1\\n5 4 4\\n10 1 2\\n10 3 7\\n10 10 10\\n10 3 1\\n10 7 6\\n1000000 21232 1234\\n999999 999999 999999\\n1000000 300001 701321\\n1000000 290001 679121\\n500000 98765 123456\\n100 1 1\\n1000000000 1 1000000000\\n1000000000 1 50...
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $n$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest nu...
0
{"tests": "{\"inputs\": [\"13 17\\nBBABBBAABABBA\\n7 1\\n7 9\\n11 12\\n3 9\\n11 9\\n2 1\\n11 5\\n12 11\\n10 8\\n1 11\\n1 8\\n7 7\\n9 10\\n8 8\\n8 12\\n6 2\\n9 11\", \"13 17\\nBBABBBAABABBA\\n7 1\\n7 9\\n11 12\\n3 9\\n11 9\\n2 1\\n11 5\\n10 11\\n10 8\\n1 11\\n1 8\\n7 7\\n9 10\\n8 8\\n8 12\\n6 2\\n9 11\", \"4 3\\nABAB\\n...
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connects vertex a_i and b_i. The phantom thief Nusook likes to choose some ...
0
{"tests": "{\"inputs\": [[\"snakeCase\", \"snake\"], [\"some-lisp-name\", \"camel\"], [\"map_to_all\", \"kebab\"], [\"doHTMLRequest\", \"kebab\"], [\"invalid-inPut_bad\", \"kebab\"], [\"valid-input\", \"huh???\"], [\"\", \"camel\"], [\"snake-kebab_case\", \"kebab\"], [\"snakeCamel_case\", \"snake\"], [\"kebabCamel-case...
In this kata, you will make a function that converts between `camelCase`, `snake_case`, and `kebab-case`. You must write a function that changes to a given case. It must be able to handle all three case types: ```python py> change_case("snakeCase", "snake") "snake_case" py> change_case("some-lisp-name", "camel") "som...
0
{"tests": "{\"inputs\": [[[0, 1, 2, 3, 4], 2], [[0, -1, -2, -3, -4], 2], [[0, -1, -2, -3, -4], 3], [[-1, -2, -3, -4], 2], [[-1, -2, -3, -4], 3], [[], 2], [[-4, -10, -1], 2], [[0, 6, 3, 5, 4], 4], [[5, 4, 3, 3, 6], 2]], \"outputs\": [[[0, 12]], [[0, 12]], [[-24, 0]], [[2, 12]], [[-24, -6]], [null], [[4, 40]], [[0, 360]]...
*This is the advanced version of the [Minimum and Maximum Product of k Elements](https://www.codewars.com/kata/minimum-and-maximum-product-of-k-elements/) kata.* --- Given a list of **integers** and a positive integer `k` (> 0), find the minimum and maximum possible product of `k` elements taken from the list. If y...
0
{"tests": "{\"inputs\": [\"6\\n1 4\\n9 9\\n5 7\\n12 29\\n137 591\\n1 1000000\\n\", \"20\\n862 928\\n758 964\\n541 789\\n622 943\\n328 900\\n14 764\\n217 972\\n461 847\\n442 468\\n900 986\\n518 529\\n938 993\\n549 851\\n690 944\\n484 601\\n320 910\\n98 868\\n816 915\\n765 880\\n551 770\\n\", \"20\\n862 928\\n758 964\\n5...
You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = a^{p}. -----Input----- The first line contains the number of queries Q (1 ≤ Q ≤ 10^5). The next Q lines contains two integers L, R each (1 ≤ L ≤...
0.375
{"tests": "{\"inputs\": [\"70\", \"27\", \"9\", \"28269\", \"729\", \"-18\", \"-45\", \"-63\", \"-54\", \"-36\", \"-495\", \"72\", \"-90\", \"99\", \"-396\", \"180\", \"198\", \"6200730\", \"-450\", \"-279\", \"-270\", \"-297\", \"-369\", \"540\", \"1663355059\", \"76\", \"120\", \"3070868988\", \"143\", \"69\", \"2599...
For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4. You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D? Constraints * D is an integer. * 1 ≤ D < 10^9 In...
0
{"tests": "{\"inputs\": [\"13\\n4 11 8 9 10 12 14 15 16 18 20 21 22\", \"3\\n0 2 3\", \"3\\n2 3 8\", \"13\\n3 16 8 9 10 19 12 24 16 18 20 21 6\", \"3\\n9 1 14\", \"8\\n2 2 3 5 7 11 13 17\", \"3\\n0 0 8\", \"13\\n4 16 8 9 10 19 14 24 18 18 20 21 22\", \"13\\n4 11 8 6 10 19 14 24 16 18 20 21 22\", \"13\\n3 1 8 9 18 19 12...
You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following opera...
0
{"tests": "{\"inputs\": [[500, 15, 0.9], [100, 10, 0.95], [0, 10, 0.95], [250, 20, 0.9], [500, 20, 0.9], [2500, 20, 0.9]], \"outputs\": [[43], [24], [2], [21], [34], [135]]}", "source": "taco"}
My friend John likes to go to the cinema. He can choose between system A and system B. ``` System A : he buys a ticket (15 dollars) every time System B : he buys a card (500 dollars) and a first ticket for 0.90 times the ticket price, then for each additional ticket he pays 0.90 times the price paid for the previous t...
0
{"tests": "{\"inputs\": [\"5\\n12\\n5 4 4 3 2 2 1 1 1 1 1 1\\n4\\n4 3 2 1\\n1\\n1000000\\n20\\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\\n32\\n64 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11\\n\", \"5\\n12\\n5 4 4 3 2 2 1 1 1 1 1 1\\n4\\n4 3 2 1\\n1\\n1000000\\n...
So the Beautiful Regional Contest (BeRC) has come to an end! $n$ students took part in the contest. The final standings are already known: the participant in the $i$-th place solved $p_i$ problems. Since the participants are primarily sorted by the number of solved problems, then $p_1 \ge p_2 \ge \dots \ge p_n$. Help ...
0
{"tests": "{\"inputs\": [\"3 8 66 951518\\n\", \"1 1000000 1 1000000\\n\", \"54772 1 1000000 1000000\\n\", \"999997 1 100000 1000000\\n\", \"3 10 90 567680\\n\", \"100000 100000 1000000 1000000\\n\", \"1 2 3 100\\n\", \"5 5 2 10\\n\", \"3 4 715494 741228\\n\", \"3 1 410364 566940\\n\", \"722229 410423 118215 838505\\n\...
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high. At the beginning of the first experiment there is a single bacterium in the test tub...
0
{"tests": "{\"inputs\": [\"2\\n5 3\\n1 2 4 5 6\\n5 3\\n1 2 4 5 7\", \"2\\n5 3\\n1 2 4 4 6\\n5 3\\n1 2 4 5 7\", \"2\\n1 3\\n0 2 6 4 6\\n5 3\\n1 2 0 1 2\", \"2\\n5 3\\n1 2 5 4 6\\n5 3\\n1 2 4 5 8\", \"2\\n5 3\\n1 2 4 4 6\\n5 3\\n1 2 0 5 7\", \"2\\n5 3\\n1 2 4 4 6\\n5 3\\n0 2 0 5 7\", \"2\\n1 3\\n1 2 4 4 6\\n5 3\\n0 2 0 5...
Read problems statements in Mandarin Chinese and Russian. Alok-nath is man of equality. He needs your help to divide his “sanskars” evenly amongst all his followers. By doing this, Alok-nath can create equality amongst his followers and he'll be called a true “sanskari”. Alok-nath has N sanskars, and K followers. E...
0
{"tests": "{\"inputs\": [\"2 2 1\\n\", \"3 3 3\\n\", \"5 3 6\\n\", \"100 1 2\\n\", \"100 1 1\\n\", \"1 100 1\\n\", \"1 100 2\\n\", \"7 8 7\\n\", \"100 100 199\\n\", \"50 47 18\\n\", \"2 3 3\\n\", \"100 100 100\\n\", \"2 2 2\\n\", \"3 4 6\\n\", \"1 1 1\\n\", \"5 6 2\\n\", \"5 4 2\\n\", \"2 3 4\\n\", \"3 3 2\\n\", \"100 ...
You are given three integers $a$, $b$ and $x$. Your task is to construct a binary string $s$ of length $n = a + b$ such that there are exactly $a$ zeroes, exactly $b$ ones and exactly $x$ indices $i$ (where $1 \le i < n$) such that $s_i \ne s_{i + 1}$. It is guaranteed that the answer always exists. For example, for t...
0
{"tests": "{\"inputs\": [\"4 2 5\\n1 2 3 1\\n\", \"1 9 10\\n1\\n\", \"3 2 10\\n1 2 1\\n\", \"1 10 10\\n1\\n\", \"1 1000000000 1000000000\\n100000\\n\", \"2 4 1\\n1 1\\n\", \"5 3 2\\n1 1 2 1 1\\n\", \"5 3 3\\n1 2 2 1 1\\n\", \"10 5 1000000000\\n1 1 1 2 2 1 2 2 2 2\\n\", \"5 2 4\\n1 2 3 2 1\\n\", \"5 3 2\\n1 1 2 1 1\\n\"...
This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city a_{i}. Today the bus has completed m trips, each time bringing n participants. The participants were then aligned ...
0
{"tests": "{\"inputs\": [\"10 2\\n4 1 5 10\\n1 4 10 5\\n\", \"7 6\\n2 1 2 1\\n4 2 4 3\\n2 5 2 5\\n2 3 5 3\\n1 2 1 2\\n3 2 5 3\\n\", \"1 0\\n\", \"200 13\\n84 113 191 187\\n52 68 74 83\\n63 46 158 68\\n38 15 170 81\\n38 81 164 183\\n109 52 141 156\\n117 151 126 155\\n21 25 128 197\\n111 30 163 59\\n138 62 154 73\\n83 16...
There is a square grid of size $n \times n$. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs $\min(h, w)$ to color a rectangle of size $h \times w$. You are to make all cells white for minimum total cost. The sq...
0
{"tests": "{\"inputs\": [\"5\\n8 6 9 1 0\", \"5\\n0 6 9 1 0\", \"5\\n1 1 1 1 0\", \"5\\n0 1 1 2 4\", \"5\\n0 6 6 1 0\", \"5\\n0 5 6 1 0\", \"5\\n0 5 6 2 0\", \"5\\n0 5 6 3 0\", \"5\\n0 4 6 3 0\", \"5\\n-1 4 6 3 0\", \"5\\n-1 4 9 3 0\", \"5\\n-1 4 0 3 0\", \"5\\n-1 4 -1 3 0\", \"5\\n0 4 -1 3 0\", \"5\\n0 4 0 3 0\", \"5\...
Auction square1001 You were watching a certain auction. An auction is a transaction in which when there are a large number of buyers and the number of items is limited, the one with the highest price is given the right to buy. (From the 7th edition of the Shinmei Kokugo Dictionary) The rules of the auction here are ...
0.25
{"tests": "{\"inputs\": [[\"2\", \"3 3\", \"1 2 3\", \"2 3 6\", \"1 3 7\", \"3 3\", \"1 2 3\", \"2 3 6\", \"1 3 9\"], \"2\\n3 3\\n1 2 3\\n2 3 6\\n1 1 7\\n3 3\\n1 2 3\\n2 3 6\\n1 3 9\", \"2\\n3 3\\n1 2 3\\n2 3 6\\n1 1 7\\n3 3\\n1 2 3\\n2 3 6\\n2 3 9\", \"2\\n3 3\\n1 2 3\\n2 3 6\\n1 1 7\\n3 3\\n2 2 3\\n2 3 6\\n2 3 9\", \...
Tomya is a girl. She loves Chef Ciel very much. Today, too, Tomya is going to Ciel's restaurant. Of course, Tomya would like to go to Ciel's restaurant as soon as possible. Therefore Tomya uses one of the shortest paths from Tomya's house to Ciel's restaurant. On the other hand, Tomya is boring now to use the same pat...
0.75
{"tests": "{\"inputs\": [\"10 5\\n\", \"6 12\\n\", \"5 13\\n\", \"1 1\\n\", \"2 1\\n\", \"100000 1\\n\", \"1 1000000000\\n\", \"100000 1000000000\\n\", \"100000 362880\\n\", \"1 4\\n\", \"9 12\\n\", \"10 123\\n\", \"9551 975275379\\n\", \"17286 948615687\\n\", \"58942 936593001\\n\", \"50000 989460910\\n\", \"22741 989...
Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1. You are given a positive integer x. Your task is to count the number of cells in a table that contain number x. -----In...
0.75
{"tests": "{\"inputs\": [[1, \"City civilians\"], [1, \"Centre receiver\"], [1, \"Chatanooga choo choo crashed\"], [1, \"Capital city cats chew cheese\"], [2, \"Photo of 5 pheasants with graphs\"], [3, \"Meet me at the same place at noon\"], [3, \"The time is now\"], [3, \"Be quite quiet\"], [3, \"Aardvarks are nice mo...
# Do you ever wish you could talk like Siegfried of KAOS ? ## YES, of course you do! https://en.wikipedia.org/wiki/Get_Smart # Task Write the function ```siegfried``` to replace the letters of a given sentence. Apply the rules using the course notes below. Each week you will learn some more rules. Und by ze fif...
0
{"tests": "{\"inputs\": [[\"A\"], [\"Z\"], [\"AA\"], [\"AZ\"], [\"BA\"], [\"CODEWARS\"], [\"ZZZTOP\"], [\"OYAJI\"], [\"LONELINESS\"], [\"UNFORGIVABLE\"]], \"outputs\": [[1], [26], [27], [52], [53], [28779382963], [321268054], [7294985], [68400586976949], [79089429845931757]]}", "source": "taco"}
Write a function `titleToNumber(title) or title_to_number(title) or titleToNb title ...` (depending on the language) that given a column title as it appears in an Excel sheet, returns its corresponding column number. All column titles will be uppercase. Examples: ``` titleTonumber('A') === 1 titleTonumber('Z') ===...
0.375
{"tests": "{\"inputs\": [\"3 5\\n\", \"4 4\\n\", \"100 100\\n\", \"1 100\\n\", \"100 1\\n\", \"1 4\\n\", \"1 1\\n\", \"8 8\\n\", \"7 2\\n\", \"24 15\\n\", \"19 30\\n\", \"15 31\\n\", \"14 15\\n\", \"58 33\\n\", \"15 25\\n\", \"59 45\\n\", \"3 73\\n\", \"48 1\\n\", \"100 25\\n\", \"40 49\\n\", \"85 73\\n\", \"29 1\\n\",...
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a_1 percent and second one is charged at a_2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not...
0.125
{"tests": "{\"inputs\": [\"2 1\\n-1000000000 1000000000\\n\", \"6 1\\n1 2 3 4 5 6\\n\", \"45 45\\n-95 -94 -92 -83 -83 -76 -75 -74 -71 -70 -68 -44 -36 -31 -20 -18 -14 -11 -8 -7 -2 -2 -1 0 1 20 26 27 31 31 43 52 57 58 59 62 63 64 64 64 64 70 73 75 79\\n\", \"10 1\\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000...
Imagine that your city is an infinite 2D plane with Cartesian coordinate system. The only crime-affected road of your city is the x-axis. Currently, there are n criminals along the road. No police station has been built on this road yet, so the mayor wants to build one. As you are going to be in charge of this new pol...
0
{"tests": "{\"inputs\": [\"ABABBBACFEYUKOTT\\n\", \"AAA\\n\", \"A\\n\", \"B\\n\", \"AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOIKLMJNHGTRWSDZXCVBNMHGFDSXVWRTPPPLKMNBXIUOIUOIUOIUOOIU\\n\", \"AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOIAEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOI\\n\", \"KMLPTGFHNBVCDRFGHNMBVXWSQFDCVB...
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of ...
0
{"tests": "{\"inputs\": [\"3\\n1 10 100\\n\", \"4\\n1 2 3 4\\n\", \"3\\n1 4 1\\n\", \"2\\n1 1\\n\", \"6\\n2 7 1 8 2 8\\n\", \"6\\n2 7 2 8 2 8\", \"3\\n-1 1 1\", \"3\\n0 4 1\", \"3\\n2 10 100\", \"4\\n2 2 3 4\", \"6\\n4 7 2 8 2 8\", \"3\\n0 1 1\", \"3\\n0 10 100\", \"4\\n0 2 3 4\", \"6\\n6 7 2 8 2 8\", \"3\\n0 11 100\",...
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: - For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. ---...
0.5
{"tests": "{\"inputs\": [[\")\"], [\"(\"], [\"\"], [\"hi)(\"], [\"hi(hi)\"], [\"hi(hi)(\"], [\"((())()())\"], [\"(c(b(a)))(d)\"], [\"hi(hi))(\"], [\"())(()\"]], \"outputs\": [[false], [false], [true], [false], [true], [false], [true], [true], [false], [false]]}", "source": "taco"}
Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return `true` if the string is valid, and `false` if it's invalid. ## Examples ``` "()" => true ")(()))" => false "(" => false "(())((()())())...
0
{"tests": "{\"inputs\": [\"RXXRLRRLRR\\n\", \"RXRRXXXRXXRR\\n\", \"XRRLXRRRLRLXXLRRLRXL\\n\", \"RXLLRXXLLRLRLLXXXXRXXRLLRRRRXLLRRLXXLRXXLXLRLLLLLRXLRXLXRXLXLRRXXRRLXLXLRLRXRXLXXXLRXLLXLRRRRXRLLXRRLLRRXRRRLRLLRLRXXXRLXLXLLLRXXLLXLRXXLLLRLXRRXRLXLXXXXXXLXRXXRXXXRXLXXRRXLLXRRXLXXRRXLXXRLXLXXLXRXXRLRLLXLXLXLRXLXLXLLLRLXXLX...
Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in which he sometimes makes the wrong steps or — horror of horrors! — stops for a while. For example, i...
0
{"tests": "{\"inputs\": [\"RL\", \"RLLRRLLLRRRLLLLRR\", \"QL\", \"RLLRRLLMRRRLLLLRR\", \"LQ\", \"KR\", \"KQ\", \"QK\", \"RK\", \"SK\", \"KS\", \"RJ\", \"QJ\", \"QI\", \"PI\", \"PJ\", \"JP\", \"JQ\", \"JO\", \"OJ\", \"OK\", \"KO\", \"PK\", \"KP\", \"IQ\", \"JR\", \"IR\", \"RI\", \"RH\", \"HR\", \"NJ\", \"JN\", \"JS\", \...
You are playing a game called Guru Guru Gururin. In this game, you can move with the vehicle called Gururin. There are two commands you can give to Gururin: 'R' and 'L'. When 'R' is sent, Gururin rotates clockwise by 90 degrees. Otherwise, when 'L' is sent, Gururin rotates counterclockwise by 90 degrees. During the ga...
0.875
{"tests": "{\"inputs\": [[\"15 20 60 75 80 100\"], [\"9 9 12 12 12 15 16 20\"], [\"4131 5508 7344 7803 8397 8667 9792 10404 11196 11556 13872 14553 14742 14928 15408 17631 18496 19404 19656 19904 20544 20925 21816 23508 23598 23949 25872 26208 27900 29088 31344 31464 31932 34496 34944 37200 38784 41792 41952 42576 4960...
Your friend Cody has to sell a lot of jam, so he applied a good 25% discount to all his merchandise. Trouble is that he mixed all the prices (initial and discounted), so now he needs your cool coding skills to filter out only the discounted prices. For example, consider this inputs: ``` "15 20 60 75 80 100" "9 9 12 1...
0
{"tests": "{\"inputs\": [[[true, true, true, false], \"AND\"], [[true, true, true, false], \"OR\"], [[true, true, true, false], \"XOR\"], [[true, true, false, false], \"AND\"], [[true, true, false, false], \"OR\"], [[true, true, false, false], \"XOR\"], [[true, false, false, false], \"AND\"], [[true, false, false, fals...
Your task is to calculate logical value of boolean array. Test arrays are one-dimensional and their size is in the range 1-50. Links referring to logical operations: [AND](https://en.wikipedia.org/wiki/Logical_conjunction), [OR](https://en.wikipedia.org/wiki/Logical_disjunction) and [XOR](https://en.wikipedia.org/wiki...
0
{"tests": "{\"inputs\": [\"4 5\\n..33\\n..33\\n2222\\n..1.\\n.111\\n5 7\\n....1\\n.1..1\\n.1..1\\n11..1\\n.2222\\n..111\\n...1.\\n3 6\\n.3.\\n233\\n23.\\n22.\\n.11\\n.11\\n4 3\\n2222\\n..11\\n..11\\n4 5\\n.3..\\n33..\\n322.\\n2211\\n.11.\\n3 3\\n222\\n2.1\\n111\\n3 4\\n11.\\n11.\\n.2/\\n222\\n3 4\\n.11\\n.11\\n.2.\\n22...
You are working for an administration office of the International Center for Picassonian Cubism (ICPC), which plans to build a new art gallery for young artists. The center is organizing an architectural design competition to find the best design for the new building. Submitted designs will look like a screenshot of a...
0
{"tests": "{\"inputs\": [\"1\\n4\\n10 20 34 55\\n4\\n7 14\\n7 21\\n14 21\\n7 35\", \"1\\n4\\n10 20 34 55\\n4\\n7 14\\n7 21\\n14 6\\n7 35\", \"1\\n4\\n10 20 34 55\\n4\\n7 14\\n7 21\\n14 6\\n7 2\", \"1\\n2\\n10 20 34 55\\n4\\n7 5\\n2 4\\n21 6\\n7 2\", \"1\\n4\\n10 8 45 28\\n4\\n7 26\\n4 21\\n21 6\\n13 35\", \"1\\n4\\n20 ...
Did you know that the yummy golden triangle was introduced in India as early as 13th century ? By the way, I'm referring to the popular South Asian snack, Samosa. I guess its hard to code while thinking of Samosa, especially if you are very hungry now ; so lets not get in to any recipe or eating game. You have N box...
0
{"tests": "{\"inputs\": [\"1 1\\n\", \"1 42\\n\", \"6 4\\n\", \"3 1\\n\", \"42 1\\n\", \"10000 239\\n\", \"5 8\\n\", \"7 11\\n\", \"16 60\\n\", \"214 210\\n\", \"620 35\\n\", \"940 480\\n\", \"1307 3420\\n\", \"6811 5416\\n\", \"7 267\\n\", \"106 6\\n\", \"10000 10000\\n\", \"10000 9999\\n\", \"9999 9998\\n\", \"9999 9...
Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this! Let us remind you...
0
{"tests": "{\"inputs\": [\"1 2\\nDI\\n\", \"2 2\\nMA\\nID\\n\", \"5 5\\nDIMAD\\nDIMAI\\nDIMAM\\nDDMAA\\nAAMID\\n\", \"1 1\\nI\\n\", \"5 5\\nDIMAD\\nADDDI\\nMDDDM\\nIDDDA\\nDAMID\\n\", \"5 5\\nAAAAA\\nAAAAA\\nAAAAA\\nAAAAA\\nAAAAA\\n\", \"1 1\\nD\\n\", \"1 4\\nDIMA\\n\", \"4 1\\nD\\nI\\nM\\nA\\n\", \"2 2\\nDI\\nAM\\n\",...
Inna and Dima bought a table of size n × m in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A". Inna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna acts as follows: initially, Inna chooses some cell of the table w...
0