info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"6\\nADD 1\\nACCEPT 1\\nADD 2\\nACCEPT 2\\nADD 3\\nACCEPT 3\\n\", \"4\\nADD 1\\nADD 2\\nADD 3\\nACCEPT 2\\n\", \"7\\nADD 1\\nADD 2\\nADD 3\\nADD 4\\nADD 5\\nACCEPT 3\\nACCEPT 5\\n\", \"6\\nADD 10\\nADD 7\\nADD 13\\nADD 15\\nADD 12\\nACCEPT 10\\n\", \"8\\nADD 10\\nADD 7\\nADD 13\\nADD 15\\nADD ... | Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price.
At every moment of time, every SELL offer has higher price than every BUY offer.
In th... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n1 2\\n\", \"4 3\\n1 3 2 4\\n1 2\\n2 3\\n1 4\\n\", \"7 4\\n7 6 4 2 1 5 3\\n1 3\\n2 1\\n7 2\\n3 5\\n\", \"10 1\\n1 2 3 4 5 6 7 8 9 10\\n1 10\\n\", \"9 20\\n9 8 7 6 5 4 3 2 1\\n4 6\\n9 4\\n5 9\\n6 8\\n1 9\\n5 8\\n6 9\\n7 3\\n1 9\\n8 3\\n4 5\\n9 6\\n3 8\\n4 1\\n1 2\\n3 2\\n4 9\\n6 7\\... | The Little Elephant loves permutations of integers from 1 to n very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a permutation 1, 2, 3, ..., n.
This time the Little Elephant has permutation p_1, p_2, ..., p_{n}. Its... | 0 |
{"tests": "{\"inputs\": [\"1 1 3 4\\n7\\n\", \"4 3 4 2\\n7 9 11\\n\", \"10 10 51 69\\n154 170 170 183 251 337 412 426 445 452\\n\", \"70 10 26 17\\n361 371 579 585 629 872 944 1017 1048 1541\\n\", \"100 20 49 52\\n224 380 690 1585 1830 1973 2490 2592 3240 3341 3406 3429 3549 3560 3895 3944 4344 4390 4649 4800\\n\", \"1... | There is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside, when one or several people come to the door and it is open, all people immediatel... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 4 3 2 5\\n\", \"5\\n1 2 2 2 1\\n\", \"7\\n10 20 40 50 70 90 30\\n\", \"1\\n1\\n\", \"2\\n1 15\\n\", \"4\\n36 54 55 9\\n\", \"5\\n984181411 215198610 969039668 60631313 85746445\\n\", \"10\\n12528139 986722043 1595702 997595062 997565216 997677838 999394520 999593240 772077 998195916\\n\... | Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last n minutes and in the i-th minute friends will send a_{i} requests.
Polycarp plans to test Fakebook under a special kind... | 0 |
{"tests": "{\"inputs\": [\"tinkoff\\nzscoder\\n\", \"xxxxxx\\nxxxxxx\\n\", \"ioi\\nimo\\n\", \"abc\\naaa\\n\", \"reddit\\nabcdef\\n\", \"cbxz\\naaaa\\n\", \"bcdef\\nabbbc\\n\", \"z\\ny\\n\", \"y\\nz\\n\"], \"outputs\": [\"fzfsirk\\n\", \"xxxxxx\\n\", \"ioi\\n\", \"aab\\n\", \"dfdeed\\n\", \"abac\\n\", \"bccdb\\n\", \"z... | Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decided to play a game. The company name will consist of n letters. Oleg and Igor ea... | 0 |
{"tests": "{\"inputs\": [\"4\\n5\\n231\\n7\\n2323\\n6\\n333\\n24\\n133321333\\n\", \"9\\n1500\\n1212\\n1500\\n1221\\n1500\\n122\\n1500\\n12121\\n1500\\n22\\n1500\\n1111112111111112\\n1500\\n1111111111221111111\\n1500\\n111111122\\n1500\\n11111121111121111111\\n\", \"1\\n1000000\\n22\\n\", \"1\\n1000000\\n221\\n\", \"1\... | We start with a string $s$ consisting only of the digits $1$, $2$, or $3$. The length of $s$ is denoted by $|s|$. For each $i$ from $1$ to $|s|$, the $i$-th character of $s$ is denoted by $s_i$.
There is one cursor. The cursor's location $\ell$ is denoted by an integer in $\{0, \ldots, |s|\}$, with the following mean... | 0 |
{"tests": "{\"inputs\": [\"5 0\\n3 7 3 7 3\\n\", \"10 0\\n1 2 1 2 3 1 1 1 50 1\\n\", \"6 0\\n6 6 3 3 4 4\\n\", \"7 0\\n3 3 1 3 2 1 2\\n\", \"5 0\\n1 2 1 2 1\\n\", \"5 0\\n2 3 2 3 3\\n\", \"100 0\\n6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62... | This is an easier version of the next problem. In this version, $q = 0$.
A sequence of integers is called nice if its elements are arranged in blocks like in $[3, 3, 3, 4, 1, 1]$. Formally, if two elements are equal, everything in between must also be equal.
Let's define difficulty of a sequence as a minimum possible... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 2\\n2 3\\n3 4\\n3 5\\n\", \"4 6\\n1 2\\n2 3\\n1 3\\n3 4\\n2 4\\n1 4\\n\", \"4 2\\n1 3\\n2 4\\n\", \"1 0\\n\", \"1000 0\\n\", \"1000 4\\n100 200\\n200 300\\n300 400\\n400 100\\n\", \"14 30\\n12 10\\n1 7\\n12 13\\n7 3\\n14 10\\n3 12\\n11 1\\n2 12\\n2 5\\n14 3\\n14 1\\n14 4\\n6 7\\n12 6\... | Vova and Marina love offering puzzles to each other. Today Marina offered Vova to cope with the following task.
Vova has a non-directed graph consisting of n vertices and m edges without loops and multiple edges. Let's define the operation of contraction two vertices a and b that are not connected by an edge. As a res... | 0 |
{"tests": "{\"inputs\": [\"6\\n\", \"9\\n\", \"2\\n\", \"10\\n\", \"100\\n\", \"1\\n\", \"3\\n\", \"5\\n\"], \"outputs\": [\"2\\n6 3\\n2 4\\n\", \"3\\n9 3\\n2 4\\n6 8\\n\", \"0\\n\", \"4\\n2 4\\n6 8\\n10 5\\n9 3\\n\", \"44\\n33 27\\n22 11\\n25 5\\n64 66\\n42 44\\n31 62\\n58 29\\n43 86\\n15 21\\n6 99\\n8 12\\n85 65\\n7 ... | Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to an apple store.
Jzzhu will pack his apples into groups and then sell them. Each group must contain two apples, and the greatest common divisor of numbers of the apples in each group must be greater... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 4 5\\n\", \"3\\n1 2 4\\n\", \"1\\n1\\n\", \"1\\n1000000\\n\", \"2\\n1000000 999999\\n\", \"12\\n4 4 10 13 28 30 41 43 58 61 70 88\\n\", \"7\\n2 13 22 32 72 91 96\\n\", \"5\\n5 11 12 109 110\\n\"], \"outputs\": [\"2\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"30\\n\", \"27\\n\", \"10... | You are given a sequence a consisting of n integers. Find the maximum possible value of $a_{i} \operatorname{mod} a_{j}$ (integer remainder of a_{i} divided by a_{j}), where 1 ≤ i, j ≤ n and a_{i} ≥ a_{j}.
-----Input-----
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·10^5).
The second l... | 0.875 |
{"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\"], \"outputs\": [\"6\\n\", \"11\\n\", \"1\\n\", \"789... | 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\": [\"10\\nmihail\\noolyana\\nkooooper\\nhoon\\nulyana\\nkoouper\\nmikhail\\nkhun\\nkuooper\\nkkkhoon\\n\", \"9\\nhariton\\nhkariton\\nbuoi\\nkkkhariton\\nboooi\\nbui\\nkhariton\\nboui\\nboi\\n\", \"2\\nalex\\nalex\\n\", \"40\\nuok\\nkuu\\nku\\no\\nkku\\nuh\\nu\\nu\\nhh\\nk\\nkh\\nh\\nh\\nou\\nokh\... | There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" and "oolyana" denote the same name.
The second ambiguity is about the Berland s... | 0 |
{"tests": "{\"inputs\": [\"7 4\\n1 2\\n1 3\\n1 4\\n3 5\\n3 6\\n4 7\\n\", \"4 1\\n1 2\\n1 3\\n2 4\\n\", \"8 5\\n7 5\\n1 7\\n6 1\\n3 7\\n8 3\\n2 1\\n4 5\\n\", \"2 1\\n1 2\\n\", \"20 7\\n9 7\\n3 7\\n15 9\\n1 3\\n11 9\\n18 7\\n17 18\\n20 1\\n4 11\\n2 11\\n12 18\\n8 18\\n13 2\\n19 2\\n10 9\\n6 13\\n5 8\\n14 1\\n16 13\\n\", ... | Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.
[Image]
There are $n$ cities and $n-1$ two-way roads connecting pairs of cities in t... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0 0\\n\", \"2\\n0 1\\n\", \"5\\n0 1 1 1 10\\n\", \"1\\n0\\n\", \"15\\n0 0 3 3 13 3 6 34 47 12 20 6 6 21 55\\n\", \"20\\n0 1 7 15 30 15 59 42 1 4 1 36 116 36 16 136 10 36 46 36\\n\", \"100\\n0 0 57 121 57 0 19 251 19 301 19 160 57 578 664 57 19 50 0 621 91 5 263 34 5 96 713 649 22 22 22 ... | An array of integers $p_{1},p_{2}, \ldots,p_{n}$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays are permutations: $[3,1,2], [1], [1,2,3,4,5]$ and $[4,3,1,2]$. The following arrays are not permutations: $[2], [1,1], [2,3,4]$.
There is a hidden permutat... | 0 |
{"tests": "{\"inputs\": [\"2\\n0 1\\n1 0\\n\", \"5\\n0 2 2 1 2\\n2 0 4 1 3\\n2 4 0 1 3\\n1 1 1 0 1\\n2 3 3 1 0\\n\", \"10\\n0 1 5 2 5 3 4 5 5 5\\n1 0 1 1 1 1 1 1 1 1\\n5 1 0 2 6 3 4 6 6 6\\n2 1 2 0 2 2 2 2 2 2\\n5 1 6 2 0 3 4 8 8 7\\n3 1 3 2 3 0 3 3 3 3\\n4 1 4 2 4 3 0 4 4 4\\n5 1 6 2 8 3 4 0 9 7\\n5 1 6 2 8 3 4 9 0 7\... | Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as p_{i}. For all pairs of distinct integers i, j between 1 and n, he wrote the number a_{i}, j = min(p_{i}, p_{j}). He writes a_{i}, i = 0 for all integer i from 1 to n.
Bob gave you all the values of a_... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 3 4 2\\n\", \"8\\n6 8 3 4 7 2 1 5\\n\", \"1\\n1\\n\", \"11\\n10 8 9 4 6 3 5 1 11 7 2\\n\", \"11\\n10 8 9 4 3 5 1 11 7 2 6\\n\", \"100\\n1 72 43 50 58 87 10 94 29 51 99 86 92 80 36 31 9 100 85 59 66 30 3 78 17 73 93 37 57 71 45 15 24 2 64 44 65 22 38 79 23 8 16 52 98 97 96 95 91 90 89 88... | Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a row in such a way that firstly come coins out of circulation, and then... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 2\\n4 3\\n1 4\\n3 4\\n\", \"6 5\\n2 3\\n2 1\\n3 4\\n6 5\\n4 5\\n\", \"2 1\\n1 2\\n\", \"100000 12\\n8 7\\n1 9\\n5 4\\n11 12\\n7 8\\n3 4\\n3 5\\n12 15\\n15 13\\n13 14\\n7 8\\n11 14\\n\", \"10 15\\n1 2\\n2 3\\n3 4\\n4 5\\n5 1\\n1 6\\n2 7\\n3 8\\n4 9\\n5 10\\n6 8\\n7 9\\n8 10\\n9 6\\n10 ... | The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo!
There are $n$ snacks flavors, numbered with integers $1, 2, \ldots, n$. Bessie has $n$ snacks, one snack of each flav... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 0 1\\n1\\n1 3\\n\", \"3\\n1 0 1\\n2\\n1 1\\n3 3\\n\", \"3\\n1 0 1\\n2\\n1 1\\n2 3\\n\", \"5\\n0 1 0 1 0\\n1\\n1 5\\n\", \"9\\n0 1 0 1 1 1 0 1 0\\n3\\n1 4\\n5 8\\n6 7\\n\", \"15\\n1 1 0 0 0 0 0 0 1 0 1 1 1 0 0\\n9\\n4 10\\n13 14\\n1 7\\n4 14\\n9 11\\n2 6\\n7 8\\n3 12\\n7 13\\n\", \"10\\n... | You are given a sequence a = \{a_1, ..., a_N\} with all zeros, and a sequence b = \{b_1, ..., b_N\} consisting of 0 and 1. The length of both is N.
You can perform Q kinds of operations. The i-th operation is as follows:
- Replace each of a_{l_i}, a_{l_i + 1}, ..., a_{r_i} with 1.
Minimize the hamming distance between... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n2\\n3\\n4\\n\", \"13 4\\n10\\n5\\n4\\n8\\n\", \"2 2\\n1\\n2\\n\", \"1 1\\n1\\n\", \"3 3\\n3\\n2\\n1\\n\", \"12 12\\n9\\n11\\n5\\n3\\n7\\n2\\n8\\n6\\n4\\n10\\n12\\n1\\n\"], \"outputs\": [\"3\\n2\\n4\\n\", \"13\\n3\\n8\\n9\\n\", \"1\\n2\\n\", \"1\\n\", \"2\\n3\\n1\\n\", \"5\\n6\\n3\\n2\\n... | Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.
Let's consider that i... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n\", \"5\\n1 2 3 4\\n\", \"31\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"29\\n1 2 2 4 4 6 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\\n\", \"2\\n1\\n\", \"3\\n1 2\\n\"], \"outputs\": [\"4 3 3\", \"5 8 9 8 5\", \"73741817 536870913 536870... | The country has n cities and n - 1 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to n inclusive.
All the roads are initially bad, but the government wants to improve the state of some roads. We will assume that... | 0 |
{"tests": "{\"inputs\": [\"5 5 3\\n1 2 1\\n2 3 2\\n1 3 3\\n3 4 4\\n1 5 5\\n3 5\\n4 5\\n5 5\\n\", \"2 2 3\\n1 2 2\\n2 1 3\\n2 1\\n2 2\\n2 3\\n\", \"5 4 3\\n1 2 999999999\\n2 3 1000000000\\n3 4 529529529\\n5 1 524524524\\n5 524444444\\n5 529999999\\n2 1000000000\\n\", \"3 2 5\\n1 2 2\\n2 3 4\\n3 5\\n3 5\\n3 5\\n3 6\\n3 7... | Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city u_{i} to v_{i} (and vise versa) using the i-th road, the length of this road is x_{i}. Finally, there are k train routes in the coun... | 0 |
{"tests": "{\"inputs\": [\"zyxxxxxxyyz\\n5\\n5 5\\n1 3\\n1 11\\n1 4\\n3 6\\n\", \"yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\\n10\\n17 67\\n6 35\\n12 45\\n56 56\\n14 30\\n25 54\\n1 1\\n46 54\\n3 33\\n19 40\\n\", \"xxxxyyxyyzzyxyxzxyzyxzyyyzyzzxxxxzyyzzzzyxxxxzzyzzyzx\\n5\\n4 4\\n3 3\\n1 24\\n3... | Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q_1q_2... q_{k}. The algorithm consists of two steps:
Find any continuous subsequence (substring) of three characters of string q, which do... | 0 |
{"tests": "{\"inputs\": [\"2\\n16 4\\n...AAAAA........\\ns.BBB......CCCCC\\n........DDDDD...\\n16 4\\n...AAAAA........\\ns.BBB....CCCCC..\\n.......DDDDD....\\n\", \"2\\n10 4\\ns.ZZ......\\n.....AAABB\\n.YYYYYY...\\n10 4\\ns.ZZ......\\n....AAAABB\\n.YYYYYY...\\n\", \"1\\n100 26\\ns................PPPP.CCCCC..UUUUUU........ | The mobile application store has a new game called "Subway Roller".
The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n columns. At the beginning of the game the hero is in some cell of the leftmo... | 0 |
{"tests": "{\"inputs\": [\"60 3\\n2012-03-16 16:15:25: Disk size is\\n2012-03-16 16:15:25: Network failute\\n2012-03-16 16:16:29: Cant write varlog\\n2012-03-16 16:16:42: Unable to start process\\n2012-03-16 16:16:43: Disk size is too small\\n2012-03-16 16:16:53: Timeout detected\\n\", \"1 2\\n2012-03-16 23:59:59:Disk ... | You've got a list of program warning logs. Each record of a log stream is a string in this format: "2012-MM-DD HH:MM:SS:MESSAGE" (without the quotes).
String "MESSAGE" consists of spaces, uppercase and lowercase English letters and characters "!", ".", ",", "?". String "2012-MM-DD" determines a correct date in the y... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n00\\n01\\n\", \"2 2\\n00\\n11\\n\", \"3 3\\n0\\n10\\n110\\n\", \"2 1\\n0\\n1\\n\", \"1 2\\n11\\n\", \"2 3\\n101\\n11\\n\"], \"outputs\": [\"Alice\\n\", \"Bob\\n\", \"Alice\\n\", \"Bob\\n\", \"Alice\\n\", \"Bob\\n\"]}", "source": "primeintellect"} | For strings s and t, we will say that s and t are prefix-free when neither is a prefix of the other.
Let L be a positive integer. A set of strings S is a good string set when the following conditions hold true:
- Each string in S has a length between 1 and L (inclusive) and consists of the characters 0 and 1.
- Any t... | 0 |
{"tests": "{\"inputs\": [\"4\\n0110\\n\", \"7\\n1101001\\n\", \"12\\n011100011100\\n\", \"100\\n0110110011011111001110000110010010000111111001100001011101101000001011001101100111011111100111101110\\n\", \"1\\n0\\n\"], \"outputs\": [\"12\\n\", \"30\\n\", \"156\\n\", \"23254\\n\", \"0\\n\"]}", "source": "primeintellect"} | Zookeeper is buying a carton of fruit to feed his pet wabbit. The fruits are a sequence of apples and oranges, which is represented by a binary string $s_1s_2\ldots s_n$ of length $n$. $1$ represents an apple and $0$ represents an orange.
Since wabbit is allergic to eating oranges, Zookeeper would like to find the lon... | 0 |
{"tests": "{\"inputs\": [\"6 4\\n()(())\\n\", \"8 8\\n(()(()))\\n\", \"20 10\\n((()))()((()()(())))\\n\", \"40 30\\n((((((((()()()))))))))((())((()())))(())\\n\", \"2 2\\n()\\n\"], \"outputs\": [\"()()\\n\", \"(()(()))\\n\", \"((()))()()\\n\", \"((((((((()()()))))))))(())()()\\n\", \"()\\n\"]}", "source": "primeintelle... | A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()" and "(())" are r... | 0 |
{"tests": "{\"inputs\": [\"4 4 2\\n2 3\\n1 2\\n1 3\\n1 4\\n\", \"5 8 2\\n2 1\\n4 2\\n5 4\\n5 2\\n4 3\\n5 1\\n4 1\\n3 2\\n\", \"5 7 2\\n1 5\\n3 2\\n2 5\\n3 4\\n1 2\\n5 3\\n1 3\\n\", \"2 1 1\\n2 1\\n\", \"16 20 2\\n10 3\\n5 3\\n10 5\\n12 7\\n7 6\\n9 12\\n9 6\\n1 10\\n11 16\\n11 1\\n16 2\\n10 2\\n14 4\\n15 14\\n4 13\\n13 ... | There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.
We want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold: ... | 0.375 |
{"tests": "{\"inputs\": [\"4\\n7 8\\nAAPAAAAA\\nPPPPAAAA\\nPPPPAAAA\\nAPAAPPPP\\nAPAPPAPP\\nAAAAPPAP\\nAAAAPPAA\\n6 5\\nAAAAA\\nAAAAA\\nAAPAA\\nAAPAP\\nAAAPP\\nAAAPP\\n4 4\\nPPPP\\nPPPP\\nPPPP\\nPPPP\\n3 4\\nPPPP\\nPAAP\\nPPPP\\n\", \"1\\n1 1\\nA\\n\", \"1\\n3 3\\nAAA\\nAAA\\nAAA\\n\", \"1\\n4 4\\nAAAA\\nAAAA\\nAAAA\\n... | You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $r \times c$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Beinga... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 3\\n2 3\\n4 3\\n4\\n2 1 2\\n3 2 3 4\\n3 1 2 4\\n4 1 2 3 4\\n\", \"7\\n1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n5 7\\n1\\n4 2 4 6 7\\n\", \"7\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n5\\n4 1 3 5 7\\n3 2 4 6\\n2 1 7\\n2 3 4\\n3 1 6 7\\n\", \"30\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n2 7\\n4 8\\n4 9\\n6 10\\n6... | Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daughter's marriage, reforms must be finished as soon as possible.
The kingdom curren... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 4\\n1 10\\n\", \"55\\n1 1\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n1 10\\n2 2\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n2 8\\n2 9\\n2 10\\n3 3\\n3 4\\n3 5\\n3 6\\n3 7\\n3 8\\n3 9\\n3 10\\n4 4\\n4 5\\n4 6\\n4 7\\n4 8\\n4 9\\n4 10\\n5 5\\n5 6\\n5 7\\n5 8\\n5 9\\n5 10\\n6 6\\n6 7\\n6 ... | Let's denote as $\text{popcount}(x)$ the number of bits set ('1' bits) in the binary representation of the non-negative integer x.
You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and $\text{popcount}(x)$ is maximum possible. If there are multiple... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n1 2\\n2 1\\n2 2\\n\", \"4\\n3 2\\n1 2\\n4 1\\n4 2\\n2 2\\n4 4\\n2 1\\n1 3\\n\", \"4\\n1 1\\n2 2\\n3 3\\n4 4\\n1 2\\n2 1\\n3 4\\n4 3\\n\", \"8\\n6 2\\n5 1\\n6 8\\n7 8\\n6 5\\n5 7\\n4 3\\n1 4\\n7 6\\n8 3\\n2 8\\n3 6\\n3 2\\n8 5\\n1 5\\n5 8\\n\", \"3\\n1 1\\n1 2\\n1 3\\n2 1\\n2 2\\n2 3... | There are 2N balls in the xy-plane. The coordinates of the i-th of them is (x_i, y_i).
Here, x_i and y_i are integers between 1 and N (inclusive) for all i, and no two balls occupy the same coordinates.
In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B.
Then, he placed the type-A ro... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n2 3\\n1 4\\n\", \"3 4\\n2 5 10\\n1 3 7 13\\n\", \"4 1\\n1 2 4 5\\n3\\n\", \"4 5\\n2 5 7 11\\n1 3 6 9 13\\n\", \"10 10\\n4 13 15 18 19 20 21 22 25 27\\n1 5 11 12 14 16 23 26 29 30\\n\"], \"outputs\": [\"3\\n\", \"8\\n\", \"1\\n\", \"6\\n\", \"22\\n\"]}", "source": "primeintellect"} | There are N robots and M exits on a number line.
The N + M coordinates of these are all integers and all distinct.
For each i (1 \leq i \leq N), the coordinate of the i-th robot from the left is x_i.
Also, for each j (1 \leq j \leq M), the coordinate of the j-th exit from the left is y_j.
Snuke can repeatedly perform t... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 3\\n5 7\\n1 3\\n\", \"3\\n2 5\\n4 6\\n1 4\\n\", \"5\\n999999999 1000000000\\n1 2\\n314 315\\n500000 500001\\n999999999 1000000000\\n\", \"5\\n123456 789012\\n123 456\\n12 345678901\\n123456 789012\\n1 23\\n\", \"1\\n1 400\\n\"], \"outputs\": [\"2\\n\", \"0\\n\", \"1999999680\\n\", \"246... | AtCoDeer the deer found N rectangle lying on the table, each with height 1.
If we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown in the following figure:
AtCoDeer will move these rectangles ho... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"4\\n1000 100 10 1\\n\", \"5\\n1 3 4 5 2\\n\", \"1\\n10000000\\n\", \"4\\n1 5 8 4\\n\", \"3\\n1 3 2\\n\", \"4\\n3 1 2 4\\n\", \"12\\n7 1 62 12 3 5 8 9 10 22 23 0\\n\", \"17\\n1 3 2 5 4 6 7 8 10 9 13 11 12 14 15 16 18\\n\", \"22\\n1 3 5 7 22 2 4 6 8 9 10 11 12 13 15 14 17 18 16 ... | You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$... | 0 |
{"tests": "{\"inputs\": [\"3 1 998244353\\n\", \"1 2 1000000007\\n\", \"10 8 861271909\\n\", \"2 1 905589253\\n\", \"14 19 964292983\\n\", \"24 26 804695321\\n\", \"39 36 991399517\\n\", \"46 46 961455263\\n\", \"60 55 931711961\\n\", \"64 64 879068783\\n\", \"75 77 988580261\\n\", \"89 89 942910693\\n\", \"94 94 82639... | Given positive integers N, K and M, solve the following problem for every integer x between 1 and N (inclusive):
- Find the number, modulo M, of non-empty multisets containing between 0 and K (inclusive) instances of each of the integers 1, 2, 3 \cdots, N such that the average of the elements is x.
-----Constraints--... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 10\\n6 3\\n8 2\\n1 4\\n4 10\\n4 1\\n3 2\\n2 6\\n1 100\\n2 15\\n10 11\\n14 100\\n\", \"7\\n5 1000000000\\n2 1\\n1 10\\n1 1\\n4 1000000000\\n3 3\\n1 1000000000\\n5 1\\n2 999999999\\n3 1\\n2 10000000\\n4 10000000\\n10000000 999999999\\n9999900 12\\n9999999 55\\n9999999 1\\n2 1000000\\n1000... | You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like reptile with multiple heads!
$m$
Initially Zmei Gorynich has $x$ heads. You can deal $n$ types of blows. If you deal a blow of the $i$-th type, you decrease the number of Gorynich's heads by $min(d_i, curX)$, there $cur... | 0.875 |
{"tests": "{\"inputs\": [\"6 2\\n5 3\\n0\\n0\\n0\\n2 2 1\\n1 4\\n1 5\\n\", \"9 3\\n3 9 5\\n0\\n0\\n3 9 4 5\\n0\\n0\\n1 8\\n1 6\\n1 2\\n2 1 2\\n\", \"3 3\\n1 2 3\\n1 2\\n1 3\\n1 1\\n\", \"5 3\\n2 1 4\\n0\\n0\\n1 5\\n0\\n0\\n\", \"5 2\\n4 1\\n0\\n1 4\\n1 5\\n0\\n2 1 2\\n\", \"5 2\\n4 5\\n2 3 4\\n1 4\\n1 4\\n0\\n0\\n\", \... | Now you can take online courses in the Berland State University! Polycarp needs to pass k main online courses of his specialty to get a diploma. In total n courses are availiable for the passage.
The situation is complicated by the dependence of online courses, for each course there is a list of those that must be pas... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n3 2 1\\n\", \"5 3\\n2 3 1\\n\", \"5 1\\n3\\n\", \"5 2\\n3 4\\n\", \"20 19\\n2 18 19 11 9 20 15 1 8 14 4 6 5 12 17 16 7 13 3\\n\", \"10 1\\n6\\n\", \"20 18\\n8 14 18 10 1 3 7 15 2 12 17 19 5 4 11 13 20 16\\n\", \"10 2\\n3 7\\n\", \"100000 3\\n43791 91790 34124\\n\", \"20 17\\n9 11 19 4 8... | Let's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty).
You may perform the following operations until both a and s are empty:
Take the first element of a, push it into s and remove it from a (if a is not empty); Take the top element from s, append it to the end of arr... | 0 |
{"tests": "{\"inputs\": [\"oXoxoXo\\n\", \"bod\\n\", \"ER\\n\", \"o\\n\", \"a\\n\", \"opo\\n\", \"HCMoxkgbNb\\n\", \"vMhhXCMWDe\\n\", \"iIcamjTRFH\\n\", \"WvoWvvWovW\\n\", \"WXxAdbAxXW\\n\", \"vqMTUUTMpv\\n\", \"iii\\n\", \"AAWW\\n\", \"ss\\n\", \"i\\n\", \"ii\\n\", \"mm\\n\", \"LJ\\n\", \"m\\n\", \"ioi\\n\", \"OA\\n\"... | Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
[Image] English alphabet
You are given... | 0 |
{"tests": "{\"inputs\": [\"123\\n222\\n\", \"3921\\n10000\\n\", \"4940\\n5000\\n\", \"23923472834\\n23589234723\\n\", \"102391019\\n491010301\\n\", \"123456789123456789\\n276193619183618162\\n\", \"1000000000000000000\\n1000000000000000000\\n\", \"1\\n1000000000000000000\\n\", \"999999999999999999\\n1000000000000000000... | You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.
It is allowed to leave a as it is.
-----Input-----
The first line contains integer a (1 ≤ a ≤ 10^18). The second lin... | 0 |
{"tests": "{\"inputs\": [\"1.1 3.4 2.5\\n\", \"2.0 2.0 2.0\\n\", \"1.9 1.8 1.7\\n\", \"2.0 2.1 2.2\\n\", \"1.5 1.7 2.5\\n\", \"1.1 1.1 1.1\\n\", \"4.2 1.1 1.2\\n\", \"113.9 125.2 88.8\\n\", \"185.9 9.6 163.4\\n\", \"198.7 23.7 89.1\\n\", \"141.1 108.1 14.9\\n\", \"153.9 122.1 89.5\\n\", \"25.9 77.0 144.8\\n\", \"38.7 1... | Wet Shark asked Rat Kwesh to generate three positive real numbers x, y and z, from 0.1 to 200.0, inclusive. Wet Krash wants to impress Wet Shark, so all generated numbers will have exactly one digit after the decimal point.
Wet Shark knows Rat Kwesh will want a lot of cheese. So he will give the Rat an opportunity to ... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n01 0\\n2 1\\n2extra 0\\n3 1\\n99 0\\n\", \"2\\n1 0\\n2 1\\n\", \"5\\n1 0\\n11 1\\n111 0\\n1111 1\\n11111 0\\n\", \"4\\nir7oz8 1\\nvj4v5t 1\\nkwkahb 1\\nj5s8o1 0\\n\", \"4\\n3 1\\n1o0bp2 0\\n9tn379 0\\nv04v6j 1\\n\", \"4\\n1 0\\nsc7czx 0\\nfr4033 1\\n3 0\\n\", \"4\\n4 0\\n1 0\\n2 0\\nizfot... | The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to re... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"7\\n\", \"39\\n\", \"14\\n\", \"94\\n\", \"60\\n\", \"60\\n\", \"59\\n\", \"181994\\n\", \"486639\\n\", \"34514\\n\", \"826594\\n\", \"1000000000000000000\\n\", \"854460\\n\", \"164960\\n\", \"618459\\n\", \"496181994\\n\", \"1000000000\\n\", \"228939226\\n\", \"973034514\\n\", \"98... | Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexagon are defined:
[Image] [Image] Ayrat is searching through the field. He started at point (... | 0 |
{"tests": "{\"inputs\": [\"2\\n0\\n\", \"4\\n1010\\n\", \"20\\n10101010101010\\n\", \"2\\n11\\n\", \"5\\n00101\\n\", \"10\\n100101\\n\", \"4\\n0011\\n\", \"7\\n1100\\n\", \"8\\n01010001\\n\", \"6\\n10\\n\", \"17\\n011100101100110\\n\", \"22\\n1110011010100111\\n\", \"17\\n1110110111010101\\n\", \"11\\n10100000100\\n\",... | You are given a binary string $s$.
Find the number of distinct cyclical binary strings of length $n$ which contain $s$ as a substring.
The cyclical string $t$ contains $s$ as a substring if there is some cyclical shift of string $t$, such that $s$ is a substring of this cyclical shift of $t$.
For example, the cyclic... | 0 |
{"tests": "{\"inputs\": [\"4\\n-1 0\\n0 -1\\n1 0\\n1 1\\n\", \"6\\n-1 0\\n0 -1\\n1 0\\n1 1\\n-4 -5\\n-4 -6\\n\", \"10\\n8 6\\n-7 -3\\n9 8\\n7 10\\n-3 -8\\n3 7\\n6 -8\\n-9 8\\n9 2\\n6 7\\n\", \"20\\n-9 8\\n-7 3\\n0 10\\n3 7\\n6 -9\\n6 8\\n7 -6\\n-6 10\\n-10 3\\n-8 -10\\n10 -2\\n1 -8\\n-8 10\\n10 10\\n10 6\\n-5 6\\n5 -8\... | You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ... | 0 |
{"tests": "{\"inputs\": [\"5 2 1 4 10\\n\", \"5 2 1 4 5\\n\", \"1 1 1 2 1\\n\", \"1000000000000 1000000 999999 1000000 1000000\\n\", \"997167959139 199252 232602 952690 802746\\n\", \"244641009859 748096 689016 889744 927808\\n\", \"483524125987 264237 209883 668942 244358\\n\", \"726702209411 813081 730750 893907 5936... | Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.
Vasiliy's car is not new — it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will ... | 0 |
{"tests": "{\"inputs\": [\"abrakadabrabrakadabra\\n\", \"acacacaca\\n\", \"abcabc\\n\", \"abababab\\n\", \"tatbt\\n\", \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"r\\n\", \"zaz\\n\", \"zaza\\n\", \"gg\\n\", \"gagaga\\n\", \"hhhh\\n\", \"sssss\\n\", \"nx... | В Берляндском государственном университете локальная сеть между серверами не всегда работает без ошибок. При передаче двух одинаковых сообщений подряд возможна ошибка, в результате которой эти два сообщения сливаются в одно. При таком слиянии конец первого сообщения совмещается с началом второго. Конечно, совмещение мо... | 0 |
{"tests": "{\"inputs\": [\"8\\nabacabac\\n1 1 1 1 1 1 1 1\\n\", \"8\\nabaccaba\\n1 2 3 4 5 6 7 8\\n\", \"8\\nabacabca\\n1 2 3 4 4 3 2 1\\n\", \"100\\nbaaacbccbccaccaccaaabcabcabccacaabcbccbccabbabcbcbbaacacbacacacaacccbcbbbbacccababcbacacbacababcacbc\\n28 28 36 36 9 53 7 54 66 73 63 30 55 53 54 74 60 2 34 36 72 56 13 6... | A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) a_{i} ≠ a_{m} - i + 1.
Ivan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic permutation of s. Also Ivan has denoted the beauty of index i as b_{i}... | 0 |
{"tests": "{\"inputs\": [\"23 5\\n\", \"13 2\\n\", \"1 2\\n\", \"1 1\\n\", \"7 2\\n\", \"7 3\\n\", \"7 4\\n\", \"521325125150442808 10\\n\", \"1 4\\n\", \"9 4\\n\", \"3 4\\n\", \"144 4\\n\", \"59 4\\n\", \"78 4\\n\", \"192 4\\n\", \"107 4\\n\", \"552 5\\n\", \"680 5\\n\", \"808 5\\n\", \"1528 5\\n\", \"1656 5\\n\", \"2... | Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:
Find k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as small as possible. As t... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"2\\n1 2\\n\", \"3\\n1 2 1\\n\", \"2\\n1 3\\n\", \"2\\n3 5\\n\", \"2\\n9 10\\n\", \"2\\n6 8\\n\", \"3\\n0 0 0\\n\", \"2\\n223 58\\n\", \"2\\n106 227\\n\", \"2\\n125 123\\n\", \"3\\n31 132 7\\n\", \"2\\n41 29\\n\", \"3\\n103 286 100\\n\", \"3\\n9 183 275\\n\", \"3\\n19 88 202\\n... | Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!
Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games.
BitLGM and Bi... | 0 |
{"tests": "{\"inputs\": [\"5\\nRURUU\\n-2 3\\n\", \"4\\nRULR\\n1 1\\n\", \"3\\nUUU\\n100 100\\n\", \"6\\nUDUDUD\\n0 1\\n\", \"100\\nURDLDDLLDDLDDDRRLLRRRLULLRRLUDUUDUULURRRDRRLLDRLLUUDLDRDLDDLDLLLULRURRUUDDLDRULRDRUDDDDDDULRDDRLRDDL\\n-59 -1\\n\", \"8\\nUUULLLUU\\n-3 0\\n\", \"9\\nUULUURRUU\\n6379095 -4\\n\", \"5\\nDUU... | Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell $(0, 0)$. Robot can perform the following four kinds of operations: U — move from $(x, y)$ to $(x, y + 1)$; D — move from $(x, y)$ to $(x, y - 1)$; L — move from $(x, y)$ to $(x - 1, y)$; R — move from $(x, y)$ to $(x + 1... | 0 |
{"tests": "{\"inputs\": [\"1 3 8 1 1\\n\", \"4 2 9 4 2\\n\", \"5 5 25 4 3\\n\", \"100 100 1000000000000000000 100 100\\n\", \"3 2 15 2 2\\n\", \"4 1 8 3 1\\n\", \"3 2 8 2 1\\n\", \"4 2 9 4 1\\n\", \"1 3 7 1 1\\n\", \"2 2 8 2 1\\n\", \"3 1 6 2 1\\n\", \"5 6 30 5 4\\n\", \"3 8 134010 3 4\\n\", \"10 10 25 5 1\\n\", \"100 ... | On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.
Seating in the class looks like a rectangle, where n rows with m pupils in each.
The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order of t... | 0 |
{"tests": "{\"inputs\": [\"3\\nKuroo\\nShiro\\nKatie\\n\", \"7\\ntreasurehunt\\nthreefriends\\nhiCodeforces\\n\", \"1\\nabcabc\\ncbabac\\nababca\\n\", \"15\\nfoPaErcvJ\\nmZaxowpbt\\nmkuOlaHRE\\n\", \"1\\naaaaaaaaaa\\nAAAAAAcAAA\\nbbbbbbzzbb\\n\", \"60\\nddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb\\ndcdXcYbca... | After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination... | 0.375 |
{"tests": "{\"inputs\": [\"27\\n\", \"3\\n\", \"25\\n\", \"9\\n\", \"91\\n\", \"57\\n\", \"31\\n\", \"555\\n\", \"700000001\\n\", \"5\\n\", \"7\\n\", \"11\\n\", \"13\\n\", \"15\\n\", \"17\\n\", \"19\\n\", \"21\\n\", \"23\\n\", \"29\\n\", \"79\\n\", \"99\\n\", \"27\\n\", \"55\\n\", \"79\\n\", \"585\\n\", \"245\\n\", \"7... | Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.
More formally, you are given an odd numer n. Find a set of numbers p_{i} (1 ≤ i ≤ k), such that
1 ≤ k ≤ 3
p_... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n.*..\\n....\\n.*..\\n\", \"3 3\\n..*\\n.*.\\n*..\\n\", \"6 5\\n..*..\\n..*..\\n*****\\n..*..\\n..*..\\n..*..\\n\", \"1 10\\n**********\\n\", \"10 1\\n*\\n*\\n*\\n*\\n*\\n*\\n*\\n*\\n*\\n*\\n\", \"10 10\\n.........*\\n.........*\\n........**\\n.........*\\n.........*\\n.........*\\n........ | You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").
You have one bomb. If you lay the bomb at the cell (x, y), then after triggering it will wipe out all walls in the row x and all walls in the column... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"4\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"100000\\n\", \"99991\\n\", \"30030\\n\", \"99594\\n\", \"91402\\n\", \"93493\\n\", \"96917\\n\", \"80555\\n\", \"30238\\n\", \"5447\\n\", \"5714\\n\", \"735\\n\", \"64\\n... | Vivek initially has an empty array $a$ and some integer constant $m$.
He performs the following algorithm: Select a random integer $x$ uniformly in range from $1$ to $m$ and append it to the end of $a$. Compute the greatest common divisor of integers in $a$. In case it equals to $1$, break Otherwise, return to ste... | 0 |
{"tests": "{\"inputs\": [\"6 10\\n\", \"21 31\\n\", \"5 10\\n\", \"1924 5834\\n\", \"9911 666013\\n\", \"1 1\\n\", \"69 4295\\n\", \"948248258 533435433\\n\", \"953 1349\\n\", \"999999973 800000007\\n\", \"112342324 524224233\\n\", \"1021211 59555555\\n\", \"1000000000 1000000000\\n\", \"199999943 999999973\\n\", \"2 9... | Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.
Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ is the smallest possible. If there are multiple optimal integers $k... | 0.875 |
{"tests": "{\"inputs\": [\"2 6\\n2 3\\n\", \"36 5\\n10 16\\n\", \"3 5\\n2 1\\n\", \"36 5\\n10 12\\n\", \"1 1\\n1 1\\n\", \"2 1\\n1 2\\n\", \"3 6\\n2 1\\n\", \"1 27\\n1 1\\n\", \"2 5\\n20 2\\n\", \"40 5\\n150 36\\n\", \"60 1080\\n60 45\\n\", \"2160 3240\\n7200 384\\n\", \"51840 900\\n48 27000\\n\", \"100 200\\n7200 25\\... | Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a_1 × b_1 segments large and the second one is a_2 × b_2 segments large.
Polycarpus wants to give Paraskevi one of the bars at the lunch break and eat the other one him... | 0 |
{"tests": "{\"inputs\": [\"2 2 30\\n4 3\\n\", \"2 2 7\\n4 3\\n\", \"3 1 1\\n1 1 1\\n\", \"25 25 25\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"13 1 60\\n3 6 3 4 3 5 1 4 4 4 3 4 3\\n\", \"10 10 1002\\n5 6 5 3 4 3 3 2 6 4\\n\", \"7 6 14\\n1 3 2 4 1 1 6\\n\", \"8 7 169\\n4 3 4 3 5 5 2 5\\n\", \"1 0 3843382... | Anya loves to fold and stick. Today she decided to do just that.
Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that the number of stickers does not exceed the number of cubes.
Anya can stick a... | 0.125 |
{"tests": "{\"inputs\": [\"11 3\\n\", \"11 6\\n\", \"20 20\\n\", \"14 5\\n\", \"1000000 100\\n\", \"1 1\\n\", \"2 1\\n\", \"100 4\\n\", \"502333439 2047\\n\", \"773014587697599 31\\n\", \"946338791423 262143\\n\", \"1000000000 4\\n\", \"13 2\\n\", \"1073741821 2\\n\", \"1000000000 100\\n\", \"1000000000 1000000000\\n\"... | At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | 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\": [\"3 2 30 4\\n6 14 25 48\\n\", \"123 1 2143435 4\\n123 11 -5453 141245\\n\", \"123 1 2143435 4\\n54343 -13 6 124\\n\", \"3 2 25 2\\n379195692 -69874783\\n\", \"3 2 30 3\\n-691070108 -934106649 -220744807\\n\", \"3 3 104 17\\n9 -73896485 -290898562 5254410 409659728 -916522518 -435516126 94354167... | Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.
You are given geometric progression b defined by two integers b_1 and q. Remind that a geometric progression is a sequence of integers b_1, b_2, b_3, ..., where for each i > 1 the respective term satisfies the condition b... | 0.125 |
{"tests": "{\"inputs\": [\"4 8\\n..w..w..\\n........\\n........\\n..w..w..\\n\", \"5 6\\n......\\n.w....\\n......\\n..w...\\n......\\n\", \"2 4\\n....\\n.w..\\n\", \"2 6\\nw..w.w\\n...w..\\n\", \"9 4\\n....\\n....\\n....\\n....\\n....\\n..w.\\n....\\n....\\n.w..\\n\", \"10 4\\n....\\n.w..\\n....\\n....\\n.w..\\n....\\n... | Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his younger brother Polycarpus.
Innocentius is touch-typing a program that pain... | 0.125 |
{"tests": "{\"inputs\": [\"6\\n1 3 4 5 6 9\\n\", \"3\\n998 999 1000\\n\", \"5\\n1 2 3 4 5\\n\", \"1\\n1\\n\", \"2\\n1 2\\n\", \"2\\n999 1000\\n\", \"9\\n1 4 5 6 7 100 101 102 103\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4... | JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \le a_1 < a_2 < \ldots < a_n \le 10^3$, and then went to the bathroom.
JATC decided to prank his friend by erasing some consecutive elements in th... | 0 |
{"tests": "{\"inputs\": [\"3 3 2 3\\n\", \"12 17 9 40\\n\", \"1 1 1 1\\n\", \"10 10 5 100\\n\", \"7 1 1 4\\n\", \"1000 1000 59 100000\\n\", \"100000 100000 1000 100000\\n\", \"100000 100000 100000 100000\\n\", \"3 100000 2 88700\\n\", \"200 100000 55 100000\\n\", \"74 2 1 36\\n\", \"2 59 1 112\\n\", \"96 33 24 928\\n\"... | While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!).
The gift bundle also includes a square scoop of size r × r, designed for fishing.... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 2 2 2\\n\", \"1\\n0\\n\", \"3\\n-3 -3 2\\n\", \"10\\n2 10 6 8 -4 -11 -10 3 -3 8\\n\", \"10\\n8 6 3 9 8 7 7 7 7 6\\n\", \"8\\n-3 -11 -4 -8 -4 -5 -3 -2\\n\", \"10\\n6 1 -11 -10 -9 -8 8 -1 -10 1\\n\", \"6\\n10 -11 -8 -11 -11 10\\n\", \"3\\n-2 -3 -4\\n\", \"5\\n0 0 0 -4 -3\\n\", \"1\\n-3\\n... | Nick had received an awesome array of integers $a=[a_1, a_2, \dots, a_n]$ as a gift for his $5$ birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product $a_1 \cdot a_2 \cdot \dots a_n$ of its elements seemed to him not large enoug... | 0 |
{"tests": "{\"inputs\": [\"2 2 2\\n\", \"2 1 2\\n\", \"1 1 3\\n\", \"3 2 1\\n\", \"100 100 100\\n\", \"1 100 100\\n\", \"100 1 100\\n\", \"100 100 1\\n\", \"1 100 99\\n\", \"99 1 100\\n\", \"100 99 1\\n\", \"100 1 99\\n\", \"1 99 100\\n\", \"99 100 1\\n\", \"1 1 1\\n\", \"100 100 2\\n\", \"100 2 100\\n\", \"2 100 100\\... | The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, then one individual kills the other one: a rock kills scissors, scissors kill paper... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"6\\n\", \"1\\n\", \"17\\n\", \"67\\n\", \"10\\n\", \"14\\n\", \"22\\n\", \"23\\n\", \"246\\n\", \"902\\n\", \"1000000000\\n\", \"1998\\n\", \"2222222\\n\", \"2222226\\n\", \"1111110\\n\", \"9999998\\n\", \"1024\\n\", \"8388608\\n\", \"4\\n\", \"8\\n\", \"16\\n\", \"492\\n\", \"49382... | Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, tripl... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n\", \"5 3\\n\", \"1 1\\n\", \"744 18\\n\", \"47879 10\\n\", \"1000000000000000000 1000000000000000000\\n\", \"657180569218773599 42\\n\", \"442762254977842799 30\\n\", \"474158606260730555 1\\n\", \"807873101233533988 39\\n\", \"423 7\\n\", \"264306177888923090 5\\n\", \"998857801526481... | Imp is watching a documentary about cave painting. [Image]
Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1 to k. Unfortunately, there are too many integers to analyze for Imp.
Imp ... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n-1 0 1\\n\", \"2 1\\n1 0\\n\", \"1 1\\n-1\\n\", \"1 0\\n-1\\n\", \"1 1\\n0\\n\", \"5 1\\n-1 -1 -1 -1 -1\\n\", \"5 0\\n-1 -1 -1 -1 -1\\n\", \"10 1\\n1 1 1 1 0 0 0 1 0 0\\n\", \"50 1\\n-1 -1 1 0 1 1 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 1 -1 1 0 -1 1 1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 -1 -1 0 1 -1 0... | Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to create a game with only a white paper, a pencil, a pair of scissors and a lot o... | 0 |
{"tests": "{\"inputs\": [\"3 595\\n43 2\\n300 4\\n554 10\\n\", \"1 1\\n1 1\\n\", \"2 50\\n20 0\\n3 1\\n\", \"5 240\\n13 0\\n50 25\\n60 5\\n155 70\\n165 70\\n\", \"1 100000\\n99998 0\\n\", \"1 100000\\n100000 0\\n\", \"1 100000\\n1 0\\n\", \"2 100000\\n1 0\\n100000 0\\n\", \"7 300\\n50 8\\n49 6\\n246 1\\n123 3\\n227 2\\... | The mayor of the Central Town wants to modernize Central Street, represented in this problem by the $(Ox)$ axis.
On this street, there are $n$ antennas, numbered from $1$ to $n$. The $i$-th antenna lies on the position $x_i$ and has an initial scope of $s_i$: it covers all integer positions inside the interval $[x_i -... | 0 |
{"tests": "{\"inputs\": [\"4 1 2\\n\", \"2 1 5\\n\", \"3 1 1\\n\", \"5 5 5\\n\", \"4 0 0\\n\", \"6 0 6\\n\", \"6 6 0\\n\", \"2 1 2\\n\", \"100000000 1 0\\n\", \"2 0 0\\n\", \"2 100000000 100000000\\n\", \"2 100000000 0\\n\", \"2 0 100000000\\n\", \"100000000 0 0\\n\", \"100000000 100000000 100000000\\n\", \"100000000 1... | R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met anoth... | 0 |
{"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\": [\"2\\n\", \"6\\n\", \"4\\n\", \"1\\n\", \"24\\n\", \"200560490130\\n\", \"999999999989\\n\", \"1000000000000\\n\", \"999966000289\\n\", \"991921850317\\n\", \"997167959139\\n\", \"244641009859\\n\", \"483524125987\\n\", \"726702209411\\n\", \"965585325539\\n\", \"213058376259\\n\", \"6908246085... | Today, Osama gave Fadi an integer $X$, and Fadi was wondering about the minimum possible value of $max(a, b)$ such that $LCM(a, b)$ equals $X$. Both $a$ and $b$ should be positive integers.
$LCM(a, b)$ is the smallest positive integer that is divisible by both $a$ and $b$. For example, $LCM(6, 8) = 24$, $LCM(4, 12) = ... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 7 28\\n\", \"1\\n1\\n\", \"1\\n548\\n\", \"1\\n963837006\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n26 723 970 13 422 968 875 329 234 983\\n\", \"10\\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\\n\", \"100\\n1 1 1 1 2 1 1 1 1 1... | You are given an array of n elements, you must make it a co-prime array in as few moves as possible.
In each move you can insert any positive integral number you want not greater than 10^9 in any place in the array.
An array is co-prime if any two adjacent numbers of it are co-prime.
In the number theory, two intege... | 0.25 |
{"tests": "{\"inputs\": [\"39\\n\", \"1\\n\", \"7\\n\", \"1000000\\n\", \"524288\\n\", \"524289\\n\", \"524287\\n\", \"699050\\n\", \"349525\\n\", \"2\\n\", \"5\\n\", \"6\\n\", \"11\\n\", \"13\\n\", \"545860\\n\", \"917503\\n\", \"174762\\n\", \"43690\\n\", \"10922\\n\", \"2730\\n\", \"682\\n\", \"170\\n\", \"42\\n\", ... | Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.
Assume that we have a cat with a number $x$. A perfect longcat is a cat with a number equal $2^m - 1$ for some no... | 0 |
{"tests": "{\"inputs\": [\"4 10 13 10 3 1\\n\", \"1 4 6 2 2 1\\n\", \"3 10 15 17 9 2\\n\", \"4 9 30 3 3 1\\n\", \"4 9 13 2 3 1\\n\", \"4 9 13 1 1 1\\n\", \"1 9 10 6 6 3\\n\", \"4 9 24 10 3 1\\n\", \"4 9 20 10 3 1\\n\", \"1 8 10 8 3 3\\n\", \"2 9 10 4 6 3\\n\", \"2 9 10 6 3 3\\n\", \"1 9 10 7 3 3\\n\", \"1 9 10 9 5 3\\n... | It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guys. For example, he can hit the ball directly to the specified point. And ye... | 0 |
{"tests": "{\"inputs\": [\"hi\\nbob\\n\", \"abca\\naccepted\\n\", \"abacaba\\nabcdcba\\n\", \"lo\\neuhaqdhhzlnkmqnakgwzuhurqlpmdm\\n\", \"aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk\\n\", \"npnkmawey\\nareakefvowledfriyjejqnnaeqheoh\\n\", \"fdtffutxkujflswyddvhusfcook\... | You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of th... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n0 1 1 0\\n\", \"2\\n1 1\\n\", \"1\\n0\\n\", \"4\\n0 0 0 0\\n\", \"6\\n0 0 0 0 0 1\\n\", \"20\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"20\\n1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0\\n\", \"1\\n1\\n\", \"2\\n0 0\\n\", \"2\\n0 1\\n\", \"2\\n1 0\\n\", \"3\\n0 0 0\\n\", \"3\\n0 0 1\\n\... | Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false.
Implication is written by using character '$\rightarrow$', and the arguments and the result of the implication are written as '0' (false) and '1'... | 0 |
{"tests": "{\"inputs\": [\"13\\n8380011223344\\n\", \"15\\n807345619350641\\n\", \"19\\n8181818181111111111\\n\", \"29\\n88811188118181818118111111111\\n\", \"15\\n980848088815548\\n\", \"13\\n9999999998888\\n\", \"13\\n0000008888888\\n\", \"13\\n2480011223348\\n\", \"17\\n87879887989788999\\n\", \"21\\n123456788888812... | A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and eras... | 0 |
{"tests": "{\"inputs\": [\"hw?ap*yn?eww*ye*ar\\n12\\n\", \"ab?a\\n2\\n\", \"ab?a\\n3\\n\", \"ababb\\n5\\n\", \"ab?a\\n1\\n\", \"z\\n1\\n\", \"n\\n96\\n\", \"c*b*dosavq*gwy*e*j?jx?t?li*m?fik*m*l?i?b?z?kv*wm*u*j?h?o?hg*c*hf?l*n*dl*q*t?bi*m?g*c*k?p*e*di*o?iqfn*sj?k*t?zyqz*ihjpt?a?vr?a*r\\n83\\n\", \"a?u?kb*exg?l*z?xc?gbpb... | Andrey received a postcard from Irina. It contained only the words "Hello, Andrey!", and a strange string consisting of lowercase Latin letters, snowflakes and candy canes. Andrey thought that this string is an encrypted message, and decided to decrypt it.
Andrey noticed that snowflakes and candy canes always stand af... | 0 |
{"tests": "{\"inputs\": [\"1 2 1000\\n\", \"2 2 1000\\n\", \"5 3 1103\\n\", \"2 17 10000\\n\", \"3 9 10000\\n\", \"6 64 941761822\\n\", \"183 3 46847167\\n\", \"472 44 364550669\\n\", \"510 76 811693420\\n\", \"783 30 602209107\\n\", \"863 47 840397713\\n\", \"422 22 411212542\\n\", \"370 9 385481464\\n\", \"312 41 915... | Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.
First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x > 0 exist such that: Decim... | 0 |
{"tests": "{\"inputs\": [\"4\\n11\\n27\\n27\\n11\\n\", \"2\\n6\\n6\\n\", \"6\\n10\\n20\\n30\\n20\\n10\\n20\\n\", \"6\\n1\\n1\\n2\\n2\\n3\\n3\\n\", \"2\\n1\\n100\\n\", \"2\\n1\\n1\\n\", \"2\\n100\\n100\\n\", \"14\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n43\\n\", \"100\\n14\\n14\\n14\\n14\\n14\\... | Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card.
Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with num... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n5 8\\n\", \"1 2\\n7 1\\n\", \"1 2\\n4 4\\n\", \"1 4\\n2 2 1 2\\n\", \"10000 100\\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 ... | Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains a_{i} soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call tw... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n0 1 0\\n\", \"5 1\\n1 1 1 0 0\\n\", \"6 4\\n1 0 0 1 1 0\\n\", \"3 2\\n1 1 1\\n\", \"5 2\\n1 1 1 0 0\\n\", \"6 4\\n0 0 1 1 1 1\\n\", \"100 1000000000\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and the number $k$. Exactly $k$ times the following happens: Two numbe... | 0 |
{"tests": "{\"inputs\": [\"6 3\\n\", \"8 5\\n\", \"22 4\\n\", \"4 3\\n\", \"57 27\\n\", \"61 3\\n\", \"5 4\\n\", \"10 6\\n\", \"20 10\\n\", \"30 5\\n\", \"25 24\\n\", \"25 3\\n\", \"12 7\\n\", \"18 6\\n\", \"100000 3\\n\", \"100000 9999\\n\", \"9999 3\\n\", \"5323 32\\n\", \"6666 66\\n\", \"38578 32201\\n\", \"49449 52... | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n3 4\\n\", \"1 0\\n0 1\\n\", \"1000000000 0\\n0 1000000000\\n\", \"8205 9482\\n11 -63\\n\", \"0 0\\n0 0\\n\", \"1000000000 -1000000000\\n1000000000 1000000000\\n\", \"1000000000 1000000000\\n1000000000 -1000000000\\n\", \"-1 -1\\n1 0\\n\", \"5 2\\n-15 -6\\n\", \"2 -5\\n-3 2\\n\", \"-5 -2... | The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$
A matrix is called degenerate if its determinant is equal to zero.
The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements.
You ar... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n4 3 5\\n\", \"3 4\\n5 3 4\\n\", \"3 7\\n1 2 3\\n\", \"1 1\\n1\\n\", \"1 2\\n1\\n\", \"5 10\\n10 10 10 10 10\\n\", \"1 1000000000\\n1000000000\\n\", \"1 1000000000000\\n42\\n\", \"3 2\\n1 1 5\\n\", \"2 1\\n1 100\\n\", \"3 1\\n5 10 15\\n\", \"2 1\\n1 1000\\n\", \"3 3\\n2 4 4\\n\", \"10 1\... | The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of k... | 0.125 |
{"tests": "{\"inputs\": [\"5\\nDDRRR\\n\", \"6\\nDDRRRR\\n\", \"1\\nD\\n\", \"1\\nR\\n\", \"2\\nDR\\n\", \"3\\nRDD\\n\", \"3\\nDRD\\n\", \"4\\nDRRD\\n\", \"4\\nDRRR\\n\", \"4\\nRDRD\\n\", \"5\\nDRDRR\\n\", \"4\\nRRRR\\n\", \"5\\nRDDRD\\n\", \"5\\nDDRRD\\n\", \"5\\nDRRRD\\n\", \"5\\nDDDDD\\n\", \"6\\nDRRDDR\\n\", \"7\\n... | There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | 0 |
{"tests": "{\"inputs\": [\"7 5 3\\n\", \"1000000000 1 2019\\n\", \"100 100000 1\\n\", \"6 4 5\\n\", \"172165 93846 84\\n\", \"9978 99 98615\\n\", \"9909 95875 20\\n\", \"42651129 26190 16875\\n\", \"5 8253 91700\\n\", \"14712 8142 9912\\n\", \"98898 1040 98615\\n\", \"79674 62280 77850\\n\", \"78139 77688 1161\\n\", \"... | A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.
Let $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, x]$. The frog doesn't ne... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 -3\\n\", \"8\\n9 -12 3 4 -4 -10 7 3\\n\", \"1\\n0\\n\", \"4\\n1 2 3 -5\\n\", \"6\\n0 0 0 0 0 0\\n\", \"7\\n0 0 0 0 3 -3 0\\n\", \"5\\n0 0 -4 0 0\\n\", \"100\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays one... | 0 |
{"tests": "{\"inputs\": [\"3454\\n\", \"10\\n\", \"111111\\n\", \"8996988892\\n\", \"5555555555\\n\", \"1\\n\", \"8147522776919916277306861346922924221557534659480258977017038624458370459299847590937757625791239188\\n\", \"8\\n\", \"14\\n\", \"2363\\n\", \"3554\\n\", \"312\\n\", \"7674\\n\", \"126\\n\", \"344\\n\", \"9... | You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-... | 0.375 |
{"tests": "{\"inputs\": [\"00\\n00\\n\", \"00X00X0XXX0\\n0XXX0X00X00\\n\", \"0X0X0\\n0X0X0\\n\", \"0XXX0\\n00000\\n\", \"0\\n0\\n\", \"0\\nX\\n\", \"X\\n0\\n\", \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... | Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | 0 |
{"tests": "{\"inputs\": [\"6 9 2 4\\n\", \"6 10 2 4\\n\", \"6 5 4 3\\n\", \"2 2 1 1\\n\", \"10 4 6 10\\n\", \"3 1 1 1\\n\", \"2 1 1 1\\n\", \"1000000 51923215 2302 10000\\n\", \"10 11 3 2\\n\", \"20 50 10 25\\n\", \"10 10 5 20\\n\", \"15 65 5 50\\n\", \"10 19 1 5\\n\", \"10 19 9 5\\n\", \"23 46 12 2\\n\", \"23 46 12 3\... | A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ... | 0 |
{"tests": "{\"inputs\": [\"3 10 1 3\\n3 4 7\\n\", \"2 9 2 3\\n6 4\\n\", \"10 100 2 8\\n93 35 24 87 39 46 86 37 73 33\\n\", \"10 1000000000 8905990 20319560\\n233244997 997992814 242452779 497363176 572234096 126615858 886769539 662035052 989086824 716655858\\n\", \"100 1000 1 4\\n228 420 360 642 442 551 940 343 24 83 9... | A sportsman starts from point x_{start} = 0 and runs to point with coordinate x_{finish} = m (on a straight line). Also, the sportsman can jump — to jump, he should first take a run of length of not less than s meters (in this case for these s meters his path should have no obstacles), and after that he can jump over a... | 0 |
{"tests": "{\"inputs\": [\"7 2\\n\", \"5 1\\n\", \"10 0\\n\", \"10 1\\n\", \"10 10\\n\", \"11 10\\n\", \"100 2\\n\", \"100 200\\n\", \"1000 1000\\n\", \"1000 31\\n\", \"1 0\\n\", \"2 0\\n\", \"3 0\\n\", \"4 0\\n\", \"5 0\\n\", \"15 0\\n\", \"153 0\\n\", \"1 1\\n\", \"2 1\\n\", \"3 1\\n\", \"4 1\\n\", \"5 1\\n\", \"15 1... | Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over.
This time Miroslav laid out $n$ skewers parallel to each other, and enumerated them with consecutive integers from $1$ to $n$ in order from left... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"3\\n\", \"6\\n\", \"10\\n\", \"64\\n\", \"1227\\n\", \"49152\\n\", \"1000000\\n\", \"524288\\n\", \"786431\\n\", \"999999\\n\", \"217292\\n\", \"16339\\n\", \"4\\n\", \"5\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"50\\n\", \"87\\n\", \"71\\n\", \"73\\n\", \"89\\n\", \"40\\n\", \"42\\n\",... | Let's define a function $f(p)$ on a permutation $p$ as follows. Let $g_i$ be the greatest common divisor (GCD) of elements $p_1$, $p_2$, ..., $p_i$ (in other words, it is the GCD of the prefix of length $i$). Then $f(p)$ is the number of distinct elements among $g_1$, $g_2$, ..., $g_n$.
Let $f_{max}(n)$ be the maximum... | 0 |
{"tests": "{\"inputs\": [\"3\\n141 592 653\\n\", \"5\\n10 21 10 21 10\\n\", \"1\\n100000\\n\", \"50\\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 1... | You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be ... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"0 10\\n\", \"10 10\\n\", \"100 100\\n\", \"10 100\\n\", \"20 1000\\n\", \"1000 20\\n\", \"100 10\\n\", \"2 2\\n\", \"3 3\\n\", \"2 15\\n\", \"15 2\\n\", \"1000 1000\\n\", \"1000 999\\n\", \"999 1000\\n\", \"987 567\\n\", \"555 555\\n\", \"555 1\\n\", \"1 4\\n\", \"955 956\\n\", \"... | You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible.
A polyline defined by points p_1, p_2, p_3, p_4 consists of the line seg... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.