info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"5\\n3 5 4 1 2\\n\", \"4\\n3 4 1 2\\n\", \"100\\n22 78 19 70 81 33 15 72 40 51 18 62 36 24 37 20 97 65 89 75 14 55 23 53 1 67 50 99 54 76 41 16 44 60 2 90 7 28 79 43 47 64 71 27 25 8 46 92 95 80 31 100 42 96 86 66 52 63 98 4 56 91 34 83 85 3 84 17 94 11 73 29 6 58 61 68 57 88 10 32 82 93 26 13... | You are given a permutation of numbers from 1 to n. Determine whether there's a pair of integers a, b (1 ≤ a, b ≤ n; a ≠ b) such that the element <image> (note, that it is usual division, not integer one) is between a and b in this permutation.
Input
First line consists of a single integer n (1 ≤ n ≤ 300000) — the si... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"10000\\n\", \"7\\n\", \"36\\n\", \"10\\n\", \"999999999999999999\\n\", \"789136710974630947\\n\", \"999999999999999989\\n\", \"1000000000000000000\\n\", \"776930\\n\", \"219760524792138559\\n\", \"58929554039\\n\", \"10\\n\", \"43\\n\", \"43\\n\", \"43\\n\", \"36\\n\", \"2\\n\", \"1... | Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll... | 0 |
{"tests": "{\"inputs\": [\"3 0\\n1 1 1\\n\", \"5 1\\n-1 -2 -3 -4 5\\n\", \"13 2\\n3 1 4 1 5 -9 -2 -6 -5 -3 -5 -8 -9\\n\", \"70 2\\n1 1 1 1 1 -1 -1 -1 -1 -1 -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 -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 -3... | Wabbit is playing a game with $n$ bosses numbered from $1$ to $n$. The bosses can be fought in any order. Each boss needs to be defeated exactly once. There is a parameter called boss bonus which is initially $0$.
When the $i$-th boss is defeated, the current boss bonus is added to Wabbit's score, and then the value o... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n0 2 3\", \"4\\n0 6 3 7 4 5 2\", \"2\\n-1 1 7\", \"4\\n0 5 3 1 4 9 2\", \"4\\n-1 5 5 0 8 2 0\", \"4\\n-2 3 3 7 7 5 0\", \"4\\n-2 3 3 7 6 1 0\", \"2\\n-1 2 3\", \"4\\n0 6 3 4 4 5 2\", \"2\\n-1 2 5\", \"4\\n0 4 3 4 4 5 2\", \"2\\n-1 2 7\", \"4\\n0 5 3 4 4 5 2\", \"4\\n0 5 3 4 4 9 2\", \"2\\n... | We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.
<image>
A pyramid with N=4 steps
Snuke wrote a per... | 0 |
{"tests": "{\"inputs\": [[3, 7], [15, 3], [10, -29], [5], [4, 2, 3, 5, 7, -8], [-3, 5], [-11, -1], [-9999999], [-25, -11, 9], [-25, 5, -9, 55, -8, -7, 8]], \"outputs\": [[\"1 1 1 1 1 1 1 1\\n 2 2 2 2 2 2 2 2 2 2 2 2 2 2 \\n 3 3 3 3 3 3 3 \\n 2 2 2 2 2 2 2 2 2 2 2 2 2 2 \\n1 1 1 1 1 ... | ## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows.
* Note:`Returning` the pattern is not the same as `Printing` the pattern.
### Parameters:
pattern( n , x );
^ ^ ... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n5 4 6\\n\", \"6 3\\n1 2 3 2 2 3\\n\", \"6 3\\n1 2 4 1 2 3\\n\", \"7 3\\n50 17 81 25 42 39 96\\n\", \"1 1\\n1\\n\", \"1 1\\n1000000000000\\n\", \"3 3\\n14159 26535 89793\\n\", \"7 4\\n1 10000 1 1 1 1 10000\\n\", \"17 10\\n465 868 29 633 291 357 62 929 22 124 182 995 903 75 71 924 416\\n\... | You are given two arrays: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers.
You can apply the following operation to the array $a$ an arbitrary number of times: choose some subsegment of $a$ of length $k$ and add the arithmetic progression $1, 2, \ldots, k$ to this subsegment — i. e. ad... | 0 |
{"tests": "{\"inputs\": [[\"a\"], [\"aaaa\"], [\"abcd\"], [\"babababababababa\"], [\"ababababa\"], [\"123a123a123a\"], [\"123A123a123a\"], [\"12aa13a21233\"], [\"12aa13a21233A\"], [\"abcdabcaccd\"]], \"outputs\": [[false], [true], [false], [true], [false], [true], [false], [true], [false], [false]]}", "source": "taco"} | Similarly to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-i/), you will need to return a boolean value if the base string can be expressed as the repetition of one subpattern.
This time there are two small changes:
* if a subpattern has been used, it will be repeated at least twice,... | 0 |
{"tests": "{\"inputs\": [\"15\\n987654329876543\\n\", \"1\\n4\\n\", \"15\\n028745260720699\\n\", \"1\\n9\\n\", \"8\\n68931246\\n\", \"2\\n26\\n\", \"1\\n2\\n\", \"9\\n987654321\\n\", \"1\\n8\\n\", \"2\\n99\\n\", \"10\\n3312667105\\n\", \"5\\n99999\\n\", \"1\\n6\\n\", \"15\\n012345781234578\\n\", \"9\\n234567899\\n\", \... | Drazil is playing a math game with Varda.
Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.
First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then th... | 0.125 |
{"tests": "{\"inputs\": [[\"yellow violet black\"], [\"yellow violet red gold\"], [\"brown black green silver\"], [\"brown black black\"], [\"brown black brown gold\"], [\"red red brown\"], [\"orange orange brown gold\"], [\"yellow violet brown silver\"], [\"blue gray brown\"], [\"brown black red silver\"], [\"brown bl... | ## Overview
Resistors are electrical components marked with colorful stripes/bands to indicate both their resistance value in ohms and how tight a tolerance that value has. While you could always get a tattoo like Jimmie Rodgers to help you remember the resistor color codes, in the meantime, you can write a function th... | 0 |
{"tests": "{\"inputs\": [\"2\\n8\\n2\\n\", \"2\\n3\\n4857\\n\", \"7\\n1\\n7\\n9\\n5\\n6\\n10\\n4\\n\", \"10\\n384\\n179\\n982\\n466\\n646\\n226\\n759\\n798\\n291\\n852\\n\", \"10\\n677\\n958\\n20\\n169\\n441\\n752\\n24\\n809\\n41\\n96\\n\", \"10\\n31\\n362\\n396\\n661\\n314\\n803\\n366\\n124\\n748\\n875\\n\", \"50\\n41... | You are given n positive integers a_1, a_2, ..., a_{n}.
For every a_{i} you need to find a positive integer k_{i} such that the decimal notation of 2^{k}_{i} contains the decimal notation of a_{i} as a substring among its last min(100, length(2^{k}_{i})) digits. Here length(m) is the length of the decimal notation of ... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n\", \"3 2\\n\", \"1000000000000000000 2\\n\", \"1000000000000000000 3\\n\", \"1000000000000000000 5\\n\", \"1000000000000000000 42\\n\", \"1000000000000000000 69\\n\", \"1000000000000000000 99\\n\", \"1000000000000000000 100\\n\", \"1 2\\n\", \"1 3\\n\", \"1 4\\n\", \"1 5\\n\", \"2 2\\n... | Reziba has many magic gems. Each magic gem can be split into $M$ normal gems. The amount of space each magic (and normal) gem takes is $1$ unit. A normal gem cannot be split.
Reziba wants to choose a set of magic gems and split some of them, so the total space occupied by the resulting set of gems is $N$ units. If a m... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n0\\n\", \"100\\n0 92 0 75 16 87 0 0 0 0 5 0 0 0 0 60 0 0 52 35 0 17 59 0 0 0 57 0 0 0 0 0 0 0 0 58 41 0 0 0 44 38 0 0 0 0 0 0 68 0 0 67 25 89 0 0 0 0 0 0 0 47 39 0 0 0 0 0 40 0 74 3 0 0 0 0 0 0 0 0 0 81 45 0 0 0 0 0 0 0 0 64 0 0 0 0 0 56 2 11\\n\", \"20\\n7 0 9 0 5 0 15 0 0 1 17 0 11 19 0... | Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland.... | 0.125 |
{"tests": "{\"inputs\": [\"5 1 5\\n1 1 1 1 1\\n3 1 5 4 2\\n\", \"4 2 9\\n3 4 8 9\\n3 2 1 4\\n\", \"6 1 5\\n1 1 1 1 1 1\\n2 3 5 4 1 6\\n\", \"5 1 7\\n1 4 4 6 5\\n5 2 1 4 3\\n\", \"5 10 100\\n12 14 15 11 13\\n4 2 1 5 3\\n\", \"2 1 1000000000\\n1000000000 1\\n2 1\\n\", \"2 1 1000000000\\n1000000000 1\\n1 2\\n\", \"5 1 5\\... | Dasha logged into the system and began to solve problems. One of them is as follows:
Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}.
About sequences a and b we know that their elements are in the range ... | 0.375 |
{"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\", \"1 4\\n1 1 1 2\\n2 1 1 6\\n1 1 1 1\\n2 1 1 7\\n\", \"2 2\\n2 1 2 8\\n2 1 2 7\\n\", \"97 29\\n2 78 82 356152\\n2 14 29 430177\\n1 59 84 3680\\n1 49 89 -2247\\n1 92 96 3701\\n2 54 89 377271\\n1 62 70 -507\\n2 94 97 431563\\n1 46 55 -9... | Levko loves array a1, a2, ... , an, 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:
1. Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j ... | 0 |
{"tests": "{\"inputs\": [\"7\\n10\\n15\\n13\\n18\\n11\\n14\\n19\\n\", \"2\\n1\\n2\\n\", \"15\\n57\\n62\\n47\\n45\\n42\\n74\\n90\\n75\\n54\\n50\\n66\\n63\\n77\\n87\\n51\\n\", \"15\\n57\\n62\\n37\\n45\\n42\\n74\\n90\\n75\\n54\\n50\\n66\\n63\\n77\\n87\\n51\", \"2\\n0\\n2\", \"7\\n10\\n15\\n13\\n18\\n11\\n24\\n19\", \"15\\... | You are given a sequence D_1, D_2, ..., D_N of length N.
The values of D_i are all distinct.
Does a tree with N vertices that satisfies the following conditions exist?
- The vertices are numbered 1,2,..., N.
- The edges are numbered 1,2,..., N-1, and Edge i connects Vertex u_i and v_i.
- For each vertex i, the sum o... | 0.625 |
{"tests": "{\"inputs\": [\"36\\n6\\n165310\\n6\\n177978\\n6\\n211759\\n6\\n212643\\n6\\n229540\\n6\\n250029\\n6\\n211519\\n6\\n256097\\n6\\n163478\\n5\\n91505\\n5\\n79280\\n6\\n260629\\n6\\n128051\\n6\\n121972\\n6\\n261633\\n6\\n172044\\n6\\n119055\\n6\\n208323\\n6\\n149942\\n6\\n161236\\n6\\n177150\\n6\\n233766\\n5\\n... | Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're still unsure what ebne numbers are, you can look at the sample notes for more clar... | 0 |
{"tests": "{\"inputs\": [\"1\\n4\\n\", \"4\\n1 3 2 5\\n\", \"4\\n1 5 2 3\\n\", \"10\\n2 2 2 17 8 9 10 17 10 5\\n\", \"100\\n102 157 177 149 138 193 19 74 127 156 128 122 6 101 154 92 24 188 51 89 18 77 112 100 65 11 113 173 79 124 102 81 11 171 114 43 60 168 44 86 87 82 177 8 12 181 139 121 140 28 108 17 173 63 18 4 14... | The next "Data Structures and Algorithms" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.
Nam created a sequence a consisting of n (1 ≤ n ≤ 10^5) elements a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5). A subseq... | 0.125 |
{"tests": "{\"inputs\": [\"2 2\\n2 6\\n3 100\\n\", \"2 3\\n10 10\\n1 1 1\\n\", \"2 2\\n888381664 866366630\\n170399907 404233949\\n\", \"3 4\\n337369924 278848730 654933675\\n866361693 732544605 890800310 350303294\\n\", \"10 10\\n510955240 684852706 455356451 284505713 595775142 646334608 563116339 941123613 818750895... | Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic.
Suppose she wants to join two tables, A and B. Each of them has certain number of rows which are distributed on different number of partitions. Table A is distributed on the first cluster consisting... | 0.625 |
{"tests": "{\"inputs\": [[60], [780], [2040], [4200], [12180], [120120], [192720], [328860], [907200], [1440600]], \"outputs\": [[[3, 4, 5]], [[5, 12, 13]], [[8, 15, 17]], [[7, 24, 25]], [[20, 21, 29]], [[33, 56, 65]], [[48, 55, 73]], [[60, 63, 87]], [[42, 144, 150]], [[49, 168, 175]]]}", "source": "taco"} | # Pythagorean Triples
A Pythagorean triplet is a set of three numbers a, b, and c where `a^2 + b^2 = c^2`. In this Kata, you will be tasked with finding the Pythagorean triplets whose product is equal to `n`, the given argument to the function `pythagorean_triplet`.
## Your task
In this Kata, you will be tasked with... | 0.875 |
{"tests": "{\"inputs\": [\"8-7+6-5+4-3+2-1-0\\n\", \"2+2\\n\", \"112-37\\n\", \"255+255+255+255+255+255+255+255+255+255\\n\", \"0-255-255-255-255-255-255-255-255-255\\n\", \"0+0+0+0+0+0+0+0+0+0\\n\", \"0-0-0-0-0-0-0-0-0-0\\n\", \"0+100+100+100+100+100+100+100+100+100\\n\", \"255-100-100-100-100-100-100-100-100-100\\n\"... | One very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like there is a bug in the reference solution...
-----Input-----
The only line of input data contain... | 0 |
{"tests": "{\"inputs\": [\"5\\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\\n\", \"1\\n4\\n\", \"1\\n15\\n\", \"1\\n1\\n\", \"3\\n6 1 14\\n\", \"4\\n1 2 2 16\\n\", \"3\\n6 1 2\\n\", \"4\\n1 2 4 22\\n\", \"5\\n1000000000000000000 352839520853234088 257894004782222768 8... | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | 0 |
{"tests": "{\"inputs\": [\"1 1 1\\n1\\n1 1 1000000000000000000\\n\", \"2 2 1\\n10\\n11\\n1 2 1000000000000000000\\n\", \"1 1 1\\n1\\n1 1 1\\n\", \"3 3 3\\n000\\n111\\n000\\n1 1 1\\n2 2 2\\n3 3 2\\n\", \"5 5 3\\n01011\\n10110\\n01101\\n11010\\n10101\\n2 1 4\\n1 2 3\\n5 5 3\\n\", \"5 5 3\\n01011\\n10110\\n01101\\n11010\\... | Please notice the unusual memory limit of this problem.
Orac likes games. Recently he came up with the new game, "Game of Life".
You should play this game on a black and white grid with n rows and m columns. Each cell is either black or white.
For each iteration of the game (the initial iteration is 0), the color of... | 0 |
{"tests": "{\"inputs\": [[\"0\"], [\"01\"], [\"012\"], [\"0123\"], [\"01234\"], [\"012345\"]], \"outputs\": [[\"###-###-####\"], [\"1##-##1-####\"], [\"12#-##1-2###\"], [\"123-##1-23##\"], [\"123-4#1-234#\"], [\"123-451-2345\"]]}", "source": "taco"} | Your Goal is to create a function that takes two strings, a guess and a phone number.
Based on the guess, the function should display a portion of the phone number:
guess_my_number('052', '123-451-2345')
would return the string: '#2#-#5#-2##5'
or
guess_my_number('142', '123-451-2345')
... | 0 |
{"tests": "{\"inputs\": [[\"fire\", \"water\", 100, 100], [\"grass\", \"water\", 100, 100], [\"electric\", \"fire\", 100, 100], [\"grass\", \"electric\", 57, 19], [\"grass\", \"water\", 40, 40], [\"grass\", \"fire\", 35, 5], [\"fire\", \"electric\", 10, 2]], \"outputs\": [[25], [100], [50], [150], [100], [175], [250]]}... | It's a Pokemon battle! Your task is to calculate the damage that a particular move would do using the following formula (not the actual one from the game):
Where:
* attack = your attack power
* defense = the opponent's defense
* effectiveness = the effectiveness of the attack based on the matchup (see explanation bel... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n4 3 1 2 1\\n1 2 1 2 1\\n1 2 3 4 5 6 7 8 9\\n\", \"2 2\\n1 2\\n0 0\\n2 1 -100 -100\\n\", \"5 4\\n4 3 2 1 1\\n0 2 6 7 4\\n12 12 12 6 -3 -5 3 10 -4\\n\", \"7 5\\n4 3 2 3 2 1 1\\n6 8 9 1 2 0 5\\n14 6 0 14 -12 -2 -13 10 -14 -3 10 -9\\n\", \"7 4\\n1 4 3 2 1 3 1\\n8 2 2 1 4 3 2\\n-6 14 8 13 -8... | A popular reality show is recruiting a new cast for the third season! $n$ candidates numbered from $1$ to $n$ have been interviewed. The candidate $i$ has aggressiveness level $l_i$, and recruiting this candidate will cost the show $s_i$ roubles.
The show host reviewes applications of all candidates from $i=1$ to $i=n... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 5\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 11\\n0 -5\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 3\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 7\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 5\\n1 18\\n0 -... | Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.
There are two types of spells: fire spell of power $x$ deals $x$ damage to the monster, and lightning spell of power $y$ deals $y$ damage to the monster and doubles the damage of the next spell Polycarp casts. Each spell c... | 0 |
{"tests": "{\"inputs\": [\"3\\n80 0 30\\n50 5 25\\n90 27 50\\n3\\n80 0 30\\n70 5 25\\n71 30 84\\n0\", \"3\\n80 0 15\\n64 5 25\\n149 27 50\\n3\\n80 0 10\\n70 10 25\\n22 30 84\\n0\", \"3\\n80 0 30\\n50 5 25\\n90 27 50\\n3\\n80 0 30\\n70 5 25\\n71 23 50\\n0\", \"3\\n1 0 30\\n50 5 25\\n90 28 50\\n3\\n80 0 40\\n70 5 25\\n71... | In Aizuwakamatsu Village, which is located far north of Aizuwakamatsu City, a bridge called "Yabashi" is the only way to move to the surrounding villages. Despite the large number of passers-by, the bridge is so old that it is almost broken.
<image>
Yabashi is strong enough to withstand up to 150 [kg]. For example,... | 0.625 |
{"tests": "{\"inputs\": [\"32\\n0 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\", \"24\\n1 2 5 3 3 6 1 1 15 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2\", \"3\\n2 2 0\", \"24\\n1 2 5 3 3 6 1 2 15 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2\", \"24\\n1 4 5 3 3 6 1 2 15 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2\", \"24\\n1 4 5 3 3 6 2 2 15 8 0... | The beauty of a sequence a of length n is defined as a_1 \oplus \cdots \oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more partitions in A to divide it into some number of non-empty contiguous subsequences.
There are 2^{N-1} possible ... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n9 10\\n13 18\\n15 12\\n11 7\\n\", \"4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n5 10\\n13 18\\n15 12\\n11 7\\n\", \"4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n5 10\\n16 18\\n15 12\\n11 7\\n\", \"4\... | On a circle lie $2n$ distinct points, with the following property: however you choose $3$ chords that connect $3$ disjoint pairs of points, no point strictly inside the circle belongs to all $3$ chords. The points are numbered $1, \, 2, \, \dots, \, 2n$ in clockwise order.
Initially, $k$ chords connect $k$ pairs of po... | 0 |
{"tests": "{\"inputs\": [\"5\\n8 3 2 1 4\\n3 7 2 4 8\\n9 2 8 9 10\\n2 3 6 10 1\\n8 2 2 8 4\\n\", \"8\\n1 1 10 1 8 4 8 7\\n9 3 3 2 2 6 2 4\\n7 4 3 5 10 3 5 1\\n8 4 4 10 4 5 9 4\\n5 5 5 2 6 7 1 8\\n4 10 1 3 2 4 8 3\\n8 1 10 2 8 2 2 4\\n2 10 6 8 10 2 8 4\\n\", \"10\\n10 8 6 5 9 8 2 5 3 2\\n3 1 8 6 8 10 5 5 7 8\\n5 9 7 7 4... | There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that
* starts in the upper left cell of the matrix;
* each following cell is to the right or down from the current cell;
* the way ends in the bottom right cell.
Moreover, if we multiply together a... | 0 |
{"tests": "{\"inputs\": [\"?D-C'KOQUA\", \"?D-B'KOQUA\", \"AUQOK'B-D?\", \"-UQOK'BAD?\", \"-UQOK'BBD?\", \"-UQNK'BBD?\", \"?DBB'KNQU-\", \".UQNK'BBD?\", \".UPNK'BBD?\", \".UPNK'BCD?\", \".UPNKB'CD?\", \"?DKC'-OPUA\", \"AUQOK'C-D?\", \"-UQPK'BAD?\", \"-UQOKBB'D?\", \"-UQNK'CBD?\", \"?-BB'KNQUD\", \"?DBB'KNPU.\", \".UPNL... | Hiroshi:? D-C'KOPUA
Peter: What's wrong, Dr. David? I'm used to shouting something I don't understand, but I'm not even writing it today.
Hiroshi: Here.
<image>
Peter: What? This table ... oh, there was something like this in the qualifying question. Replacing characters using a table reduces the number of charact... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 1 1\\n1 1 1\\n1 1 1\\n2 2 2\\n2 2 2\\n2 2 2\\n4 3 3\\n5 2 2\\n4 3 3\\n6 1 1\\n6 1 1\\n6 1 -1\\n1 0 0\\n0 2 0\\n0 0 0\\n5 1 2\\n5 1 2\\n0 0 0\\n2 0 0\\n0 3 0\\n0 0 0\\n0 0 0\\n0 0 0\\n3 0 1\", \"4\\n1 1 1\\n1 2 1\\n1 1 1\\n2 2 2\\n2 2 2\\n2 2 2\\n4 3 3\\n5 2 2\\n4 3 3\\n6 1 1\\n6 1 1\\n6... | Let’s try a dice puzzle. The rules of this puzzle are as follows.
1. Dice with six faces as shown in Figure 1 are used in the puzzle.
<image>
Figure 1: Faces of a die
2. With twenty seven such dice, a 3 × 3 × 3 cube is built as shown in Figure 2.
<image>
Figure 2: 3 × 3 × 3 cube
3. When building up a cube made o... | 0 |
{"tests": "{\"inputs\": [[\"\"], [\"abc\", \"def\", \"ghi\", \"jklm\", \"nop\"], [\"ape\", \"apple\"], [\"ape\", \"appendix\", \"apel\"], [\"ape\", \"apple\", \"applet\", \"appendix\"], [\"romane\", \"romanus\", \"romulus\"], [\"test\", \"tester\", \"testers\"], [\"test\", \"tester\", \"testers\", \"tester\"], [\"teste... | Implement a function which
creates a **[radix tree](https://en.wikipedia.org/wiki/Radix_tree)** (a space-optimized trie [prefix tree])
in which each node that is the only child is merged with its parent [unless a word from the input ends there])
from a given list of words
using dictionaries (aka hash maps or hash t... | 0 |
{"tests": "{\"inputs\": [\"8 50 50 0\", \"1 000 0 0\", \"2 100 0 0\", \"6 50 50 0\", \"1 101 0 -1\", \"100001 31 41 28\", \"1 100 -1 1\", \"000001 31 41 28\", \"000011 31 41 28\", \"2 25 25 50\", \"10 50 50 0\", \"5 50 50 0\", \"3 50 50 0\", \"2 101 0 -1\", \"18 50 50 0\", \"1 101 1 -2\", \"1 100 -2 2\", \"36 50 50 0\"... | Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.
When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %. Find the expected number of games that wi... | 0 |
{"tests": "{\"inputs\": [\"8 3\\n14 3 1 8 4 6 2 5\", \"7 3\\n2 3 1 4\", \"3 3\\n2 2 3\", \"12 3\\n0 4 0 4\", \"20 3\\n-1 4 0 4\", \"34 3\\n-1 4 0 6\", \"31 3\\n-1 4 0 6\", \"31 8\\n-2 2 0 6\", \"4 3\\n2 3 2 4\", \"64 3\\n-1 4 0 6\", \"57 3\\n-2 4 0 6\", \"44 3\\n-4 3 1 6\", \"31 5\\n-8 3 1 6\", \"8 2\\n14 5 1 4 2 6 2 5... | There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.
On this sequence, Snuke can perform the following operation:
* Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n?\\n18\\n1?\\n\", \"2\\n??\\n?\\n\", \"5\\n12224\\n12??5\\n12226\\n?0000\\n?00000\\n\", \"10\\n473883\\n3499005\\n4?74792\\n58146??\\n8?90593\\n9203?71\\n?39055?\\n1?692641\\n11451902\\n?22126?2\\n\", \"8\\n?\\n2\\n3\\n4\\n?\\n?\\n?\\n9\\n\", \"98\\n?\\n?0\\n2?\\n6?\\n6?\\n69\\n??\\n??\\n... | Peter wrote on the board a strictly increasing sequence of positive integers a_1, a_2, ..., a_{n}. Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit.
Restore the the original sequence knowing digits remaining on the board.
... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n999999998 999999998 1\\n999999998 999999999 1\\n999999999 999999999 1\\n-999999999 -999999998 1\\n\", \"10\\n963610297 -512417928 19\\n963610296 -512417926 11\\n963610298 -512417930 16\\n963610296 -512417927 9\\n963610297 -512417926 14\\n963610300 -512417927 6\\n963610300 -512417930 18\\n... | At the foot of Liyushan Mountain, n tents will be carefully arranged to provide accommodation for those who are willing to experience the joy of approaching nature, the tranquility of the night, and the bright starry sky.
The i-th tent is located at the point of (x_i, y_i) and has a weight of w_i. A tent is important ... | 0.375 |
{"tests": "{\"inputs\": [\"4\\n\", \"3\\n\", \"2\\n\", \"5\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"1\\n\", \"21\\n\", \"14\\n\", \"360561\\n\", \"25\\n\", \"85\\n\", \"699049\\n\", \"699047\\n\", \"6\\n\", \"10\\n\", \"699050\\n\", \"699048\\n\", \"1000000\\n\", \"786432\\n\", \"750096\\n\", \"10922\\n\", \"699051\\n\", ... | Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key stored in the right subtree.
The depth of a vertex is the number o... | 0 |
{"tests": "{\"inputs\": [\"4 4 2\\n2\\n2\\n2\\n1\\n\", \"3 6 3\\n3\\n3\\n2\\n2\\n1\\n1\\n\", \"2 2 1\\n1\\n1\\n\", \"3 6 3\\n1\\n2\\n1\\n3\\n1\\n3\\n\", \"4 8 4\\n2\\n3\\n2\\n3\\n2\\n3\\n2\\n3\\n\", \"10 100 20\\n4\\n1\\n15\\n2\\n11\\n1\\n18\\n9\\n17\\n5\\n17\\n12\\n20\\n6\\n14\\n19\\n20\\n3\\n6\\n14\\n12\\n17\\n17\\n1... | This is an interactive problem. Refer to the Interaction section below for better understanding.
Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.
<image>
Initially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n from left to right.
This game ... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"2 4\\n\", \"5 14\\n\", \"0 4\", \"8 14\", \"0 14\", \"1 14\", \"2 14\", \"2 1\", \"0 1\", \"2 5\", \"2 26\", \"2 2\", \"0 5\", \"9 14\", \"0 28\", \"2 10\", \"0 2\", \"3 1\", \"1 5\", \"2 11\", \"0 3\", \"9 12\", \"1 28\", \"1 10\", \"4 2\", \"1 4\", \"3 11\", \"9 18\", \"1 7\", \... | In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.
Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographi... | 0 |
{"tests": "{\"inputs\": [\"3\\n1000000000 1000000000 1000000000\\n\", \"6\\n-1 3 3 5 5 -1\\n\", \"10\\n-589330597 -126288833 -126288833 -834860352 -834860352 -834860352 -834860352 -21170405 -834860352 -834860352\\n\", \"20\\n-808998072 733614990 579897311 -337992089 579897311 120800519 -337992089 -803027570 733614990 -... | — Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n1 2 3\\n2\\n42 42\", \"2\\n3\\n1 4 3\\n2\\n42 42\", \"2\\n3\\n1 4 3\\n2\\n42 28\", \"2\\n3\\n1 4 3\\n2\\n38 42\", \"2\\n3\\n1 0 3\\n2\\n38 42\", \"2\\n3\\n1 -1 3\\n2\\n38 42\", \"2\\n3\\n1 0 1\\n2\\n38 42\", \"2\\n3\\n2 0 1\\n2\\n38 42\", \"2\\n3\\n1 4 3\\n2\\n42 7\", \"2\\n3\\n1 0 3\... | Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th worker equals to W_{i} (i = 1, 2, ..., N). Once, chief decided to equalize all workers, that is, he wants to make salaries of all workers to be equal. But for this goal he can use only one ... | 0 |
{"tests": "{\"inputs\": [[[\"APP_PASSIVE_OPEN\", \"RCV_SYN\", \"RCV_ACK\", \"APP_CLOSE\"]], [[\"APP_PASSIVE_OPEN\", \"RCV_SYN\", \"RCV_ACK\"]], [[\"APP_PASSIVE_OPEN\", \"RCV_SYN\"]], [[\"APP_PASSIVE_OPEN\"]], [[\"APP_ACTIVE_OPEN\", \"APP_CLOSE\"]], [[\"APP_ACTIVE_OPEN\", \"RCV_SYN\", \"APP_CLOSE\", \"RCV_FIN\", \"RCV_A... | Automatons, or Finite State Machines (FSM), are extremely useful to programmers when it comes to software design. You will be given a simplistic version of an FSM to code for a basic TCP session.
The outcome of this exercise will be to return the correct state of the TCP FSM based on the array of events given.
------... | 0 |
{"tests": "{\"inputs\": [[[\"+--+ +----+\", \"| | | | +-+\", \"| | +----+ | |\", \"+--+ +-+\"]], [[\"+-----+\", \"| |\", \"+-----+\"]], [[\"+---+\", \"| |\", \"| +-+-+\", \"| | | |\", \"+-+-+ |\", \" | |\", \" +---+\"]], [[\"+-+-+\", \"| | |\", \"+-+-+\", \"| | |\", \"+-+-+\"]], [[\"+... | Your task is to write a function which counts the number of squares contained in an ASCII art picture.
The input pictures contain rectangles---some of them squares---drawn with the characters `-`, `|`, and `+`, where `-` and `|` are used to represent horizontal and vertical sides, and `+` is used to represent corners ... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 3 4 2\\n1 2 2 3\\n5\\n2 3 4 5 1\\n1 2 3 4 5\\n8\\n7 4 5 6 1 8 3 2\\n5 3 6 4 7 5 8 4\\n\", \"3\\n4\\n1 3 4 2\\n1 2 2 3\\n5\\n2 3 4 5 1\\n1 2 3 4 5\\n8\\n7 4 5 6 1 8 3 2\\n5 3 6 8 7 5 8 4\\n\", \"3\\n4\\n1 3 4 2\\n1 2 2 3\\n5\\n2 3 4 5 1\\n1 2 5 4 5\\n8\\n7 4 5 6 1 8 3 2\\n5 3 6 4 7 5... | You are given a colored permutation $p_1, p_2, \dots, p_n$. The $i$-th element of the permutation has color $c_i$.
Let's define an infinite path as infinite sequence $i, p[i], p[p[i]], p[p[p[i]]] \dots$ where all elements have same color ($c[i] = c[p[i]] = c[p[p[i]]] = \dots$).
We can also define a multiplication of ... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n1 3 5 7\\n1 5 5 7\\n100000 200000 300000 400000\\n1 1 977539810 977539810\\n\", \"1\\n1 1 1 1\\n\", \"3\\n31796 38166 39580 43622\\n3002 27223 58836 70214\\n13832 74454 78650 89847\\n\", \"14\\n2374453 2374454 8591131 23094546\\n5813291 5813292 9709163 35032815\\n4280399 23049698 23049701... | Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.
These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to attend the contest. Now sh... | 0.875 |
{"tests": "{\"inputs\": [\"5\\n1 2\\n2 3\\n3 4\\n4 5\\n5\\n1 3 1 2 2\\n1 4 1 3 2\\n1 4 1 3 3\\n4 2 3 3 9\\n5 2 3 3 9\\n\", \"9\\n3 9\\n3 4\\n7 2\\n6 9\\n5 3\\n6 2\\n8 3\\n1 9\\n10\\n8 4 8 2 5\\n9 2 7 4 4\\n8 5 7 3 3\\n1 2 3 8 4\\n2 9 2 4 3\\n6 4 3 4 5\\n6 7 6 6 4\\n7 5 3 1 4\\n5 4 7 8 3\\n4 5 1 5 2\\n\", \"14\\n4 9\\n3... | Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are called 1-trees. Since Gildong was bored of solving too many tree problems, he wan... | 0 |
{"tests": "{\"inputs\": [[2, 5], [48, 101], [7, 733], [48, 733], [2, 733], [229, 101], [229, 103], [229, 105], [5, 5], [61965, 17408], [101014, 125445], [156435434, 3543432125]], \"outputs\": [[3], [40], [419], [168], [367], [15], [9], [94], [null], [null], [7969], [1056765589]]}", "source": "taco"} | A common problem in number theory is to find x given a such that:
a * x = 1 mod [n]
Then x is called the inverse of a modulo n.
Your goal is to code a function inverseMod wich take a and n as parameters and return x.
You may be interested by these pages:
http://en.wikipedia.org/wiki/Modular_multiplicative_invers... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n><>\\nv^v\\n\", \"4 6\\n<><>\\nv^v^v^\\n\", \"2 2\\n<>\\nv^\\n\", \"2 2\\n>>\\n^v\\n\", \"3 3\\n>><\\n^^v\\n\", \"3 4\\n>><\\n^v^v\\n\", \"3 8\\n>><\\nv^^^^^^^\\n\", \"7 2\\n<><<<<>\\n^^\\n\", \"4 5\\n><<<\\n^^^^v\\n\", \"2 20\\n><\\n^v^^v^^v^^^v^vv^vv^^\\n\", \"2 20\\n<>\\nv^vv^v^^vvv^... | Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traff... | 0.5 |
{"tests": "{\"inputs\": [\"12 1 1\\n0 1 2 3 4 5 6 7 8 9 10 11\\n001010001000\\n001010001000 100\\n\", \"1 1 1\\n67\\n0\\n1 47\\n\", \"12 1 1\\n0 1 2 3 4 5 6 7 0 9 10 11\\n001010001000\\n001010001000 100\\n\", \"1 2 4\\n100\\n0\\n1\\n1 0\\n0 100\\n1 0\\n1 100\\n\", \"1 2 4\\n100\\n0\\n0\\n1 0\\n0 100\\n1 0\\n1 100\\n\",... | Childan is making up a legendary story and trying to sell his forgery — a necklace with a strong sense of "Wu" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few questions about Childan's so-called "personal treasure" necklace.
This "personal treasure" is a multis... | 0.875 |
{"tests": "{\"inputs\": [\"2 3\\n-1 -1\\n\", \"5 2\\n1 -1 -1 1 2\\n\", \"5 3\\n1 -1 -1 1 2\\n\", \"4 200000\\n-1 -1 12345 -1\\n\", \"9 3\\n-1 -1 -1 -1 1 2 3 -1 -1\\n\", \"10 5\\n4 -1 -1 1 -1 -1 -1 2 -1 -1\\n\", \"10 8\\n-1 3 5 2 4 -1 -1 1 -1 -1\\n\", \"10 11\\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\\n\", \"10 14\\n-1 9 11 11 -1... | Let's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\forall i \in \{0, 1, \dots, r - l\}$ $b_{l + i} = b_{r - i}$.
If an array is not bad, it is good.
Now you are given an array $a_1, a_2, \dots, a_n$. S... | 0 |
{"tests": "{\"inputs\": [[0, 5], [12345, 17], [313, 2], [832696988485, 170], [769832696988484, 170], [10395, 11], [31428, \"47\"], [1, 171], [7392984749, 900], [123, 0], [-987654321, 99], [999999, [101]], [10396, 11], [0, 1], [2017, 4], [769832696988485, 170]], \"outputs\": [[1808], [29535], [1], [769000000000000], [1]... | In this Kata you are a game developer and have programmed the #1 MMORPG(Massively Multiplayer Online Role Playing Game) worldwide!!! Many suggestions came across you to make the game better, one of which you are interested in and will start working on at once.
Players in the game have levels from 1 to 170, XP(short fo... | 0 |
{"tests": "{\"inputs\": [\"1\\nU\\n\", \"6\\nRURUUR\\n\", \"7\\nURRRUUU\\n\", \"100\\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\\n\", \"7\\nURURRUR\\n\", \"15\\nRUURRRRURRUUUUU\\n\", \"6\\nUURRRU\\n\", \"7\\nRRRRRRR\\n\", \"2\\nUR\\n\", \"2\\nUU\\n\", \"2\\nUR\... | Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.
The world can be represented by the first quadrant of a plane and the wall is built along the identity line (... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n\", \"1 2\\n\", \"4 1\\n\", \"1 3\", \"1 1\", \"2 3\", \"2 5\", \"3 3\", \"2 6\", \"6 3\", \"2 8\", \"6 4\", \"3 6\", \"6 8\", \"3 8\", \"4 8\", \"4 2\", \"4 3\", \"4 5\", \"4 7\", \"5 7\", \"3 7\", \"2 7\", \"2 4\", \"4 4\", \"4 10\", \"6 10\", \"6 13\", \"2 13\", \"3 13\", \"3 1\", \"... | Let's define a good tree:It is a tree with k * n nodes labeled from 0 to k * n - 1
Node i and node j are not adjacent, for all 0 ≤ i, j < k * n such that i div k = j div k (here div means integer division. E.g. 7 div 2 = 3)
Given n and k, how many different good trees are there?
------ Input ------
Two integers n(... | 0 |
{"tests": "{\"inputs\": [[[2, 4, 7]], [[1, 1, 3, 4]], [[23]], [[-10, -10, -10, -10, -10, -9, -9, -9, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 1, 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, 40, 41, 42, 43, 44, 45, ... | # Task
Given a sorted array of integers `A`, find such an integer x that the value of `abs(A[0] - x) + abs(A[1] - x) + ... + abs(A[A.length - 1] - x)`
is the smallest possible (here abs denotes the `absolute value`).
If there are several possible answers, output the smallest one.
# Example
For `A = [2, 4, 7]`, th... | 0 |
{"tests": "{\"inputs\": [\"7 3 2 2\\n1 2 3 3 2 1 2\\n2 2\\n\", \"13 4 3 3\\n3 2 6 4 1 4 4 7 1 3 3 2 4\\n4 3 4\\n\", \"13 4 1 3\\n3 2 6 4 1 4 4 7 1 3 3 2 4\\n4 3 4\\n\", \"1 1 1 1\\n1\\n1\\n\", \"1 1 1 1\\n1\\n2\\n\", \"2 1 1 1\\n1 2\\n2\\n\", \"2 2 1 2\\n1 2\\n2 1\\n\", \"10 3 3 2\\n2 1 1 2 1 1 2 1 1 2\\n2 2\\n\", \"10... | At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly $k$ flowers.
The work material for the wreaths for all $n$ citizens of Shortriver is cut from the longest flowered liana that grew in the... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n20 35 60 70\\n15 30 40 80 91\\n3 2\\n10 20 30\\n42 60\\n0 1\\n100\\n1 1\\n10\\n50\\n0 0\", \"4 5\\n20 35 60 70\\n15 30 40 80 170\\n3 2\\n10 20 30\\n42 60\\n0 1\\n100\\n1 1\\n10\\n50\\n0 0\", \"4 5\\n20 35 87 70\\n15 30 40 80 91\\n3 2\\n10 20 30\\n42 60\\n0 1\\n100\\n1 1\\n10\\n50\\n0 0\... | There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure)
<image>
Monitoring systems are connected to the cam... | 0 |
{"tests": "{\"inputs\": [\"4\", \"1100000\", \"8\", \"0100000\", \"14\", \"0110000\", \"0110010\", \"6\", \"1100010\", \"0100100\", \"12\", \"0110100\", \"16\", \"1110010\", \"0110110\", \"0\", \"1000010\", \"0000010\", \"0100010\", \"0000100\", \"24\", \"1001000\", \"20\", \"1100100\", \"18\", \"44\", \"1110000\", \"0... | Given is a positive even number N.
Find the number of strings s of length N consisting of `A`, `B`, and `C` that satisfy the following condition:
* s can be converted to the empty string by repeating the following operation:
* Choose two consecutive characters in s and erase them. However, choosing `AB` or `BA` is no... | 0 |
{"tests": "{\"inputs\": [\"2 1 1\\n30 9\\n46\\n73\\n\", \"2 1 1\\n76 91\\n34\\n77\\n\", \"4 1 2\\n1 19 10 3\\n18\\n19\\n13\\n15\\n\", \"3 2 1\\n500 498 564\\n100002 3\\n772286 2\\n232323 1\\n\", \"4 1 2\\n2 4 10 3\\n18\\n19\\n23\\n3\\n\", \"2 1 1\\n30 9\\n46\\n87\\n\", \"2 1 1\\n76 146\\n34\\n77\\n\", \"4 1 2\\n1 16 10... | Alice, the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of p players playing in p different positions. She also recognizes the importance of audience support, so she wants to select k people as part of the audience.
There are n people in Byteland. Alice needs ... | 0.5 |
{"tests": "{\"inputs\": [[21200], [3211000], [42101000], [21230], [11200], [1210], [51120111], [2020], [11201], [6210001000]], \"outputs\": [[true], [true], [true], [false], [false], [true], [false], [true], [false], [true]]}", "source": "taco"} | A number is self-descriptive when the n'th digit describes the amount n appears in the number.
E.g. 21200:
There are two 0's in the number, so the first digit is 2.
There is one 1 in the number, so the second digit is 1.
There are two 2's in the number, so the third digit is 2.
There are no 3's in the number, so t... | 0.5 |
{"tests": "{\"inputs\": [\"6 732284177\\n\", \"634 982032773\\n\", \"199862 999999937\\n\", \"2 554714911\\n\", \"124953 922406879\\n\", \"8045 992942057\\n\", \"200000 665880409\\n\", \"158032 121694641\\n\", \"199568 100000007\\n\", \"48 166017469\\n\", \"200000 187160003\\n\", \"199995 597768679\\n\", \"200000 55892... | This version of the problem differs from the next one only in the constraint on n.
Note that the memory limit in this problem is lower than in others.
You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.
You also have a token that is initially placed in cell n. You will move... | 0 |
{"tests": "{\"inputs\": [[\"GFEDCBA\", \"-----------------------\"], [\"GFEDCBA\", \"------------...-----------\"], [\"GFEDCBA\", \"------------.....---------\"], [\"GFEDCBA\", \"------.....------.....---------\"], [\"GFEDCBA\", \"------------...-----..----\"], [\"CBA\", \"--.--.---\"], [\"GFEDCBA\", \"------....-.---\... | # Background
My pet bridge-maker ants are marching across a terrain from left to right.
If they encounter a gap, the first one stops and then next one climbs over him, then the next, and the next, until a bridge is formed across the gap.
What clever little things they are!
Now all the other ants can walk over the ... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n1 100\\n\", \"5 5\\n2 100\\n3 200\\n4 300\\n5 400\\n5 900\\n\", \"5 5\\n2 100\\n3 200\\n4 300\\n5 800\\n5 900\\n\", \"5 5\\n1 3\\n1 6\\n5 4\\n3 7\\n2 10\\n\", \"5 5\\n1 7\\n3 3\\n2 7\\n2 4\\n1 2\\n\", \"5 5\\n2 5\\n2 4\\n2 1\\n3 6\\n3 7\\n\", \"1 3000\\n918 548706881\\n\", \"10 10\\n7 2... | As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — $n$ and $m$ respectively. For each ... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n3 7 9 7 8\\n5 2 5 7 5\\n\", \"5\\n1 2 3 4 5\\n1 1 1 1 1\\n\", \"5\\n12 4 19 18 19\\n15467 14873 66248 58962 90842\\n\", \"40\\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 6 4 4 12 5 4 11 8 1 2 8 11 19 18 4\\n52258 5648 46847 9200 63940 79328 64407 54479 1788 60107 82... | VK news recommendation system daily selects interesting publications of one of $n$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $i$ batch algorithm selects $a_i$ publications.
The latest A/B test suggests that users are reading recommended publications more act... | 0 |
{"tests": "{\"inputs\": [\"3 3\\naaa\\n\", \"3 3\\naab\\n\", \"1 2\\na\\n\", \"10 9\\nabacadefgh\\n\", \"15 3\\nabababababababa\\n\", \"100 26\\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\\n\", \"1 26\\nz\\n\", \"100 26\\njysrixyptvsesnapfljeqkytlpeepjopspmkviqd... | You are given a string S of length n with each character being one of the first m lowercase English letters.
Calculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is n - 1.
Recall that LCS ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1\\n1337\\n3\\n10 8 10\\n5\\n1 2 3 4 5\\n3\\n7 77 777\\n\", \"1\\n1\\n6006\\n\", \"1\\n1\\n6006\\n\", \"1\\n1\\n2668\\n\", \"4\\n1\\n1337\\n3\\n10 8 1\\n5\\n1 2 3 4 5\\n3\\n7 77 777\\n\", \"1\\n1\\n865\\n\", \"1\\n1\\n483\\n\", \"1\\n1\\n132\\n\", \"1\\n1\\n245\\n\", \"1\\n1\\n78\\n\", \"... | One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles.
The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi... | 0 |
{"tests": "{\"inputs\": [\"3\\n121\\n\", \"6\\n000000\\n\", \"6\\n211200\\n\", \"6\\n120110\\n\", \"6\\n111111\\n\", \"69\\n000000000000000000000000000000000000000000000000000000000000000000000\\n\", \"12\\n222222200000\\n\", \"3\\n111\\n\", \"9\\n222210000\\n\", \"12\\n111111111111\\n\", \"12\\n222111220110\\n\", \"12... | You are given a string $s$ consisting of exactly $n$ characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.
Your task is to replace minimum number of characters in this string with other characters to obtain a balanced ternary string (balanced ternary string is a ternary str... | 0 |
{"tests": "{\"inputs\": [\"0 0\\n4 6\\n3\\nUUU\\n\", \"0 3\\n0 0\\n3\\nUDD\\n\", \"0 0\\n0 1\\n1\\nL\\n\", \"0 0\\n0 1\\n2\\nLU\\n\", \"0 0\\n1000000000 1000000000\\n2\\nDR\\n\", \"0 1\\n2 1\\n1\\nR\\n\", \"0 1\\n2 1\\n1\\nR\\n\", \"0 0\\n0 1\\n2\\nLU\\n\", \"0 0\\n1000000000 1000000000\\n2\\nDR\\n\", \"1 0\\n0 0\\n2\\... | You a captain of a ship. Initially you are standing in a point $(x_1, y_1)$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $(x_2, y_2)$.
You know the weather forecast — the string $s$ of length $n$, consisting only of letters U, D, L and R. The letter corre... | 0 |
{"tests": "{\"inputs\": [\"6 3 2\\n2 3 1 3 4 2\\n\", \"5 3 3\\n1 2 4 2 3\\n\", \"5 5 6\\n1 2 6 10 3\\n\", \"100 2 1\\n2 1 2 2 2 2 1 1 2 1 2 2 2 1 2 2 1 1 2 1 1 1 1 1 2 1 1 2 2 2 2 1 1 2 1 1 1 1 2 2 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 2 2 2 1 2 1 2 1 2 1 2 1 1 2 1 1 1 2 2 2 2 2 1 1 1 2 1 2 1 1 2 2 1 1 2 1 1 2 2 2\\n... | You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.
There are $n$ doors, the $i$-th door initially has durability equal to $a_i$.
During your move you can try... | 0 |
{"tests": "{\"inputs\": [\"10\\n1 3\\n4 3\\n10 4\\n10 6\\n6 2\\n5 2\\n7 5\\n7 8\\n7 9\\n\", \"10\\n2 8\\n10 8\\n8 3\\n4 3\\n6 3\\n6 1\\n10 7\\n9 1\\n5 10\\n\", \"10\\n4 10\\n6 10\\n10 5\\n10 7\\n8 10\\n4 2\\n9 10\\n4 1\\n3 10\\n\", \"10\\n1 3\\n4 3\\n10 4\\n10 6\\n6 2\\n5 2\\n7 6\\n7 8\\n7 9\\n\", \"10\\n3 10\\n6 10\\n... | Tree is a connected graph without cycles. A leaf of a tree is any vertex connected with exactly one other vertex.
You are given a tree with n vertices and a root in the vertex 1. There is an ant in each leaf of the tree. In one second some ants can simultaneously go to the parent vertex from the vertex they were in. N... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 3 1 5\\n6 4 1 10\\n2 3 4 4\\n6 4 3 7\\n8 10 5 14\", \"5\\n2 3 1 5\\n6 4 1 10\\n2 3 4 4\\n6 4 3 7\\n8 2 5 8\", \"5\\n2 3 1 5\\n6 4 1 10\\n2 3 4 4\\n6 7 3 7\\n8 10 5 14\", \"5\\n2 3 1 5\\n6 4 1 10\\n2 3 6 4\\n6 4 3 7\\n8 2 5 8\", \"5\\n2 3 1 5\\n9 4 1 10\\n2 3 6 4\\n6 4 3 7\\n8 2 5 8\", \... | Let f(A, B), where A and B are positive integers, be the string satisfying the following conditions:
* f(A, B) has length A + B;
* f(A, B) contains exactly A letters `A` and exactly B letters `B`;
* The length of the longest substring of f(A, B) consisting of equal letters (ex., `AAAAA` or `BBBB`) is as small as possi... | 0 |
{"tests": "{\"inputs\": [\"4\\n-5 R\\n0 P\\n3 P\\n7 B\\n\", \"5\\n10 R\\n14 B\\n16 B\\n21 R\\n32 R\\n\", \"10\\n66 R\\n67 R\\n72 R\\n73 R\\n76 R\\n78 B\\n79 B\\n83 B\\n84 B\\n85 P\\n\", \"10\\n61 R\\n64 R\\n68 R\\n71 R\\n72 R\\n73 R\\n74 P\\n86 P\\n87 B\\n90 B\\n\", \"15\\n-9518 R\\n-6858 P\\n-6726 B\\n-6486 R\\n-4496 ... | The cities of Byteland and Berland are located on the axis $Ox$. In addition, on this axis there are also disputed cities, which belong to each of the countries in their opinion. Thus, on the line $Ox$ there are three types of cities: the cities of Byteland, the cities of Berland, disputed cities.
Recently, the pr... | 0 |
{"tests": "{\"inputs\": [\"541 9\\nbxhwcmunbdxcatppdsw\\nshbppncwbnsxxnxunwsbncpdchcbcspdcppdchmbbcuapphpdxbpcswcxpxpdscxpddbcppdxhpxbuxxdbpdpuudb\\n\", \"8058035 2\\nrioqrqetkzfbldjiemsfzbhzfnwywmxxgdpyl\\ngfmhefhyyndzmsbfnefmwmpxfxfhflzplgoxfrrdxilibzlephlezisfztsfitnrzrilzmtipzofkrwlmhnifdzwexzzxjpy\\n\", \"1181362 ... | Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc.
We'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain string s. For example, string... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n1 2\\n2 3\\n3 4\\n4 1\\n\", \"7 0\\n\", \"3 1\\n1 3\\n\", \"7 21\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n3 4\\n3 5\\n3 6\\n3 7\\n4 5\\n4 6\\n4 7\\n5 6\\n5 7\\n6 7\\n\", \"4 4\\n4 2\\n2 3\\n3 4\\n2 1\\n\", \"5 7\\n4 3\\n3 2\\n1 4\\n5 3\\n5 2\\n4 5\\n1 5\\n\", ... | Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $a$ and $b$ such that $1 \leq a \leq b \leq 6$, there is exactly one domino with $a$ dots on one half and $b$ dots on the other half. The set contains exactly $21$ dominoes. Here is an exact illustration of his set:
[... | 0.5 |
{"tests": "{\"inputs\": [\"6 4\\n1 2 0 2 3 2\", \"6 6\\n1 2 1 2 1 2\", \"6 5\\n1 2 0 2 2 2\", \"6 5\\n1 2 0 0 2 2\", \"6 5\\n1 0 0 0 2 2\", \"6 5\\n0 0 0 0 2 2\", \"6 4\\n1 2 1 2 6 2\", \"6 5\\n1 2 0 2 3 2\", \"6 6\\n1 1 1 2 1 2\", \"6 5\\n0 0 0 1 2 2\", \"6 6\\n1 2 0 2 3 2\", \"3 6\\n1 2 3\", \"6 8\\n1 2 0 2 3 2\", \"... | For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $S$, find the smallest sub-array size (smallest window length) where the sum of the sub-array is greater than or equal to $S$. If there is not such sub-array, report 0.
Constraints
* $1 \leq N \leq 10^5$
* $1 \leq S \leq 10^9$
* $1 \leq a_i \... | 0 |
{"tests": "{\"inputs\": [[\"a **& bZ\"], [\"Abc e $$ z\"], [\"!!a$%&RgTT\"], [\"\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"aaaaaaaaaaa\"], [\"&%&%/$%$%$%$%GYtf67fg34678hgfdyd\"]], \"outputs\": [[\"11000000000000000000000001\"], [\"11101000000000000000000001\"], [\"10000010000000000101000000\"], [\"0000000000000000000... | Create a function which accepts one arbitrary string as an argument, and return a string of length 26.
The objective is to set each of the 26 characters of the output string to either `'1'` or `'0'` based on the fact whether the Nth letter of the alphabet is present in the input (independent of its case).
So if an `'... | 0 |
{"tests": "{\"inputs\": [\"1 4\\n\", \"2 2\\n\", \"3 2\\n\", \"2 1\\n\", \"5 3\\n\", \"5 2\\n\", \"8 5\\n\", \"97 101\\n\", \"1 3\\n\", \"1000000000000000000 999999999999999999\\n\", \"55 89\\n\", \"610 987\\n\", \"4181 6765\\n\", \"46368 75025\\n\", \"832040 514229\\n\", \"5702887 9227465\\n\", \"701408733 433494437\\... | Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a let... | 0 |
{"tests": "{\"inputs\": [[true], [false], [\"4+2==5\"], [\"2+2==4\"], [\"not True and False or False or False\"], [\"3 is 3\"], [\"True\"], [\"not True\"], [\"2+2==5\"], [\"4+1==5\"], [\"4 is 3\"], [\"9+2==3\"], [\"105+30076==30181\"], [\"3 is 3 is 3 is 9\"], [\"False\"], [\"\\\"orange\\\" is not \\\"red\\\"\"], [\"4 i... | Remember the movie with David Bowie: 'The Labyrinth'?
You can remember your childhood here: https://www.youtube.com/watch?v=2dgmgub8mHw
In this scene the girl is faced with two 'Knights" and two doors. One door leads the castle where the Goblin King and her kid brother is, the other leads to certain death. She can as... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 5\\n1 2\\n3 4\\n2 1000000000\\n1 1\\n999999999 999999999\\n10 3\\n5 10\\n7 8\\n\", \"1\\n200000 88635750\\n4971058 40181766\\n6012372 78925196\\n\", \"1\\n200000 598920770\\n24529366 24846325\\n35694819 90253337\\n\", \"1\\n1 1\\n1 1\\n1 1\\n\", \"1\\n4 9\\n4 10\\n5 5\\n\", \"1\\n1 1\\n... | You are given two lists of segments $[al_1, ar_1], [al_2, ar_2], \dots, [al_n, ar_n]$ and $[bl_1, br_1], [bl_2, br_2], \dots, [bl_n, br_n]$.
Initially, all segments $[al_i, ar_i]$ are equal to $[l_1, r_1]$ and all segments $[bl_i, br_i]$ are equal to $[l_2, r_2]$.
In one step, you can choose one segment (either from ... | 0 |
{"tests": "{\"inputs\": [\"6 6 1 1\\n0 0\\n1 1\\n2 1\\n0 1\\n1 2\\n3 4\\n\", \"4 1 1 3\\n0 3\\n\", \"2 15 1 1\\n0 0\\n0 1\\n0 0\\n0 1\\n0 0\\n0 1\\n0 0\\n0 1\\n0 0\\n0 1\\n0 0\\n0 1\\n0 0\\n0 1\\n0 0\\n\", \"2 15 1 1\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n\", \"10 10... | Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), then in a second he will be at cell <image>. The following condition is satisfi... | 0 |
{"tests": "{\"inputs\": [\"2 0\\n\", \"2 1\\n\", \"3 2\\n\", \"1 411\\n\", \"1 692\\n\", \"16 8\\n\", \"18 12\\n\", \"1 1000000000000000000\\n\", \"0 24\\n\", \"24 0\\n\", \"1000000000000000000 1\\n\", \"348612312017571993 87570063840727716\\n\", \"314647997243943415 107188213956410843\\n\", \"375000003 2\\n\", \"451 9... | Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month).
Unfortunately, right after the doubling the wardrobe eats one of the dresses (if any) with ... | 0.125 |
{"tests": "{\"inputs\": [\"6 5\\n1 5\\n2 1\\n1 4\\n3 1\\n6 1\\n\", \"10 10\\n6 8\\n9 10\\n10 1\\n2 10\\n10 7\\n3 1\\n8 1\\n2 1\\n4 1\\n5 10\\n\", \"10 10\\n6 3\\n4 7\\n7 1\\n9 8\\n8 10\\n7 2\\n5 2\\n4 8\\n6 7\\n8 7\\n\", \"10 10\\n4 3\\n6 8\\n5 3\\n4 1\\n2 9\\n7 8\\n9 6\\n10 2\\n9 3\\n6 3\\n\", \"10 10\\n1 3\\n9 6\\n4 ... | You are given a connected undirected graph consisting of $n$ vertices and $m$ edges. There are no self-loops or multiple edges in the given graph.
You have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of path is denoted as the ... | 0.125 |
{"tests": "{\"inputs\": [[50], [25], [52], [57], [75], [100], [521], [1], [5071], [705], [1241367], [50011117], [1002], [50011111112], [2057], [50001111312], [500111117], [64954713879], [71255535569], [72046951686], [68151901446], [3848363615], [75733989998], [87364011400], [2992127830], [98262144757], [81737102196], [... | In this Kata, you will be given a number and your task will be to rearrange the number so that it is divisible by `25`, but without leading zeros. Return the minimum number of digit moves that are needed to make this possible. If impossible, return `-1` ( `Nothing` in Haskell ).
For example:
More examples in test cas... | 0 |
{"tests": "{\"inputs\": [\"2\\n1000 1\\n\", \"5\\n2 2 1 1 3\\n\", \"100\\n12 18 1 1 14 23 1 1 22 5 7 9 7 1 1 1 3 8 4 2 1 6 9 1 3 2 11 1 11 2 3 2 1 4 2 7 1 16 3 4 2 13 3 1 5 11 2 10 20 24 3 21 5 2 6 2 1 10 10 5 17 1 1 4 19 8 5 5 3 9 4 2 7 8 10 4 9 1 3 3 9 7 6 4 4 3 6 8 12 1 3 6 2 1 8 4 1 15 2 5\\n\", \"50\\n7 1 6 5 15 3... | A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not.
There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine that somebody took... | 0.125 |
{"tests": "{\"inputs\": [\"7\\n1 3 4 30\\n1 4 1 2\\n1 3 6 8\\n2 4 3\\n1 6 1 40\\n2 3 7\\n2 2 4\\n\", \"1\\n2 666077344481199252 881371880336470888\\n\", \"10\\n1 1 63669439577744021 396980128\\n1 2582240553355225 63669439577744021 997926286\\n1 2582240553355225 1 619026011\\n1 1 4 231881718\\n2 63669439577744021 388607... | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 0.25 |
{"tests": "{\"inputs\": [\"5 10\\n1 15\\n5 3\\n6 11\\n7 2\\n11 22\\n\", \"3 5\\n1 8\\n2 19\\n3 11\\n\", \"10 8\\n1 16\\n23 27\\n26 2\\n32 21\\n38 50\\n51 53\\n62 79\\n77 97\\n94 18\\n100 5\\n\", \"22 936\\n20 743\\n55 46\\n83 282\\n157 3\\n168 979\\n241 338\\n293 113\\n312 292\\n333 509\\n339 632\\n345 149\\n347 109\\n... | Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit.
Vasya has $n$ problems to choose from. They are numbered from $1$ to $n$. The difficulty of the $i$-th problem is $d_i$. Moreover, the problems are given in the increasing or... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 8 5 4\\n\", \"4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 0 1 6 7 8 5 4\\n\", \"4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 1 5 4\\n\", \"4\\n3\\n1 2 0\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 0 1 6 7 8 5... | You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).
Let's call an array a bipartite if the following undirected graph is bipartite:
* the graph consists of n vertices;
* two vertices i and j are connected by an edge i... | 0 |
{"tests": "{\"inputs\": [\"5\\n28 15 22 43 30\\n20 22 43 33 32\", \"4\\n1 2 3 4\\n5 6 8 8\", \"3\\n3 4 3\\n3 0 3\", \"5\\n4 46 6 31 43\\n33 15 18 27 37\", \"4\\n1 2 3 2\\n5 6 7 8\", \"4\\n2 1 3 3\\n5 0 4 16\", \"4\\n1 2 5 0\\n18 7 16 0\", \"2\\n2 0\\n1 2\", \"4\\n1 2 3 4\\n5 0 8 8\", \"3\\n3 4 3\\n3 0 5\", \"5\\n4 26 6... | We have N cards numbered 1, 2, ..., N. Card i (1 \leq i \leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side. Initially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.
Determine whether it is ... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n6\\n1 5 4 3 2 6\\n5 3 1 4 6 2\\n6\\n3 5 4 6 2 1\\n3 6 4 5 2 1\\n1\\n1\\n1\\n\", \"3\\n8\\n1 2 3 4 5 6 7 8\\n1 2 3 4 5 7 8 6\\n7\\n1 2 3 4 5 6 7\\n2 1 5 3 6 7 4\\n4\\n1 2 3 4\\n1 4 2 3\\n\", \"1\\n10\\n5 3 7 4 6 10 9 8 1 2\\n2 7 1 3 9 4 8 10 5 6\\n\", \"1\\n10\\n3 4 1 2 7 6 10 9 5 8\\n4 6 ... | Tokitsukaze has two colorful tapes. There are $n$ distinct colors, numbered $1$ through $n$, and each color appears exactly once on each of the two tapes. Denote the color of the $i$-th position of the first tape as $ca_i$, and the color of the $i$-th position of the second tape as $cb_i$.
Now Tokitsukaze wants to sel... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 4\\n1 3\\n1 5\\n\", \"5\\n2 7\\n2 8\\n1 2\\n2 4\\n1 8\\n\", \"1\\n8 2\\n\", \"8\\n1 8\\n1 6\\n1 5\\n1 3\\n1 3\\n1 8\\n1 7\\n1 3\\n\", \"4\\n4 1\\n2 2\\n1 6\\n1 2\\n\", \"8\\n1 63658803333197\\n1 26806908300107\\n1 37622010993115\\n1 8932487734606\\n1 55358687683237\\n1 44940811911137\\n... | Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store — "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | 0 |
{"tests": "{\"inputs\": [\"2\\n11 8\", \"3\\n7 12 11\", \"2\\n8 8\", \"2\\n10 2\", \"2\\n2 0\", \"3\\n9 12 8\", \"2\\n6 8\", \"2\\n12 8\", \"2\\n9 7\", \"1\\n11\", \"1\\n9\", \"1\\n10\", \"3\\n8 12 11\", \"2\\n8 1\", \"2\\n10 1\", \"2\\n4 2\", \"2\\n8 2\", \"2\\n2 1\", \"2\\n3 0\", \"2\\n8 6\", \"3\\n8 12 0\", \"2\\n8 ... | In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.
Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if t... | 0 |
{"tests": "{\"inputs\": [\"0 2 5\\n1 3 5\\n\", \"0 1 3\\n2 3 6\\n\", \"0 1 5\\n2 4 5\\n\", \"1 8 10\\n0 7 9\\n\", \"11 13 18\\n4 6 12\\n\", \"7 13 18\\n2 6 12\\n\", \"372839920 992839201 1000000000\\n100293021 773829394 999999993\\n\", \"100293023 882738299 1000000000\\n0 445483940 500000000\\n\", \"339403920 743344311... | Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, for Alice days $[l_a; r_a]$ are lucky, then there are some unlucky days: $[r_a ... | 0 |
{"tests": "{\"inputs\": [\"1\\n0 0\\n1 2 3 4 5 6\\nRRRRBBBBLLLLFFFF\\n2\\n0 0\\n1 1 1 1 1 1\\nRRR\\n2 2\\n100 100 100 100 100 100\\nFFF\\n1\\n1010 -1000\\n1 2 3 4 5 6\\nLFRB\\n4\\n-3 -4\\n1 2 3 4 5 6\\nBBBBBBBB\\n4 -3\\n11 12 13 14 15 16\\nLLLLLLLL\\n3 4\\n21 22 23 24 25 26\\nFFFFFFFF\\n-4 3\\n31 32 33 34 35 36\\nRRRRR... | Dice Stamp
Dice stamp
At a local fair, you found a game store you've never seen before. This is a game in which N 6-sided dice are dropped and rolled on the board. More precisely, N buttons are tied to N dice on a one-to-one basis, and pressing the button causes the corresponding dice to fall onto the board. It is a ... | 0 |
{"tests": "{\"inputs\": [\"4\\n2\\n1\\n3\\n12\\n1\\n6\\n3\\n72\\n2\\n12\\n7\\n2\\n1\\n0\\n0\", \"4\\n2\\n1\\n3\\n12\\n1\\n6\\n3\\n11\\n2\\n12\\n7\\n2\\n1\\n0\\n0\", \"4\\n2\\n0\\n5\\n12\\n1\\n6\\n3\\n72\\n2\\n12\\n7\\n2\\n1\\n0\\n0\", \"4\\n2\\n1\\n3\\n12\\n1\\n6\\n3\\n9\\n2\\n12\\n7\\n2\\n1\\n0\\n0\", \"4\\n1\\n1\\n3\... | problem
Hanako is playing with n (4 ≤ n ≤ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≤ k ≤ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of integers can Hanako make in total?
For example, consider that you are given five c... | 0 |
{"tests": "{\"inputs\": [\"5\\n4 0 3 1 2\\n\", \"5\\n1 2 3 4 0\\n\", \"5\\n1 3 4 0 2\\n\", \"10\\n9 8 7 6 5 4 3 2 1 0\\n\", \"5\\n0 4 1 3 2\\n\", \"6\\n3 0 1 4 5 2\\n\", \"3\\n0 2 1\\n\", \"3\\n1 0 2\\n\", \"3\\n1 2 0\\n\", \"3\\n2 0 1\\n\", \"3\\n2 1 0\\n\", \"7\\n4 0 3 5 1 2 6\\n\", \"8\\n1 5 4 0 2 7 3 6\\n\", \"9\\n... | Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that implements this algorithm and sorts the given integer zero-indexed array a of size n in the non-decre... | 0.875 |
{"tests": "{\"inputs\": [\"3 3\\n...\\n..#\\n...\\n\", \"4 2\\n..\\n..\\n..\\n..\\n\", \"4 5\\n#...#\\n#...#\\n###.#\\n###.#\\n\", \"6 4\\n####\\n####\\n....\\n####\\n####\\n####\\n\", \"4 6\\n######\\n######\\n......\\n######\\n\", \"6 4\\n##.#\\n##.#\\n##.#\\n##.#\\n##.#\\n##.#\\n\", \"4 6\\n##.###\\n##.###\\n##.###\... | On a certain meeting of a ruling party "A" minister Pavel suggested to improve the sewer system and to create a new pipe in the city.
The city is an n × m rectangular squared field. Each square of the field is either empty (then the pipe can go in it), or occupied (the pipe cannot go in such square). Empty squares are... | 0 |
{"tests": "{\"inputs\": [\"3 3 1\\n\", \"300 2 300\\n\", \"4000 4000 1\\n\", \"4000 4000 100\\n\", \"4 2 3\\n\", \"3 300 300\\n\", \"4000 100 4000\\n\", \"3 300 1\\n\", \"300 300 1\\n\", \"4000 1000 3000\\n\", \"3 2 4000\\n\", \"4 3 2\\n\", \"3 2 300\\n\", \"4000 3998 2\\n\", \"100 200 300\\n\", \"300 300 300\\n\", \"3... | Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to ta... | 0.125 |
{"tests": "{\"inputs\": [\"20\\n1\\n1 10\", \"20\\n1\\n0 7\", \"20\\n1\\n2 10\", \"20\\n1\\n3 7\", \"20\\n1\\n0 19\", \"20\\n1\\n0 12\", \"20\\n1\\n2 7\", \"20\\n1\\n4 10\", \"20\\n1\\n0 28\", \"20\\n0\\n0 12\", \"20\\n1\\n0 3\", \"20\\n1\\n4 6\", \"20\\n1\\n1 15\", \"20\\n1\\n-1 12\", \"20\\n1\\n6 7\", \"20\\n1\\n1 19... | D: Sunburn-Suntan-
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so I made a schedule for the band to go to listen to. I'm worried abou... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n3 4\\n3 1 2\\n1 1\\n1\\n2 4\\n8 8\", \"3\\n3 4\\n3 1 2\\n1 1\\n1\\n2 4\\n8 1\", \"3\\n3 4\\n3 1 2\\n1 1\\n1\\n2 2\\n8 1\", \"3\\n3 4\\n6 1 2\\n1 1\\n1\\n2 2\\n8 1\", \"3\\n3 4\\n6 1 2\\n1 1\\n1\\n2 2\\n10 1\", \"3\\n3 4\\n3 1 0\\n1 1\\n1\\n2 4\\n8 8\", \"3\\n3 4\\n3 1 4\\n1 1\\n1\\n2 4\\n... | Read problems statements in Mandarin Chinese and Russian.
Some chefs go for a tour lasting N days. They take packages of bread for food. Each package has K pieces of breads. On the i^{th} day, they eat A_{i} pieces of bread.
Unfortunately, chefs are very lazy people, and they always forget to close the package of bre... | 0 |
{"tests": "{\"inputs\": [\"2\\n4 3 2 3 4\\n1 2 3\\n1 2\\n1 3\\n1 4\\n7 9 1 5 7\\n2 10 4 8 5 6 7 3 3\\n1 2\\n1 3\\n1 4\\n3 2\\n3 5\\n4 2\\n5 6\\n1 7\\n6 7\\n\", \"2\\n4 3 2 3 4\\n1 2 3\\n1 2\\n1 3\\n1 4\\n7 9 1 5 7\\n2 10 4 8 5 6 7 3 3\\n1 2\\n1 3\\n1 4\\n3 2\\n3 5\\n4 2\\n5 6\\n1 4\\n6 7\\n\", \"2\\n4 3 2 3 4\\n2 2 3\\... | You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).
Mike has planned a trip from the vertex (district) $a$ to the vertex (d... | 0.375 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.