info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"1000000000 1000000000\", \"1 10\", \"4 2\", \"6 3\", \"1000001000 1000000000\", \"1 5\", \"2 2\", \"11 3\", \"1000001000 1010000000\", \"2 4\", \"16 3\", \"1000000000 1010000000\", \"2 0\", \"4 4\", \"25 3\", \"1001000000 1010000000\", \"6 4\", \"25 1\", \"1001000000 1010010000\", \"100110000... | Takahashi and Aoki are going to together construct a sequence of integers.
First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:
* The length of a is N.
* Each element in a is an integer between 1 and K, inclusive.
* a is a palindrome, that is, reversing the order of elem... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n4 6\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n5 0\\n0 0\", \"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n4 6\\n1 2\\n1 3\\n1 4\\n2 4\\n2 4\\n3 4\\n5 0\\n0 0\", \"5 4\\n1 2\\n2 3\\n3 4\\n5 5\\n4 6\\n1 2\\n1 3\\n1 4\\n2 4\\n2 4\\n3 4\\n5 0\\n0 0\", \"5 4\\n2 2\\n2 3\\n3 4\\n5 5\\n4 ... | A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.
Her magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tying several pairs of ston... | 0.25 |
{"tests": "{\"inputs\": [\"4 4\\n1 2 3\\n2 3 1\\n2 4 5\\n3 4 2\\n5\\n4 5 6\", \"4 4\\n1 3 3\\n2 3 1\\n2 4 5\\n3 4 2\\n5\\n4 5 6\", \"4 4\\n1 2 3\\n2 3 1\\n2 4 5\\n3 4 2\\n5\\n4 5 7\", \"4 4\\n1 3 4\\n2 3 1\\n2 4 5\\n3 4 2\\n5\\n4 5 6\", \"4 4\\n1 3 4\\n2 3 0\\n2 4 5\\n3 4 2\\n5\\n4 5 6\", \"4 4\\n1 3 4\\n2 3 1\\n2 2 10... | D: Country In Distortion-
story
Alice was completely bored. This is because the White Rabbit, who is always playing with him, is out to Trump Castle. (Ah, I wish I had gone out with him in this case.) Alice thought. However, this is a country of distortion. If you go out so easily, you will get very tired. What does ... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n5 1 6\\n2 3 4\", \"3 3\\n5 2 6\\n2 3 4\", \"3 3\\n4 2 6\\n2 3 4\", \"2 3\\n4 2 6\\n2 3 4\", \"2 3\\n4 2 6\\n2 2 4\", \"2 4\\n4 2 6\\n2 2 4\", \"3 3\\n5 1 7\\n2 3 4\", \"3 0\\n5 4 6\\n2 3 4\", \"2 4\\n8 3 6\\n2 3 4\", \"2 4\\n4 2 6\\n2 3 5\", \"2 2\\n2 2 6\\n2 0 6\", \"2 2\\n5 2 5\\n2 0 ... | F: MOD Rush
problem
Given a positive integer sequence A of length N and a positive integer sequence B of length M.
For all (i, j) (1 \ leq i \ leq N, 1 \ leq j \ leq M), find the remainder of A_i divided by B_j and output the sum of them.
Input format
N M
A_1 A_2 ... A_N
B_1 B_2 ... B_M
Constraint
* 1 \ leq N,... | 0 |
{"tests": "{\"inputs\": [\"14 86\\n9 1 20\", \"14 86\\n15 1 20\", \"14 86\\n4 1 20\", \"11 86\\n4 1 20\", \"20 86\\n4 1 20\", \"20 86\\n4 1 37\", \"20 86\\n4 0 37\", \"20 86\\n4 0 39\", \"20 73\\n4 0 39\", \"20 73\\n5 0 39\", \"20 73\\n5 0 47\", \"20 73\\n5 0 27\", \"20 73\\n10 0 27\", \"20 124\\n10 0 27\", \"20 122\\n... | Run, Twins
E869120 You started running from home to school at a speed of $ P $ meters per minute.
square1001 noticed E869120's forgotten thing $ A $ minutes after E869120 left home and chased at $ Q $ meters per minute.
Then E869120 noticed something left behind $ B $ minutes after E869120 left home and turned back ... | 0 |
{"tests": "{\"inputs\": [\"6 7\\n0 1 3 1\\n0 2 4 -2\\n1 0 5\\n1 0 1\\n0 3 5 3\\n1 3 4\\n1 0 5\", \"6 7\\n0 1 3 1\\n0 2 4 -2\\n1 0 4\\n1 0 1\\n0 3 5 3\\n1 3 4\\n1 0 5\", \"6 7\\n0 1 3 1\\n0 2 2 -2\\n1 0 4\\n1 0 1\\n0 3 5 3\\n1 3 4\\n1 0 5\", \"6 7\\n0 1 3 1\\n0 2 4 -2\\n1 0 5\\n1 0 1\\n0 3 5 0\\n1 3 4\\n1 0 5\", \"6 7\\... | Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.
* $getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$.
Note that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0.
Constraints
* $... | 0 |
{"tests": "{\"inputs\": [\"1\\n4\\n10 20 34 55\\n4\\n7 14\\n7 21\\n14 21\\n7 35\", \"1\\n4\\n10 20 34 55\\n4\\n7 14\\n7 21\\n14 6\\n7 35\", \"1\\n4\\n10 20 34 55\\n4\\n7 14\\n7 21\\n14 6\\n7 2\", \"1\\n2\\n10 20 34 55\\n4\\n7 5\\n2 4\\n21 6\\n7 2\", \"1\\n4\\n10 8 45 28\\n4\\n7 26\\n4 21\\n21 6\\n13 35\", \"1\\n4\\n20 ... | Did you know that the yummy golden triangle was introduced in India as early as 13th century ? By the way, I'm referring to the popular South Asian snack, Samosa. I guess its hard to code while thinking of Samosa, especially if you are very hungry now ; so lets not get in to any recipe or eating game.
You have N box... | 0.25 |
{"tests": "{\"inputs\": [\"7\\nabacaba\\nbacabaa\\n\", \"5\\nzcabd\\ndbacz\\n\", \"1\\na\\nb\\n\", \"5\\nahmad\\nyogaa\\n\", \"5\\nahmad\\nyngaa\\n\", \"7\\nabacaba\\naabacab\\n\", \"5\\nzcabd\\nebacz\\n\", \"7\\nabacaaa\\naabacab\\n\", \"5\\nzcabd\\neaacz\\n\", \"5\\nzcabd\\nzcabd\\n\", \"5\\nahmac\\nyngaa\\n\", \"5\\... | You are given two strings a and b consisting of lowercase English letters, both of length n. The characters of both strings have indices from 1 to n, inclusive.
You are allowed to do the following changes:
* Choose any index i (1 ≤ i ≤ n) and swap characters a_i and b_i;
* Choose any index i (1 ≤ i ≤ n) and sw... | 0 |
{"tests": "{\"inputs\": [\"3\\n8\\n1 0\\n4 1\\n2 0\\n4 1\\n5 1\\n6 1\\n3 0\\n2 0\\n4\\n1 1\\n1 1\\n2 1\\n2 1\\n9\\n2 0\\n2 0\\n4 1\\n4 1\\n4 1\\n7 0\\n7 1\\n7 0\\n7 1\\n\", \"3\\n8\\n1 0\\n4 1\\n2 0\\n4 1\\n5 1\\n6 1\\n3 0\\n2 0\\n4\\n1 1\\n1 1\\n2 1\\n2 1\\n9\\n2 0\\n2 0\\n4 1\\n4 1\\n4 1\\n7 0\\n9 1\\n7 0\\n7 1\\n\",... | This problem is a version of problem D from the same contest with some additional constraints and tasks.
There are n candies in a candy box. The type of the i-th candy is a_i (1 ≤ a_i ≤ n).
You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type pres... | 0.125 |
{"tests": "{\"inputs\": [\"4\\nababcd\\nabcba\\na\\nb\\ndefi\\nfed\\nxyz\\nx\\n\", \"3\\nababc\\nabcba\\nfeded\\ndefed\\nababcfeded\\nabcdebafed\\n\", \"1\\nbbbaaaaabbabaabbbbaabbbbabbaabbaababbbbbbababbababbbaaaaaaabaababbbaababbbbababbbabbbbbabaabbaaaabaa\\nbbbababbaabbbbbaabaaabaababaaaabaabbbabbababaaabba\\n\", \"3... | You are given a string s. You can build new string p from s using the following operation no more than two times:
1. choose any subsequence s_{i_1}, s_{i_2}, ..., s_{i_k} where 1 ≤ i_1 < i_2 < ... < i_k ≤ |s|;
2. erase the chosen subsequence from s (s can become empty);
3. concatenate chosen subsequence to th... | 0 |
{"tests": "{\"inputs\": [\"5 2 3\\n1 3 2\\n2 5 0\\n3 3 3\\n\", \"4 3 2\\n1 3 3\\n3 4 6\\n\", \"1 30 2\\n1 1 32443264\\n1 1 1337\\n\", \"20 10 20\\n9 12 48\\n13 14 527\\n6 6 343\\n13 15 5\\n12 14 515\\n8 11 0\\n10 14 0\\n6 9 256\\n16 16 767\\n8 12 0\\n12 14 515\\n16 17 630\\n6 8 324\\n15 15 101\\n8 9 904\\n5 6 85\\n19 2... | You are given three integers n, k, m and m conditions (l_1, r_1, x_1), (l_2, r_2, x_2), ..., (l_m, r_m, x_m).
Calculate the number of distinct arrays a, consisting of n integers such that:
* 0 ≤ a_i < 2^k for each 1 ≤ i ≤ n;
* bitwise AND of numbers a[l_i] \& a[l_i + 1] \& ... \& a[r_i] = x_i for each 1 ≤ i ≤ m... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 2\\n2 3\\n1 3\\n4\\n1 2\\n2 3\\n3 4\\n4 2\\n5\\n1 2\\n2 3\\n1 3\\n2 5\\n4 3\\n\", \"3\\n3\\n1 2\\n2 3\\n1 3\\n4\\n1 4\\n2 3\\n3 4\\n4 2\\n5\\n1 2\\n2 3\\n1 3\\n2 5\\n4 3\\n\", \"3\\n3\\n1 2\\n2 3\\n1 3\\n4\\n1 2\\n1 3\\n3 4\\n4 2\\n5\\n1 2\\n2 3\\n1 3\\n2 5\\n4 3\\n\", \"3\\n3\\n1 2... | You are given an undirected graph consisting of n vertices and n edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.
Your task is to calculate the number of simple paths of length at leas... | 0 |
{"tests": "{\"inputs\": [\"6\\n2\\n8 12 8 12\\n2\\n7 7 9 11\\n2\\n7 11 7 11\\n1\\n1 1\\n4\\n40 56 48 40 80 56 80 48\\n6\\n240 154 210 162 174 154 186 240 174 186 162 210\\n\", \"1\\n2\\n8 12 12 12\\n\", \"1\\n2\\n10 12 12 12\\n\", \"6\\n2\\n3 12 8 12\\n2\\n7 7 9 11\\n2\\n7 11 7 11\\n1\\n1 1\\n4\\n40 56 48 40 80 56 80 4... | Long time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer 1 ≤ j ≤ 2n such that a_i = -a_j.
For each integer 1 ≤ i ≤ 2n, Nezzar wrote down an integer d_i equal to the sum of absolute d... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"2\\n\", \"972408\\n\", \"956022\\n\", \"54\\n\", \"448\\n\", \"68\\n\", \"941322\\n\", \"6\\n\", \"160\\n\", \"908550\\n\", \"635758\\n\", \"966\\n\", \"992164\\n\", \"924936\\n\", \"24\\n\", \"180\\n\", \"1000000\\n\", \"38\\n\", \"10\\n\", \"921566\\n\", \"999998\\n\", \"999994\\n... | Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not by the fear of the wolf, but by a strange, in his opinion, pattern of the forest that has n levels,... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n..+.#\\n#+..+\\n+.#+.\\n\", \"4 10\\n...+.##+.+\\n+#++..+++#\\n++.#++++..\\n.+##.++#.+\\n\", \"2 2\\n..\\n++\\n\", \"10 10\\n.+++++++++\\n+++++++++.\\n.+++++++++\\n+++++++++.\\n.+++++++++\\n+++++++++.\\n.+++++++++\\n+++++++++.\\n.+++++++++\\n+++++++++.\\n\", \"4 100\\n.++++.+++++..+++.+... | Joe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.
Joe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty cell), or has a brick or a concrete wall (always something one of three). It is believed that each f... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 1 4 3\\n4\\n1 2 0 2\\n\", \"1\\n1 2\\n3\\n0 1 1\\n\", \"2\\n1 1 3 1\\n3\\n0 1 2\\n\", \"2\\n2 1 8 3\\n4\\n1 2 0 2\\n\", \"2\\n1 1 3 1\\n3\\n0 1 0\\n\", \"2\\n2 1 4 3\\n4\\n1 2 0 0\\n\", \"1\\n1 2\\n3\\n0 0 1\\n\", \"2\\n2 1 8 1\\n4\\n1 2 0 2\\n\", \"2\\n2 1 3 1\\n3\\n0 1 0\\n\", \"2\\n2... | Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog... | 0.375 |
{"tests": "{\"inputs\": [\"6\\n\", \"20\\n\", \"99\\n\", \"27\\n\", \"35\\n\", \"12\\n\", \"56\\n\", \"61\\n\", \"38\\n\", \"24\\n\", \"22\\n\", \"15\\n\", \"55\\n\", \"8\\n\", \"2\\n\", \"72\\n\", \"62\\n\", \"51\\n\", \"7\\n\", \"34\\n\", \"82\\n\", \"49\\n\", \"32\\n\", \"0\\n\", \"19\\n\", \"95\\n\", \"16\\n\", \"8... | Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.
His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.
<image>
He ate coffee mi... | 0.5 |
{"tests": "{\"inputs\": [\"1 1 1\\n\", \"1 2 1\\n\", \"1000 1000 1000\\n\", \"4346 1611 880\\n\", \"100 100000 100000\\n\", \"2626 6150 9532\\n\", \"2390 4197 2086\\n\", \"4138 4245 30\\n\", \"3414 2092 6298\\n\", \"40000 40000 4000\\n\", \"20 12 32\\n\", \"6232 1674 3837\\n\", \"0 1 1\\n\", \"100000 100000 10\\n\", \"... | Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no two s... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 7\\n\", \"3\\n4 7 8\\n\", \"1\\n1000000000\\n\", \"2\\n948507270 461613425\\n\", \"200\\n1 2 4 10 5 8 1 10 9 10 1 9 5 5 3 10 4 7 7 1 5 10 1 6 7 3 9 3 5 8 8 9 7 3 1 5 6 7 3 3 1 4 9 2 8 7 2 10 2 1 10 9 6 1 9 5 3 5 9 3 3 2 4 9 5 9 4 8 5 6 10 1 3 10 8 6 10 10 4 6 8 4 10 7 5 2 6 6 8 8 8 10 3... | There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains ai balls, all of which have color i. You have to write a program that will divide all balls into sets such that:
* each ball belongs to exactly one of the sets,
* there are no empty sets,
* there is no set con... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0 100 0 100 0 0 0\\n100 0 100 0 0 0 100 100\\n0 0 0 100 100 0 0 0\\n100 100 0 0 0 0 100 100\\n0 100 0 100 0 0 100 0\\n100 100 100 100 100 0 0 0\\n100 0 100 0 0 100 0 0\\n100 0 100 0 100 100 100 0\\n\", \"2\\n0 21 41 26\\n79 0 97 33\\n59 3 0 91\\n74 67 9 0\\n\", \"2\\n0 40 100 100\\n60 0... | The annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, numbered from 1 to 2N. The tournament lasts N rounds, with each round eliminating half the teams. The first round consists of 2N - ... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n11010\\n00101\\n11000\\n\", \"30 2\\n010101010101010010101010101010\\n110110110110110011011011011011\\n\", \"30 10\\n001000000011000111000010010000\\n000001100001010000000000000100\\n000110100010100000000000101000\\n110000010000000001000000000000\\n100001000000000010010101000101\\n00100... | You are given an integer m.
Let M = 2m - 1.
You are also given a set of n integers denoted as the set T. The integers will be provided in base 2 as n binary strings of length m.
A set of integers S is called "good" if the following hold.
1. If <image>, then <image>.
2. If <image>, then <image>
3. <image>
... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 3\\n\", \"4\\n1 2\\n3 2\\n4 2\\n\", \"19\\n2 19\\n7 15\\n8 10\\n16 1\\n12 5\\n11 5\\n6 18\\n12 14\\n14 15\\n2 6\\n9 14\\n4 17\\n16 10\\n4 2\\n7 18\\n3 2\\n9 13\\n11 10\\n\", \"24\\n19 14\\n8 15\\n13 4\\n18 16\\n1 17\\n10 3\\n22 21\\n10 14\\n6 11\\n9 12\\n15 22\\n11 3\\n21 7\\n2 12... | The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.
The Galaxy contains N planets, connected by bidirectional hyperspace tunnels i... | 0 |
{"tests": "{\"inputs\": [\"5\\nhello\\nhi hello hi\\ndef\\nabc def\\njava\\npython\\nc\\ncplusplus\\nhellohi\\nhellotherehi\\n\\nSAMPLE\", \"5\\nlehlo\\nhi hello hi\\ndef\\nabc def\\njava\\npython\\nc\\ncplusplus\\nhellohi\\nhellotherehi\\n\\nSAMPLE\", \"5\\nlehlo\\nhi olleh hi\\ndef\\nabc fed\\naavj\\npython\\nc\\ncpl... | Ed, Edd and Eddy are given an art homework. They have to prepare a banner and print a single line of text on it. They can print any text they want. Ed has decided the text that he wants to put on his banner. Lets call it string s1. But he is too lazy to make a new banner all by himself. He borrows an old banner from ... | 0.25 |
{"tests": "{\"inputs\": [\"3 3\\n1 1 1\\n2 2 2\\n3 1 5\\n\\nSAMPLE\", \"3 3\\n1 1 1\\n2 2 3\\n3 1 5\\n\\nSAMPLE\", \"3 3\\n1 1 1\\n2 2 1\\n6 1 5\\n\\nSAMPLE\", \"2 3\\n1 2 1\\n1 2 1\\n6 1 5\\n\\nSAMPLE\", \"3 2\\n1 1 1\\n2 4 2\\n3 1 5\\n\\nSAMQEL\", \"3 3\\n1 0 1\\n2 2 -1\\n6 2 5\\n\\nSAMPLE\", \"3 2\\n1 1 0\\n2 4 2\\n... | You want to repaint your house entirely for an upcoming occasion. The total area of your house is D units. There are a total of N workers. The i^th worker has his available time Ti, hiring cost Xi and speed Yi. This means that he is available for hiring from time Ti and remains available ever since. Once available, yo... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n1 2 3 2 1\\n2 1 5\\n3 2 3\\n1 3 1\\n2 2 4\\n3 1 3\", \"5 5\\n1 2 3 2 1\\n2 1 5\\n3 2 3\\n1 3 1\\n2 2 4\\n3 1 0\", \"5 3\\n1 2 3 2 1\\n2 1 5\\n3 2 3\\n1 3 1\\n2 2 4\\n3 1 0\", \"5 1\\n1 2 3 2 1\\n2 0 5\\n3 2 3\\n1 1 2\\n2 2 4\\n3 1 0\", \"5 5\\n1 2 1 2 1\\n2 1 5\\n3 2 3\\n1 3 1\\n2 2 4\\... | You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.
The type of i-th query is represented by T_i.
* T_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.
* T_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},... | 0.375 |
{"tests": "{\"inputs\": [\"11 97\\n3 1 4 1 5 9 2 6 5 3 5\", \"5 10\\n1 2 3 2 3\", \"6 1000000000000\\n1 1 2 2 3 3\", \"3 2\\n1 2 3\", \"5 10\\n1 3 3 2 3\", \"6 1000000000000\\n1 2 2 2 3 3\", \"6 1000000000000\\n1 2 2 4 3 3\", \"11 97\\n3 2 4 1 5 9 2 6 5 3 5\", \"6 1000000000000\\n1 1 2 4 3 3\", \"11 97\\n0 2 4 1 5 9 2 ... | We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds.
Snuke has an integer sequence s, which is initially empty... | 0.375 |
{"tests": "{\"inputs\": [\"10\\n66 47 71040136000\\n65 77 74799603000\\n80 53 91192869000\\n24 34 24931901000\\n91 78 49867703000\\n68 71 46108236000\\n46 73 74799603000\\n56 63 93122668000\\n32 51 71030136000\\n51 26 70912345000\\n21\\nL 51 1\\nL 7 0\\nU 47 4\\nR 92 0\\nR 91 1\\nD 53 2\\nR 65 3\\nD 13 0\\nU 63 3\\nL 6... | A museum exhibits N jewels, Jewel 1, 2, ..., N. The coordinates of Jewel i are (x_i, y_i) (the museum can be regarded as a two-dimensional plane), and the value of that jewel is v_i.
Snuke the thief will steal some of these jewels.
There are M conditions, Condition 1, 2, ..., M, that must be met when stealing jewels,... | 0.75 |
{"tests": "{\"inputs\": [\"4 3\\n.S.\\n.o.\\n.o.\\n.T.\", \"3 4\\nS...\\n.oo.\\n...T\", \"3 3\\nS.o\\n.o.\\no.T\", \"10 10\\n.o...o..o.\\n....o.....\\n....oo.oo.\\n..oooo..o.\\n....oo....\\n..o..o....\\no..o....So\\no....T....\\n....o.....\\n........oo\", \"2 3\\nS.o\\n.o.\\no.T\", \"4 3\\n.S.\\no..\\n.o.\\n.T.\", \"9 ... | There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j).
Some of the squares in the pond contains a lotus leaf floating on the water. On one of those leaves, S, there ... | 0 |
{"tests": "{\"inputs\": [\"2\\n0\\n10\\n20\\n30\", \"3\\n3\\n10\\n8\\n7\\n12\\n5\", \"2\\n0\\n10\\n20\\n34\", \"3\\n3\\n10\\n8\\n7\\n0\\n10\", \"3\\n3\\n10\\n8\\n7\\n0\\n0\", \"3\\n3\\n10\\n8\\n7\\n2\\n5\", \"2\\n0\\n10\\n20\\n68\", \"3\\n3\\n10\\n8\\n7\\n1\\n5\", \"2\\n1\\n10\\n20\\n68\", \"3\\n3\\n10\\n8\\n7\\n0\\n5\... | There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct.
Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to onl... | 0 |
{"tests": "{\"inputs\": [\"1\\n6 9 9 9 9\\n5\\n5 9 5 5 9\\n5 5 6 9 9\\n4 6 3 6 9\\n3 3 2 9 9\\n2 2 1 1 1\\n10\\n3 5 6 5 6\\n2 2 2 8 3\\n6 2 5 9 2\\n7 7 7 6 1\\n4 6 6 4 9\\n8 9 1 1 8\\n5 6 1 8 1\\n6 8 2 1 2\\n9 6 3 3 5\\n5 3 8 8 8\\n5\\n1 2 3 4 5\\n6 7 8 9 1\\n2 3 4 5 6\\n7 8 9 1 2\\n3 4 5 6 7\\n3\\n2 2 8 7 4\\n6 5 7 7 ... | Chain Disappearance Puzzle
We are playing a puzzle. An upright board with H rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the... | 0 |
{"tests": "{\"inputs\": [\"4\\n6 4\\nC E D# F G A\\nC E F G\\n6 4\\nC E D# F G A\\nC D# F G\\n3 6\\nC D D\\nD# B D B D# C#\\n8 8\\nC B B B B B F F\\nC B B B B B B B\", \"4\\n6 4\\nC E D# E G A\\nC E F G\\n6 4\\nC E D# F G A\\nC D# F G\\n3 6\\nC D D\\nD# B D B D# C#\\n8 8\\nC B B B B B F F\\nC B B B B B B B\", \"4\\n6 4... | An angel lives in the clouds above the city where Natsume lives. The angel, like Natsume, loves cats and often comes down to the ground to play with cats. To get down to the ground, the angel made a long, long staircase leading from the clouds to the ground. However, the angel thought that it would be boring to just go... | 0 |
{"tests": "{\"inputs\": [\"5 2 3\\n3\\n5\\n1\\n2\\n3\\n3 100 100\\n3\\n3\\n4\\n20 3 8\\n3\\n2\\n6\\n1\\n9\\n1\\n8\\n4\\n2\\n2\\n8\\n1\\n8\\n8\\n2\\n5\\n3\\n4\\n3\\n8\\n7 2 2\\n0\\n2\\n5\\n2\\n5\\n2\\n1\\n0 0 0\", \"5 2 3\\n3\\n5\\n1\\n2\\n3\\n3 100 100\\n3\\n3\\n4\\n20 3 8\\n3\\n2\\n6\\n1\\n9\\n1\\n8\\n4\\n2\\n2\\n8\\n... | coastline
Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T), a wave from point P to the point exactly xi m rushes in i second... | 0 |
{"tests": "{\"inputs\": [\"?&?|?&?|?&?\", \"?&?&?|?|?&?\", \"?|?&?|?&?&?\", \"?&?&?|?&?|?\", \"?&?|?|?&?&?\", \"?|?|?&?&?&?\", \"?&?&?&?|?|?\", \"?|?&?&?|?&?\", \"?&?|?&?&?|?\", \"?|?|?&?&??&\", \"?|?&?&?&?|?\", \"?|?&?|?&??&\", \"?&?|?|?&??&\", \"?|?|?&??&?&\", \"?|?|?&?&?&?\", \"?&?&?&?|?|?\", \"?|?&?&?|?&?\", \"?&?|... | C: Short-circuit evaluation
problem
Naodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF.
<formula> :: = <or-expr>
<or-expr> :: = <and-expr>
| <or-expr> "|" <and-expr>
<and-expr> :: = <term>
| <and-expr> "&" <term>
<term> :: =... | 0 |
{"tests": "{\"inputs\": [\"1\\n5 6\\n\", \"4\\n1 2\\n2 1\\n3 5\\n5 3\\n\", \"3\\n1 1\\n1 1\\n1 1\\n\", \"10\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000000\\n1000000000 1000000... | You invited n guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles.
Your guests happen to be a little bit shy, so the i-th guest wants to have a least l_i free chairs to the left of his chair, and a... | 0 |
{"tests": "{\"inputs\": [\"4\\nGGGG\\n\", \"10\\nGGGSGGGSGG\\n\", \"3\\nSSS\\n\", \"11\\nSSGSSGGGSSG\\n\", \"10\\nSGGGSSGGSS\\n\", \"10\\nGSGSGSGSGG\\n\", \"6\\nGSSGGG\\n\", \"32\\nGSGSSGGSGGSGGSGGSGGSGSGGSSSGGGGG\\n\", \"11\\nGSSSGGGGGGG\\n\", \"4\\nGGGS\\n\", \"100\\nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS... | Vova has won n trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row.
The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two trophies (not necessarily adjacent ones) to make the arrangement as ... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n1 1 1\\n5\\n2 3 1 2 2\\n\", \"2\\n3\\n1 1 1\\n5\\n2 3 1 2 4\\n\", \"2\\n3\\n1 1 1\\n5\\n2 3 1 1 2\\n\", \"2\\n3\\n1 2 2\\n5\\n2 3 1 2 2\\n\", \"2\\n3\\n1 2 2\\n5\\n2 1 1 2 2\\n\", \"2\\n3\\n1 1 1\\n5\\n2 4 2 2 4\\n\", \"2\\n3\\n1 1 1\\n5\\n1 1 1 1 2\\n\", \"2\\n3\\n1 1 1\\n5\\n2 3 1 2... | Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possible. Russell was trying to form groups, but ran into some difficulties...
Most of the young explorer... | 0 |
{"tests": "{\"inputs\": [\"5\\n4 -5 9 -2 1\\n\", \"4\\n5 6 7 8\\n\", \"5\\n-56 101 87 0 -24\\n\", \"6\\n72 91 46 -72 -36 -25\\n\", \"9\\n286474128 -767346318 14465977 -736068092 594841463 -281215614 214724210 -313802706 43797330\\n\", \"5\\n9 3 7 4 6\\n\", \"10\\n41 6 -34 98 -68 108 -109 -32 -30 33\\n\", \"5\\n2 -86 61... | While playing yet another strategy game, Mans has recruited n [Swedish heroes](https://www.youtube.com/watch?v=5sGOwFVUU0I), whose powers which can be represented as an array a.
Unfortunately, not all of those mighty heroes were created as capable as he wanted, so that he decided to do something about it. In order to ... | 0 |
{"tests": "{\"inputs\": [\"3\\n7\\n1 4 2 2 2 2 2\\n2\\n2 3\\n5\\n1 1 1 1 1\\n\", \"1\\n1\\n69\\n\", \"1\\n1\\n67\\n\", \"3\\n7\\n2 4 2 2 2 2 2\\n2\\n2 3\\n5\\n1 1 1 1 1\\n\", \"1\\n1\\n12\\n\", \"3\\n7\\n2 4 2 2 2 2 2\\n2\\n2 3\\n5\\n1 1 1 2 1\\n\", \"1\\n1\\n9\\n\", \"1\\n1\\n14\\n\", \"1\\n1\\n26\\n\", \"1\\n1\\n108\... | There is a trampoline park with n trampolines in a line. The i-th of which has strength S_i.
Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice.
If at the moment Pekora jumps on trampoline i, the trampoline will launch her to position i + S_i, and S_i wi... | 0 |
{"tests": "{\"inputs\": [\"2 2 2\\n\", \"5 6 7\\n\", \"55 45 45\\n\", \"21 16 9\\n\", \"91 96 36\\n\", \"44 18 24\\n\", \"60 8 35\\n\", \"4 9 20\\n\", \"100 9 88\\n\", \"4 21 45\\n\", \"18 86 27\\n\", \"76 12 17\\n\", \"63 90 23\\n\", \"64 12 36\\n\", \"82 29 45\\n\", \"13 31 33\\n\", \"36 3 32\\n\", \"68 14 28\\n\", \... | Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:
<image>
Find the sum modulo 1073741824 (230).
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 100).
Output
Print a singl... | 0.5 |
{"tests": "{\"inputs\": [\"3 2 2 2\\n\", \"3 3 2 2\\n\", \"3 0 2 2\\n\", \"4 2 2 1\\n\", \"4 3 2 1\\n\", \"6 3 1 1\\n\", \"6 1 2 2\\n\", \"7 12 2 2\\n\", \"3 1 1 1\\n\", \"8 664 100 100\\n\", \"10 189 44 100\\n\", \"7 4 1 2\\n\", \"5 4 3 2\\n\", \"5 2 1 1\\n\", \"3 2 3 1\\n\", \"48 512559680 100 100\\n\", \"5 1 2 2\\n\... | Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve (we Russians actually expect Santa for the New Year, not for Christmas).
... | 0 |
{"tests": "{\"inputs\": [\"3 2 5\\nabrakadabra\\n\", \"4 1 2\\nabrakadabra\\n\", \"10 1 200\\nolahgjusovchbowjxtwzvjakrktyjqcgkqmcxknjchzxcvbnkbakwnxdouebomyhjsrfsicmzsgdweabbuipbzrhuqfpynybaohzquqbbsqpoaskccszzsmnfleevtasmjuwqgcqtvysohvyutqipnvuhjumwwyytkeuebbncxsnpavwdkoxyycqrhcidf\\n\", \"15 2 5\\nkddainaviqrjsesrhh... | Anfisa the monkey learns to type. She is yet unfamiliar with the "space" key and can only type in lower-case Latin letters. Having typed for a fairly long line, Anfisa understood that it would be great to divide what she has written into k lines not shorter than a and not longer than b, for the text to resemble human s... | 0 |
{"tests": "{\"inputs\": [\"9435152 272\\n\", \"21 5\\n\", \"10 10\\n\", \"325508499 119510657\\n\", \"233758336 10665466\\n\", \"124 24\\n\", \"2 0\\n\", \"49106 46\\n\", \"77 75\\n\", \"257424 24\\n\", \"944387968 700818251\\n\", \"121 0\\n\", \"89768760 885778845\\n\", \"5 2\\n\", \"1 10\\n\", \"997920 0\\n\", \"1 0\... | Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by <image>. A Modular Equation, as Hamed's teacher described, is an equation of the form <image> in which a and b are two non-negative integers a... | 0 |
{"tests": "{\"inputs\": [\"e4\\n\", \"h2\\n\", \"h5\\n\", \"f2\\n\", \"b1\\n\", \"h1\\n\", \"h4\\n\", \"d8\\n\", \"h3\\n\", \"h6\\n\", \"a4\\n\", \"c7\\n\", \"e8\\n\", \"a2\\n\", \"g8\\n\", \"b8\\n\", \"g7\\n\", \"e1\\n\", \"f8\\n\", \"b2\\n\", \"c8\\n\", \"a8\\n\", \"h8\\n\", \"a1\\n\", \"e2\\n\", \"a3\\n\", \"d7\\n\"... | The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.
Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).
<image> King moves from the posi... | 0.75 |
{"tests": "{\"inputs\": [\"ares\\n\", \"zeus\\n\", \"map\\n\", \"nnnnnnnnnnnnnnnnnnnnaaaaaaaaaaaaaaaaaaaakkkkkkkkkkkkkkkkkkkkkkaaaaaaaaaaaaaaaaaaaaxxxxxxxxxxxxxxxxxx\\n\", \"dbvnkktasjdwqsrzfwwtmjgbcxggdxsoeilecihduypktkkbwfbruxzzhlttrssicgdwqruddwrlbtxgmhdbatzvdxbbro\\n\", \"uhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhu... | Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character... | 0.625 |
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"5\\n2 1 5 3 3\", \"3 1\\n2 3\\n\", \"2 0\\n\", \"3 0\\n\", \"4 3\\n3 1\\n1 2\\n2 4\\n\", \"1 0\\n\", \"18 2\\n9 17\\n1 18\\n\", \"3 2\\n1 2\\n2 3\\n\", \"5 4\\n1 2\\n1 3\\n1 4\\n3 5\\n\", \"10000 1\\n1725 10000\\n\", \"5 1\\n4 5\\n\", \"5 4\\n1 3\\n1 4\\n4 2\\n5 2\\n\", \"2 1\\n... | PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.
There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For e... | 0 |
{"tests": "{\"inputs\": [\"1\\n#define sum x + y\\n1 * sum\\n\", \"4\\n#define sum x + y\\n#define mul a * b\\n#define div a / b\\n#define expr sum + mul * div * mul\\nexpr\\n\", \"1\\n#define sum (x + y)\\nsum - sum\\n\", \"3\\n#define SumSafe (a+b)\\n#define DivUnsafe a/b\\n#define DenominatorUnsafe a*b\\n((S... | Most C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use.
In this problem we consider the following model of #define constructions (also called macros). Each macro has its name and value. T... | 0 |
{"tests": "{\"inputs\": [\"1 5\\n\", \"2 3\\n\", \"987 4237\\n\", \"417 1045\\n\", \"817 3719\\n\", \"22 3481\\n\", \"939 407\\n\", \"841 7185\\n\", \"446 5030\\n\", \"1000 10000\\n\", \"4 6\\n\", \"494 6155\\n\", \"10 1\\n\", \"969 6030\\n\", \"918 7704\\n\", \"393 4874\\n\", \"20 10\\n\", \"174 2688\\n\", \"646 1171\... | Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other point... | 0 |
{"tests": "{\"inputs\": [\"5\\n01\\n10\\n101\\n11111\\n0\\n3\\n1 2\\n6 5\\n4 4\\n\", \"2\\n1\\n0\\n40\\n1 2\\n3 3\\n4 4\\n5 5\\n6 6\\n7 7\\n8 8\\n9 9\\n10 10\\n11 11\\n12 12\\n13 13\\n14 14\\n15 15\\n16 16\\n17 17\\n18 18\\n19 19\\n20 20\\n21 21\\n22 22\\n23 23\\n24 24\\n25 25\\n26 26\\n27 27\\n28 28\\n29 29\\n30 30\\n... | You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation saisbi is saved into a new string sn + i (the operations are numbered starting from 1). After each operation ... | 0.25 |
{"tests": "{\"inputs\": [\"QAQAQYSYIOIWIN\\n\", \"QAQQQZZYNOIWIN\\n\", \"W\\n\", \"AAQXAAQAYQAAAAGAQHVQYAGIVACADFAAQAAAAQZAAQMAKZAADQAQDAAQDAAAMQQOXYAQQQAKQBAAQQKAXQBJZDDLAAHQQ\\n\", \"QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\\n\", \"AQEGQHQQKQAQQPQKAQQQAAAAQQ... | "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond is so cute!).
<image> illustration by 猫屋 https://twitter.com/nekoy... | 0.25 |
{"tests": "{\"inputs\": [\"3 4\\n1 2\\n2 3\\n3 2\\n3 1\\n\", \"5 6\\n1 2\\n2 3\\n3 2\\n3 1\\n2 1\\n4 5\\n\", \"3 4\\n1 2\\n2 1\\n1 3\\n3 1\\n\", \"4 6\\n1 2\\n2 4\\n2 3\\n3 1\\n4 3\\n3 2\\n\", \"4 5\\n1 2\\n2 4\\n2 3\\n3 1\\n4 3\\n\", \"9 12\\n1 2\\n2 3\\n2 4\\n4 5\\n3 5\\n5 6\\n6 7\\n6 8\\n7 9\\n8 9\\n9 1\\n3 6\\n\", ... | You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.
Can you make this graph [acyclic](https://en.wikipedia.org/wiki/Directed_acyclic... | 0.75 |
{"tests": "{\"inputs\": [\"2\\n1 3\\n\", \"3\\n1 1 2\\n\", \"7\\n177679021 237356752 791250000 455912656 693129227 678510224 60382864\\n\", \"1\\n364489807\\n\", \"1\\n194945396\\n\", \"3\\n855856619 518546431 920370158\\n\", \"4\\n1 1 8 10\\n\", \"9\\n25401015 88843847 702650194 306965770 57623156 571088345 835502151 ... | You are given an array a of length n. We define fa the following way:
* Initially fa = 0, M = 1;
* for every 2 ≤ i ≤ n if aM < ai then we set fa = fa + aM and then set M = i.
Calculate the sum of fa over all n! permutations of the array a modulo 109 + 7.
Note: two elements are considered different if their i... | 0 |
{"tests": "{\"inputs\": [\"10\\n19 8 17 20 13 2 3 20 30 40\\n10\\n1\\n1\\n1\\n2\\n2\\n2\\n40\\n30\\n10\\n10\", \"10\\n19 8 17 20 13 2 3 20 30 75\\n10\\n1\\n1\\n1\\n2\\n2\\n2\\n40\\n30\\n10\\n10\", \"10\\n19 10 17 20 13 2 3 20 30 75\\n10\\n1\\n1\\n1\\n2\\n2\\n2\\n40\\n30\\n10\\n10\", \"10\\n19 10 17 20 13 2 3 20 30 75\\... | Little Deepu loves positive things in life, positive girlfriends, positive marks. He's, in general a lover of positive things, so for obvious reasons he loves an array which contains positive elements.
Anyway, Little Deepu also thinks that not every value in his so called positive array deserves to be valued so high, ... | 0.875 |
{"tests": "{\"inputs\": [\"3 3 3\\n0 0 0\\n1 0 1\\n0 1 1\\n1 2\\n2 2\\n3 3\\n\\nSAMPLE\", \"3 3 3\\n0 0 0\\n1 0 1\\n0 1 1\\n1 1\\n2 2\\n3 3\\n\\nSAMPLE\", \"3 3 3\\n0 0 0\\n1 0 1\\n1 1 1\\n1 2\\n2 2\\n3 3\\n\\nSAMPLE\", \"3 3 3\\n0 0 1\\n1 0 1\\n1 1 1\\n1 2\\n2 2\\n3 3\\n\\nSAMPLE\", \"3 3 3\\n0 0 0\\n1 0 1\\n0 1 1\\n1... | An intergallactic war is on. Aliens are throwing fire-balls at our planet and this fire is so deadly that whichever nation it hits, it will wipe out not only that nation, but also spreads to any other nation which lies adjacent to it.
Given an NxM map which has N x M cells. Each cell may have a country or else it may... | 0.125 |
{"tests": "{\"inputs\": [\"4 2\\n1 2 -3 -4\", \"10 10\\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\", \"4 3\\n-1 -2 -3 -4\", \"2 1\\n-1 1000000000\", \"4 2\\n1 2 -3 0\", \"10 2\\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\", \"4 3\\n-1 -3 -3 -4\", \"3 1\\n-1 1000000000\", \"4... | Given are N integers A_1,\ldots,A_N.
We will choose exactly K of these elements. Find the maximum possible product of the chosen elements.
Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).
Constraints
* 1 \leq K \leq N \leq 2\times 10^5
* |A_i| \leq 10^9
Input
Inp... | 0 |
{"tests": "{\"inputs\": [\"2 2 4\", \"12 21 10\", \"3 1 8\", \"2 4 4\", \"12 30 10\", \"3 2 8\", \"5 30 10\", \"3 4 8\", \"2 30 10\", \"3 4 3\", \"2 18 10\", \"2 18 18\", \"2 18 26\", \"2 18 6\", \"2 18 2\", \"2 4 5\", \"15 21 10\", \"3 1 14\", \"12 30 9\", \"1 2 8\", \"5 30 14\", \"3 7 8\", \"2 9 10\", \"2 16 18\", \"... | Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)
We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.
Whe... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n.#.\\n..#\\n#..\", \"4 3\\n\\n\\n...\", \"3 3\\n.#.\\n..#\\n..\", \"2 4\\n....\\n....\", \"3 4\\n.#.\\n..#\\n#..\", \"4 4\\n\\n\\n...\", \"3 3\\n.#.\\n-.#\\n..\", \"3 4\\n.#.\\n..#\\n#./\", \"3 2\\n.#.\\n-.#\\n..\", \"3 1\\n.#.\\n..#\\n#./\", \"3 2\\n.#.\\n#.-\\n..\", \"4 2\\n.#.\\n#.-\... | There is a grid with H rows and W columns, where each square is painted black or white.
You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is `#`; if that square is painted whi... | 0 |
{"tests": "{\"inputs\": [\"4 2 2 2\\n3\\n3 2\\n5 3\\n2 4\", \"1 1 6 5\\n3\\n3 2\\n5 3\\n2 4\", \"3 5 6 4\\n3\\n3 2\\n5 3\\n2 4\", \"4 2 2 2\\n3\\n3 0\\n5 3\\n2 4\", \"0 1 6 5\\n3\\n3 2\\n5 3\\n2 4\", \"3 5 6 5\\n3\\n3 2\\n5 3\\n2 4\", \"0 1 6 8\\n3\\n3 2\\n5 3\\n2 4\", \"3 1 6 5\\n3\\n3 4\\n5 3\\n2 4\", \"4 2 2 2\\n3\\... | In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1. All streets run straight from west to east, and all avenues run straight from south to north. The distance between neighboring streets and between neighboring avenues is exactly 100 meters.
Every street intersects every ... | 0 |
{"tests": "{\"inputs\": [\"D D\", \"H H\", \"D H\", \"H I\", \"E H\", \"I H\", \"F H\", \"G H\", \"J H\", \"H J\", \"H G\", \"H K\", \"H F\", \"H L\", \"H E\", \"K H\", \"H D\", \"C H\", \"H M\", \"L H\", \"H C\", \"B H\", \"M H\", \"H B\", \"A H\", \"N H\", \"O H\", \"H A\", \"H N\", \"H O\", \"H P\", \"@ H\", \"? H\"... | Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information:
If a=`H`, AtCoDe... | 0.625 |
{"tests": "{\"inputs\": [\"4\\nsandwich 80 120\\napple 50 200\\ncheese 20 40\\ncake 100 100\\n9\\nonigiri 80 300\\nonigiri 80 300\\nanpan 70 280\\nmikan 50 80\\nkanzume 100 500\\nchocolate 50 350\\ncookie 30 80\\npurin 40 400\\ncracker 40 160\\n0\", \"4\\nsandwich 80 120\\napple 50 200\\ncheese 20 40\\ncake 100 100\\n9... | I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't fall over, but some foods are soft and will collapse if I put a heav... | 0.25 |
{"tests": "{\"inputs\": [\"5 3\\n1 5 2\\n3 8 5\\n1 2 3\\n5 5 5\\n4 8 2\\n0\\n1 2 3\\n2\\n2 2 3 1\\n4 3 1 2\", \"5 2\\n1 1\\n2 1\\n3 1\\n4 4\\n5 2\\n3\\n1 4\\n2 4\\n2 5\\n1 2\\n1\\n3 2 1\", \"5 3\\n1 5 2\\n3 8 5\\n1 2 3\\n5 5 5\\n4 8 2\\n0\\n1 2 3\\n1\\n2 2 3 1\\n4 3 1 2\", \"5 2\\n1 1\\n2 1\\n6 1\\n4 4\\n5 2\\n3\\n1 4\... | You are working on the development of the unique operating system "Unsgune 15" and are struggling to design a scheduler that determines performance. A scheduler is a program that expresses the processes to be executed in units called tasks and determines the order in which they are executed. The scheduler manages tasks... | 0.25 |
{"tests": "{\"inputs\": [\"3\\nA sample input\\n9\\nforward word\\ndelete char\\nforward word\\ndelete char\\nforward word\\ndelete char\\nbackward word\\nbackward word\\nforward word\\nHallow, Word.\\n7\\nforward char\\ndelete word\\ninsert \\\"ello, \\\"\\nforward word\\nbackward char\\nbackward char\\ninsert \\\"l\\... | A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the text obtained by perfor... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 10\\n2 3 10\\n3 3 10\\n1 3 10\\n6\\n1 20 1000\\n3 25 10000\\n5 15 5000\\n22 300 5500\\n10 295 9000\\n7 7 6000\\n8\\n32 251 2261\\n123 281 1339\\n211 235 5641\\n162 217 7273\\n22 139 7851\\n194 198 9190\\n119 274 878\\n122 173 8640\\n0\", \"4\\n1 2 10\\n2 3 10\\n3 3 10\\n1 3 10\\n6\\n1... | You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms are of the same size and arrangement... | 0 |
{"tests": "{\"inputs\": [\"((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]()))\", \"((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]()*)\", \"((()[8]())[2]())[5](((()[3]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]())... | C --Misawa's rooted tree
Problem Statement
You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1)
* Each vertex has exactly one vertex called the parent of that vertex, which is c... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n2 1\\n\", \"3 10\\n4 6 8\\n2 2 3\\n\", \"2 1000000000\\n99999999 1000000000\\n1 1\\n\", \"2 2\\n4 5\\n1 2\\n\", \"2 1000000000\\n999999999 1000000000\\n1 2\\n\", \"2 1000000000\\n1 1000000000\\n2 2\\n\", \"2 10\\n4 5\\n2 2\\n\", \"2 1000000000\\n99999999 1000100000\\n1 1\\n\", \"2... | There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the route.
At each station one can find a sorted list of moments of time when a... | 0 |
{"tests": "{\"inputs\": [\"4 6 2\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n\", \"10 18 2\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n1 10\\n2 3\\n3 4\\n2 4\\n5 6\\n6 7\\n5 7\\n8 9\\n9 10\\n8 10\\n\", \"15 34 1\\n1 8\\n2 8\\n3 8\\n4 8\\n5 8\\n6 8\\n7 8\\n9 8\\n10 8\\n11 8\\n12 8\\n13 8\\n14 8\\n15 8\\n1 9\\n3 9\\n5 9\... | Today is tuesday, that means there is a dispute in JOHNNY SOLVING team again: they try to understand who is Johnny and who is Solving. That's why guys asked Umnik to help them. Umnik gave guys a connected graph with n vertices without loops and multiedges, such that a degree of any vertex is at least 3, and also he gav... | 0 |
{"tests": "{\"inputs\": [\"6\\nLRU\\nDURLDRUDRULRDURDDL\\nLRUDDLRUDRUL\\nLLLLRRRR\\nURDUR\\nLLL\\n\", \"6\\nLRU\\nDURLDRUDRULRDURDDL\\nLRUDDLRUDRUL\\nLLLLRRRR\\nURDUR\\nLLL\\n\", \"6\\nLRU\\nDURLDRUDRULRDURDDL\\nLURDURLDDURL\\nLLLLRRRR\\nURDUR\\nLLL\\n\", \"6\\nLRU\\nLDDRUDRLURDURDLRUD\\nLURDURLDDURL\\nLLLLRRRR\\nURDUR... | Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid.
You also have the sequence of instructions of this robot. It is written as the string s consisting of characters 'L', 'R', 'U' and 'D'. If the robot is in the cell (x, y) right now, he can move to... | 0 |
{"tests": "{\"inputs\": [\"????\\n\", \"1?1\\n\", \"1010\\n\", \"0011000100000011110100010001110011101011111100111111101010110111100100110100110110000010111111?0110100010010011001010111000101100100111010110110110011001010011011001001000101000010000011101011110110011000111110110101010001101101011011110110100011010000001... | Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him.
Before the very beginning of the game several cards are lain out on a table in one line from the left to the right. Each card c... | 0 |
{"tests": "{\"inputs\": [\"5\\n()\\n(?)\\n(??)\\n??()\\n)?(?\\n\", \"5\\n()??\\n()??\\n()??\\n()??\\n()??\\n\", \"12\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n\", \"1\\n???????????????????()???????????????????\\n\", \"12\\n()\\n()\\n()\\n()\\n(????????)\\n(?)\\n()\\n()\\n()\\... | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a regular bracket sequence "RBS".
You are given a sequence s of n c... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n5 6\\n-1 1 5 11 15\\n-4 -3 -2 6 7 15\\n2 2\\n-1 1\\n-1000000000 1000000000\\n2 2\\n-1000000000 1000000000\\n-1 1\\n3 5\\n-1 1 2\\n-2 -1 1 2 5\\n2 1\\n1 2\\n10\\n\", \"1\\n2 4\\n-2 -1\\n-7 -5 -2 -1\\n\", \"1\\n10 10\\n-963625377 -868027420 -582832806 -399654630 -299751944 -233765513 -22076... | You are playing a game similar to Sokoban on an infinite number line. The game is discrete, so you only consider integer positions on the line.
You start on a position 0. There are n boxes, the i-th box is on a position a_i. All positions of the boxes are distinct. There are also m special positions, the j-th position... | 0 |
{"tests": "{\"inputs\": [\"512\\n\", \"256\\n\", \"39210\\n\", \"187719774\\n\", \"999999190\\n\", \"15\\n\", \"999999940\\n\", \"828\\n\", \"3761248\\n\", \"296798673\\n\", \"18\\n\", \"5\\n\", \"85\\n\", \"11\\n\", \"82\\n\", \"7\\n\", \"80\\n\", \"934\\n\", \"41\\n\", \"816761542\\n\", \"3\\n\", \"895\\n\", \"10\\n\... | As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as <image>, where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.
A well-known hipster Andrew adores everything funky ... | 0 |
{"tests": "{\"inputs\": [\"2 3 4\\n\", \"3 2 2\\n\", \"789 894 2\\n\", \"384 458 284\\n\", \"7 8 13\\n\", \"485 117 521\\n\", \"3 3 3\\n\", \"1000 1000 1000\\n\", \"7 23 595\\n\", \"2 2 2\\n\", \"1000 2 2\\n\", \"1000 2 1000\\n\", \"201 108 304\\n\", \"38 291 89\\n\", \"2 3 3\\n\", \"2 1000 2\\n\", \"48 38 193\\n\", \"... | Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles.
The hall also turned out hexagonal in its shape. The King walked along the perimeter of ... | 0.875 |
{"tests": "{\"inputs\": [\"-10 5\\n\", \"10 5\\n\", \"-1000000000 -1\\n\", \"20 -10\\n\", \"1 1\\n\", \"1000000000 1000000000\\n\", \"-1000000000 -1000000000\\n\", \"1 -1\\n\", \"42 -2\\n\", \"76 -76\\n\", \"-1000000000 -999999999\\n\", \"1000000000 -1\\n\", \"-1 -1\\n\", \"-23423 -243242423\\n\", \"1000000000 1\\n\", ... | Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you t... | 0.25 |
{"tests": "{\"inputs\": [\"W|T\\nF\\n\", \"AC|T\\nL\\n\", \"ABC|\\nD\\n\", \"|ABC\\nXYZ\\n\", \"CKQHRUZMISGE|FBVWPXDLTJYN\\nOA\\n\", \"V|CMOEUTAXBFWSK\\nDLRZJGIYNQHP\\n\", \"|ABC\\nD\\n\", \"|C\\nA\\n\", \"|\\nA\\n\", \"|FGRT\\nAC\\n\", \"A|BCDEF\\nGH\\n\", \"QWHNMALDGKTJ|\\nPBRYVXZUESCOIF\\n\", \"EQJWDOHKZRBISPLXUYVCM... | Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium.
The scales is in equilibrium ... | 0.75 |
{"tests": "{\"inputs\": [\"3 3\\n3 7 14\\n1 5\\n6 10\\n11 15\\n\", \"3 4\\n1 2 3\\n1 2\\n2 3\\n5 6\\n2 2\\n\", \"2\\n0 2\\n2 3\\n\", \"3\\n1 3\\n1 2\\n2 3\\n\", \"6\\n1 5\\n1 3\\n3 5\\n2 10\\n11 11\\n12 12\\n\", \"3 1\\n1 2 3\\n2 3\\n\", \"10\\n1 10\\n4 10\\n4 9\\n1 8\\n6 10\\n3 10\\n4 5\\n0 2\\n2 3\\n4 7\\n\", \"3 3\\... | Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segme... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n><>\\nv^v\\n\", \"4 6\\n<><>\\nv^v^v^\\n\", \"2 3\\n<>\\nv^^\\n\", \"20 20\\n<><><><><><><><><><>\\nvvvvvvvvvvvvvvvvvvvv\\n\", \"2 2\\n><\\nv^\\n\", \"19 18\\n><><>>><<<<<>>><<<>\\n^^v^^v^^v^vv^v^vvv\\n\", \"20 20\\n<>>>>>>>><>>><>><<<>\\nvv^^vv^^^^v^vv^v^^^^\\n\", ... | 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\": [\"2\\n\\n3 4\\n2 3 2 1\\n1 0\\n0 0\\n\\n5 5\\n1 2 1 3 1\\n3 0\\n0 0\\n2 1\\n4 0\\n\", \"4\\n\\n2 1\\n42\\n0 0\\n\\n2 1\\n2\\n0 0\\n\\n2 1\\n42\\n1 0\\n\\n2 1\\n2\\n1 0\\n\", \"5\\n\\n3 3\\n1 1 1\\n0 0\\n0 1\\n\\n3 3\\n1 1 1\\n1 0\\n2 1\\n\\n3 3\\n1 1 1\\n1 0\\n0 1\\n\\n3 3\\n1 1 1\\n0 0\\n1 0\\... | Polycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sitting on seat m, that means, he will be the m-th person to get food.
The flight menu has k dishes in t... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n-1 0\\n1 0\\n0 -1\\n0 1\\n\", \"4 4\\n1 0\\n0 1\\n-1 0\\n0 -1\\n1 1\\n-1 1\\n-1 -1\\n1 -1\\n\", \"3 4\\n-9998 -10000\\n-10000 -9998\\n-9999 -9999\\n-9997 9996\\n-9996 9997\\n-9998 9995\\n-9995 9998\\n\", \"1 2\\n8961 -7819\\n-3068 -3093\\n-742 4108\\n\", \"2 1\\n-7087 5671\\n7159 -5255\... | Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha — m. Since their subordinates constantly had conflicts with each other, they decided to build a fence in the form of a circle, so that ... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 1\\n\", \"5\\n20 4 3 2 1\\n\", \"3\\n800000000 1 1\\n\", \"5\\n100000000 100000000 100000000 100000000 500000000\\n\", \"5\\n10 4 3 2 1\\n\", \"10\\n1 2 3 4 5 6 7 8 9 1000000000\\n\", \"7\\n77486105 317474713 89523018 332007362 7897847 949616701 54820086\\n\", \"14\\n245638694 2941428... | <image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to tran... | 0.625 |
{"tests": "{\"inputs\": [\"8 4\\n3 8 7 9 9 4 6 8\\n2 5 9 4 3 8 9 1\\n\", \"10 6\\n60 8 63 72 1 100 23 59 71 59\\n81 27 66 53 46 64 86 27 41 82\\n\", \"13 13\\n93 19 58 34 96 7 35 46 60 5 36 40 41\\n57 3 42 68 26 85 25 45 50 21 60 23 79\\n\", \"12 1\\n49 49 4 16 79 20 86 94 43 55 45 17\\n15 36 51 20 83 6 83 80 72 22 66 ... | The marmots need to prepare k problems for HC2 over n days. Each problem, once prepared, also has to be printed.
The preparation of a problem on day i (at most one per day) costs ai CHF, and the printing of a problem on day i (also at most one per day) costs bi CHF. Of course, a problem cannot be printed before it has... | 0 |
{"tests": "{\"inputs\": [\"find\\n4\\nfind\\nfindfirstof\\nfindit\\nf\", \"next\\n2\\nnextpermutation\\nnextelement\\n\\nSAMPLE\", \"next\\n2\\nnextpermutation\\nnextelement\", \"find\\n4\\nfind\\nfindfirstof\\nfjndit\\nf\", \"next\\n2\\nnextpermutation\\nnextelement\\n\\nSAMPEL\", \"txen\\n2\\nnextpermutation\\nnextel... | Steve Jobs' ghost has come down to BITS Pilani Hyderabad Campus, since he has heard a lot about the coding culture here. Hoping to recruit talented people to work on top-secret Apple software, he keeps a strict coding test.
Apple is currently working on a upgraded version of a automated form filler. They call it the i... | 0.625 |
{"tests": "{\"inputs\": [\"11 2\", \"314159265 3\", \"1010101 10\", \"22 2\", \"279134799 3\", \"1011101 10\", \"1010001 2\", \"29240007 3\", \"1010001 3\", \"1010001 5\", \"0110111 5\", \"0110111 9\", \"314159265 4\", \"15 2\", \"550505180 3\", \"49139062 3\", \"1011111 4\", \"1 2\", \"49139062 5\", \"89316102 4\", \"... | Given is an integer N. Find the number of digits that N has in base K.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^9
* 2 \leq K \leq 10
Input
Input is given from Standard Input in the following format:
N K
Output
Print the number of digits that N has in base K.
Examples
Input
11 2
O... | 0.625 |
{"tests": "{\"inputs\": [\"5\\n2 2\\n2 2\\n2 2\\n2 2\\n2 2\", \"3\\n1 3\\n2 5\\n1 9\", \"22\\n93 6440\\n78 6647\\n862 11\\n8306 9689\\n798 99\\n801 521\\n188 206\\n6079 971\\n4559 209\\n50 94\\n92 6270\\n5403 560\\n803 83\\n1855 99\\n42 504\\n75 484\\n629 11\\n92 122\\n3359 37\\n28 16\\n648 14\\n11 269\", \"5\\n2 2\\n2... | Snuke loves flags.
Snuke is placing N flags on a line.
The i-th flag can be placed at either coordinate x_i or coordinate y_i.
Snuke thinks that the flags look nicer when the smallest distance between two of them, d, is larger. Find the maximum possible value of d.
Constraints
* 2 ≤ N ≤ 10^{4}
* 1 ≤ x_i, y_i ≤ 10^... | 0 |
{"tests": "{\"inputs\": [\"C0DEFESTIVAL2O16\", \"FESTIVAL2016CODE\", \"C0DEFESTIVAL2O61\", \"EDOC6102LAVITSEF\", \"C0DEFERTIVAL2O61\", \"C0DEGERTIVAL2O61\", \"CTDEGER0IVAL2O61\", \"CT/EGERDIVAL2O61\", \"CT0EGERDIVAK2O61\", \"1DO2LAVI6REGE0TC\", \"VT0EGER6ICAL2OD0\", \"VV1EFFR7ICAK2OD0\", \"VW1EFFR7ICAK3OD0\", \"107DFFR... | CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.
He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.
So Mr. Takahashi decided to perform an operation that replaces a ce... | 0.75 |
{"tests": "{\"inputs\": [\"2\\n1 0 3\\n4 5 6 7 8\\n9 0 11\\n10\\n0\\n1 2 3\\n4 5 6 7 8\\n9 10 11\\n0\\n0\\n11 10 9\\n8 7 6 5 4\\n3 2 1\\n0\\n-1\", \"2\\n1 0 3\\n4 5 6 7 8\\n9 0 11\\n10\\n0\\n1 2 3\\n4 5 6 7 8\\n9 10 11\\n0\\n0\\n11 10 9\\n3 7 6 5 4\\n3 2 1\\n0\\n-1\", \"2\\n1 0 3\\n4 5 6 7 8\\n9 0 11\\n10\\n0\\n0 2 3\\... | Taro is very good at 8 puzzles and always has his friends sort them out during breaks. At that time, my friend asked me, "Can you solve more complicated puzzles?", But I have never done other puzzles. Apparently the friend made 11 puzzles by himself. The puzzle has the following shape.
<image>
11 The puzzle is done ... | 0 |
{"tests": "{\"inputs\": [\"6 6\\n\\n_|A%#\\nB#_|#\\n^BBa#\\nB&A##\\n\\n2\\n\\n*|*.#\\n.#.|#\\n*.**#\\n...##\\n\\n\\n*|*.#\\n*#.|#\\n..**#\\n..*##\", \"8 3\\n\\n%||Aa&#\\n\\n2\\n\\n*||*..#\\n\\n\\n.||*.*#\", \"3 5\\n\\n%#\\n^#\\n&#\\n\\n0\", \"3 4\\n\\n%#\\n&#\\n\\n0\", \"6 6\\n######\\n#_|A%#\\n#B#_|#\\n#^BBa#\\n#B&A##... | It was the last day of the summer camp you strayed into the labyrinth on the way to Komaba Campus, the University of Tokyo. The contest has just begun. Your teammates must impatiently wait for you. So you have to escape from this labyrinth as soon as possible.
The labyrinth is represented by a grid map. Initially, each... | 0 |
{"tests": "{\"inputs\": [\"1\", \"3\\n0 1\\n0 2\", \"7\\n0 1\\n1 2\\n2 3\\n3 4\\n0 5\\n0 6\", \"3\\n0 1\\n1 2\", \"7\\n0 1\\n1 2\\n2 3\\n0 4\\n0 5\\n0 6\", \"7\\n0 1\\n1 2\\n0 3\\n3 4\\n0 5\\n0 6\", \"3\\n0 2\\n0 1\", \"7\\n0 1\\n1 2\\n0 3\\n3 4\\n0 5\\n1 6\", \"3\\n1 2\\n0 1\", \"7\\n0 1\\n1 2\\n2 3\\n2 4\\n0 5\\n0 6\... | There are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided to make a table T showing the magnitude relationship between them. T has N × N elements, and each el... | 0 |
{"tests": "{\"inputs\": [\"6 4\\n1 4 5 6\", \"6 4\\n0 4 5 6\", \"6 4\\n0 4 4 6\", \"9 3\\n0 0 0 3\", \"6 4\\n0 4 6 6\", \"6 4\\n0 1 4 6\", \"6 4\\n0 2 4 6\", \"6 3\\n0 2 4 6\", \"6 3\\n0 2 4 5\", \"6 3\\n0 2 4 3\", \"6 3\\n0 0 4 3\", \"9 3\\n0 0 4 3\", \"9 3\\n0 1 0 3\", \"0 3\\n0 1 0 3\", \"1 3\\n0 1 0 3\", \"1 0\\n0 ... | problem
$ M $ students will be tested in a classroom with $ N $ seats in a straight line. Seats are numbered $ 1 \ dots N $ from the front, and $ 1 $ per seat can seat $ 1 $ students.
Now each student is sitting in the $ A_1, \ dots, A_M $ seats.
To start the test, the following conditions must be met:
* $ 1 \ dots... | 0 |
{"tests": "{\"inputs\": [\"8\\ninsert 30\\ninsert 88\\ninsert 12\\ninsert 1\\ninsert 20\\ninsert 17\\ninsert 25\\nprint\", \"8\\ninsert 30\\ninsert 88\\ninsert 18\\ninsert 1\\ninsert 20\\ninsert 17\\ninsert 25\\nprint\", \"8\\ninsert 30\\ninsert 113\\ninsert 18\\ninsert 1\\ninsert 20\\ninsert 17\\ninsert 25\\nprint\", ... | Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.
Binary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to sat... | 0.625 |
{"tests": "{\"inputs\": [\"5 6 5\\n23\\n30\\n42\\n57\\n90\\n21 \\n23 \\n35 \\n57 \\n90 \\n92 \\n21 \\n23 \\n30 \\n57 \\n90\", \"5 6 5\\n23\\n30\\n42\\n57\\n90\\n21 \\n23 \\n35 \\n57 \\n89 \\n92 \\n21 \\n23 \\n30 \\n57 \\n90\", \"5 6 5\\n23\\n30\\n42\\n57\\n90\\n33 \\n23 \\n35 \\n13 \\n89 \\n92 \\n21 \\n23 \\n30 \\n57 \... | As you might remember, the collector of Siruseri had ordered
a complete revision of the Voters List. He knew that constructing
the list of voters is a difficult task, prone to errors. Some
voters may have been away on vacation, others may have moved
during the enrollment and so on.
To be as accurate as possible, he e... | 0.5 |
{"tests": "{\"inputs\": [\"9 2 26\\n2 3\\n\", \"12 3 1\\n2 5 6\\n\", \"3 1 2\\n1\\n\", \"1000000000 1 1\\n1\\n\", \"1000000000 2 2\\n1 500000000\\n\", \"6 2 5\\n1 3\\n\", \"8 1 8\\n2\\n\", \"2 1 1000000000\\n1\\n\", \"2 1 1\\n1\\n\", \"2 1 234\\n1\\n\", \"1010000000 1 1\\n1\\n\", \"1000000000 2 2\\n2 500000000\\n\", \"... | Consider some set of distinct characters A and some string S, consisting of exactly n characters, where each character is present in A.
You are given an array of m integers b (b_1 < b_2 < ... < b_m).
You are allowed to perform the following move on the string S:
1. Choose some valid i and set k = b_i;
2. Take ... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n10 10\\nqq\\n\", \"8 1\\n10 15 2 1 4 8 15 16\\nqqwweerr\\n\", \"7 3\\n1 5 16 18 7 2 10\\nbaaaaca\\n\", \"5 5\\n2 4 1 3 1000\\naaaaa\\n\", \"6 3\\n14 18 9 19 2 15\\ncccccc\\n\", \"5 4\\n2 4 1 3 1000\\naaaaa\\n\", \"1 1\\n1\\na\\n\", \"38 1\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | You are playing a new famous fighting game: Kortal Mombat XII. You have to perform a brutality on your opponent's character.
You are playing the game on the new generation console so your gamepad have 26 buttons. Each button has a single lowercase Latin letter from 'a' to 'z' written on it. All the letters on buttons ... | 0.25 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\\n4 5 6\\n7 8 9\\n1 4 7\\n2 5 6\\n3 8 9\\n\", \"2 2\\n1 1\\n6 1\\n1 6\\n1 1\\n\", \"2 2\\n4 4\\n4 5\\n5 4\\n4 4\\n\", \"3 3\\n1 1 4\\n1 1 1\\n1 1 1\\n1 1 3\\n1 2 1\\n1 1 1\\n\", \"3 3\\n1 2 3\\n2 2 2\\n2 2 1\\n1 2 2\\n2 3 2\\n3 2 1\\n\", \"3 2\\n5 3\\n5 5\\n2 3\\n5 5\\n3 5\\n2 3\\... | Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.
Two matrices A and B are given, each of them has size n × m. Nastya can perform the following operation to matrix A unlimited number of times:
* take any square square submatrix of A and... | 0.5 |
{"tests": "{\"inputs\": [\"5\\n2 4 8 3 6\\n\", \"5\\n5 2 11 3 7\\n\", \"6\\n2 5 10 1 10 2\\n\", \"4\\n7 7 6 7\\n\", \"5\\n7 4 5 5 5\\n\", \"5\\n5 5 4 5 8\\n\", \"3\\n6 7 8\\n\", \"5\\n7 6 7 8 5\\n\", \"3\\n3 4 3\\n\", \"2\\n999999 1000000\\n\", \"2\\n8 8\\n\", \"4\\n8 6 8 1\\n\", \"2\\n6 5\\n\", \"2\\n6 7\\n\", \"4\\n2... | You are given an array a consisting of n integers a_1, a_2, ..., a_n.
Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible.
lcm(x, y) is the least common multiple of x and y (minimum positive number such that both x and y are divisors of this number).
Input
The fi... | 0.625 |
{"tests": "{\"inputs\": [\"1 1\\n1 1\\n\", \"3 595\\n43 2\\n300 4\\n554 10\\n\", \"5 240\\n13 0\\n50 25\\n60 5\\n155 70\\n165 70\\n\", \"2 50\\n20 0\\n3 1\\n\", \"10 100000\\n57437 57\\n78480 2\\n30047 2\\n22974 16\\n19579 201\\n25666 152\\n77014 398\\n94142 2\\n65837 442\\n69836 23\\n\", \"40 100000\\n97514 53\\n80797... | 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 - s_i; x_i + s_i... | 0 |
{"tests": "{\"inputs\": [\"4\\n4\\n0001\\n1000\\n0011\\n0111\\n3\\n010\\n101\\n0\\n2\\n00000\\n00001\\n4\\n01\\n001\\n0001\\n00001\\n\", \"4\\n4\\n0001\\n1000\\n0011\\n0111\\n3\\n010\\n111\\n0\\n2\\n00000\\n00001\\n4\\n01\\n001\\n0001\\n00001\\n\", \"4\\n4\\n0001\\n1000\\n0011\\n0111\\n3\\n010\\n111\\n0\\n2\\n00000\\n0... | Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: "0001", "11", "0" and "0011100".
Polycarp wants to offer his set of n binary words to play a game "words". In this game, players name words and each next word (starting from the ... | 0 |
{"tests": "{\"inputs\": [\"3 8\\n7 0 8 8 7 1 5 2\\n4 3 7\\n2 1\\n3 2\\n4 1 6\\n2 3\\n1 5 16\\n4 8 8\\n3 0\\n\", \"2 3\\n7 4 9 9\\n1 2 8\\n3 1\\n4 2 4\\n\", \"1 1\\n765529946 133384866\\n4 1 2\\n\", \"0 2\\n394521962\\n4 1 1\\n2 0\\n\", \"0 1\\n102372403\\n4 1 1\\n\", \"2 1\\n170229564 772959316 149804289 584342409\\n4 ... | You are given an array a of length 2^n. You should process q queries on it. Each query has one of the following 4 types:
1. Replace(x, k) — change a_x to k;
2. Reverse(k) — reverse each subarray [(i-1) ⋅ 2^k+1, i ⋅ 2^k] for all i (i ≥ 1);
3. Swap(k) — swap subarrays [(2i-2) ⋅ 2^k+1, (2i-1) ⋅ 2^k] and [(2i-1) ... | 0.5 |
{"tests": "{\"inputs\": [\"3 3\\n2\\nb\\nb\\nbbac\\n0\\na\\naca\\nacba\\n1\\nab\\nc\\nccb\\n\", \"5 5\\n2\\na\\nabcbb\\nabcaacac\\naab\\naaa\\n0\\nb\\nb\\nbb\\nbbaaaabca\\nbbcbbc\\n4\\ncbcb\\ncbcbac\\ncabbcbbca\\ncaca\\ncc\\n1\\nba\\nbacbbabcc\\nbaccac\\nbccababc\\na\\n3\\naaccacabac\\nacbb\\nacaaaac\\nc\\ncb\\n\", \"5... | While exploring the old caves, researchers found a book, or more precisely, a stash of mixed pages from a book. Luckily, all of the original pages are present and each page contains its number. Therefore, the researchers can reconstruct the book.
After taking a deeper look into the contents of these pages, linguists t... | 0 |
{"tests": "{\"inputs\": [\"3 1\\na\\nb\\nc\\n\", \"2 3\\na\\nb\\n\", \"1 2\\nab\\n\", \"3 3\\nabasdfabab\\nabaaasdfdsf\\nasdfaba\\n\", \"4 1\\naa\\naba\\nba\\nbba\\n\", \"3 8\\nso\\nbad\\ntest\\n\", \"1 3\\nab\\n\", \"5 6\\nabas\\ndsfdf\\nabacaba\\ndartsidius\\nkolobok\\n\", \"4 2\\naaaa\\nbbbb\\nccccc\\ndumbavumba\\n\... | Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the re... | 0 |
{"tests": "{\"inputs\": [\"5\\n4 2 1 5 3\\n00100\\n00011\\n10010\\n01101\\n01010\\n\", \"7\\n5 2 4 3 6 7 1\\n0001001\\n0000000\\n0000010\\n1000001\\n0000000\\n0010000\\n1001000\\n\", \"15\\n6 1 2 7 9 13 14 8 4 5 3 12 10 15 11\\n000100100100100\\n000010010010010\\n000001001001001\\n100000100100100\\n010000010010010\\n00... | User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.
Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≤ k ≤ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak < bk all ho... | 0 |
{"tests": "{\"inputs\": [\"2 2 7\\n4 3\\n\", \"3 1 1\\n1 1 1\\n\", \"2 2 30\\n4 3\\n\", \"1 1 1\\n1\\n\", \"23 2 5065472115\\n428801639 184568779 477337858 18989778 249804431 579004904 679880522 901530462 200642926 941909941 377757672 300378484 103633484 503801915 910270476 13399319 214483686 671551510 986061470 346894... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.