source int64 2 2 | difficulty int64 7 25 | name stringlengths 9 60 | description stringlengths 164 7.12k | public_tests dict | private_tests dict | cf_rating int64 0 3.5k | cf_points float64 0 4k |
|---|---|---|---|---|---|---|---|
2 | 9 | 362_C. Insertion Sort | Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that implements this algorithm and sorts the given integer zero-indexed array a of size n in the non-decre... | {
"input": [
"5\n1 2 3 4 0\n",
"5\n4 0 3 1 2\n"
],
"output": [
"3 4",
"3 2"
]
} | {
"input": [
"13\n5 11 12 10 3 8 4 0 7 9 6 1 2\n",
"3\n2 0 1\n",
"8\n1 5 4 0 2 7 3 6\n",
"3\n0 2 1\n",
"3\n1 0 2\n",
"100\n73 98 9 92 43 77 32 2 29 5 58 59 61 17 10 94 60 12 80 16 24 91 8 70 62 99 47 23 78 19 22 30 44 96 63 74 48 18 69 45 33 88 97 11 31 66 1 82 7 28 27 41 51 0 37 39 71 75 13 2... | 1,900 | 2,500 |
2 | 7 | 386_A. Second-Price Auction | In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organizer of the auction price he is willing to pay. After that, the auct... | {
"input": [
"6\n3 8 2 9 4 14\n",
"2\n5 7\n",
"3\n10 2 8\n"
],
"output": [
"6 9\n",
"2 5\n",
"1 8\n"
]
} | {
"input": [
"3\n30 20 10\n",
"3\n3 4 1\n",
"3\n30 10 20\n",
"100\n2515 3324 7975 6171 4240 1217 4829 5203 8603 6900 3031 4699 4732 6070 4221 3228 6497 7359 9130 4346 4619 1109 3945 5442 3271 16 9711 2045 6410 2301 3406 8125 6003 1892 1260 9661 3940 6692 4708 7027 4930 6925 1979 5361 4263 3144 867 863... | 800 | 500 |
2 | 7 | 434_A. Ryouko's Memory Note | Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the notebook became her memory.
Though Ryouko is forgetful, she is also bo... | {
"input": [
"4 6\n1 2 3 4 3 2\n",
"10 5\n9 4 3 8 8\n"
],
"output": [
"3\n",
"6\n"
]
} | {
"input": [
"5 10\n2 5 2 2 3 5 3 2 1 3\n",
"1000 10\n1 1 1 1 1 1000 1000 1000 1000 1000\n",
"10 20\n6 3 9 6 1 9 1 9 8 2 7 6 9 8 4 7 1 2 4 2\n",
"100000 1\n14542\n",
"100000 50\n43104 45692 17950 43454 99127 33540 80887 7990 116 79790 66870 61322 5479 24876 7182 99165 81535 3498 54340 7460 43666 9... | 1,800 | 1,500 |
2 | 9 | 456_C. Boredom | Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and... | {
"input": [
"9\n1 2 1 3 2 2 2 2 3\n",
"3\n1 2 3\n",
"2\n1 2\n"
],
"output": [
"10\n",
"4\n",
"2\n"
]
} | {
"input": [
"5\n3 3 4 5 4\n",
"10\n8 9 6 5 6 4 10 9 1 4\n",
"100\n6 6 8 9 7 9 6 9 5 7 7 4 5 3 9 1 10 3 4 5 8 9 6 5 6 4 10 9 1 4 1 7 1 4 9 10 8 2 9 9 10 5 8 9 5 6 8 7 2 8 7 6 2 6 10 8 6 2 5 5 3 2 8 8 5 3 6 2 1 4 7 2 7 3 7 4 10 10 7 5 4 7 5 10 7 1 1 10 7 7 7 2 3 4 2 8 4 7 4 4\n",
"100\n7 5 1 8 5 6 6 2 ... | 1,500 | 500 |
2 | 7 | 479_A. Expression | Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resulting e... | {
"input": [
"2\n10\n3\n",
"1\n2\n3\n"
],
"output": [
"60\n",
"9\n"
]
} | {
"input": [
"2\n1\n2\n",
"5\n6\n1\n",
"10\n10\n10\n",
"8\n9\n7\n",
"9\n2\n1\n",
"6\n7\n1\n",
"1\n2\n1\n",
"9\n7\n2\n",
"1\n9\n1\n",
"10\n1\n1\n",
"1\n3\n1\n",
"2\n6\n1\n",
"2\n8\n3\n",
"1\n10\n1\n",
"4\n2\n10\n",
"3\n1\n5\n",
"2\n1\n1\n",
"9\n1\... | 1,000 | 500 |
2 | 7 | 501_A. Contest | Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contes... | {
"input": [
"1000 1000 1 1\n",
"1500 1000 176 177\n",
"500 1000 20 30\n"
],
"output": [
"Tie",
"Misha",
"Vasya"
]
} | {
"input": [
"1250 2000 101 180\n",
"3000 3250 16 34\n",
"250 3500 0 180\n",
"3500 250 0 180\n",
"3250 250 175 173\n",
"1500 1000 74 177\n",
"750 2500 175 178\n",
"1750 2250 178 53\n",
"1250 2500 100 176\n",
"250 750 180 176\n",
"2500 2750 73 179\n",
"1000 250 175 48\n"... | 900 | 500 |
2 | 8 | 552_B. Vanya and Books | Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned distinct numbers.
Vanya wants to know how many digits he will have to write down as he labels the bo... | {
"input": [
"13\n",
"4\n"
],
"output": [
"17\n",
"4\n"
]
} | {
"input": [
"995\n",
"100000\n",
"10000\n",
"99995\n",
"100001\n",
"1\n",
"10001\n",
"36123011\n",
"290092\n",
"10\n",
"999999998\n",
"35\n",
"996\n",
"999\n",
"999999999\n",
"349463\n",
"30660\n",
"96482216\n",
"9999\n",
"1342\n",
"... | 1,200 | 1,000 |
2 | 8 | 579_B. Finding Team Member | There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.
Every contestant hopes that he can find a... | {
"input": [
"2\n6\n1 2\n3 4 5\n",
"3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960\n"
],
"output": [
"2 1 4 3\n",
"6 5 4 3 2 1\n"
]
} | {
"input": [
"3\n8\n1 6\n14 13 15\n4 2 11 9\n12 5 3 7 10\n",
"3\n1000000\n999999 999998\n999997 999996 999995\n999994 999993 999992 999991\n999990 999989 999988 999987 999986\n",
"1\n1000000\n"
],
"output": [
"6 5 4 3 2 1\n",
"2 1 4 3 6 5\n",
"2 1\n"
]
} | 1,300 | 500 |
2 | 7 | 600_A. Extract Numbers | You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for example, the string s=";;" contains three empty words separated by ';'.
You ... | {
"input": [
"1;;01,a0,\n",
"a\n",
"aba,123;1a;0\n",
"1\n"
],
"output": [
"\"1\"\n\",01,a0,\"\n",
"-\n\"a\"\n",
"\"123,0\"\n\"aba,1a\"\n",
"\"1\"\n-\n"
]
} | {
"input": [
"5345rhhr34t.k;k;k;k;k;5677;000000,000000;000098,0.70k;89.;;;\n",
",2\n",
";\n",
"00\n",
"ashasg,00000,00,;,hahaha,kheng\n",
"01\n",
"6;2,\n",
"000\n",
"123456789\n",
",;,,;\n",
"000.0039255805110943267,0.7362934823735448084,Y3x2yDItgcQYwqPy,0.43008021190538275... | 1,600 | 0 |
2 | 10 | 622_D. Optimal Number Permutation | You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.
Let number i be in positions xi, yi (xi < yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the valu... | {
"input": [
"1\n",
"2\n"
],
"output": [
"1 1 ",
"1 1 2 2 "
]
} | {
"input": [
"10\n",
"100\n",
"1232\n",
"1134\n",
"4\n",
"1234\n",
"1233\n",
"3\n"
],
"output": [
"1 3 5 7 9 9 7 5 3 1 2 4 6 8 10 8 6 4 2 10 ",
"1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89... | 1,900 | 0 |
2 | 12 | 670_F. Restore a Number | Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n.
Magically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remembers, is a non-empty substr... | {
"input": [
"199966633300\n63\n",
"003512\n021\n"
],
"output": [
"3036366999",
"30021"
]
} | {
"input": [
"712\n17\n",
"11007000\n1000\n",
"12140051050330004342310455231200020252193200\n23012\n",
"50104\n10\n",
"1110006\n1001\n",
"10\n0\n",
"1516532320120301262110112013012410838210025280432402042406224604110031740090203024020012\n0126064\n",
"1111110111101011411101100110100111... | 2,300 | 2,500 |
2 | 9 | 696_C. PLEASE | As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup.
<image>
Then at one turn Barney swaps the cup in the midd... | {
"input": [
"1\n2\n",
"3\n1 1 1\n"
],
"output": [
"1/2\n",
"0/1\n"
]
} | {
"input": [
"1\n983155795040951739\n",
"12\n254904759290707697 475737283258450340 533306428548398547 442127134828578937 779740159015946254 272877594683860919 93000149670491971 349640818793278778 498293278222136720 551099726729989816 149940343283925029 989425634209891686\n",
"1\n1000000005\n",
"1\n100... | 2,000 | 1,500 |
2 | 10 | 717_D. Dexterina’s Lab | Dexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes in a peaceful and nonviolent way. After god knows how many different challenges they’ve given to one another, their score is equal and they’re ... | {
"input": [
"2 2\n0.500000 0.250000 0.250000\n"
],
"output": [
"0.62500000\n"
]
} | {
"input": [
"9 9\n0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000\n",
"1000000 5\n0.000000 0.000000 1.000000 0.000000 0.000000 0.000000\n",
"100 20\n0.065682 0.015963 0.024840 0.025856 0.000807 0.004366 0.020977 0.151841 0.050870 0.009918 0.044345 0.009672 0.0776... | 1,900 | 0 |
2 | 11 | 761_E. Dasha and Puzzle | Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, but remembered the puzzle that she could not solve.
<image>
The tree is a non-oriented connected graph without cycles. In particular, there always are n - 1 edges in a tree with n vertices.
The puzz... | {
"input": [
"6\n1 2\n2 3\n2 4\n2 5\n2 6\n",
"4\n1 2\n2 3\n3 4",
"7\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"
],
"output": [
"NO\n",
"YES\n0 0\n1073741824 0\n1610612736 0\n1879048192 0\n",
"YES\n0 0\n0 1073741824\n1073741824 0\n0 1610612736\n536870912 1073741824\n1073741824 536870912\n1610612736 0\n"... | {
"input": [
"28\n24 3\n3 8\n8 21\n21 23\n23 6\n6 16\n16 22\n22 11\n11 12\n11 20\n11 7\n22 15\n22 13\n16 14\n16 27\n6 26\n6 19\n23 17\n23 1\n21 2\n21 18\n8 28\n8 25\n3 5\n3 10\n24 9\n24 4\n",
"3\n2 1\n3 1\n",
"13\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13\n",
"30\n1 2\n1 3\n2 4\n2... | 2,000 | 2,500 |
2 | 13 | 784_G. BF Calculator | In this problem you will write a simple generator of Brainfuck (<https://en.wikipedia.org/wiki/Brainfuck>) calculators.
You are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will print the result of eval... | {
"input": [
"2+3\n",
"9-7\n"
],
"output": [
"+++++++++++++++++++++++++++++++++++++++++++++++++++++.>\n",
"++++++++++++++++++++++++++++++++++++++++++++++++++.>\n"
]
} | {
"input": [
"255-255+255-255+255-255+255-255+255\n",
"255-12-34-56-69-78\n",
"1+1+1\n",
"0+0+0+0+0+0+0+0+0+0\n",
"9+1\n",
"34+45+29-49+52-111-4+4+2+9\n",
"31+49+49+71-51-61+59-111+51\n",
"1+11+111\n",
"255+255+255+255+255-255-255-255-255-255\n",
"10-1\n",
"2+3\n",
"243... | 2,000 | 0 |
2 | 7 | 831_A. Unimodal Array | Array of integers is unimodal, if:
* it is strictly increasing in the beginning;
* after that it is constant;
* after that it is strictly decreasing.
The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.
For example, the following th... | {
"input": [
"7\n3 3 3 3 3 3 3\n",
"6\n1 5 5 5 4 2\n",
"4\n1 2 1 2\n",
"5\n10 20 30 20 10\n"
],
"output": [
"YES\n",
"YES\n",
"NO\n",
"YES\n"
]
} | {
"input": [
"5\n2 2 1 1 1\n",
"3\n1 2 3\n",
"6\n5 7 11 11 2 1\n",
"4\n4 5 5 6\n",
"2\n1 3\n",
"100\n360 362 367 369 374 377 382 386 389 391 396 398 399 400 405 410 413 416 419 420 423 428 525 436 441 444 445 447 451 453 457 459 463 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 4... | 1,000 | 500 |
2 | 8 | 852_B. Neural Network country | Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with many layers, each layer possibly having many cities. They also have one entry, and one exit point.
There are exactly L layers, each having N cities. Let us look at... | {
"input": [
"2 3 13\n4 6\n2 1\n3 4\n"
],
"output": [
"2\n"
]
} | {
"input": [
"5 4 3\n2 1 0 1 2\n0 1 2 1 0\n1 2 1 0 2\n",
"1 1234 5\n1\n1\n1\n",
"3 2 2\n0 1 0\n0 0 1\n1 1 0\n",
"4 4 4\n0 1 3 2\n1 2 0 3\n2 3 1 0\n",
"2 4 5\n1 1\n1 1\n1 1\n"
],
"output": [
"209\n",
"1\n",
"3\n",
"64\n",
"16\n"
]
} | 2,000 | 0 |
2 | 9 | 876_C. Classroom Watch | Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain posi... | {
"input": [
"20\n",
"21\n"
],
"output": [
"0\n",
"1\n15 "
]
} | {
"input": [
"10\n",
"66\n",
"39\n",
"2\n",
"100\n",
"2014\n",
"101\n",
"999999994\n",
"1000000000\n",
"9\n",
"999999979\n",
"3\n",
"11\n",
"100000001\n",
"1\n",
"75\n"
],
"output": [
"1\n5 ",
"1\n60 ",
"1\n33 ",
"1\n1 ",
"1\n86 "... | 1,200 | 500 |
2 | 9 | 8_C. Looking for Order | Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag were thrown about the room. Of course, she wanted to put them back into her handbag. The problem is that the girl canno... | {
"input": [
"0 0\n2\n1 1\n-1 1\n",
"1 1\n3\n4 3\n3 4\n0 0\n"
],
"output": [
"8\n0 1 2 0\n",
"32\n0 1 2 0 3 0\n"
]
} | {
"input": [
"-21 -47\n24\n-37 1\n-65 8\n-74 74\n58 -7\n81 -31\n-77 90\n-51 10\n-42 -37\n-14 -17\n-26 -71\n62 45\n56 43\n-75 -73\n-33 68\n39 10\n-65 -93\n61 -93\n30 69\n-28 -53\n5 24\n93 38\n-45 -14\n3 -86\n63 -80\n",
"11 3\n6\n-17 -17\n-4 -9\n15 19\n7 4\n13 1\n5 -6\n",
"-49 4\n23\n-18 -53\n-42 31\n18 -84... | 2,000 | 0 |
2 | 8 | 922_B. Magic Forest | Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Forma... | {
"input": [
"6\n",
"10\n"
],
"output": [
"1\n",
"2\n"
]
} | {
"input": [
"1051\n",
"2498\n",
"846\n",
"1508\n",
"2451\n",
"1566\n",
"194\n",
"952\n",
"1322\n",
"1946\n",
"2444\n",
"2\n",
"1294\n",
"1703\n",
"1731\n",
"1781\n",
"1079\n",
"2433\n",
"2500\n",
"857\n",
"818\n",
"2207\n",
"... | 1,300 | 1,000 |
2 | 9 | 94_C. Frames | Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbies, one can quit something as well.
This time Igor K. got disappointed in ... | {
"input": [
"20 5 2 20\n",
"11 4 3 9\n"
],
"output": [
"2\n",
"3\n"
]
} | {
"input": [
"28 5 4 26\n",
"4 3 3 4\n",
"14 8 2 12\n",
"7 3 2 6\n",
"79 8 41 64\n",
"63 11 23 48\n",
"51474721 867363452 12231088 43489285\n",
"7 3 1 3\n",
"8 3 6 6\n",
"9 2 4 7\n",
"7 3 5 7\n",
"149 49 92 129\n",
"192293793 2864 5278163 190776899\n",
"7 3 1 7\... | 1,700 | 500 |
2 | 7 | 978_A. Remove Duplicates | Petya has an array a consisting of n integers. He wants to remove duplicate (equal) elements.
Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed.
Input
The first line contains a single integer n (1 ≤ n ≤ ... | {
"input": [
"5\n6 6 6 6 6\n",
"6\n1 5 5 1 6 1\n",
"5\n2 4 2 4 4\n"
],
"output": [
"1\n6\n",
"3\n5 6 1\n",
"2\n2 4\n"
]
} | {
"input": [
"28\n997 994 991 994 994 995 1000 992 995 994 994 995 991 996 991 996 991 999 999 993 994 997 995 992 991 992 998 1000\n",
"6\n1000 1 1000 2 1 1000\n",
"36\n999 1000 993 993 1000 999 996 997 998 995 995 997 999 995 1000 998 998 994 993 998 994 999 1000 995 996 994 991 991 999 996 993 999 996 ... | 800 | 0 |
2 | 10 | 1030_D. Vasya and Triangle | Vasya has got three integers n, m and k. He'd like to find three integer points (x_1, y_1), (x_2, y_2), (x_3, y_3), such that 0 ≤ x_1, x_2, x_3 ≤ n, 0 ≤ y_1, y_2, y_3 ≤ m and the area of the triangle formed by these points is equal to nm/k.
Help Vasya! Find such points (if it's possible). If there are multiple solutio... | {
"input": [
"4 4 7\n",
"4 3 3\n"
],
"output": [
"NO",
"YES\n0 0\n4 0\n0 2\n"
]
} | {
"input": [
"1 156483121 156483121\n",
"71 7 918774577\n",
"1 23 96139333\n",
"8 2 802716944\n",
"3 4 2\n",
"1 1 2\n",
"307439915 61744535 511\n",
"626673832 329016046 38\n",
"185 5 955376075\n",
"2 2 8\n",
"4354 3801 181\n",
"4 16 540162752\n",
"4 3 3\n",
"799... | 1,800 | 1,500 |
2 | 8 | 1053_B. Vasya and Good Sequences | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | {
"input": [
"3\n6 7 14\n",
"4\n1 2 1 16\n"
],
"output": [
"2",
"4"
]
} | {
"input": [
"5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n",
"1\n4\n",
"1\n15\n"
],
"output": [
"3",
"0",
"0"
]
} | 2,000 | 2,000 |
2 | 9 | 1075_C. The Tower is Going Home | On a chessboard with a width of 10^9 and a height of 10^9, the rows are numbered from bottom to top from 1 to 10^9, and the columns are numbered from left to right from 1 to 10^9. Therefore, for each cell of the chessboard you can assign the coordinates (x,y), where x is the column number and y is the row number.
Ever... | {
"input": [
"1 3\n4\n1 5 3\n1 9 4\n4 6 6\n",
"0 0\n",
"0 2\n1 1000000000 4\n1 1000000000 2\n",
"2 3\n6\n8\n1 5 6\n1 9 4\n2 4 2\n",
"2 3\n4\n6\n1 4 3\n1 5 2\n1 6 5\n"
],
"output": [
"1\n",
"0\n",
"2\n",
"1\n",
"2\n"
]
} | {
"input": [
"0 1\n1 999999999 1\n",
"0 5\n1 96762320 50510976\n243235878 312125306 50510976\n326016273 338641867 50510976\n385105810 445224816 50510976\n456157384 569789185 50510976\n",
"4 7\n1\n2\n3\n4\n1 1000000000 1\n1 1000000000 2\n1 1000000000 3\n1 1000000000 4\n1 1000000000 5\n1 1000000000 6\n1 100... | 1,700 | 750 |
2 | 10 | 1096_D. Easy Problem | Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length n consisting of lowercase Latin latters. Vasya thinks that the statement can be considered hard if it contains a subsequence hard; otherwise the statement is easy. For example, hard, hzazrzd, haaaaa... | {
"input": [
"6\nhhaarr\n1 2 3 4 5 6\n",
"6\nhhardh\n3 2 9 11 7 1\n",
"8\nhhzarwde\n3 2 6 9 4 8 7 1\n"
],
"output": [
"0\n",
"5\n",
"4\n"
]
} | {
"input": [
"13\nahrhzhdrrhrra\n129663316 931385006 161287509 358388863 419876340 273873401 62842415 300480437 457244082 211902320 180793874 526023462 380455601\n",
"3\nxdd\n1 2 3\n",
"14\nhrdddddzdaahdh\n618683599 53236412 430255850 527201063 76877367 826920910 356360303 624569082 297964311 44495952 517... | 1,800 | 0 |
2 | 11 | 1117_E. Decypher the String | This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You m... | {
"input": [
"yzx\naab\nbaa\naba"
],
"output": [
"? abc\n? aaa\n? aaa\n! axa\n"
]
} | {
"input": [
"aaaaaaaabaabbabaabaaabbabbbbabbababbbbbaaabaaaaababbbaaaababbbabbababbabbbbabbbaabbaabbabbaabbababab\n0\n",
"rbonbwjolsbxvxarphavacqsgocwkfiezfibxvjgrfgmnqulggrkhtkhgmtcbpjfwbajrhifuclyjsmhunfxckbanswnsofcxdsr\n0\n",
"kibcfurptlvrwhgwoihxiabvdm\n26\n5 3\n5 12\n19 1\n13 19\n19 22\n2 8\n16 21\... | 2,200 | 0 |
2 | 7 | 1144_A. Diverse Strings | A string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the following strings are diverse: "fced", "xyz", "r" and "dabcef". The following string are not diverse: "az", "aa", "bad" and "babc". Note that the letters 'a' and 'z' are n... | {
"input": [
"8\nfced\nxyz\nr\ndabcef\naz\naa\nbad\nbabc\n"
],
"output": [
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\n"
]
} | {
"input": [
"1\nshh\n",
"1\nsoo\n",
"1\naaaab\n",
"1\nabcdefghijkm\n",
"1\nabczz\n",
"1\naadde\n",
"1\ndaa\n",
"1\nefhi\n",
"2\nrtsuvwyz\nzyxwvutsrqponmlkjihgfedcbaaa\n",
"1\nabbdf\n",
"69\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc... | 800 | 0 |
2 | 8 | 1184_B2. The Doctor Meets Vader (Medium) | Thanks to the Doctor's help, the rebels managed to steal enough gold to launch a full-scale attack on the Empire! However, Darth Vader is looking for revenge and wants to take back his gold.
The rebels have hidden the gold in various bases throughout the galaxy. Darth Vader and the Empire are looking to send out their... | {
"input": [
"6 7\n1 2\n2 3\n3 4\n4 6\n6 5\n4 4\n3 6\n4 2 7 3\n1 10 2\n3 8 2\n5 1 0\n6 5 4\n3 7\n5 2\n"
],
"output": [
"12\n"
]
} | {
"input": [
"1 1\n1 1\n2 1 657705832 300429230\n1 435788130 187757098\n1 464180683 238039721\n1 101041215\n",
"1 1\n1 1\n1 2 498328473 730315543\n1 267535146 337021959\n1 340728578\n1 82073826\n",
"1 0\n1 1 154608701 257538154\n1 148757376 932599775\n1 953264671\n",
"1 1\n1 1\n2 2 551454259 292052813... | 2,200 | 0 |
2 | 8 | 1202_B. You Are Given a Decimal String... | Suppose you have a special x-y-counter. This counter can store some value as a decimal number; at first, the counter has value 0.
The counter performs the following algorithm: it prints its lowest digit and, after that, adds either x or y to its value. So all sequences this counter generates are starting from 0. For ... | {
"input": [
"0840\n"
],
"output": [
"-1 17 7 7 7 -1 2 17 2 7 \n17 17 7 5 5 5 2 7 2 7 \n7 7 7 4 3 7 1 7 2 5 \n7 5 4 7 3 3 2 5 2 3 \n7 5 3 3 7 7 1 7 2 7 \n-1 5 7 3 7 -1 2 9 2 7 \n2 2 1 2 1 2 2 2 0 1 \n17 7 7 5 7 9 2 17 2 3 \n2 2 2 2 2 2 0 2 2 2 \n7 7 5 3 7 7 1 3 2 7 \n"
]
} | {
"input": [
"01984783\n",
"001\n",
"0\n",
"014039\n",
"0198009473\n",
"01\n",
"011\n",
"03\n",
"01985222473\n",
"000473\n",
"01992473\n",
"0198588473\n",
"017928473\n",
"0198499473\n",
"0198717473\n",
"000198473\n",
"0195258473\n",
"018473\n",
... | 1,700 | 0 |
2 | 8 | 1244_B. Rooms and Staircases | Nikolay lives in a two-storied house. There are n rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between 1 and n).
If Nikolay is currently in some room, he c... | {
"input": [
"4\n5\n00100\n8\n00000000\n5\n11111\n3\n110\n"
],
"output": [
"6\n8\n10\n6\n"
]
} | {
"input": [
"1\n100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n",
"14\n1\n0\n1\n1\n2\n00\n2\n01\n2\n10\n2\n11\n3\n000\n3\n001\n3\n010\n3\n011\n3\n100\n3\n101\n3\n110\n3\n111\n"
],
"output": [
"100\n",
"1\n2\n2\n4\n4\n4\n3\n6\n4\n6\n6\n6\... | 1,000 | 1,000 |
2 | 8 | 1285_B. Just Eat It! | Today, Yasser and Adel are at the shop buying cupcakes. There are n cupcake types, arranged from 1 to n on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type i is an integer a_i. There are both tasty and nasty cupcakes, so the tastiness can be positive, zero or negative.
Yasser, ... | {
"input": [
"3\n4\n1 2 3 4\n3\n7 4 -1\n3\n5 -5 5\n"
],
"output": [
"YES\nNO\nNO\n"
]
} | {
"input": [
"1\n2\n0 0\n",
"12\n3\n7 -4 5\n3\n7 -5 4\n3\n4 -5 7\n3\n5 -4 7\n4\n5 -5 -6 6\n5\n100 100 100 -50 50\n10\n10 5 -12 7 -10 20 30 -10 50 60\n10\n10 5 -14 7 -7 20 30 -50 50 60\n2\n1 1\n2\n-1 -1\n3\n1000000000 1000000000 1000000000\n3\n-1000000000 -1000000000 -1000000000\n"
],
"output": [
"NO\n... | 1,300 | 1,000 |
2 | 10 | 1304_D. Shortest and Longest LIS | Gildong recently learned how to find the [longest increasing subsequence](https://en.wikipedia.org/wiki/Longest_increasing_subsequence) (LIS) in O(nlog{n}) time for a sequence of length n. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though the... | {
"input": [
"3\n3 <<\n7 >><>><\n5 >>><\n"
],
"output": [
"3 2 1 \n1 2 3 \n7 6 5 4 3 2 1 \n1 2 3 4 5 6 7 \n5 4 3 2 1 \n1 2 3 4 5 \n"
]
} | {
"input": [
"3\n3 <<\n7 >><>><\n5 >>><\n"
],
"output": [
"1 2 3\n1 2 3\n7 6 4 5 3 1 2\n3 2 1 6 5 4 7\n5 4 3 1 2\n4 3 2 1 5\n"
]
} | 1,800 | 1,750 |
2 | 11 | 1328_E. Tree Queries | You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i distinct vertices v_i[1], v_i[2], ..., v_i[k_i]. Your task is to say if there ... | {
"input": [
"10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 2 1 5\n3 4 8 2\n2 6 10\n3 5 4 7\n"
],
"output": [
"YES\nYES\nYES\nYES\nNO\nNO\n"
]
} | {
"input": [
"2 3\n1 2\n1 1\n1 2\n2 1 2\n",
"3 7\n1 2\n2 3\n1 1\n1 2\n1 3\n2 1 2\n2 1 3\n2 2 3\n3 1 2 3\n"
],
"output": [
"YES\nYES\nYES\n",
"YES\nYES\nYES\nYES\nYES\nYES\nYES\n"
]
} | 1,900 | 0 |
2 | 11 | 1348_E. Phoenix and Berries | Phoenix is picking berries in his backyard. There are n shrubs, and each shrub has a_i red berries and b_i blue berries.
Each basket can contain k berries. But, Phoenix has decided that each basket may only contain berries from the same shrub or berries of the same color (red or blue). In other words, all berries in a... | {
"input": [
"1 5\n2 3\n",
"1 2\n1000000000 1\n",
"2 4\n5 2\n2 1\n",
"2 5\n2 1\n1 3\n"
],
"output": [
"1\n",
"500000000\n",
"2\n",
"0\n"
]
} | {
"input": [
"3 4\n7 0\n0 3\n3 3\n",
"1 5\n999999999 1\n",
"5 500\n87 43\n44 29\n15 58\n94 29\n65 7\n",
"1 5\n0 0\n",
"5 11\n3 7\n2 10\n4 7\n7 4\n9 2\n",
"3 5\n1 8\n8 0\n0 8\n",
"5 7\n4 0\n3 1\n1 6\n6 4\n2 2\n",
"3 5\n2 2\n1 1\n4 1\n",
"15 5\n19 6\n10 15\n19 2\n12 17\n13 17\n0 18\n... | 2,400 | 2,500 |
2 | 8 | 1391_B. Fix You | Consider a conveyor belt represented using a grid consisting of n rows and m columns. The cell in the i-th row from the top and the j-th column from the left is labelled (i,j).
Every cell, except (n,m), has a direction R (Right) or D (Down) assigned to it. If the cell (i,j) is assigned direction R, any luggage kept o... | {
"input": [
"4\n3 3\nRRD\nDDR\nRRC\n1 4\nDDDC\n6 9\nRDDDDDRRR\nRRDDRRDDD\nRRDRDRRDR\nDDDDRDDRR\nDRRDRDDDR\nDDRDRRDDC\n1 1\nC\n"
],
"output": [
"1\n3\n9\n0\n"
]
} | {
"input": [
"10\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n1 1\nC\n",
"10\n4 4\nDDDD\nDRDR\nDRDD\nDRRC\n4 4\nDDRR\nDDRR\nDDRD\nDRRC\n4 4\nRRDR\nDRRR\nRRRR\nDDRC\n4 4\nDRRR\nRDDD\nDDDR\nRDRC\n4 4\nRDDD\nRRDR\nDDRD\nDRRC\n4 4\nRDRR\nRDRR\nRDDR\nRDDC\n4 4\nDRDD\nDRRR\nDDDD\nDDRC\n4... | 800 | 750 |
2 | 11 | 1413_E. Solo mid Oracle | Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for exactly c seconds, starting one second after the ability is used. That means that if the ability is used at time t, the ... | {
"input": [
"7\n1 1 1 1\n2 2 2 2\n1 2 3 4\n4 3 2 1\n228 21 11 3\n239 21 11 3\n1000000 1 1000000 1\n"
],
"output": [
"1\n2\n1\n5\n534\n-1\n500000500000\n"
]
} | {
"input": [
"4\n568133 729913 934882 371491\n916127 997180 932938 203988\n112133 793452 857041 842130\n572010 190716 396183 683429\n",
"2\n395916 225366 921987 169483\n604656 668976 459504 264596\n",
"1\n1000000 1000000 1 1000000\n",
"6\n879274 712902 672766 383030\n997653 839911 351405 69197\n31160 ... | 2,100 | 2,250 |
2 | 11 | 1455_E. Four Points | You are given four different integer points p_1, p_2, p_3 and p_4 on XY grid.
In one step you can choose one of the points p_i and move it in one of four directions by one. In other words, if you have chosen point p_i = (x, y) you can move it to (x, y + 1), (x, y - 1), (x + 1, y) or (x - 1, y).
Your goal to move poin... | {
"input": [
"3\n0 2\n4 2\n2 0\n2 4\n1 0\n2 0\n4 0\n6 0\n1 6\n2 2\n2 5\n4 1\n"
],
"output": [
"\n8\n7\n5\n"
]
} | {
"input": [
"1\n0 0\n5 5\n0 5\n5 0\n",
"6\n41 77\n11 61\n31 38\n18 43\n41 77\n11 61\n18 43\n31 38\n41 77\n31 38\n11 61\n18 43\n41 77\n31 38\n18 43\n11 61\n41 77\n18 43\n11 61\n31 38\n41 77\n18 43\n31 38\n11 61\n",
"1\n1 1\n1 0\n0 1\n0 0\n"
],
"output": [
"0\n",
"38\n38\n38\n38\n38\n38\n",
... | 2,400 | 0 |
2 | 7 | 147_A. Punctuation | You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters.
Your task is to add spaces to the text by the following rules:
* if there is no punctuation mark between two wor... | {
"input": [
"galileo was born in pisa\n",
"galileo galilei was an italian physicist ,mathematician,astronomer\n"
],
"output": [
"galileo was born in pisa\n",
"galileo galilei was an italian physicist, mathematician, astronomer\n"
]
} | {
"input": [
"mck . gq dauqminf wee bazyzy humnv d pgtvx , vxntxgrkrc rg rwr, uuyweyz l\n",
"read problem carefully ! heh\n",
"a ! a\n",
"ksdfk sdlfsdf sdf sdf sdf\n",
"gg gg,h,h,j,i,jh , jjj , jj ,aadd , jjj jjj\n",
"xx\n",
"ff ! ff\n",
"a, a\n",
"... | 1,300 | 500 |
2 | 7 | 161_A. Dress'em in Vests! | The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.
The Two-dimensional kingdom has a regular army of n people. Each soldier registered himse... | {
"input": [
"5 3 0 0\n1 2 3 3 4\n1 3 5\n",
"3 3 2 2\n1 5 9\n3 5 7\n"
],
"output": [
"2\n1 1\n3 2\n",
"3\n1 1\n2 2\n3 3\n"
]
} | {
"input": [
"33 23 17 2\n1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 5\n10 10 10 10 10 10 10 11 11 11 11 11 11 11 12 12 12 12 12 12 13 13 13\n",
"10 1 1 1\n1 1 1 5 5 7 7 8 8 8\n3\n",
"1 1 0 2\n9\n7\n",
"2 2 0 2\n2 8\n3 5\n",
"10 1 2 1\n1 2 5 8 9 9 9 10 10 10\n7\n",
"2 2 3 ... | 1,300 | 1,000 |
2 | 9 | 180_C. Letter | Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.
Patrick believes that a message is fancy if any uppercase letter stands to... | {
"input": [
"OYPROSTIYAOPECHATALSYAPRIVETSTASYA\n",
"helloworld\n",
"PRuvetSTAaYA\n"
],
"output": [
"0\n",
"0\n",
"5\n"
]
} | {
"input": [
"yysxwlyqboatikfnpxczmpijziiojbvadlfozjqldssffcxdegyxfrvohoxvgsrvlzjlkcuffoeisrpvagxtbkapkpzcafadzzjd\n",
"FSFlNEelYY\n",
"lgtyasficu\n",
"MMVESdOCALHJCTBTUWWQRGUUVTTTABKKAAdIINAdKLRLLVLODHDXDPMcQfUhPNHFBJSDRGsHZNORSCPNvKOOIuZnZAmTPUCoPNlR\n",
"WYKUDTDDBT\n",
"P\n",
"MMbJIBhgF... | 1,400 | 0 |
2 | 10 | 203_D. Hit Ball | When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced ... | {
"input": [
"7 2 11\n3 -11 2\n",
"7 2 11\n4 -3 3\n"
],
"output": [
"6.5000000000 2.0000000000\n",
"4.1666666667 1.0000000000\n"
]
} | {
"input": [
"7 21 86\n1 -19 20\n",
"1 1 1\n0 -100 100\n",
"86 1 77\n5 -70 48\n",
"1 1 1\n0 -1 0\n",
"4 28 25\n-86 -75 68\n",
"87 4 63\n49 -53 68\n",
"48 25 5\n26 -73 2\n",
"100 100 100\n100 -1 100\n",
"57 7 78\n-31 -63 98\n",
"89 20 95\n-32 -52 23\n",
"100 100 77\n-14 -100... | 1,700 | 2,000 |
2 | 7 | 252_A. Little Xor | Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements, such that the xor of all numbers from this segment was maximal possible. Help him with that.
The ... | {
"input": [
"5\n1 2 1 1 2\n",
"3\n1 2 7\n",
"4\n4 2 4 8\n"
],
"output": [
"3\n",
"7\n",
"14\n"
]
} | {
"input": [
"20\n1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10\n",
"99\n3511 2076 9314 3598 7737 271 4110 4454 5830 8661 8584 8227 2236 2626 1025 3806 3162 2837 6071 9627 1836 7729 6629 4054 9377 3261 1325 8859 3610 7616 5052 9736 1249 6224 7031 6074 4196 8075 4005 5419 5664 8214 4391 731 8714 8622 6122 6976 405... | 1,100 | 500 |
2 | 8 | 277_B. Set of Points | Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a straight line.
Input
The single line contains two integers n and m... | {
"input": [
"6 6\n",
"7 4\n",
"6 3\n",
"4 3\n"
],
"output": [
"0 10000000\n1 10000001\n2 10000004\n3 10000009\n4 10000016\n5 10000025\n",
"0 10000000\n1 10000001\n2 10000004\n3 10000009\n0 -10000000\n1 -10000001\n2 -10000004\n",
"-1\n",
"0 0\n3 0\n0 3\n1 1\n"
]
} | {
"input": [
"99 99\n",
"49 30\n",
"198 100\n",
"9 5\n",
"50 37\n",
"4 4\n",
"99 99\n",
"199 100\n",
"80 42\n",
"198 100\n",
"101 100\n",
"199 100\n",
"150 100\n",
"10 5\n",
"10 6\n",
"198 99\n",
"6 5\n",
"8 5\n",
"16 8\n",
"181 95\n",
... | 2,300 | 1,500 |
2 | 10 | 29_D. Ant on the Tree | Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and they are connected by n - 1 edges so that there is a path between any pair of ver... | {
"input": [
"6\n1 2\n1 3\n2 4\n4 5\n4 6\n5 6 3\n",
"3\n1 2\n2 3\n3\n",
"6\n1 2\n1 3\n2 4\n4 5\n4 6\n5 3 6\n"
],
"output": [
"1 2 4 5 4 6 4 2 1 3 1 ",
"1 2 3 2 1 ",
"-1"
]
} | {
"input": [
"20\n4 13\n17 7\n19 10\n18 1\n5 15\n2 6\n11 7\n3 6\n5 1\n20 16\n12 5\n10 17\n14 18\n8 13\n13 15\n19 1\n9 19\n6 13\n17 20\n14 12 4 2 3 9 8 11 16\n",
"37\n27 3\n27 35\n6 8\n12 21\n4 7\n32 27\n27 17\n24 14\n1 10\n3 23\n20 8\n12 4\n16 33\n2 34\n15 36\n5 31\n31 14\n5 9\n8 28\n29 12\n33 35\n24 10\n18 2... | 2,000 | 2,000 |
2 | 7 | 371_A. K-Periodic Array | This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.
Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly <image> times consecutively. In other words, array a is k-periodic, if it has period... | {
"input": [
"9 3\n2 1 1 1 2 1 1 1 2\n",
"8 4\n1 1 2 1 1 1 2 1\n",
"6 2\n2 1 2 2 2 1\n"
],
"output": [
"3",
"0",
"1"
]
} | {
"input": [
"20 10\n1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 1 2 2 2 1\n",
"10 2\n2 2 2 1 1 2 2 2 2 1\n",
"100 20\n2 2 2 1 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 2 2 2 2 1 2 1 2 1 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1\n... | 1,000 | 500 |
2 | 10 | 415_D. Mashmokh and ACM | 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... | {
"input": [
"2 1\n",
"3 2\n",
"6 4\n"
],
"output": [
"2",
"5",
"39"
]
} | {
"input": [
"2000 2000\n",
"1544 1794\n",
"1639 1056\n",
"56 48\n",
"1066 995\n",
"49 110\n",
"478 1301\n",
"158 772\n",
"162 161\n",
"83 37\n",
"1454 296\n",
"500 1304\n",
"1307 1247\n",
"525 314\n",
"359 896\n",
"1000 1\n",
"2000 1000\n",
"147... | 1,400 | 1,000 |
2 | 8 | 442_B. Andrey and Problem | Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him.
Help Andrey choose... | {
"input": [
"2\n0.1 0.2\n",
"4\n0.1 0.2 0.3 0.8\n"
],
"output": [
"0.2600000000\n",
"0.8000000000\n"
]
} | {
"input": [
"20\n0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001\n",
"4\n0.801024 0.610878 0.808545 0.732504\n",
"5\n0.01 0.01 0.01 0.01 0.01\n",
"2\n0.057750 0.013591\n",
"7\n0.14 0.28 0.13 0.31 0.15 0.17 0.27\n",
"5\n0.... | 1,800 | 1,500 |
2 | 9 | 464_C. Substitutes in Number | Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type "di → ti", that means "replace all digits di in string s with substrings equal to ti". For example, if s = 123123, then query "2 → 00" transforms s to 10031003, and query "3 → " ("rep... | {
"input": [
"123123\n1\n3->\n",
"222\n2\n2->0\n0->7\n",
"1000000008\n0\n",
"123123\n1\n2->00\n"
],
"output": [
"0\n",
"7\n",
"1\n",
"3\n"
]
} | {
"input": [
"123123\n1\n2->00\n",
"21222\n10\n1->\n2->1\n1->1\n1->1\n1->1\n1->22\n2->2\n2->1\n1->21\n1->\n",
"100\n5\n1->301\n0->013\n1->013\n0->103\n0->103\n",
"332434109630379\n20\n7->1\n0->2\n3->6\n1->8\n6->8\n4->0\n9->8\n2->4\n4->8\n0->1\n1->7\n7->3\n3->4\n4->6\n6->3\n8->4\n3->8\n4->2\n2->8\n8->1... | 2,100 | 1,500 |
2 | 8 | 488_B. Candy Boxes | There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {x1, x2, x3, x4} (x1 ≤ x2 ≤ x3 ≤ x4) arithmetic mean is <image>, median is <image> and range is x4 - x1. Th... | {
"input": [
"4\n1\n2\n2\n3\n",
"3\n1\n1\n1\n",
"2\n1\n1\n"
],
"output": [
"YES",
"NO",
"YES\n3\n3"
]
} | {
"input": [
"3\n1\n1\n3\n",
"2\n472\n107\n",
"2\n66\n135\n",
"1\n121\n",
"3\n215\n137\n256\n",
"2\n288\n399\n",
"2\n500\n497\n",
"1\n67\n",
"3\n361\n387\n130\n",
"3\n2\n2\n3\n",
"3\n63\n28\n56\n",
"1\n318\n",
"2\n68\n151\n",
"4\n186\n129\n119\n62\n",
"1\n50... | 1,900 | 1,500 |
2 | 7 | 512_A. Fox And Names | Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in l... | {
"input": [
"10\npetr\negor\nendagorion\nfeferivan\nilovetanyaromanova\nkostka\ndmitriyh\nmaratsnowbear\nbredorjaguarturnik\ncgyforever\n",
"3\nrivest\nshamir\nadleman\n",
"10\ntourist\npetr\nwjmzbmr\nyeputons\nvepifanov\nscottwu\noooooooooooooooo\nsubscriber\nrowdark\ntankengineer\n",
"7\ncar\ncare\... | {
"input": [
"2\naa\na\n",
"5\naaaaa\naaaa\naaa\naa\na\n",
"2\nanud\nanu\n",
"4\nax\nay\nby\nbz\n",
"1\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n",
"6\nax\nay\nby\nbz\ncz\ncx\n",
"4\nax\nay\nby\nbx\n",
"1\na\n",
"8\nwa\nw... | 1,600 | 1,500 |
2 | 8 | 536_B. Tavas and Malekas | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.
<image>
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions... | {
"input": [
"6 2\nioi\n1 3\n",
"5 2\nioi\n1 2\n"
],
"output": [
"26\n",
"0\n"
]
} | {
"input": [
"10 4\ne\n1 2 9 10\n",
"1 1\na\n1\n",
"10 0\naaa\n",
"100000 0\njlasosafuywefgwefdyktfwydugewdefwdulewdopqywgdwqdiuhdbcxxiuhfiehfewhfoewihfwoiefewiugwefgiuwgfiwefuiwgefwefwppoollmmzzqaayudgsufzxcvbnmasdfghjklqwertyuiop\n",
"10 5\naa\n1 2 3 7 9\n",
"173700 6\nbcabcbcbcbaaacaccaacac... | 1,900 | 2,000 |
2 | 9 | 560_C. Gerald's Hexagon | Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.
... | {
"input": [
"1 2 1 2 1 2\n",
"1 1 1 1 1 1\n"
],
"output": [
"13\n",
"6\n"
]
} | {
"input": [
"30 36 36 32 34 38\n",
"125 7 128 8 124 11\n",
"7 1 7 3 5 3\n",
"4 60 4 60 4 60\n",
"50 40 46 38 52 34\n",
"1 1000 1 1 1000 1\n",
"718 466 729 470 714 481\n",
"66 6 65 6 66 5\n",
"1 6 1 5 2 5\n",
"7 5 4 8 4 5\n",
"677 303 685 288 692 296\n",
"2 4 5 3 3 6\n"... | 1,600 | 500 |
2 | 11 | 586_E. Alice, Bob, Oranges and Apples | Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a let... | {
"input": [
"3 2\n",
"2 2\n",
"1 4\n"
],
"output": [
"1A1B",
"Impossible",
"3B"
]
} | {
"input": [
"4181 6765\n",
"416445288135075809 416445288135075809\n",
"964542760623675601 965233603018687501\n",
"2 1000000000000000000\n",
"999999999999999999 999999999999999998\n",
"498454011879264 806515533049393\n",
"1 1000000000000000000\n",
"519421744863260201 572972909476222789... | 2,400 | 1,250 |
2 | 7 | 609_A. USB Flash Drives | Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1, a2, ..., an megabytes. The file size is equal to m megabytes.
Find the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.
Input
The first line contai... | {
"input": [
"3\n5\n2\n1\n3\n",
"3\n6\n2\n3\n2\n",
"2\n5\n5\n10\n"
],
"output": [
"2\n",
"3\n",
"1\n"
]
} | {
"input": [
"70\n149\n5\n3\n3\n4\n6\n1\n2\n9\n8\n3\n1\n8\n4\n4\n3\n6\n10\n7\n1\n10\n8\n4\n9\n3\n8\n3\n2\n5\n1\n8\n6\n9\n10\n4\n8\n6\n9\n9\n9\n3\n4\n2\n2\n5\n8\n9\n1\n10\n3\n4\n3\n1\n9\n3\n5\n1\n3\n7\n6\n9\n8\n9\n1\n7\n4\n4\n2\n3\n5\n7\n",
"90\n40579\n448\n977\n607\n745\n268\n826\n479\n59\n330\n609\n43\n301\n... | 800 | 0 |
2 | 10 | 656_D. Rosetta Problem |
++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+
++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++
+++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<
<<<<<>>>>>>>>>>>>>+.-<<<<<<<<<<<<<>>>>>>>>>>>>>>--.++<<<<<<<<<<<<<... | {
"input": [
"129\n"
],
"output": [
"1\n"
]
} | {
"input": [
"398929\n",
"23982\n",
"262144\n",
"299593\n",
"9852\n",
"33345\n",
"2122\n",
"6218\n",
"953086\n",
"11249\n",
"266305\n",
"1000000\n",
"121\n",
"3593\n",
"42705\n",
"569\n",
"4\n",
"6\n",
"456910\n",
"0\n",
"67\n",
"... | 2,100 | 0 |
2 | 10 | 67_D. Optical Experiment | Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.
There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each... | {
"input": [
"3\n3 1 2\n2 3 1\n",
"5\n1 4 5 2 3\n3 4 2 1 5\n"
],
"output": [
"2\n",
"3\n"
]
} | {
"input": [
"3\n1 2 3\n1 3 2\n",
"5\n1 2 4 5 3\n1 5 4 2 3\n",
"5\n1 2 4 5 3\n1 2 5 4 3\n",
"5\n1 5 2 4 3\n4 3 2 5 1\n",
"3\n1 2 3\n2 3 1\n",
"10\n4 7 8 1 2 3 5 9 6 10\n6 3 8 7 10 2 1 4 5 9\n",
"5\n5 3 2 4 1\n2 4 5 1 3\n",
"5\n1 3 5 4 2\n1 4 5 3 2\n",
"2\n1 2\n2 1\n",
"4\n2 4 1... | 1,900 | 2,000 |
2 | 10 | 702_D. Road to Post Office | Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.
Vasiliy's car is not new — it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will ... | {
"input": [
"5 2 1 4 10\n",
"5 2 1 4 5\n"
],
"output": [
"14\n",
"13\n"
]
} | {
"input": [
"100 120 1 2 509\n",
"100 120 1 2 520\n",
"100 123 1 2 1007\n",
"1000000000000 1 1 10 1\n",
"7 2 4 16 19\n",
"1 2 1 2 2\n",
"100 120 1 2 600\n",
"1 100 1 5 10\n",
"100 120 1 2 300\n",
"100 120 1 2 306\n",
"5 1000 1 4 10\n",
"100 120 1 2 512\n",
"100 111... | 1,900 | 0 |
2 | 11 | 746_E. Numbers Exchange | Eugeny has n cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd integers, and that all these numbers would be distinct.
Nikolay has m cards, distinct numbers from 1 to m are written ... | {
"input": [
"4 1\n4 2 1 10\n",
"8 6\n7 7 7 7 8 8 8 8\n",
"6 2\n5 6 7 9 4 5\n"
],
"output": [
"-1",
"6\n7 1 3 5 8 2 4 6 ",
"1\n5 6 7 9 4 2 "
]
} | {
"input": [
"20 16\n23 27 17 29 23 21 24 23 19 25 16 24 20 17 18 17 16 17 28 17\n",
"100 20\n28 42 37 40 26 40 46 46 25 28 36 36 35 38 45 40 21 38 36 22 30 24 40 38 27 50 47 40 30 45 39 20 18 32 34 24 34 26 27 37 18 40 42 41 26 50 22 27 37 21 30 30 49 36 16 48 46 26 33 22 47 32 38 50 29 46 31 42 26 24 50 26 ... | 1,900 | 2,500 |
2 | 11 | 793_E. Problem of offices | Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices.
Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offic... | {
"input": [
"10\n3 8 9 10\n1 2 2 2 2 2 1 1 1\n",
"5\n2 3 4 5\n1 1 1 1\n",
"13\n13 12 9 7\n1 1 1 1 5 5 2 2 2 3 3 4\n"
],
"output": [
"No\n",
"Yes\n",
"Yes\n"
]
} | {
"input": [
"100\n3 80 100 32\n1 2 1 4 1 6 1 8 1 1 11 1 13 1 1 16 1 18 1 1 1 1 1 24 1 26 1 1 29 1 1 1 1 34 1 36 1 38 1 40 1 42 1 1 1 1 47 1 1 50 1 52 1 1 55 1 57 1 1 60 1 62 1 1 1 66 1 68 1 1 1 72 1 1 75 1 1 1 79 1 81 1 83 1 1 1 1 1 1 90 1 1 93 1 95 1 97 1 99\n",
"100\n23 6 94 20\n1 2 2 2 3 2 1 8 8 8 8 9 1 1... | 2,900 | 2,500 |
2 | 8 | 814_B. An express train to reveries | Sengoku still remembers the mysterious "colourful meteoroids" she discovered with Lala-chan when they were little. In particular, one of the nights impressed her deeply, giving her the illusion that all her fancies would be realized.
On that night, Sengoku constructed a permutation p1, p2, ..., pn of integers from 1 t... | {
"input": [
"5\n1 2 3 4 3\n1 2 5 4 5\n",
"4\n1 1 3 4\n1 4 3 4\n",
"5\n4 4 2 3 1\n5 4 5 3 1\n"
],
"output": [
"1 2 3 4 5 ",
"1 2 3 4\n",
"5 4 2 3 1\n"
]
} | {
"input": [
"5\n4 5 3 3 1\n2 5 3 2 1\n",
"5\n1 2 3 4 3\n1 2 5 4 2\n",
"10\n2 9 7 7 8 5 4 10 6 1\n2 8 7 3 8 5 4 10 6 1\n",
"5\n2 5 3 2 1\n4 5 3 3 1\n",
"3\n2 2 3\n1 2 1\n",
"4\n2 3 3 4\n2 4 3 4\n",
"10\n8 6 1 7 9 3 5 2 10 9\n8 6 1 7 4 3 5 2 10 4\n",
"4\n1 3 1 4\n1 3 4 4\n",
"5\n5 4... | 1,300 | 1,000 |
2 | 8 | 83_B. Doctor | There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his... | {
"input": [
"3 3\n1 2 1\n",
"4 10\n3 3 2 1\n",
"7 10\n1 3 3 1 2 3 1\n"
],
"output": [
"2 ",
"-1",
"6 2 3 "
]
} | {
"input": [
"6 101\n9 78 54 62 2 91\n",
"5 12\n1 3 4 1 5\n",
"50 68\n12 6 15 15 7 4 1 18 11 2 3 4 9 6 8 2 6 10 1 2 16 10 22 28 23 2 17 33 3 3 5 1 5 6 5 5 2 6 2 10 2 14 1 24 12 12 4 4 2 10\n",
"20 430\n25 27 25 24 24 49 11 30 24 50 48 40 41 5 19 45 16 43 43 12\n",
"1 0\n1\n",
"5 41\n19 19 19 1... | 1,800 | 1,000 |
2 | 9 | 886_C. Petya and Catacombs | A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.
Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages ... | {
"input": [
"2\n0 0\n",
"5\n0 1 0 1 3\n"
],
"output": [
"2\n",
"3\n"
]
} | {
"input": [
"1\n0\n",
"14\n0 0 1 1 2 2 3 3 4 4 5 5 6 6\n",
"2\n0 1\n",
"100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52... | 1,300 | 1,500 |
2 | 9 | 909_C. Python Indentation | In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation.
We will consider an extremely simplified subset of Python with only two types of statements.
Simple statements are written in a single line, one per line. An ex... | {
"input": [
"4\ns\nf\nf\ns\n",
"4\nf\ns\nf\ns\n"
],
"output": [
"1",
"2"
]
} | {
"input": [
"156\nf\ns\nf\ns\nf\ns\ns\ns\ns\nf\ns\ns\nf\nf\ns\nf\nf\nf\nf\ns\ns\ns\nf\ns\ns\nf\nf\nf\nf\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\nf\nf\nf\ns\ns\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\ns\ns\ns\nf\ns\ns\nf\ns\nf\nf\ns\ns\ns\nf\nf\nf\nf\ns\ns\nf\nf\nf\nf\nf\nf\nf\ns\nf\ns\ns\ns\nf\nf\ns\ns\ns\ns\ns\nf... | 1,800 | 1,500 |
2 | 11 | 958_E1. Guard Duty (easy) | The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | {
"input": [
"2 1\n1 0\n2 2\n3 1\n",
"3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2\n"
],
"output": [
"No",
"Yes"
]
} | {
"input": [
"5 8\n-5325 1383\n-5441 3351\n-3870 1465\n669 -8381\n-4377 5913\n4360 -329\n8725 8620\n7810 -2479\n4019 4850\n8052 9911\n4130 -4668\n3744 2537\n-7171 -3933\n",
"5 3\n9670 8440\n1091 -9784\n6422 4884\n3314 -9610\n8523 -7107\n-2963 8293\n3092 -3950\n-4093 -6502\n",
"1 8\n8741 3638\n381 -9191\n7... | 1,600 | 0 |
2 | 8 | 1016_B. Segment Occurrences | You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a string b is a position i (1 ≤ i ≤ |b| - |a| + 1) such that b[i..i... | {
"input": [
"15 2 3\nabacabadabacaba\nba\n1 15\n3 4\n2 14\n",
"10 3 4\ncodeforces\nfor\n1 3\n3 10\n5 6\n5 7\n",
"3 5 2\naaa\nbaaab\n1 3\n1 1\n"
],
"output": [
"4\n0\n3\n",
"0\n1\n0\n1\n",
"0\n0\n"
]
} | {
"input": [
"1 1 1\na\nb\n1 1\n",
"7 7 1\nlilkbeg\nmmjeiet\n1 7\n",
"2 1 3\naa\na\n1 1\n1 2\n2 2\n",
"7 7 1\nfekjogq\nhucavjy\n1 7\n",
"22 22 1\nbabbabbaabaaababbbbbbb\nabbbbbabbabbbabababbab\n1 22\n",
"5 5 1\naaafe\nkzvaa\n1 5\n",
"2 2 1\nan\nba\n1 2\n",
"10 10 1\naaaaaaaaaa\naaadlyn... | 1,300 | 0 |
2 | 8 | 103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | {
"input": [
"6 5\n5 6\n4 6\n3 1\n5 1\n1 2\n",
"6 6\n6 3\n6 4\n5 1\n2 5\n1 4\n5 4\n"
],
"output": [
"NO\n",
"FHTAGN!\n"
]
} | {
"input": [
"100 66\n41 14\n19 13\n70 43\n79 62\n9 62\n71 40\n53 86\n80 4\n34 33\n72 68\n40 96\n84 59\n36 77\n55 50\n40 3\n79 81\n3 43\n33 47\n22 98\n33 90\n56 49\n69 28\n73 30\n65 22\n98 20\n9 52\n54 20\n32 70\n51 80\n63 12\n21 48\n35 17\n48 87\n25 43\n65 80\n42 3\n86 35\n95 98\n43 59\n51 46\n66 37\n88 34\n32 4... | 1,500 | 1,000 |
2 | 9 | 1062_C. Banh-mi | JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | {
"input": [
"3 2\n111\n1 2\n3 3\n",
"4 2\n1011\n1 4\n3 4\n"
],
"output": [
"3\n1\n",
"14\n3\n"
]
} | {
"input": [
"6 5\n111101\n1 1\n4 6\n3 6\n1 2\n4 4\n",
"10 8\n0110000110\n3 3\n1 10\n4 4\n1 8\n1 2\n9 10\n2 10\n3 9\n",
"3 5\n111\n1 1\n1 2\n3 3\n2 2\n1 3\n",
"1 1\n0\n1 1\n",
"10 4\n1110101101\n3 5\n7 8\n8 10\n1 1\n",
"3 3\n101\n1 3\n2 3\n1 1\n"
],
"output": [
"1\n6\n14\n3\n1\n",
... | 1,600 | 1,500 |
2 | 8 | 1084_B. Kvass and the Fair Nut | The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | {
"input": [
"3 4\n5 3 4\n",
"3 3\n4 3 5\n",
"3 7\n1 2 3\n"
],
"output": [
"2\n",
"3\n",
"-1\n"
]
} | {
"input": [
"5 1\n1 1 1 1 1000\n",
"4 2\n5 7 8 9\n",
"1 2\n1\n",
"5 2\n4 6 8 10 14\n",
"2 1\n2 5\n",
"2 1\n1 1000000000\n",
"2 2\n900000000 2\n",
"1 1000000000000\n42\n",
"2 50\n1 500\n",
"2 1\n2 4\n",
"4 2\n2 3 4 5\n",
"2 5000\n1 1000000000\n",
"3 6\n1 99 99\n",
... | 1,200 | 1,000 |
2 | 10 | 1131_D. Gourmet choice | Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | {
"input": [
"3 3\n>>>\n<<<\n>>>\n",
"3 2\n==\n=<\n==\n",
"3 4\n>>>>\n>>>>\n>>>>\n"
],
"output": [
"Yes\n1 1 1 \n1 1 1 ",
"Yes\n1 1 1 \n1 1 \n",
"Yes\n1 1 1 \n1 1 1 1 "
]
} | {
"input": [
"3 4\n>>>>\n>>>>\n>>>>\n",
"10 24\n<><>>>><>>><>>>>>>>><<>>\n<><>>>><>>><>>>>>>>><<>>\n>><>>>><>>><>>>>>>>><>>>\n<<<><><<<<<<><<><>>><<<>\n<<<=<=<<<<<<><<=<>==<<<>\n>><>>>><>>><>>>>>>>><>>>\n>>>>>>>>>>>>>>>>>>>>>>>>\n<<<<<<<<<<<<=<<<<=<<<<<<\n<><>>>><>>><>>>>>>>><<>>\n<><>>>><>>><>>>>>>>><<>>\n",... | 2,000 | 2,000 |
2 | 12 | 1151_F. Sonya and Informatics | A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | {
"input": [
"3 2\n0 1 0\n",
"5 1\n1 1 1 0 0\n",
"6 4\n1 0 0 1 1 0\n"
],
"output": [
"333333336\n",
"0\n",
"968493834\n"
]
} | {
"input": [
"39 67\n1 0 1 0 1 1 0 0 1 1 1 1 0 1 1 1 0 0 1 0 1 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 0 1\n",
"92 1000000000\n0 0 1 1 0 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 1 1 0 1 1 1\n",
... | 2,300 | 2,750 |
2 | 8 | 1191_B. Tokitsukaze and Mahjong | Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | {
"input": [
"3p 9m 2p\n",
"9m 9m 9m\n",
"1s 2s 3s\n"
],
"output": [
"1\n",
"0\n",
"0\n"
]
} | {
"input": [
"2m 9s 1m\n",
"1m 1m 2m\n",
"3p 9p 4m\n",
"4p 4s 2m\n",
"3s 5s 7s\n",
"5m 6m 7s\n",
"1s 8m 9m\n",
"6p 8p 6s\n",
"2p 2p 2p\n",
"8m 9s 4p\n",
"7s 2s 3m\n",
"4s 1m 1s\n",
"1p 5p 9p\n",
"1s 2s 4s\n",
"2s 8p 2s\n",
"9s 7s 8s\n",
"9m 7p 4s\n",... | 1,200 | 1,000 |
2 | 11 | 122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | {
"input": [
"4 7\n",
"7 4\n"
],
"output": [
"1\n",
"1\n"
]
} | {
"input": [
"7 1000\n",
"10 1000000000\n",
"7 4999\n",
"10 1\n",
"7479 58884598\n",
"47 1\n",
"7 3856\n",
"40 8544\n",
"9985 5888454\n",
"10 1023\n",
"777777 2\n",
"27 1\n",
"7 5000\n",
"10 10000\n",
"6 121\n",
"7 124\n",
"10 100000\n",
"1000000... | 1,900 | 1,500 |
2 | 10 | 1251_D. Salary Changing | You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2).
You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ... | {
"input": [
"3\n3 26\n10 12\n1 4\n10 11\n1 1337\n1 1000000000\n5 26\n4 4\n2 4\n6 8\n5 6\n2 7\n"
],
"output": [
"11\n1337\n6\n"
]
} | {
"input": [
"1\n1 1000000000\n1000000000 1000000000\n"
],
"output": [
"1000000000\n"
]
} | 1,900 | 0 |
2 | 8 | 1271_B. Blocks | There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | {
"input": [
"8\nBWWWWWWB\n",
"5\nWWWWW\n",
"3\nBWB\n",
"4\nBWBB\n"
],
"output": [
"3\n2 4 6 ",
"0\n",
"2\n1 2 ",
"-1\n"
]
} | {
"input": [
"195\nWWWWWWWWBWWWWWWWWWWWWBBBWWWBBWWWWWWWWBWWWWWWWWWWWWWWWWWWWWBWWWWWWWBWWWWWWWWWWWWWWWWBWWWWWWWWWBBBWWWWWWWWWWBWWWWWWWBBWWBWBBWWWWWWWWWWBWWWBWWWWWWWWWBBWBWWWBWWBWBWWWWBBWWWWWWWWWWWWWWWWWWWWWWWWWWBWWW\n",
"10\nWWBBBWBBWB\n",
"174\nWWWWWBWWBWWWWBWWWWBWWWWWWWWWWWWWWWWBBWWBWWWWWWWBBWWWWWWWWWWWW... | 1,300 | 1,000 |
2 | 9 | 1294_C. Product of Three Numbers | You are given one integer number n. Find three distinct integers a, b, c such that 2 ≤ a, b, c and a ⋅ b ⋅ c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 ≤ t ≤ 100)... | {
"input": [
"5\n64\n32\n97\n2\n12345\n"
],
"output": [
"YES\n2 4 8\nNO\nNO\nNO\nYES\n3 5 823\n"
]
} | {
"input": [
"6\n10\n10\n10\n10\n10\n10\n",
"1\n1112\n",
"100\n121\n122\n123\n124\n125\n126\n127\n128\n129\n130\n131\n132\n133\n134\n135\n136\n137\n138\n139\n140\n141\n142\n143\n144\n145\n146\n147\n148\n149\n150\n151\n152\n153\n154\n155\n156\n157\n158\n159\n160\n161\n162\n163\n164\n165\n166\n167\n168\n169... | 1,300 | 0 |
2 | 9 | 1315_C. Restoring Permutation | You are given a sequence b_1, b_2, …, b_n. Find the lexicographically minimal permutation a_1, a_2, …, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100).
The first line of... | {
"input": [
"5\n1\n1\n2\n4 1\n3\n4 1 3\n4\n2 3 4 5\n5\n1 5 7 2 8\n"
],
"output": [
"1 2 \n-1\n4 5 1 2 3 6 \n-1\n1 3 5 6 7 9 2 4 8 10 \n"
]
} | {
"input": [
"20\n5\n4 3 2 8 1\n5\n3 2 5 1 4\n5\n5 4 2 3 1\n5\n3 1 5 9 2\n5\n4 6 2 1 3\n5\n3 5 4 2 1\n5\n5 3 7 2 1\n5\n2 5 4 1 7\n5\n6 1 3 2 7\n5\n1 5 6 2 3\n5\n1 8 6 2 4\n5\n8 1 2 7 5\n5\n3 1 2 7 5\n5\n6 2 8 3 1\n5\n2 5 1 8 3\n5\n5 3 4 1 2\n5\n5 1 2 4 6\n5\n4 5 2 1 6\n5\n5 3 6 8 1\n5\n9 6 1 3 2\n",
"1\n100\n... | 1,200 | 1,500 |
2 | 9 | 1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | {
"input": [
"3\n30 10 20\n41 15 30\n18 13 18\n"
],
"output": [
"2\n7\n1\n"
]
} | {
"input": [
"1\n999855 999262 999557\n",
"1\n114515 114514 114514\n",
"1\n1138 4 643\n"
],
"output": [
"2\n",
"2\n",
"7\n"
]
} | 1,700 | 0 |
2 | 11 | 1379_E. Inverse Genealogy | Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in... | {
"input": [
"3 0\n",
"5 1\n",
"3 2\n"
],
"output": [
"YES\n0 1 1 \n",
"YES\n0 1 1 3 3 \n",
"NO\n"
]
} | {
"input": [
"300 127\n",
"282 2\n",
"999 437\n",
"31 3\n",
"279 37\n",
"511 0\n",
"99982 0\n",
"99 47\n",
"100 2\n",
"223 50\n",
"299 149\n",
"9 3\n",
"8 2\n",
"95 33\n",
"10 0\n",
"7 0\n",
"99983 0\n",
"251 0\n",
"31 1\n",
"89 1\n",
... | 2,800 | 2,500 |
2 | 9 | 139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | {
"input": [
"2 1\na\na\na\na\na\na\ne\ne\n",
"1 1\nday\nmay\ngray\nway\n",
"1 1\nday\nmay\nsun\nfun\n",
"2 1\nday\nmay\nsun\nfun\ntest\nhill\nfest\nthrill\n"
],
"output": [
"aabb\n",
"aaaa\n",
"aabb\n",
"NO\n"
]
} | {
"input": [
"3 2\netba\ntfecetba\nzkitbgcuuy\nuuy\nbuxeoi\nmekxoi\nblviwoehy\niwoehy\njyfpaqntiz\nqvaqntiz\nhciak\niak\n",
"2 1\na\na\na\na\na\nb\nb\nb\n",
"1 1\ne\ne\ne\ne\n",
"3 2\nexdaoao\nrdwunurp\ndunurp\ntyqzuxao\ndupocgsps\nzsiravcm\nnqiravcm\nlnupocgsps\niwashk\neepkqcykbv\nyviwashk\neepkqcyk... | 1,600 | 500 |
2 | 8 | 1493_B. Planet Lapituletti | The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t... | {
"input": [
"5\n24 60\n12:21\n24 60\n23:59\n90 80\n52:26\n1 100\n00:01\n10 10\n04:04\n"
],
"output": [
"\n12:21\n00:00\n52:28\n00:00\n00:00\n"
]
} | {
"input": [
"15\n1 1\n00:00\n1 100\n00:01\n100 100\n02:82\n10 10\n04:04\n100 100\n99:00\n100 2\n30:00\n50 3\n30:00\n51 3\n30:01\n52 16\n21:12\n100 20\n20:07\n23 100\n21:45\n11 11\n02:02\n89 89\n88:86\n100 1\n01:00\n1 100\n00:01\n"
],
"output": [
"00:00\n00:00\n02:82\n00:00\n00:00\n00:00\n00:00\n50:00\n21... | 1,300 | 1,250 |
2 | 8 | 171_B. Star | <image>
Input
The input contains a single integer a (1 ≤ a ≤ 18257).
Output
Print a single integer output (1 ≤ output ≤ 2·109).
Examples
Input
2
Output
13 | {
"input": [
"2\n"
],
"output": [
"13\n"
]
} | {
"input": [
"3823\n",
"3994\n",
"8543\n",
"12504\n",
"3202\n",
"7530\n",
"15000\n",
"7\n",
"1481\n",
"16344\n",
"13170\n",
"15302\n",
"6543\n",
"6\n",
"11808\n",
"4845\n",
"5\n",
"427\n",
"9\n",
"16331\n",
"18257\n",
"4\n",
"... | 1,300 | 0 |
2 | 9 | 263_C. Circle of Numbers | One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c ar... | {
"input": [
"6\n5 6\n4 3\n5 3\n2 4\n6 1\n3 1\n6 2\n2 5\n1 4\n3 6\n1 2\n4 5\n",
"5\n1 2\n2 3\n3 4\n4 5\n5 1\n1 3\n2 4\n3 5\n4 1\n5 2\n"
],
"output": [
"1 2 4 5 3 6 \n",
"1 2 3 4 5 \n"
]
} | {
"input": [
"6\n1 2\n3 1\n4 1\n5 1\n2 3\n4 2\n2 5\n4 3\n3 6\n5 4\n4 6\n5 6\n",
"6\n4 6\n4 3\n5 3\n2 4\n6 1\n3 1\n6 2\n2 5\n1 4\n3 6\n1 2\n4 5\n",
"7\n4 5\n6 2\n4 1\n3 1\n3 2\n7 5\n2 1\n7 6\n6 3\n5 2\n6 4\n4 7\n1 5\n7 3\n",
"5\n2 1\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n3 5\n4 5\n",
"7\n2 1\n3 1\n5 1... | 2,000 | 2,500 |
2 | 9 | 287_C. Lucky Permutation | A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n).
A lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition ppi = n - i + 1.
You have integer n. Find some lucky permutation p of size n.
Input
T... | {
"input": [
"1\n",
"5\n",
"4\n",
"2\n"
],
"output": [
"1 ",
"2 5 3 1 4 ",
"2 4 1 3 ",
"-1"
]
} | {
"input": [
"13\n",
"505\n",
"10000\n",
"20001\n",
"10001\n",
"7\n",
"505\n",
"9\n",
"8\n",
"30001\n",
"10004\n",
"10004\n",
"10002\n",
"565\n",
"99999\n",
"101\n",
"30001\n",
"3\n",
"17\n",
"33\n",
"10000\n",
"101\n",
"20001... | 1,400 | 500 |
2 | 9 | 312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | {
"input": [
"2 100\n",
"4 3\n"
],
"output": [
"no solution\n",
"0 0\n0 1\n0 2\n0 3\n"
]
} | {
"input": [
"1657 1371995\n",
"2000 1998999\n",
"1834 1680860\n",
"1000 500\n",
"1885 1096142\n",
"2000 1000000000\n",
"1750 215129\n",
"5 6\n",
"1000 500\n",
"1834 1680860\n",
"1792 341122\n",
"1892 948371814\n",
"1854 631695\n",
"1885 1096142\n",
"1750 21... | 1,300 | 500 |
2 | 7 | 335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | {
"input": [
"banana\n3\n",
"banana\n2\n",
"banana\n4\n"
],
"output": [
"3\nabn",
"-1",
"2\naabn"
]
} | {
"input": [
"a\n5\n",
"a\n4\n",
"p\n1000\n",
"aba\n2\n",
"aaaaa\n100\n",
"aaaaaaabbbbbbb\n3\n",
"baba\n3\n",
"aaaaaaaabbbbbccccccccccccccccccccccccccccccc\n7\n",
"aaa\n2\n",
"aaaaa\n10\n",
"bbbbb\n6\n",
"aaa\n9\n",
"abc\n100\n",
"abc\n1000\n",
"a\n1000\n",
... | 1,400 | 500 |
2 | 7 | 358_A. Dima and Continuous Line | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | {
"input": [
"4\n0 10 5 15\n",
"4\n0 15 5 10\n"
],
"output": [
"yes\n",
"no\n"
]
} | {
"input": [
"4\n3 1 4 2\n",
"15\n0 -1 1 2 3 13 12 4 11 10 5 6 7 9 8\n",
"10\n3 2 4 5 1 6 9 7 8 10\n",
"4\n-2 -4 1 -3\n",
"5\n1 9 8 7 0\n",
"3\n1 0 3\n",
"11\n3 4 2 5 1 6 11 7 10 8 9\n",
"6\n1 3 -1 5 2 4\n",
"5\n0 1000 2000 3000 1500\n",
"4\n2 3 4 1\n",
"50\n384672 661179 -... | 1,400 | 500 |
2 | 7 | 498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | {
"input": [
"1 1\n-1 -1\n3\n1 0 0\n0 1 0\n1 1 -3\n",
"1 1\n-1 -1\n2\n0 1 0\n1 0 0\n"
],
"output": [
"2\n",
"2\n"
]
} | {
"input": [
"0 1\n2 2\n1\n1 1 2\n",
"1 1\n-1 -1\n1\n1 1 0\n",
"1 1\n3 3\n1\n1 0 2\n",
"-632 -387435\n942 798117\n10\n249 0 135705\n536 0 271752\n750 0 375750\n799 0 -206142\n1102 0 -437494\n-453 0 197055\n-581 0 260288\n-322 0 161322\n1317 0 -878439\n-811 0 594463\n",
"527189 -306471\n-998939 648... | 1,700 | 500 |
2 | 8 | 521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | {
"input": [
"3\n2 1\n1 0\n0 1\n",
"5\n0 0\n0 1\n0 2\n0 3\n0 4\n"
],
"output": [
"19\n",
"2930\n"
]
} | {
"input": [
"2\n72098079 0\n72098078 1\n",
"2\n-32566075 1\n-32566075 0\n",
"15\n-491189818 2\n-491189821 6\n-491189823 4\n-491189821 4\n-491189822 5\n-491189819 1\n-491189822 4\n-491189822 7\n-491189821 1\n-491189820 2\n-491189823 3\n-491189817 3\n-491189821 3\n-491189820 0\n-491189822 2\n",
"20\n90... | 2,100 | 2,000 |
2 | 10 | 548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | {
"input": [
"10\n1 2 3 4 5 4 3 2 1 6\n"
],
"output": [
"6 4 4 3 3 2 2 1 1 1\n"
]
} | {
"input": [
"19\n519879446 764655030 680293934 914539062 744988123 317088317 653721289 239862203 605157354 943428394 261437390 821695238 312192823 432992892 547139308 408916833 829654733 223751525 672158759\n",
"2\n10 9\n",
"20\n452405440 586588704 509061481 552472140 16115810 148658854 66743034 62830515... | 1,900 | 1,000 |
2 | 7 | 618_A. Slime Combining | Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a... | {
"input": [
"8\n",
"2\n",
"3\n",
"1\n"
],
"output": [
"4 \n",
"2 \n",
"2 1 \n",
"1 \n"
]
} | {
"input": [
"91706\n",
"8192\n",
"97205\n",
"149\n",
"100000\n",
"34768\n",
"12345\n",
"16277\n",
"32\n",
"32728\n",
"33301\n",
"99701\n",
"85371\n",
"97593\n",
"256\n",
"12705\n",
"70958\n",
"65536\n",
"4096\n",
"30151\n",
"16725\n"... | 800 | 500 |
2 | 9 | 638_C. Road Improvement | In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to work simulta... | {
"input": [
"6\n3 4\n5 4\n3 2\n1 3\n4 6\n",
"4\n1 2\n3 4\n3 2\n"
],
"output": [
"3\n2 4 2\n1 1\n2 5 3\n",
"2\n2 1 2 \n1 3 \n"
]
} | {
"input": [
"4\n1 2\n1 3\n1 4\n",
"4\n1 4\n1 2\n4 3\n",
"6\n1 2\n1 3\n1 4\n3 5\n3 6\n",
"2\n1 2\n",
"4\n3 4\n1 4\n3 2\n",
"2\n2 1\n",
"10\n2 4\n6 10\n10 3\n7 4\n7 9\n8 2\n3 1\n4 5\n2 6\n",
"4\n1 3\n4 3\n2 4\n",
"8\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n1 8\n",
"12\n1 2\n2 3\n2 4\n2 5\... | 1,800 | 1,500 |
2 | 7 | 666_A. Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | {
"input": [
"abaca\n",
"abacabaca\n"
],
"output": [
"0\n",
"3\naca\nba\nca\n"
]
} | {
"input": [
"hzobjysjhbebobkoror\n",
"bbbbbccaaaaaa\n",
"prntaxhysjfcfmrjngdsitlguahtpnwgbaxptubgpwcfxqehrulbxfcjssgocqncscduvyvarvwxzvmjoatnqfsvsilubexmwugedtzavyamqjqtkxzuslielibjnvkpvyrbndehsqcaqzcrmomqqwskwcypgqoawxdutnxmeivnfpzwvxiyscbfnloqjhjacsfnkfmbhgzpujrqdbaemjsqphokkiplblbflvadcyykcqrdohfassto... | 1,800 | 500 |
2 | 9 | 712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | {
"input": [
"8 5\n",
"22 4\n",
"6 3\n"
],
"output": [
"3\n",
"6\n",
"4\n"
]
} | {
"input": [
"75749 55910\n",
"70434 39286\n",
"15332 5489\n",
"100 3\n",
"87099 7410\n",
"16 3\n",
"15108 10033\n",
"14746 7504\n",
"48258 12837\n",
"40651 5137\n",
"28 4\n",
"59859 33779\n",
"65310 32879\n",
"41 3\n",
"58915 26212\n",
"43575 4086\n",
... | 1,600 | 1,500 |
2 | 8 | 733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | {
"input": [
"2\n6 5\n5 6\n",
"6\n5 9\n1 3\n4 8\n4 5\n23 54\n12 32\n",
"3\n5 6\n8 9\n10 3\n"
],
"output": [
"1\n",
"0\n",
"3\n"
]
} | {
"input": [
"10\n18 18\n71 471\n121 362\n467 107\n138 254\n13 337\n499 373\n337 387\n147 417\n76 417\n",
"5\n10 8\n7 6\n2 8\n9 1\n7 1\n",
"4\n4 1\n5 3\n7 6\n3 5\n",
"1\n139 252\n",
"5\n10 1\n10 1\n10 1\n100 1\n1 5\n",
"2\n500 499\n500 500\n",
"3\n6 5\n9 8\n3 10\n",
"5\n1 2\n4 8\n4 8\n... | 1,100 | 1,000 |
2 | 9 | 757_C. Felicity is Coming! | It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t... | {
"input": [
"1 3\n3 1 2 3\n",
"2 3\n2 1 2\n2 2 3\n",
"2 2\n3 2 2 1\n2 1 2\n",
"3 7\n2 1 2\n2 3 4\n3 5 6 7\n",
"2 4\n2 1 2\n3 2 3 4\n"
],
"output": [
"6\n",
"1\n",
"1\n",
"24\n",
"2\n"
]
} | {
"input": [
"65 3\n1 1\n1 1\n1 1\n1 1\n2 1 2\n1 1\n2 1 2\n2 1 2\n2 1 2\n1 1\n1 1\n2 1 2\n1 1\n2 1 2\n2 1 2\n2 1 2\n2 1 2\n2 1 2\n2 1 2\n1 1\n1 1\n2 1 2\n1 1\n1 1\n2 1 2\n2 1 2\n2 1 2\n1 1\n2 1 2\n2 1 2\n1 1\n2 1 2\n1 1\n2 1 2\n1 1\n1 1\n1 1\n1 1\n2 1 2\n1 1\n1 1\n2 1 2\n1 1\n1 1\n1 1\n2 1 2\n1 1\n2 1 2\n2 1 2\n1... | 1,900 | 1,500 |
2 | 14 | 802_H. Fake News (medium) | Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she... | {
"input": [
"2\n",
"4\n",
"6\n"
],
"output": [
"aa a",
"abbbb ab\n",
"abccbcc abc\n"
]
} | {
"input": [
"249727\n",
"2023\n",
"2152\n",
"968951\n",
"230003\n",
"58997\n",
"8\n",
"10\n",
"1898\n",
"52382\n",
"696457\n",
"331741\n",
"6\n",
"454507\n",
"29\n",
"17\n",
"930454\n",
"28\n",
"26\n",
"3\n",
"3493\n",
"343121\n"... | 2,200 | 0 |
2 | 10 | 825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | {
"input": [
"??b?\nza\n",
"?aa?\nab\n",
"abcd\nabacaba\n"
],
"output": [
"azba\n",
"baab\n",
"abcd\n"
]
} | {
"input": [
"????????????????????\nxwkxsxlrre\n",
"ng?\nvu\n",
"??a?\na\n",
"ccaaa?bc?baccbccccbca?cccab??aacccbaac?bccacc?accccaccbcbbcbc\ncbaaacccc\n",
"???\nb\n",
"mqwstphetbfrsyxuzdww\nrutseqtsbh\n",
"cc?cdb?????b?cc?b?\ncabdacd\n",
"fzjqgrgzzzghrwgwhfjq\nggwfrjzzqh\n",
"aacaa... | 1,500 | 0 |
2 | 8 | 848_B. Rooter's Song | Wherever the destination is, whoever we meet, let's render this song together.
On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisions will happen before one enters the stage.
On the sides of t... | {
"input": [
"3 2 3\n1 1 2\n2 1 1\n1 1 5\n",
"8 10 8\n1 1 10\n1 4 13\n1 7 1\n1 8 2\n2 2 0\n2 5 14\n2 6 0\n2 6 1\n"
],
"output": [
"1 3\n2 1\n1 3\n",
"4 8\n10 5\n8 8\n10 6\n10 2\n1 8\n7 8\n10 6\n"
]
} | {
"input": [
"5 20 20\n1 15 3\n2 15 3\n2 3 1\n2 1 0\n1 16 4\n",
"15 15 15\n1 10 1\n2 11 0\n2 6 4\n1 1 0\n1 7 5\n1 14 3\n1 3 1\n1 4 2\n1 9 0\n2 10 1\n1 12 1\n2 2 0\n1 5 3\n2 3 0\n2 4 2\n",
"15 80 80\n2 36 4\n2 65 5\n1 31 2\n2 3 1\n2 62 0\n2 37 5\n1 16 4\n2 47 2\n1 17 5\n1 9 5\n2 2 0\n2 62 5\n2 34 2\n1 33 1... | 1,900 | 1,000 |
2 | 9 | 967_C. Stairs and Elevators | In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l... | {
"input": [
"5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3\n"
],
"output": [
"7\n5\n4\n"
]
} | {
"input": [
"1000 1000 1 1 10\n1\n2\n1\n1 900 1 1000\n",
"2 4 1 1 1\n1\n4\n1\n1 2 1 3\n",
"10 10 1 8 4\n10\n2 3 4 5 6 7 8 9\n10\n1 1 3 1\n2 1 7 1\n1 1 9 1\n7 1 4 1\n10 1 7 1\n2 1 7 1\n3 1 2 1\n5 1 2 1\n10 1 5 1\n6 1 9 1\n",
"2 10 1 1 1\n1\n10\n1\n1 5 1 8\n",
"4 4 1 0 1\n4\n\n5\n1 1 2 2\n1 3 2 2\n... | 1,600 | 500 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.