dataset
stringclasses
1 value
solutions
null
task_id
int64
0
467
exe_method
stringclasses
1 value
example_input
listlengths
1
5
example_output
listlengths
1
5
test_input
listlengths
1
20
test_output
listlengths
1
20
question
stringlengths
474
5.27k
test_time_limit
int64
1
1
Codeforces_test
null
401
stdin
[ "8\n3 9 2\n4 9 1\n7 9 2\n2 10 2\n154 220 2\n147 294 2\n998 24435 3\n1 1000000000 2\n" ]
[ "2\n6\n0\n4\n0\n1\n7148\n500000000\n" ]
[ "8\n3 9 2\n4 9 1\n7 9 2\n2 10 2\n154 220 2\n147 294 2\n998 24435 3\n1 1000000000 2\n" ]
[ "2\n6\n0\n4\n0\n1\n7148\n500000000\n" ]
You are given a positive integer $$$k$$$ and a set $$$S$$$ of all integers from $$$l$$$ to $$$r$$$ (inclusive). You can perform the following two-step operation any number of times (possibly zero): 1. First, choose a number $$$x$$$ from the set $$$S$$$, such that there are at least $$$k$$$ multiples of $$$x$$$ in $$$...
1
Codeforces_test
null
402
stdin
[ "3\n6 1 1\n1 3 3\n10 1 2\n" ]
[ "14\n1\n53\n" ]
[ "3\n6 1 1\n1 3 3\n10 1 2\n", "1\n1 1 1\n", "1\n437300461 96625 34833\n", "1\n910351181 78173 15387\n", "1\n793467309 94313 52836\n", "1\n971550733 43158 33390\n", "1\n854666861 92002 38136\n", "10\n33854166 29066 49060\n32759898 53835 75905\n78083558 64545 62296\n47722624 64272 48425\n3707310 69455 39...
[ "14\n1\n53\n", "1\n", "49488359\n", "400820889\n", "782606669\n", "69892732\n", "228818698\n", "709113841\n853853654\n191196773\n702907510\n397887101\n320084139\n818836875\n661913564\n916869136\n216310942\n", "725044695\n564214506\n974277617\n939267073\n206169492\n792733781\n432236563\n484626689\n91...
Let $$$n$$$ and $$$d$$$ be positive integers. We build the the divisor tree $$$T_{n,d}$$$ as follows: - The root of the tree is a node marked with number $$$n$$$. This is the $$$0$$$-th layer of the tree. - For each $$$i$$$ from $$$0$$$ to $$$d - 1$$$, for each vertex of the $$$i$$$-th layer, do the following. If the ...
1
Codeforces_test
null
403
stdin
[ "3\n4 2 2\n1 2 3 4\n1 1\n1 2\n1 1\n3 6 2\n1 2 3\n1 1 2 3 3 2\n3 3\n2 2\n4 6 2\n3 1 4 2\n3 1 1 2 3 4\n3 4\n4 2\n" ]
[ "YA\nTIDAK\nYA\nYA\nTIDAK\nYA\nTIDAK\nYA\nYA\n" ]
[ "3\n4 2 2\n1 2 3 4\n1 1\n1 2\n1 1\n3 6 2\n1 2 3\n1 1 2 3 3 2\n3 3\n2 2\n4 6 2\n3 1 4 2\n3 1 1 2 3 4\n3 4\n4 2\n" ]
[ "YA\nTIDAK\nYA\nYA\nTIDAK\nYA\nTIDAK\nYA\nYA\n" ]
This is the hard version of the problem. In the two versions, the constraints on $$$q$$$ and the time limit are different. In this version, $$$0 \leq q \leq 2 \cdot 10^5$$$. You can make hacks only if all the versions of the problem are solved. A team consisting of $$$n$$$ members, numbered from $$$1$$$ to $$$n$$$, is...
1
Codeforces_test
null
404
stdin
[ "2\n6\n\n0\n\n2\n\n3\n\n5\n\n3\n" ]
[ "xor 1 1\n\nxor 2 2\n\nxor 3 3\n\nxor 4 6\n\nans 2 3 5\n\nans 1 2 3\n" ]
[ "2\n6 2 3 5\n3 1 2 3\n", "7\n1000000000000000000 1000000000000000000 1 2\n1000000000000000000 2 1 1000000000000000000\n1000000000000000000 2 1000000000000000000 1\n1000000000000000000 4096 2048 6144\n1000000000000000000 864691128455135232 576460752303423488 288230376151711744\n864691128455135232 86469112845513523...
[ "1\n1\n", "1\n1\n1\n1\n1\n1\n1\n", "1\n", "1\n" ]
This is an interactive problem. The Department of Supernatural Phenomena at the Oxenfurt Academy has opened the Library of Magic, which contains the works of the greatest sorcerers of Redania — $$$n$$$ ($$$3 \leq n \leq 10^{18}$$$) types of books, numbered from $$$1$$$ to $$$n$$$. Each book's type number is indicated ...
1
Codeforces_test
null
405
stdin
[ "5\n4\n4 2 1 3\n2\n1 2\n6\n5 4 1 3 2 6\n7\n5 6 1 3 7 2 4\n5\n3 1 2 5 4\n" ]
[ "1 1 2\n1\n1 1 2 1 3\n1 1 1 2 1 2\n1 1 2 1\n" ]
[ "5\n4\n4 2 1 3\n2\n1 2\n6\n5 4 1 3 2 6\n7\n5 6 1 3 7 2 4\n5\n3 1 2 5 4\n" ]
[ "1 1 2\n1\n1 1 2 1 3\n1 1 1 2 1 2\n1 1 2 1\n" ]
You are given a permutation $$$p$$$ of length $$$n$$$. You can perform operations of two types: - mark all positions $$$i$$$ such that $$$1 \le i < n$$$ and $$$p_i < p_{i + 1}$$$, and simultaneously remove the elements at these positions; - mark all positions $$$i$$$ such that $$$2 \le i \le n$$$ and $$$p_{i - 1} > p...
1
Codeforces_test
null
406
stdin
[ "5\n1\n000\n1001\n10101\n01100101011101\n" ]
[ "1\n0\n2\n3\n8\n" ]
[ "5\n1\n000\n1001\n10101\n01100101011101\n", "1\n00000000000000000000000000000000000000000000000000\n" ]
[ "1\n0\n2\n3\n8\n", "0\n" ]
You are given a string $$$s$$$ of length $$$n$$$ consisting of $$$\mathtt{0}$$$ and/or $$$\mathtt{1}$$$. In one operation, you can select a non-empty subsequence $$$t$$$ from $$$s$$$ such that any two adjacent characters in $$$t$$$ are different. Then, you flip each character of $$$t$$$ ($$$\mathtt{0}$$$ becomes $$$\ma...
1
Codeforces_test
null
407
stdin
[ "3\n4 4 2\n1 2 2\n2 4 2\n1 3 4\n3 4 1\n1 4 2\n2 3 1\n6 7 3\n1 2 10\n2 3 3\n3 4 9\n4 5 2\n5 6 1\n2 4 10\n4 6 10\n1 6 3\n1 6 2\n2 4 1\n11 17 10\n1 4 5\n1 3 19\n1 2 10\n3 2 13\n4 5 1\n4 6 11\n3 5 9\n3 6 18\n2 7 17\n5 8 15\n5 10 8\n6 9 4\n7 10 20\n7 8 16\n8 11 3\n9 11 6\n10 11 14\n3 11 1\n3 11 3\n1 11 1\n1 11 4\n1 11 3...
[ "1 2\n2 9 9\n11 3 11 1 3 10 8 4 11 4\n" ]
[ "3\n4 4 2\n1 2 2\n2 4 2\n1 3 4\n3 4 1\n1 4 2\n2 3 1\n6 7 3\n1 2 10\n2 3 3\n3 4 9\n4 5 2\n5 6 1\n2 4 10\n4 6 10\n1 6 3\n1 6 2\n2 4 1\n11 17 10\n1 4 5\n1 3 19\n1 2 10\n3 2 13\n4 5 1\n4 6 11\n3 5 9\n3 6 18\n2 7 17\n5 8 15\n5 10 8\n6 9 4\n7 10 20\n7 8 16\n8 11 3\n9 11 6\n10 11 14\n3 11 1\n3 11 3\n1 11 1\n1 11 4\n1 11 3...
[ "1 2\n2 9 9\n11 3 11 1 3 10 8 4 11 4\n", "1000000000 1\n" ]
This is the hard version of the problem. The difference between the versions is that in this version, there is no additional constraint on $$$m$$$. You can hack only if you solved all versions of this problem. Recently, the instructors of "T-generation" needed to create a training contest. They were missing one proble...
1
Codeforces_test
null
408
stdin
[ "3\n4\n#...\n.#..\n..#.\n...#\n2\n.#..\n.#..\n1\n...#\n" ]
[ "4 3 2 1 \n2 2 \n4\n" ]
[ "3\n4\n#...\n.#..\n..#.\n...#\n2\n.#..\n.#..\n1\n...#\n" ]
[ "4 3 2 1 \n2 2 \n4 \n" ]
You are playing your favorite rhythm game, osu!mania. The layout of your beatmap consists of $$$n$$$ rows and $$$4$$$ columns. Because notes at the bottom are closer, you will process the bottommost row first and the topmost row last. Each row will contain exactly one note, represented as a '#'. For each note $$$1, 2,...
1
Codeforces_test
null
409
stdin
[ "4\n3\nAAA\nAJJ\n6\nJAJAJJ\nJJAJAJ\n6\nAJJJAJ\nAJJAAA\n9\nAJJJJAJAJ\nJAAJJJJJA\n" ]
[ "2\n2\n3\n2\n" ]
[ "4\n3\nAAA\nAJJ\n6\nJAJAJJ\nJJAJAJ\n6\nAJJJAJ\nAJJAAA\n9\nAJJJJAJAJ\nJAAJJJJJA\n" ]
[ "2\n2\n3\n2\n" ]
Álvaro and José are the only candidates running for the presidency of Tepito, a rectangular grid of $$$2$$$ rows and $$$n$$$ columns, where each cell represents a house. It is guaranteed that $$$n$$$ is a multiple of $$$3$$$. Under the voting system of Tepito, the grid will be split into districts, which consist of an...
1
Codeforces_test
null
410
stdin
[ "5\n1\n1\n2\n1 2\n3\n2 4 6\n4\n1000000000 999999999 999999998 999999997\n10\n3 1 4 1 5 9 2 6 5 3\n" ]
[ "0\n2\n1\n3\n8\n" ]
[ "5\n1\n1\n2\n1 2\n3\n2 4 6\n4\n1000000000 999999999 999999998 999999997\n10\n3 1 4 1 5 9 2 6 5 3\n", "1\n6\n1000000000 900000000 900000000 800000000 694967296 998046875\n" ]
[ "0\n2\n1\n3\n8\n", "2\n" ]
To train young Kevin's arithmetic skills, his mother devised the following problem. Given $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ and a sum $$$s$$$ initialized to $$$0$$$, Kevin performs the following operation for $$$i = 1, 2, \ldots, n$$$ in order: - Add $$$a_i$$$ to $$$s$$$. If the resulting $$$s$$$ is even, ...
1
Codeforces_test
null
411
stdin
[ "4\n3\n5 4 5\n3\n4 5 4\n10\n3 3 3 3 4 1 2 3 4 5\n9\n17 89 92 42 29 92 14 70 45\n" ]
[ "7\n6\n10\n97\n" ]
[ "4\n3\n5 4 5\n3\n4 5 4\n10\n3 3 3 3 4 1 2 3 4 5\n9\n17 89 92 42 29 92 14 70 45\n" ]
[ "7\n6\n10\n97\n" ]
You are given an array $$$a_1, a_2, \ldots, a_n$$$ of positive integers. You can color some elements of the array red, but there cannot be two adjacent red elements (i.e., for $$$1 \leq i \leq n-1$$$, at least one of $$$a_i$$$ and $$$a_{i+1}$$$ must not be red). Your score is the maximum value of a red element plus t...
1
Codeforces_test
null
412
stdin
[ "3\n2 1\n10 20\n10\n6 7\n3 1 2 4 5 6\n1\n2\n4\n8\n16\n32\n64\n10 4\n1 2 4 8 16 32 64 128 256 512\n10\n100\n1000\n10000\n" ]
[ "26\n7 8 10 12 19 35 67\n513 560 1011 10001\n" ]
[ "3\n2 1\n10 20\n10\n6 7\n3 1 2 4 5 6\n1\n2\n4\n8\n16\n32\n64\n10 4\n1 2 4 8 16 32 64 128 256 512\n10\n100\n1000\n10000\n" ]
[ "26\n7 8 10 12 19 35 67\n513 560 1011 10001\n" ]
One day, the teachers of "T-generation" decided to instill discipline in the pupils, so they lined them up and made them calculate in order. There are a total of $$$n$$$ pupils, the height of the $$$i$$$-th pupil in line is $$$a_i$$$. The line is comfortable, if for each $$$i$$$ from $$$1$$$ to $$$n - 1$$$, the follow...
1
Codeforces_test
null
413
stdin
[ "3\n4 4 2\n1 2 2\n2 4 2\n1 3 4\n3 4 1\n1 4 2\n2 3 1\n6 7 3\n1 2 10\n2 3 3\n3 4 9\n4 5 2\n5 6 1\n2 4 10\n4 6 10\n1 6 3\n1 6 2\n2 4 1\n11 17 10\n1 4 5\n1 3 19\n1 2 10\n3 2 13\n4 5 1\n4 6 11\n3 5 9\n3 6 18\n2 7 17\n5 8 15\n5 10 8\n6 9 4\n7 10 20\n7 8 16\n8 11 3\n9 11 6\n10 11 14\n3 11 1\n3 11 3\n1 11 1\n1 11 4\n1 11 3...
[ "1 2\n2 9 9\n11 3 11 1 3 10 8 4 11 4\n" ]
[ "3\n4 4 2\n1 2 2\n2 4 2\n1 3 4\n3 4 1\n1 4 2\n2 3 1\n6 7 3\n1 2 10\n2 3 3\n3 4 9\n4 5 2\n5 6 1\n2 4 10\n4 6 10\n1 6 3\n1 6 2\n2 4 1\n11 17 10\n1 4 5\n1 3 19\n1 2 10\n3 2 13\n4 5 1\n4 6 11\n3 5 9\n3 6 18\n2 7 17\n5 8 15\n5 10 8\n6 9 4\n7 10 20\n7 8 16\n8 11 3\n9 11 6\n10 11 14\n3 11 1\n3 11 3\n1 11 1\n1 11 4\n1 11 3...
[ "1 2\n2 9 9\n11 3 11 1 3 10 8 4 11 4\n", "1000000000 1\n" ]
This is the easy version of the problem. The difference between the versions is that in this version, there is an additional constraint on $$$m$$$. You can hack only if you solved all versions of this problem. Recently, the instructors of "T-generation" needed to create a training contest. They were missing one proble...
1
Codeforces_test
null
414
stdin
[ "3\n2\n1 2\n4\n1 2\n2 3\n2 4\n7\n1 2\n1 3\n2 4\n4 5\n5 6\n5 7\n" ]
[ "0\n2\n4\n" ]
[ "3\n2\n1 2\n4\n1 2\n2 3\n2 4\n7\n1 2\n1 3\n2 4\n4 5\n5 6\n5 7\n", "1\n22\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 2\n17 4\n17 6\n17 8\n18 10\n18 12\n18 14\n18 16\n17 19\n18 19\n19 20\n19 21\n19 22\n", "1\n16\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n6 8\n3 9\n3 10\n9 11\n10 12\n4 13\n4 14\n13 15\n14 16\n" ]
[ "0\n2\n4\n", "9\n", "5\n" ]
Recently, Little John got a tree from his aunt to decorate his house. But as it seems, just one tree is not enough to decorate the entire house. Little John has an idea. Maybe he can remove a few vertices from the tree. That will turn it into more trees! Right? You are given a tree$$$^{\text{∗}}$$$ of $$$n$$$ vertices...
1
Codeforces_test
null
415
stdin
[ "6\n0001100111\n0000011111\n010101\n111000\n0101\n0110\n0101\n1010\n011001\n001110\n0\n1\n", "6\n010101\n?0?0??\n0101\n?0?0\n11100101\n????????\n11100101\n???11?1?\n1000100011\n?11?000?0?\n10101\n?1011\n" ]
[ "1\n3\n1\n-1\n-1\n-1\n", "2\n-1\n0\n2\n2\n-1\n" ]
[ "6\n0001100111\n0000011111\n010101\n111000\n0101\n0110\n0101\n1010\n011001\n001110\n0\n1\n", "6\n010101\n?0?0??\n0101\n?0?0\n11100101\n????????\n11100101\n???11?1?\n1000100011\n?11?000?0?\n10101\n?1011\n" ]
[ "1\n3\n1\n-1\n-1\n-1\n", "2\n-1\n0\n2\n2\n-1\n" ]
This is the hard version of the problem. The difference between the versions is that in this version, string $$$t$$$ consists of '0', '1' and '?'. You can hack only if you solved all versions of this problem. Kevin has a binary string $$$s$$$ of length $$$n$$$. Kevin can perform the following operation: - Choose two ...
1
Codeforces_test
null
416
stdin
[ "10\n4\n0 1 2 3\n6\n0 0 0 0 0 0\n5\n1 0 1 0 1\n5\n3 1 4 1 5\n4\n3 2 1 0\n7\n9 100 0 89 12 2 3\n4\n0 3 9 0\n7\n0 7 0 2 0 7 0\n1\n0\n2\n0 1\n" ]
[ "1\n0\n2\n1\n1\n2\n1\n2\n0\n1\n" ]
[ "10\n4\n0 1 2 3\n6\n0 0 0 0 0 0\n5\n1 0 1 0 1\n5\n3 1 4 1 5\n4\n3 2 1 0\n7\n9 100 0 89 12 2 3\n4\n0 3 9 0\n7\n0 7 0 2 0 7 0\n1\n0\n2\n0 1\n", "1\n8\n1 0 1 0 1 0 1 0\n" ]
[ "1\n0\n2\n1\n1\n2\n1\n2\n0\n1\n", "2\n" ]
Evirir the dragon snuck into a wizard's castle and found a mysterious contraption, and their playful instincts caused them to play with (destroy) it... Evirir the dragon found an array $$$a_1, a_2, \ldots, a_n$$$ of $$$n$$$ non-negative integers. In one operation, they can choose a non-empty subarray$$$^{\text{∗}}$$$...
1
Codeforces_test
null
417
stdin
[ "3\n4 2 0\n1 2 3 4\n1 1\n3 6 0\n1 2 3\n1 1 2 3 3 2\n4 6 0\n3 1 4 2\n3 1 1 2 3 4\n" ]
[ "YA\nYA\nTIDAK\n" ]
[ "3\n4 2 0\n1 2 3 4\n1 1\n3 6 0\n1 2 3\n1 1 2 3 3 2\n4 6 0\n3 1 4 2\n3 1 1 2 3 4\n" ]
[ "YA\nYA\nTIDAK\n" ]
This is the easy version of the problem. In the two versions, the constraints on $$$q$$$ and the time limit are different. In this version, $$$q=0$$$. You can make hacks only if all the versions of the problem are solved. A team consisting of $$$n$$$ members, numbered from $$$1$$$ to $$$n$$$, is set to present a slide...
1
Codeforces_test
null
418
stdin
[ "5\n2 1\n1 1\n2 2\n1 2\n3 4\n2 1 3\n10 50\n1 1 3 8 8 9 12 13 27 27\n2 1000000000\n1000000000 500000000\n" ]
[ "1\n2\n5\n53\n1000000000\n" ]
[ "5\n2 1\n1 1\n2 2\n1 2\n3 4\n2 1 3\n10 50\n1 1 3 8 8 9 12 13 27 27\n2 1000000000\n1000000000 500000000\n" ]
[ "1\n2\n5\n53\n1000000000\n" ]
There is a vending machine that sells lemonade. The machine has a total of $$$n$$$ slots. You know that initially, the $$$i$$$-th slot contains $$$a_i$$$ cans of lemonade. There are also $$$n$$$ buttons on the machine, each button corresponds to a slot, with exactly one button corresponding to each slot. Unfortunately,...
1
Codeforces_test
null
419
stdin
[ "3\n5\n1 2 3 4 5\n8\n8 8 5 3 4 6 8 12\n4\n3 3 3 4\n" ]
[ "4\nAmbiguous\n3\n" ]
[ "3\n5\n1 2 3 4 5\n8\n8 8 5 3 4 6 8 12\n4\n3 3 3 4\n" ]
[ "4\nAmbiguous\n3\n" ]
Jane has decided to solve a list of $$$n$$$ problems on Codeforces. The $$$i$$$-th problem in her list has difficulty $$$d_i$$$, and the last problem in the list is the hardest one (for every problem $$$j < n$$$, $$$d_j < d_n$$$). Jane's problem-solving skill is some integer $$$x$$$ (unknown to you). If a problem's di...
1
Codeforces_test
null
420
stdin
[ "2\n5\n10\n" ]
[ "1 5 2 4 3\n1 2 10 9 7 4 8 3 6 5\n" ]
[ "2\n5\n10\n", "99\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\...
[ "1 5 4 3 2\n1 10 9 8 7 6 5 4 3 2\n", "1 2 \n1 3 2 \n1 4 3 2 \n1 5 4 3 2 \n1 6 5 4 3 2 \n1 7 6 5 4 3 2 \n1 8 7 6 5 4 3 2 \n1 9 8 7 6 5 4 3 2 \n1 10 9 8 7 6 5 4 3 2 \n1 11 10 9 8 7 6 5 4 3 2 \n1 12 11 10 9 8 7 6 5 4 3 2 \n1 13 12 11 10 9 8 7 6 5 4 3 2 \n1 14 13 12 11 10 9 8 7 6 5 4 3 2 \n1 15 14 13 12 11 10 9 8 7 6...
Yes, this is another one of those constructive permutation problems. You are given an integer $$$n$$$. You have to construct a permutation $$$p$$$ of size $$$n$$$, i. e. an array of $$$n$$$ integers, where every integer from $$$1$$$ to $$$n$$$ appears exactly once. Every pair of adjacent elements in the permutation (...
1
Codeforces_test
null
421
stdin
[ "8\n2\n114 109\n2\n17 10\n3\n76 83 88\n8\n38 45 38 80 85 92 99 106\n5\n63 58 65 58 65\n8\n117 124 48 53 48 43 54 49\n5\n95 102 107 114 121\n10\n72 77 82 75 70 75 68 75 68 75\n" ]
[ "YES\nYES\nYES\nNO\nYES\nNO\nYES\nYES\n" ]
[ "8\n2\n114 109\n2\n17 10\n3\n76 83 88\n8\n38 45 38 80 85 92 99 106\n5\n63 58 65 58 65\n8\n117 124 48 53 48 43 54 49\n5\n95 102 107 114 121\n10\n72 77 82 75 70 75 68 75 68 75\n", "19\n38\n1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 126 121 126 121 126 121 126 121 126 121 126 121 1...
[ "YES\nYES\nYES\nNO\nYES\nNO\nYES\nYES\n", "YES\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n" ]
Boris Notkin composes melodies. He represents them as a sequence of notes, where each note is encoded as an integer from $$$0$$$ to $$$127$$$ inclusive. The interval between two notes $$$a$$$ and $$$b$$$ is equal to $$$|a - b|$$$ semitones. Boris considers a melody perfect if the interval between each two adjacent not...
1
Codeforces_test
null
422
stdin
[ "3\n5 1 1\n10101\n5 2 1\n10101\n6 3 2\n000000\n" ]
[ "2\n0\n1\n" ]
[ "3\n5 1 1\n10101\n5 2 1\n10101\n6 3 2\n000000\n" ]
[ "2\n0\n1\n" ]
Rostam's loyal horse, Rakhsh, has seen better days. Once powerful and fast, Rakhsh has grown weaker over time, struggling to even move. Rostam worries that if too many parts of Rakhsh's body lose strength at once, Rakhsh might stop entirely. To keep his companion going, Rostam decides to strengthen Rakhsh, bit by bit, ...
1
Codeforces_test
null
423
stdin
[ "5\n1 1\n-179\n1 1\n5 3\n-2 2 -1 3 -1\n2 4\n1 5\n1 3\n7 1\n1 1 1 -4 1 1 1\n1 7\n7 2\n2 -2 2 -2 1 2 -1\n1 7\n2 7\n4 4\n1000000000 1000000000 999999999 -1000000000\n2 4\n3 4\n2 3\n1 3\n" ]
[ "-1\n2\n5\n-1\n8\n6\n6\n2\n-1\n1\n2\n" ]
[ "5\n1 1\n-179\n1 1\n5 3\n-2 2 -1 3 -1\n2 4\n1 5\n1 3\n7 1\n1 1 1 -4 1 1 1\n1 7\n7 2\n2 -2 2 -2 1 2 -1\n1 7\n2 7\n4 4\n1000000000 1000000000 999999999 -1000000000\n2 4\n3 4\n2 3\n1 3\n" ]
[ "-1\n2\n5\n-1\n8\n6\n6\n2\n-1\n1\n2\n" ]
In a desert city with a hilly landscape, the city hall decided to level the road surface by purchasing a dump truck. The road is divided into $$$n$$$ sections, numbered from $$$1$$$ to $$$n$$$ from left to right. The height of the surface in the $$$i$$$-th section is equal to $$$a_i$$$. If the height of the $$$i$$$-th ...
1
Codeforces_test
null
424
stdin
[ "7\n5 5\n100 20 80\n1 5 30 100\n1 2 20 50\n2 3 20 50\n3 4 20 50\n4 5 20 50\n2 1\n100 50 60\n1 2 55 110\n4 4\n100 40 60\n1 2 30 100\n2 4 30 100\n1 3 20 50\n3 4 20 50\n3 3\n100 80 90\n1 2 1 10\n2 3 10 50\n1 3 20 21\n3 2\n58 55 57\n2 1 1 3\n2 3 3 4\n2 1\n12 9 10\n2 1 6 10\n5 5\n8 5 6\n2 1 1 8\n2 3 4 8\n4 2 2 4\n5 3 3 ...
[ "0\n-1\n60\n80\n53\n3\n2\n" ]
[ "7\n5 5\n100 20 80\n1 5 30 100\n1 2 20 50\n2 3 20 50\n3 4 20 50\n4 5 20 50\n2 1\n100 50 60\n1 2 55 110\n4 4\n100 40 60\n1 2 30 100\n2 4 30 100\n1 3 20 50\n3 4 20 50\n3 3\n100 80 90\n1 2 1 10\n2 3 10 50\n1 3 20 21\n3 2\n58 55 57\n2 1 1 3\n2 3 3 4\n2 1\n12 9 10\n2 1 6 10\n5 5\n8 5 6\n2 1 1 8\n2 3 4 8\n4 2 2 4\n5 3 3 ...
[ "0\n-1\n60\n80\n53\n3\n2\n" ]
You live in a city consisting of $$$n$$$ intersections and $$$m$$$ streets connecting some pairs of intersections. You can travel in either direction on each street. No two streets connect the same pair of intersections, and no street connects an intersection to itself. You can reach any intersection from any other, po...
1
Codeforces_test
null
425
stdin
[ "3\n2 6\n7 1\n8 5\n" ]
[ "1 3 \n1 3 7 9 \n1 3 5 7 9\n" ]
[ "3\n2 6\n7 1\n8 5\n", "9\n1000000000 1\n1000000000 2\n1000000000 3\n1000000000 4\n1000000000 5\n1000000000 6\n1000000000 7\n1000000000 8\n1000000000 9\n", "3\n5388586 7\n1625078 5\n548212 3\n" ]
[ "1 3 \n1 3 7 9 \n1 3 5 7 9 \n", "1 3 7 9 \n1 3 7 9 \n1 3 7 9 \n1 3 7 9 \n1 3 5 7 9 \n1 3 7 9 \n1 3 7 9 \n1 3 7 9 \n1 3 7 9 \n", "1 3 7 9 \n1 3 5 7 9 \n1 3 7 9 \n" ]
Artem wrote the digit $$$d$$$ on the board exactly $$$n!$$$ times in a row. So, he got the number $$$dddddd \dots ddd$$$ (exactly $$$n!$$$ digits). Now he is curious about which odd digits from $$$1$$$ to $$$9$$$ divide the number written on the board. Input format: The first line contains a single integer $$$t$$$ ($...
1
Codeforces_test
null
426
stdin
[ "9\n5\n1 1 1 2 3\n6\n2 1 2 2 1 1\n4\n1 2 1 1\n6\n2 1 1 2 2 4\n4\n2 1 2 3\n6\n1 2 2 1 2 1\n5\n4 5 5 1 5\n7\n1 4 3 5 1 1 3\n7\n3 1 3 2 2 3 3\n" ]
[ "1\n2\n1\n0\n0\n1\n1\n0\n2\n" ]
[ "9\n5\n1 1 1 2 3\n6\n2 1 2 2 1 1\n4\n1 2 1 1\n6\n2 1 1 2 2 4\n4\n2 1 2 3\n6\n1 2 2 1 2 1\n5\n4 5 5 1 5\n7\n1 4 3 5 1 1 3\n7\n3 1 3 2 2 3 3\n" ]
[ "1\n2\n1\n0\n0\n1\n1\n0\n2\n" ]
Even in university, students need to relax. That is why Sakurakos teacher decided to go on a field trip. It is known that all of the students will be walking in one line. The student with index $$$i$$$ has some topic of interest which is described as $$$a_i$$$. As a teacher, you want to minimise the disturbance of the ...
1
Codeforces_test
null
427
stdin
[ "4\n1 1\n3 2\n3 3\n15 8\n" ]
[ "1\n1\n3\n1 2 3\n-1\n5\n1 4 7 10 13\n" ]
[ "4\n1 1\n3 2\n3 3\n15 8\n", "2\n199999 199999\n1 1\n", "2\n1 1\n199999 1\n", "1\n199999 62226\n", "2\n3 1\n199997 108263\n", "10\n9999 1\n9999 9999\n15673 1\n38721 38721\n89211 1\n30183 30183\n5023 1\n1023 1023\n111 1\n57 57\n", "10\n57 1\n111 111\n1023 1\n5023 5023\n30183 1\n89211 89211\n38721 1\n15673...
[ "1\n1\n3\n1 2 3\n-1\n3\n1 8 9\n", "-1\n1\n1\n", "1\n1\n-1\n", "3\n1 62226 62227\n", "-1\n3\n1 108262 108265\n", "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n", "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n", "3\n1 199998 199999\n" ]
You are given an array $$$a = [1, 2, \ldots, n]$$$, where $$$n$$$ is odd, and an integer $$$k$$$. Your task is to choose an odd positive integer $$$m$$$ and to split $$$a$$$ into $$$m$$$ subarrays$$$^{\dagger}$$$ $$$b_1, b_2, \ldots, b_m$$$ such that: - Each element of the array $$$a$$$ belongs to exactly one subarra...
1
Codeforces_test
null
428
stdin
[ "4\n1 2\n3 4\n2 5\n2 5\n3 7\n6 7\n4 5\n2 8\n" ]
[ "1\n3\n2\n3\n" ]
[ "4\n1 2\n3 4\n2 5\n2 5\n3 7\n6 7\n4 5\n2 8\n", "1\n10 100\n10 100\n" ]
[ "1\n3\n2\n3\n", "90\n" ]
There are $$$100$$$ rooms arranged in a row and $$$99$$$ doors between them; the $$$i$$$-th door connects rooms $$$i$$$ and $$$i+1$$$. Each door can be either locked or unlocked. Initially, all doors are unlocked. We say that room $$$x$$$ is reachable from room $$$y$$$ if all doors between them are unlocked. You know...
1
Codeforces_test
null
429
stdin
[ "4\n5\n2 4 6 2 5\n5\n5 4 4 5 1\n4\n6 8 2 3\n1\n1\n" ]
[ "10\n11\n10\n1\n" ]
[ "4\n5\n2 4 6 2 5\n5\n5 4 4 5 1\n4\n6 8 2 3\n1\n1\n" ]
[ "10\n11\n10\n1\n" ]
You're given an array $$$a$$$ initially containing $$$n$$$ integers. In one operation, you must do the following: - Choose a position $$$i$$$ such that $$$1 < i \le |a|$$$ and $$$a_i = |a| + 1 - i$$$, where $$$|a|$$$ is the current size of the array. - Append $$$i - 1$$$ zeros onto the end of $$$a$$$. After performin...
1
Codeforces_test
null
430
stdin
[ "3\n2 2 4\n1 1 3\n2 1 2\n100 2 1\n4 1 10\n4 4 10\n10 5 2\n1 1 4\n3 1 2\n4 2 5\n2 2 1\n5 3 4\n" ]
[ "Anda\nKamu\nAnda\n" ]
[ "3\n2 2 4\n1 1 3\n2 1 2\n100 2 1\n4 1 10\n4 4 10\n10 5 2\n1 1 4\n3 1 2\n4 2 5\n2 2 1\n5 3 4\n" ]
[ "Anda\nKamu\nAnda\n" ]
Your friends, Anda and Kamu decide to play a game called Grid Game and ask you to become the gamemaster. As the gamemaster, you set up a triangular grid of size $$$N$$$. The grid has $$$N$$$ rows (numbered from $$$1$$$ to $$$N$$$). Row $$$r$$$ has $$$r$$$ cells; the $$$c$$$-th cell of row $$$r$$$ is denoted as $$$(r, c...
1
Codeforces_test
null
431
stdin
[ "3 2\n", "5 3\n" ]
[ "7\n", "67\n" ]
[ "3 2\n", "5 3\n", "1000000 1000000000\n", "1000000 999999\n", "1000000 1\n", "1 1000000000\n", "644271 497470\n", "1000000 2\n", "514514 514\n", "514514 515515\n", "514514 514513\n", "998789 789897\n", "999888 3\n", "556888 1324\n", "51515 55\n", "8 9\n", "18 18\n" ]
[ "7\n", "67\n", "793302832\n", "793302830\n", "1\n", "1\n", "189775039\n", "421273116\n", "638444431\n", "915424391\n", "915424389\n", "658100689\n", "117498587\n", "580017151\n", "18469295\n", "2187\n", "129140163\n" ]
Image generated by ChatGPT 4o. Alice likes singing. As a singing enthusiast, Alice has listened to countless songs and has tried singing them many times. However, occasionally, some songs make Alice feel bored. After some research, Alice believes that this is because even though the songs she chose are all different, ...
1
Codeforces_test
null
432
stdin
[ "6\n5 2\n3 5\n16 4\n100 3\n6492 10\n10 1\n" ]
[ "2\n3\n1\n4\n21\n10\n" ]
[ "6\n5 2\n3 5\n16 4\n100 3\n6492 10\n10 1\n" ]
[ "2\n3\n1\n4\n21\n10\n" ]
You are given two integers $$$n$$$ and $$$k$$$. In one operation, you can subtract any power of $$$k$$$ from $$$n$$$. Formally, in one operation, you can replace $$$n$$$ by $$$(n-k^x)$$$ for any non-negative integer $$$x$$$. Find the minimum number of operations required to make $$$n$$$ equal to $$$0$$$. Input forma...
1
Codeforces_test
null
433
stdin
[ "5\n?????\nxbx\nab??e\nabcde\nayy?x\na\nab??e\ndac\npaiu\nmom\n" ]
[ "YES\nxabax\nYES\nabcde\nYES\nayyyx\nNO\nNO\n" ]
[ "5\n?????\nxbx\nab??e\nabcde\nayy?x\na\nab??e\ndac\npaiu\nmom\n" ]
[ "YES\nxbxaa\nYES\nabcde\nYES\nayyax\nNO\nNO\n" ]
Slavic has a very tough exam and needs your help in order to pass it. Here is the question he is struggling with: There exists a string $$$s$$$, which consists of lowercase English letters and possibly zero or more "?". Slavic is asked to change each "?" to a lowercase English letter such that string $$$t$$$ becomes ...
1
Codeforces_test
null
434
stdin
[ "4\n2 2\n7 2\n5 3\n1000000000 1000000000\n" ]
[ "1\n5\n1\n347369930\n" ]
[ "4\n2 2\n7 2\n5 3\n1000000000 1000000000\n" ]
[ "1\n5\n1\n347369930\n" ]
Klee has an array $$$a$$$ of length $$$n$$$ containing integers $$$[k, k+1, ..., k+n-1]$$$ in that order. Klee wants to choose an index $$$i$$$ ($$$1 \leq i \leq n$$$) such that $$$x = |a_1 + a_2 + \dots + a_i - a_{i+1} - \dots - a_n|$$$ is minimized. Note that for an arbitrary integer $$$z$$$, $$$|z|$$$ represents the...
1
Codeforces_test
null
435
stdin
[ "3\n5\n1 2 5 905 2000000\n15\n- 2\n? 2\n? 1\n- 1\n? 1\n+ 4\n+ 2\n? 2\n+ 6\n- 4\n+ 7\n? 2\n? 3\n? 4\n? 2000000\n5\n3 4 5 6 8\n9\n? 5\n- 5\n? 5\n+ 1\n? 2\n- 6\n- 8\n+ 6\n? 5\n5\n6 7 8 9 10\n10\n? 5\n- 6\n? 4\n- 10\n+ 5\n- 8\n+ 3\n+ 2\n- 3\n+ 10\n" ]
[ "2 2 1 6 3 8 8 2000001 \n9 9 9 7 \n1 1\n" ]
[ "3\n5\n1 2 5 905 2000000\n15\n- 2\n? 2\n? 1\n- 1\n? 1\n+ 4\n+ 2\n? 2\n+ 6\n- 4\n+ 7\n? 2\n? 3\n? 4\n? 2000000\n5\n3 4 5 6 8\n9\n? 5\n- 5\n? 5\n+ 1\n? 2\n- 6\n- 8\n+ 6\n? 5\n5\n6 7 8 9 10\n10\n? 5\n- 6\n? 4\n- 10\n+ 5\n- 8\n+ 3\n+ 2\n- 3\n+ 10\n" ]
[ "2 2 1 6 3 8 8 2000001 \n9 9 9 7 \n1 1 \n" ]
Ksyusha decided to start a game development company. To stand out among competitors and achieve success, she decided to write her own game engine. The engine must support a set initially consisting of $$$n$$$ distinct integers $$$a_1, a_2, \ldots, a_n$$$. The set will undergo $$$m$$$ operations sequentially. The opera...
1
Codeforces_test
null
436
stdin
[ "3\n4\n\n1\n\n5\n\n1\n\n0\n\n9\n" ]
[ "? 2 3\n\n! 0 0 1\n\n? 2 3\n\n? 2 4\n\n! 0 0 1 2\n\n! 0 0 0 1 3 5 6 7\n" ]
[ "3\n4\n0 0 1\n5\n0 0 1 2\n9\n0 0 0 1 3 5 6 7\n" ]
[ "0 0 1\n0 0 1 2\n0 0 0 1 3 5 6 7\n" ]
This is an interactive problem. Upon clearing the Waterside Area, Gretel has found a monster named Genokraken, and she's keeping it contained for her scientific studies. The monster's nerve system can be structured as a tree$$$^{\dagger}$$$ of $$$n$$$ nodes (really, everything should stop resembling trees all the tim...
1
Codeforces_test
null
437
stdin
[ "3\n2 1 2\n1 2 1\n", "4\n5 5 5 5\n0 0 0 0\n", "5\n1 9 3 7 5\n2 4 6 8 5\n" ]
[ "2 332748119 1\n", "5 5 5 5\n", "6 4 3 199648873 2\n" ]
[ "3\n2 1 2\n1 2 1\n", "4\n5 5 5 5\n0 0 0 0\n", "5\n1 9 3 7 5\n2 4 6 8 5\n", "1\n0\n0\n", "1\n0\n1000000\n", "1\n1000000\n0\n", "1\n1000000\n1000000\n", "20\n443309 129766 7146 25306 61735 943035 371598 498745 993335 611156 910260 422340 664742 667842 954783 553879 829847 999710 772830 428350\n148617 66...
[ "2 332748119 1 \n", "5 5 5 5 \n", "6 4 3 199648873 2 \n", "0 \n", "1000000 \n", "1000000 \n", "1000000 \n", "150385282 646686036 580024390 459931971 720047846 40653046 997940504 821058607 405459823 463788016 324476726 740478844 379558797 206919447 271286963 701987283 528912628 709293146 449220549 7146...
Suppose you are working in the Ministry of Digital Development of Berland, and your task is to monitor the industry of video blogging. There are $$$n$$$ bloggers in Berland. Recently, due to the poor state of the main video platform in Berland, two alternative platforms were introduced. That's why bloggers started to ...
1
Codeforces_test
null
438
stdin
[ "4\n???\nY??D?X\n???\nD??DXYXYX\n" ]
[ "YES\nYDX\nX 0 D 0 Y 0 \nYES\nYDXDYX\nX 0 Y 0 D 1\nX 2 D 3 Y 4\nYES\nYDX\nY 0 D 1 X 2\nNO\n" ]
[ "4\n???\nY??D?X\n???\nD??DXYXYX\n", "27\nYYY\nDYY\nXYY\nYDY\nDDY\nXDY\nYXY\nDXY\nXXY\nYYD\nDYD\nXYD\nYDD\nDDD\nXDD\nYXD\nDXD\nXXD\nYYX\nDYX\nXYX\nYDX\nDDX\nXDX\nYXX\nDXX\nXXX\n", "64\nYYY\nDYY\nXYY\n?YY\nYDY\nDDY\nXDY\n?DY\nYXY\nDXY\nXXY\n?XY\nY?Y\nD?Y\nX?Y\n??Y\nYYD\nDYD\nXYD\n?YD\nYDD\nDDD\nXDD\n?DD\nYXD\nDXD...
[ "YES\nYDX\nX 0 D 0 Y 0 \nYES\nYDXDYX\nX 0 Y 0 D 0 \nX 0 D 0 Y 0 \nYES\nYDX\nX 0 D 0 Y 0 \nNO\n", "NO\nNO\nNO\nNO\nNO\nYES\nXDY\nY 0 D 0 X 0 \nNO\nYES\nDXY\nY 0 X 0 D 0 \nNO\nNO\nNO\nYES\nXYD\nD 0 Y 0 X 0 \nNO\nNO\nNO\nYES\nYXD\nD 0 X 0 Y 0 \nNO\nNO\nNO\nYES\nDYX\nX 0 Y 0 D 0 \nNO\nYES\nYDX\nX 0 D 0 Y 0 \nNO\nNO\n...
This is the hard version of the problem. The difference between the versions is that in this version, there is no restriction on the number of question marks. You can hack only if you solved all versions of this problem. For a long time, no one could decipher Sumerian cuneiform. However, it has finally succumbed to pr...
1
Codeforces_test
null
439
stdin
[ "3\n5\n3 5 2 1 3\n2\nabfda\nafbfa\n2\n1 2\n3\nab\nabc\naa\n4\n5 -3 5 -3\n4\naaaa\nbcbc\naba\ncbcb\n" ]
[ "YES\nNO\nYES\nNO\nNO\nNO\nYES\nNO\nYES\n" ]
[ "3\n5\n3 5 2 1 3\n2\nabfda\nafbfa\n2\n1 2\n3\nab\nabc\naa\n4\n5 -3 5 -3\n4\naaaa\nbcbc\naba\ncbcb\n" ]
[ "YES\nNO\nYES\nNO\nNO\nNO\nYES\nNO\nYES\n" ]
Kristina has an array $$$a$$$, called a template, consisting of $$$n$$$ integers. She also has $$$m$$$ strings, each consisting only of lowercase Latin letters. The strings are numbered from $$$1$$$ to $$$m$$$. She wants to check which strings match the template. A string $$$s$$$ is considered to match the template if...
1
Codeforces_test
null
440
stdin
[ "4\n1\n6\n3\n98\n" ]
[ "Kosuke\nSakurako\nKosuke\nSakurako\n" ]
[ "4\n1\n6\n3\n98\n", "100\n100\n99\n98\n97\n96\n95\n94\n93\n92\n91\n90\n89\n88\n87\n86\n85\n84\n83\n82\n81\n80\n79\n78\n77\n76\n75\n74\n73\n72\n71\n70\n69\n68\n67\n66\n65\n64\n63\n62\n61\n60\n59\n58\n57\n56\n55\n54\n53\n52\n51\n50\n49\n48\n47\n46\n45\n44\n43\n42\n41\n40\n39\n38\n37\n36\n35\n34\n33\n32\n31\n30\n29\...
[ "Kosuke\nSakurako\nKosuke\nSakurako\n", "Sakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSakurako\nKosuke\nSak...
Sakurako and Kosuke decided to play some games with a dot on a coordinate line. The dot is currently located in position $$$x=0$$$. They will be taking turns, and Sakurako will be the one to start. On the $$$i$$$-th move, the current player will move the dot in some direction by $$$2\cdot i-1$$$ units. Sakurako will a...
1
Codeforces_test
null
441
stdin
[ "3\n1\n0\n5\n00101\n00101\n11001\n00001\n11110\n6\n000000\n000000\n000000\n000000\n000000\n000000\n" ]
[ "1 \n4 2 1 3 5 \n6 5 4 3 2 1\n" ]
[ "3\n1\n0\n5\n00101\n00101\n11001\n00001\n11110\n6\n000000\n000000\n000000\n000000\n000000\n000000\n" ]
[ "1 \n4 2 1 3 5 \n6 5 4 3 2 1 \n" ]
You are given an undirected graph with $$$n$$$ vertices, labeled from $$$1$$$ to $$$n$$$. This graph encodes a hidden permutation$$$^{\text{∗}}$$$ $$$p$$$ of size $$$n$$$. The graph is constructed as follows: - For every pair of integers $$$1 \le i < j \le n$$$, an undirected edge is added between vertex $$$p_i$$$ and...
1
Codeforces_test
null
442
stdin
[ "6\n1 1 3 5\n1 3 2 1\n8 10 28 100\n100 1 100 1\n1 100 1 100\n100 100 100 100\n" ]
[ "3\n2\n2\n1\n1\n2\n" ]
[ "6\n1 1 3 5\n1 3 2 1\n8 10 28 100\n100 1 100 1\n1 100 1 100\n100 100 100 100\n", "1\n7 8 22 38\n" ]
[ "3\n2\n2\n1\n1\n2\n", "1\n" ]
There is an array of $$$5$$$ integers. Initially, you only know $$$a_1,a_2,a_4,a_5$$$. You may set $$$a_3$$$ to any positive integer, negative integer, or zero. The Fibonacciness of the array is the number of integers $$$i$$$ ($$$1 \leq i \leq 3$$$) such that $$$a_{i+2}=a_i+a_{i+1}$$$. Find the maximum Fibonacciness ov...
1
Codeforces_test
null
443
stdin
[ "6\n1\nABCD\n2\nAAAAAAAA\n2\nAAAABBBB\n2\n????????\n3\nABCABCABCABC\n5\nACADC??ACAC?DCAABC?C\n" ]
[ "4\n2\n4\n0\n9\n13\n" ]
[ "6\n1\nABCD\n2\nAAAAAAAA\n2\nAAAABBBB\n2\n????????\n3\nABCABCABCABC\n5\nACADC??ACAC?DCAABC?C\n", "1\n5\nA?B?C?D??D?C?B?A????\n" ]
[ "4\n2\n4\n0\n9\n13\n", "8\n" ]
Tim is doing a test consisting of $$$4n$$$ questions; each question has $$$4$$$ options: 'A', 'B', 'C', and 'D'. For each option, there are exactly $$$n$$$ correct answers corresponding to that option — meaning there are $$$n$$$ questions with the answer 'A', $$$n$$$ questions with the answer 'B', $$$n$$$ questions wit...
1
Codeforces_test
null
444
stdin
[ "3\n2\n8 0\n5\n2 2 2 2 2\n5\n0 0 9 0 0\n" ]
[ "8 4 \n4 5 4 5 4 \n4 6 9 6 4\n" ]
[ "3\n2\n8 0\n5\n2 2 2 2 2\n5\n0 0 9 0 0\n", "2\n1\n1000000000\n4\n0 2 2 8\n" ]
[ "8 4 \n4 5 4 5 4 \n4 6 9 6 4 \n", "1000000000 \n3 5 7 9 \n" ]
There are very long classes in the T-Generation. In one day, you need to have time to analyze the training and thematic contests, give a lecture with new material, and, if possible, also hold a mini-seminar. Therefore, there is a break where students can go to drink coffee and chat with each other. There are a total o...
1
Codeforces_test
null
445
stdin
[ "3\n2\n3\n6\n" ]
[ "uo\niae\noeiiua\n" ]
[ "3\n2\n3\n6\n", "100\n39\n77\n67\n25\n81\n26\n50\n11\n73\n95\n86\n16\n90\n33\n14\n79\n12\n100\n68\n64\n60\n27\n41\n15\n34\n24\n3\n61\n83\n47\n57\n65\n99\n43\n40\n21\n94\n72\n82\n85\n23\n71\n76\n32\n10\n17\n30\n18\n44\n59\n35\n89\n6\n63\n7\n69\n62\n70\n4\n29\n92\n87\n31\n48\n36\n28\n45\n97\n93\n98\n56\n38\n58\n80\...
[ "ae\naei\naaeiou\n", "aaaaaaaaeeeeeeeeoooooooouuuuuuuuiiiiiii\naaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeooooooooooooooouuuuuuuuuuuuuuuiiiiiiiiiiiiiii\naaaaaaaaaaaaaaeeeeeeeeeeeeeeooooooooooooouuuuuuuuuuuuuiiiiiiiiiiiii\naaaaaeeeeeooooouuuuuiiiii\naaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeoooooooooooooooouuuuuuuuuuuuuuuuiiiiiiiiiii...
Narek has to spend 2 hours with some 2-year-old kids at the kindergarten. He wants to teach them competitive programming, and their first lesson is about palindromes. Narek found out that the kids only know the vowels of the English alphabet (the letters $$$\mathtt{a}$$$, $$$\mathtt{e}$$$, $$$\mathtt{i}$$$, $$$\mathtt...
1
Codeforces_test
null
446
stdin
[ "2\n3 1\n2 1 2\n5 2\n2 1 4\n4 2 5\n" ]
[ "5\n15\n" ]
[ "2\n3 1\n2 1 2\n5 2\n2 1 4\n4 2 5\n" ]
[ "5\n15\n" ]
Claire loves drawing lines. She receives a sheet of paper with an $$$n \times n$$$ grid and begins drawing "lines" on it. Well—the concept of a "line" here is not what we usually think of. Claire refers each line to be a set of consecutive vertical grid cells. When she draws a line, these cells are all covered with bla...
1
Codeforces_test
null
447
stdin
[ "6\n7 2\n11 3\n55 13\n5801 6\n8919 64\n8765432 1\n" ]
[ "12\n18\n196\n1975581\n958900\n38416403456028\n" ]
[ "6\n7 2\n11 3\n55 13\n5801 6\n8919 64\n8765432 1\n", "1\n2000000000 2000000000\n" ]
[ "12\n18\n196\n1975581\n958900\n38416403456028\n", "0\n" ]
Iris looked at the stars and a beautiful problem emerged in her mind. She is inviting you to solve it so that a meteor shower is believed to form. There are $$$n$$$ stars in the sky, arranged in a row. Iris has a telescope, which she uses to look at the stars. Initially, Iris observes stars in the segment $$$[1, n]$$...
1
Codeforces_test
null
448
stdin
[ "16\n51\n60\n61\n777\n12345689\n1000000000\n2002\n3001\n977\n989898986\n80\n800001\n96\n70\n15\n90\n" ]
[ "3\n2\n1\n0\n1\n3\n5\n4\n0\n7\n1\n2\n7\n0\n7\n3\n" ]
[ "16\n51\n60\n61\n777\n12345689\n1000000000\n2002\n3001\n977\n989898986\n80\n800001\n96\n70\n15\n90\n" ]
[ "3\n2\n1\n0\n1\n3\n5\n4\n0\n7\n1\n2\n7\n0\n7\n3\n" ]
You are given a positive integer $$$n$$$. In one operation, you can add to $$$n$$$ any positive integer whose decimal representation contains only the digit $$$9$$$, possibly repeated several times. What is the minimum number of operations needed to make the number $$$n$$$ contain at least one digit $$$7$$$ in its dec...
1
Codeforces_test
null
449
stdin
[ "3\n3\n2 5\n1 6\n3 4\n4\n1 6\n7 8\n2 3\n4 5\n6\n2 3\n1 6\n7 8\n9 12\n10 11\n4 5\n" ]
[ "5 1 1 1\n14 2 2 1 1\n132 42 5 2 1 1 1\n" ]
[ "3\n3\n2 5\n1 6\n3 4\n4\n1 6\n7 8\n2 3\n4 5\n6\n2 3\n1 6\n7 8\n9 12\n10 11\n4 5\n" ]
[ "5 1 1 1\n14 2 2 1 1\n132 42 5 2 1 1 1\n" ]
This is the hard version of the problem. The difference between the versions is that in this version, the limits on $$$t$$$ and $$$n$$$ are bigger. You can hack only if you solved all versions of this problem. Now Little John is rich, and so he finally buys a house big enough to fit himself and his favorite bracket se...
1
Codeforces_test
null
450
stdin
[ "6\n2 1 1\n1 2\n4 1 2\n1 2\n2 4\n7 2 3\n1 2\n1 3\n6 7\n5 1 2\n1 2\n3 5\n9 2 1\n2 8\n9 2 4\n7 9\n4 8\n1 3\n2 3\n" ]
[ "1 1\n2 1\n1 4\n1 1\n1 1\n3 4\n" ]
[ "6\n2 1 1\n1 2\n4 1 2\n1 2\n2 4\n7 2 3\n1 2\n1 3\n6 7\n5 1 2\n1 2\n3 5\n9 2 1\n2 8\n9 2 4\n7 9\n4 8\n1 3\n2 3\n" ]
[ "1 1\n2 1\n1 4\n1 1\n1 1\n3 4\n" ]
Robin's brother and mother are visiting, and Robin gets to choose the start day for each visitor. All days are numbered from $$$1$$$ to $$$n$$$. Visitors stay for $$$d$$$ continuous days, all of those $$$d$$$ days must be between day $$$1$$$ and $$$n$$$ inclusive. Robin has a total of $$$k$$$ risky 'jobs' planned. Th...
1
Codeforces_test
null
451
stdin
[ "2\n4 3\n1 5 2 4\n4 9 5 3\n4 5 2 3\n1 5 5 2\n1 1 4 4\n2 2 3 3\n1 2 4 3\n3 3\n1 2 3\n4 5 6\n7 8 9\n1 1 1 3\n1 3 3 3\n2 2 2 2\n" ]
[ "500 42 168 \n14 42 5\n" ]
[ "2\n4 3\n1 5 2 4\n4 9 5 3\n4 5 2 3\n1 5 5 2\n1 1 4 4\n2 2 3 3\n1 2 4 3\n3 3\n1 2 3\n4 5 6\n7 8 9\n1 1 1 3\n1 3 3 3\n2 2 2 2\n" ]
[ "500 42 168 \n14 42 5 \n" ]
Swing is opening a pancake factory! A good pancake factory must be good at flattening things, so Swing is going to test his new equipment on 2D matrices. Swing is given an $$$n \times n$$$ matrix $$$M$$$ containing positive integers. He has $$$q$$$ queries to ask you. For each query, he gives you four integers $$$x_1...
1
Codeforces_test
null
452
stdin
[ "6\n2 3\n10\n2 3\n11\n5 1\n11101\n7 9\n1101011\n17 34\n11001010001010010\n1 500\n1\n" ]
[ "3\n2\n0\n8\n32\n0\n" ]
[ "6\n2 3\n10\n2 3\n11\n5 1\n11101\n7 9\n1101011\n17 34\n11001010001010010\n1 500\n1\n", "4\n5 347\n11111\n61 373\n1000000000000000000000000000100000000000000000000000000000000\n57 439\n100010101011110000010111010000110010000110101000110111010\n77 488\n100000000000000000000000000000000000100000000000000000000000000...
[ "3\n2\n0\n8\n32\n0\n", "344\n374\n0\n0\n", "6\n3\n1\n77\n", "3\n38\n49\n0\n", "2\n0\n0\n0\n", "323\n3\n0\n486\n", "12\n3\n12\n6\n", "128\n5\n0\n333\n", "0\n4\n3\n57\n", "385\n219\n3\n3\n", "10\n", "11\n", "0\n0\n1\n24\n", "0\n384\n449\n368\n", "32\n461\n458\n227\n", "96\n236\n256\n0\n"...
This is the easy version of the problem. The difference between the versions is that in this version, the constraints on $$$t$$$, $$$k$$$, and $$$m$$$ are lower. You can hack only if you solved all versions of this problem. A sequence $$$a$$$ of $$$n$$$ integers is called good if the following condition holds: - Let ...
1
Codeforces_test
null
453
stdin
[ "3\n3\n1 2\n2 3\n2 2\n3\n1 2\n2 3\n3 3\n6\n1 2\n1 3\n2 4\n2 5\n1 6\n4 4\n" ]
[ "Bob\nAlice\nAlice\n" ]
[ "3\n3\n1 2\n2 3\n2 2\n3\n1 2\n2 3\n3 3\n6\n1 2\n1 3\n2 4\n2 5\n1 6\n4 4\n" ]
[ "Bob\nAlice\nAlice\n" ]
This is the easy version of the problem. In this version, $$$\mathbf{u = v}$$$. You can make hacks only if both versions of the problem are solved. Alice and Bob are playing a fun game on a tree. This game is played on a tree with $$$n$$$ vertices, numbered from $$$1$$$ to $$$n$$$. Recall that a tree with $$$n$$$ vert...
1
Codeforces_test
null
454
stdin
[ "9 5\n0 1 2 1 3 4 5 6 0\n1 5\n2 5\n3 5\n4 5\n1 9\n" ]
[ "4 1\n2 1\n0 1\n-1\n8 2\n" ]
[ "9 5\n0 1 2 1 3 4 5 6 0\n1 5\n2 5\n3 5\n4 5\n1 9\n", "1 1\n0\n1 1\n", "1 1\n50\n1 1\n" ]
[ "4 1\n2 1\n0 1\n-1\n8 2\n", "0 1\n", "-1\n" ]
Recall the rules of the game "Nim". There are $$$n$$$ piles of stones, where the $$$i$$$-th pile initially contains some number of stones. Two players take turns choosing a non-empty pile and removing any positive (strictly greater than $$$0$$$) number of stones from it. The player unable to make a move loses the game....
1
Codeforces_test
null
455
stdin
[ "4\n4\n2 0\n1 1\n3 0\n5 1\n6\n4 6\n1 3\n4 6\n4 0\n7 6\n6 3\n7\n9 0\n7 1\n5 0\n7 1\n9 0\n1 1\n2 0\n10\n10 7\n4 9\n2 2\n7 9\n2 8\n8 5\n11 7\n15 5\n12 7\n4 0\n" ]
[ "2 2 4 5 \n4 4 7 7 10 10 \n9 9 9 9 9 9 10 \n10 10 10 10 10 10 12 15 15 15\n" ]
[ "4\n4\n2 0\n1 1\n3 0\n5 1\n6\n4 6\n1 3\n4 6\n4 0\n7 6\n6 3\n7\n9 0\n7 1\n5 0\n7 1\n9 0\n1 1\n2 0\n10\n10 7\n4 9\n2 2\n7 9\n2 8\n8 5\n11 7\n15 5\n12 7\n4 0\n", "1\n10\n1000000000 1\n1 0\n1000000000 1\n1 0\n1000000000 1\n1 0\n1000000000 1\n1 0\n1000000000 1\n1 0\n" ]
[ "2 2 4 5 \n4 4 7 7 10 10 \n9 9 9 9 9 9 10 \n10 10 10 10 10 10 12 15 15 15 \n", "1000000000 1000000000 1999999999 1999999999 2999999998 2999999998 3999999997 3999999997 4999999996 4999999996 \n" ]
Given an array of integers $$$s_1, s_2, \ldots, s_l$$$, every second, cosmic rays will cause all $$$s_i$$$ such that $$$i=1$$$ or $$$s_i\neq s_{i-1}$$$ to be deleted simultaneously, and the remaining parts will be concatenated together in order to form the new array $$$s_1, s_2, \ldots, s_{l'}$$$. Define the strength ...
1
Codeforces_test
null
456
stdin
[ "7\n4\n5 5 5 10\n4\n10 5 10 5\n4\n1 2 3 4\n4\n1 1 1 3\n6\n4 2 1 5 7 1\n6\n10 200 30 300 30 100\n4\n100000000 100000000 1 2\n" ]
[ "5 5 5 10\n5 5 10 10\n-1\n-1\n1 1 4 5\n-1\n100000000 100000000 1 2\n" ]
[ "7\n4\n5 5 5 10\n4\n10 5 10 5\n4\n1 2 3 4\n4\n1 1 1 3\n6\n4 2 1 5 7 1\n6\n10 200 30 300 30 100\n4\n100000000 100000000 1 2\n", "1\n4\n1 2 2 4\n", "1\n5\n8 10 10 12 100\n", "1\n4\n10 11 11 12\n", "1\n4\n100 105 105 106\n", "1\n4\n1 5 5 6\n", "1\n4\n1 10 10 20\n", "1\n4\n3 4 4 5\n", "1\n4\n1 2 2 3\n",...
[ "5 10 5 5\n5 5 10 10\n-1\n-1\n4 5 1 1\n-1\n1 2 100000000 100000000\n", "1 4 2 2\n", "8 12 10 10\n", "10 12 11 11\n", "100 106 105 105\n", "1 6 5 5\n", "1 20 10 10\n", "3 5 4 4\n", "1 3 2 2\n", "1 1 1 1\n", "4 4 4 4\n" ]
Kevin has $$$n$$$ sticks with length $$$a_1,a_2,\ldots,a_n$$$. Kevin wants to select $$$4$$$ sticks from these to form an isosceles trapezoid$$$^{\text{∗}}$$$ with a positive area. Note that rectangles and squares are also considered isosceles trapezoids. Help Kevin find a solution. If no solution exists, output $$$-1...
1
Codeforces_test
null
457
stdin
[ "7\n1\n1\n3\n1 2 3\n3\n1 2 2\n5\n5 4 3 2 1\n6\n1 1 2 2 3 3\n8\n8 7 6 3 8 7 6 3\n6\n1 1 4 5 1 4\n" ]
[ "0\n2\n1\n4\n4\n6\n3\n" ]
[ "7\n1\n1\n3\n1 2 3\n3\n1 2 2\n5\n5 4 3 2 1\n6\n1 1 2 2 3 3\n8\n8 7 6 3 8 7 6 3\n6\n1 1 4 5 1 4\n" ]
[ "0\n2\n1\n4\n4\n6\n3\n" ]
You are given a cyclic array $$$a_1, a_2, \ldots, a_n$$$. You can perform the following operation on $$$a$$$ at most $$$n - 1$$$ times: - Let $$$m$$$ be the current size of $$$a$$$, you can choose any two adjacent elements where the previous one is no greater than the latter one (In particular, $$$a_m$$$ and $$$a_1$$...
1
Codeforces_test
null
458
stdin
[ "6\n3\nabc\n4\nxyyx\n8\nalphabet\n1\nk\n10\naabbccddee\n6\nttbddq\n" ]
[ "cbc\nyyyx\nalphaaet\nk\neabbccddee\ntttddq\n" ]
[ "6\n3\nabc\n4\nxyyx\n8\nalphabet\n1\nk\n10\naabbccddee\n6\nttbddq\n" ]
[ "cbc\nyyyx\nalphaaet\nk\neabbccddee\ntttddq\n" ]
You're given a string $$$s$$$ of length $$$n$$$, consisting of only lowercase English letters. You must do the following operation exactly once: - Choose any two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$). You can choose $$$i = j$$$. - Set $$$s_i := s_j$$$. You need to minimize the number of distinct permu...
1
Codeforces_test
null
459
stdin
[ "2\n5\n\n4\n\n0\n\n1\n\n2\n\n2\n\n0\n" ]
[ "? 1 5\n\n? 2 4\n\n? 4 5\n\n? 3 5\n\n! 01001\n\n? 1 2\n\n! IMPOSSIBLE\n" ]
[ "2\n5\n01001\n2\n11\n" ]
[ "01001\nIMPOSSIBLE\n" ]
This is an interactive problem. Kachina challenges you to guess her favorite binary string$$$^{\text{∗}}$$$ $$$s$$$ of length $$$n$$$. She defines $$$f(l, r)$$$ as the number of subsequences$$$^{\text{†}}$$$ of $$$\texttt{01}$$$ in $$$s_l s_{l+1} \ldots s_r$$$. Two subsequences are considered different if they are for...
1
Codeforces_test
null
460
stdin
[ "11\n1 998244353\n2 998244353\n3 998244353\n4 998244353\n5 998244353\n6 998244353\n7 998244353\n8 998244353\n9 998244353\n10 102275857\n10 999662017\n" ]
[ "0 1 \n1 2 1 \n14 7 4 2 \n183 34 19 16 4 \n2624 209 112 120 48 12 \n42605 1546 793 992 468 216 36 \n785910 13327 6556 9190 4672 2880 864 144 \n16382863 130922 61939 94992 50100 36960 14256 4608 576 \n382823936 1441729 657784 1086596 583344 488700 216000 96480 23040 2880 \n20300780 17572114 7751377 13641280 7376068 ...
[ "11\n1 998244353\n2 998244353\n3 998244353\n4 998244353\n5 998244353\n6 998244353\n7 998244353\n8 998244353\n9 998244353\n10 102275857\n10 999662017\n", "25\n14 616004887\n16 795653233\n15 156499103\n15 531841069\n16 725817269\n16 959122081\n13 362265263\n18 639275569\n19 303815327\n15 889963901\n11 523951873\n16...
[ "0 1 \n1 2 1 \n14 7 4 2 \n183 34 19 16 4 \n2624 209 112 120 48 12 \n42605 1546 793 992 468 216 36 \n785910 13327 6556 9190 4672 2880 864 144 \n16382863 130922 61939 94992 50100 36960 14256 4608 576 \n382823936 1441729 657784 1086596 583344 488700 216000 96480 23040 2880 \n20300780 17572114 7751377 13641280 7376068 ...
This is the hard version of the problem. In the three versions, the constraints on $$$n$$$ and the time limit are different. You can make hacks only if all the versions of the problem are solved. This is the statement of Problem D1B: - There are $$$n$$$ cities in a row, numbered $$$1, 2, \ldots, n$$$ left to right. ...
1
Codeforces_test
null
461
stdin
[ "3\nGARAGE\nGARAGEFORSALE\nABCDE\nAABCD\nTRAINING\nDRAINING\n" ]
[ "14\n10\n16\n" ]
[ "3\nGARAGE\nGARAGEFORSALE\nABCDE\nAABCD\nTRAINING\nDRAINING\n", "1\nABCD\nDABC\n", "1\nGUFY\nTFIG\n", "6\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\n" ]
[ "14\n10\n16\n", "8\n", "8\n", "2\n2\n2\n2\n2\n2\n" ]
There are two screens which can display sequences of uppercase Latin letters. Initially, both screens display nothing. In one second, you can do one of the following two actions: - choose a screen and an uppercase Latin letter, and append that letter to the end of the sequence displayed on that screen; - choose a scr...
1
Codeforces_test
null
462
stdin
[ "1\n", "3\n", "1000\n" ]
[ "2\n", "4\n", "1167\n" ]
[ "1\n", "3\n", "1000\n", "2\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "993\n", "994\n", "995\n", "996\n", "997\n", "998\n", "999\n", "730\n", "418\n", "550\n" ]
[ "2\n", "4\n", "1167\n", "3\n", "5\n", "6\n", "7\n", "9\n", "10\n", "11\n", "1159\n", "1160\n", "1161\n", "1162\n", "1164\n", "1165\n", "1166\n", "852\n", "488\n", "642\n" ]
Recently, Monocarp started working as a director of a park located near his house. The park is quite large, so it even has a small river splitting it into several zones. Several bridges are built across this river. Three of these bridges are especially old and need to be repaired. All three bridges have the same lengt...
1
Codeforces_test
null
463
stdin
[ "4\n3\n1 2 3\n1 3\n2 3\n4\n3 1 1 3\n1 2\n2 3\n4 2\n4\n2 4 4 2\n1 2\n2 3\n3 4\n13\n1 4 4 7 4 7 1 1 7 11 11 11 11\n1 2\n2 3\n3 4\n4 5\n4 6\n2 7\n7 8\n2 9\n6 10\n5 11\n11 12\n10 13\n" ]
[ "000\n1010\n0001\n1001001000100\n" ]
[ "4\n3\n1 2 3\n1 3\n2 3\n4\n3 1 1 3\n1 2\n2 3\n4 2\n4\n2 4 4 2\n1 2\n2 3\n3 4\n13\n1 4 4 7 4 7 1 1 7 11 11 11 11\n1 2\n2 3\n3 4\n4 5\n4 6\n2 7\n7 8\n2 9\n6 10\n5 11\n11 12\n10 13\n" ]
[ "000\n1010\n0001\n1001001000100\n" ]
Let's define the majority of a sequence of $$$k$$$ elements as the unique value that appears strictly more than $$$\left \lfloor {\frac{k}{2}} \right \rfloor$$$ times. If such a value does not exist, then the sequence does not have a majority. For example, the sequence $$$[1,3,2,3,3]$$$ has a majority $$$3$$$ because i...
1
Codeforces_test
null
464
stdin
[ "2\n3 2 4\n0 0 0 0\n5 5 7\n0 0 0 0 0 0 0\n" ]
[ "6\n190\n" ]
[ "2\n3 2 4\n0 0 0 0\n5 5 7\n0 0 0 0 0 0 0\n", "1\n39 1 1\n0\n" ]
[ "6\n190\n", "1\n" ]
This is the easy version of the problem. The difference between the versions is that in this version, all $$$a_i = 0$$$. You can hack only if you solved all versions of this problem. There is an $$$n$$$-story building, with floors numbered from $$$1$$$ to $$$n$$$ from bottom to top. There is exactly one person living ...
1
Codeforces_test
null
465
stdin
[ "5\n5\n1 2 3 4 5\n4\n4 3 2 1\n4\n4 5 2 3\n8\n4 5 4 5 4 5 4 5\n9\n9 9 8 2 4 4 3 5 3\n" ]
[ "YES\nNO\nYES\nYES\nNO\n" ]
[ "5\n5\n1 2 3 4 5\n4\n4 3 2 1\n4\n4 5 2 3\n8\n4 5 4 5 4 5 4 5\n9\n9 9 8 2 4 4 3 5 3\n", "1\n3\n1 1 2\n" ]
[ "YES\nNO\nYES\nYES\nNO\n", "YES\n" ]
You are given a sequence $$$a$$$ consisting of $$$n$$$ positive integers. You can perform the following operation any number of times. - Select an index $$$i$$$ ($$$1 \le i < n$$$), and subtract $$$\min(a_i,a_{i+1})$$$ from both $$$a_i$$$ and $$$a_{i+1}$$$. Determine if it is possible to make the sequence non-decrea...
1
Codeforces_test
null
466
stdin
[ "2\n\n18\n\n25\n\n\n9999\n" ]
[ "? 3 5\n\n? 4 4\n\n! 4\n? 99 100\n\n! 100\n" ]
[ "2\n4\n100\n" ]
[ "4\n100\n" ]
This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most $$$\mathbf{10}$$$ queries. This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants. We have a secret ru...
1
Codeforces_test
null
467
stdin
[ "9\n2 1\n4 5\n9\n2 1\n3 6\n9\n4 2\n1 2 2 2\n3 4\n4 2\n1 1 3 3\n3 5\n4 2\n1 2 3 4\n3 5\n5 5\n1 2 3 4 5\n5 4 3 2 1\n4 2\n1 1 1 1\n1 1\n4 4\n1 1 1 1\n1 1 1 2\n1 1\n1\n1000000000\n" ]
[ "Yes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\nNo\n" ]
[ "9\n2 1\n4 5\n9\n2 1\n3 6\n9\n4 2\n1 2 2 2\n3 4\n4 2\n1 1 3 3\n3 5\n4 2\n1 2 3 4\n3 5\n5 5\n1 2 3 4 5\n5 4 3 2 1\n4 2\n1 1 1 1\n1 1\n4 4\n1 1 1 1\n1 1 1 2\n1 1\n1\n1000000000\n", "4\n1 1\n1000000000\n1000000000\n2 2\n500000000 500000000\n1000000000 1000000000\n3 1\n1 500000000 500000000\n1000000000\n8 1\n53687091...
[ "Yes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\nNo\n", "Yes\nNo\nNo\nNo\n" ]
Kevin wrote an integer sequence $$$a$$$ of length $$$n$$$ on the blackboard. Kevin can perform the following operation any number of times: - Select two integers $$$x, y$$$ on the blackboard such that $$$|x - y| \leq 1$$$, erase them, and then write down an integer $$$x + y$$$ instead. Kevin wants to know if it is p...
1
Free AI Image Generator No sign-up. Instant results. Open Now