messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.\n\nThe area looks like a strip of cells 1 Γ n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions writ... | [{"input": "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 6\n", "output": "INFINITE\n"}, {"input": "10\n>>>>>>>>><\n2 1 1 1 1 1 1 1 1 5\n", "output": "INFINITE\n"}, {"input": "10\n>>>>>>>>>>\n1 1 1 1 1 1 2 1 1 100\n", "output": "FINITE\n"}, {"input": "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 4\n", "output": "INFINITE\n"}, {"input": "10\n... | code_stdio |
[
{
"content": "Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer number in range [1, a].\n\nBy <image> we denote the quotien... | [{"input": "10000000 10000000\n", "output": "425362313\n"}, {"input": "10000000 9999999\n", "output": "930564389\n"}, {"input": "3865975 13943620\n", "output": "633381536\n"}, {"input": "6407688 3000816\n", "output": "895399645\n"}, {"input": "1507925 5483803\n", "output": "727607740\n"}, {"input": "9900111 1082917\n",... | code_stdio |
[
{
"content": "Alice and Brown loves games. Today, they will play the following game.\nIn this game, there are two piles initially consisting of X and Y stones, respectively.\nAlice and Bob alternately perform the following operation, starting from Alice:\n - Take 2i stones from one of the piles. Then, throw awa... | [{"input": "13 -1", "output": "Alice\n"}, {"input": "-1 10", "output": "Alice\n"}, {"input": "18 -1", "output": "Alice\n"}, {"input": "-1 14", "output": "Alice\n"}, {"input": "14 -1", "output": "Alice\n"}, {"input": "-1 12", "output": "Alice\n"}, {"input": "-1 21", "output": "Alice\n"}, {"input": "-1 20", "output": "Al... | code_stdio |
[
{
"content": "Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.\n\nFor convenience, each of the two rooms is considered to have W Γ H cells arranged in a grid pattern. The ... | [{"input": "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0", "output": "Yes\nNo\nNo\n"}, {"input": "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.$. %..R\n0 0", "output": "Yes\nNo\nNo\n"}, {"input": "... | code_stdio |
[
{
"content": "Homer has two friends Alice and Bob. Both of them are string fans.\n\nOne day, Alice and Bob decide to play a game on a string $s = s_1 s_2 \\dots s_n$ of length $n$ consisting of lowercase English letters. They move in turns alternatively and Alice makes the first move.\n\nIn a move, a player mus... | [{"input": "5\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nazazazazazazazazazazazazazazazazazazazazazazazazaz\nzazazazazazazazazazazazazazazazazazazazazazazazaza\nzzazzazzazzazzazzazzazzazzazzazzazzazzazzazza\n", "output": "bzbzbzbzbzbzbzbzbzbzbzbzbzbzbzbzbzbz... | code_stdio |
[
{
"content": "Vasya has got $n$ books, numbered from $1$ to $n$, arranged in a stack. The topmost book has number $a_1$, the next one β $a_2$, and so on. The book at the bottom of the stack has number $a_n$. All numbers are distinct.\n\nVasya wants to move all the books to his backpack in $n$ steps. During $i$-... | [{"input": "10\n4 7 10 2 1 8 3 5 9 6\n4 2 7 1 8 10 5 3 9 6\n", "output": "1 3 0 1 1 0 2 0 1 1 \n"}, {"input": "10\n4 7 10 2 1 8 3 5 9 6\n4 2 7 1 8 10 5 3 9 6\n", "output": "1 3 0 1 1 0 2 0 1 1 "}, {"input": "10\n4 7 10 2 1 8 3 5 9 6\n4 2 7 1 8 10 5 3 7 6\n", "output": "1 3 0 1 1 0 2 0 0 2\n"}, {"input": "10\n4 7 10 2 1... | code_stdio |
[
{
"content": "D: The Diversity of Prime Factorization\n\nProblem\n\nEbi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \\ log $ M) time! But unfortunately, the machine could display only digits and white spaces.\n\nIn general, we consider the factorization of ... | [{"input": "3\n2 3 11", "output": "3\n"}, {"input": "3\n2 2 11", "output": "1\n"}, {"input": "3\n2 2 13", "output": "1\n"}, {"input": "3\n2 3 17", "output": "3\n"}, {"input": "3\n2 2 15", "output": "0\n"}, {"input": "3\n3 2 11", "output": "1\n"}, {"input": "3\n2 2 17", "output": "1\n"}, {"input": "3\n4 3 10", "output":... | code_stdio |
[
{
"content": "We start with a permutation $a_1, a_2, \\ldots, a_n$ and with an empty array $b$. We apply the following operation $k$ times.\n\nOn the $i$-th iteration, we select an index $t_i$ ($1 \\le t_i \\le n-i+1$), remove $a_{t_i}$ from the array, and append one of the numbers $a_{t_i-1}$ or $a_{t_i+1}$ (i... | [{"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 3 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "output": "1\n0\n2\n0\n0\n4\n"}, {"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 3 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "out... | code_stdio |
[
{
"content": "You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour.\n\nLet's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour c. So it's possible that two or more colours will be d... | [{"input": "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13\n", "output": "6 5 4 3 2 3 3 1 1 3 2 2 1 2 3 \n"}, {"input": "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13\n", "output": "6 5 4 3 2 3... | code_stdio |
[
{
"content": "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.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself... | [{"input": "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 46 39 16 30 18 23 53 13\n", "output": "66\n"}, {"input": "100\n0 0 0 0 0 0 1 4... | code_stdio |
[
{
"content": "Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a_1, a_2, ..., a_{n} of positive integers: Initially, x = 1 and y = 0. If, after any step, x β€ 0 or x > n, the program immediately t... | [{"input": "98\n94 24 17 92 275858941 58 91 57 13 468038892 42 195790073 494005784 8 468106970 518962936 33 27 61 72 42 206673418 10 82 23 34 29 77 90 39 9 67 34 71 29 95 49 48 60 69 86 64 94 77 48 74 19 96700186 5 67 881058074 663483223 64 64 78 23 8 60 7 17 96 71 70 20 5 63 35 34 63 30 86 76 32 86 11 6 96 10 4 378916... | code_stdio |
[
{
"content": "There are various parking lots such as three-dimensional type and tower type in the city to improve the utilization efficiency of the parking lot. In some parking lots, a \"two-stage parking device\" as shown in the figure is installed in one parking space to secure a parking space for two cars. T... | [{"input": "5 5\n136\n68\n82\n84\n114\n2 4\n14\n30\n118\n54\n0 0", "output": "2 3 4 1 5\n1 2 4 3\n"}, {"input": "2 5\n123\n52\n195\n87\n105\n2 4\n18\n30\n80\n24\n0 0", "output": "4 2 3 1 5\n1 2 4 3\n"}, {"input": "1 5\n123\n52\n105\n87\n105\n2 4\n18\n30\n80\n14\n0 0", "output": "2 3 1 5 4\n1 2 4 3\n"}, {"input": "1 5\n... | code_stdio |
[
{
"content": "Alexey is travelling on a train. Unfortunately, due to the bad weather, the train moves slower that it should!\n\nAlexey took the train at the railroad terminal. Let's say that the train starts from the terminal at the moment $0$. Also, let's say that the train will visit $n$ stations numbered fro... | [{"input": "2\n2\n2 4\n10 12\n0 2\n5\n1 4\n7 8\n9 10\n13 15\n19 20\n1 2 3 4 5\n", "output": "\n12\n32\n"}, {"input": "2\n2\n2 4\n10 12\n0 2\n5\n1 4\n7 8\n9 10\n13 15\n19 20\n1 2 3 4 5\n", "output": "12\n32\n"}, {"input": "2\n2\n2 3\n10 12\n0 2\n5\n1 4\n7 8\n9 10\n13 15\n19 20\n1 2 3 4 5\n", "output": "12\n32\n"}, {"inp... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ ($n \\geq 2$) positive integers and an integer $p$. Consider an undirected weighted graph of $n$ vertices numbered from $1$ to $n$ for which the edges between the vertices $i$ and $j$ ($i<j$) are added in the following manner:\n\nIf $gcd(a_i, a_{i+1}, a_{i+2}, \\d... | [{"input": "1\n10 195593331\n886547706 549473499 719535263 337021357 357872635 1071822623 699988186 10455 29750933 887846992\n", "output": "1760339979\n"}, {"input": "1\n10 121406599\n432485522 549473499 522487623 1009120577 698965406 845977171 252631181 1770 81120106 717095635\n", "output": "1092659391\n"}, {"input": ... | code_stdio |
[
{
"content": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put... | [{"input": "100 20 149 72\n67 101 52 15 0 92 26 74 44 61 6 44 45 19 22 8 10 85 67 78 24 61 81 99 62 84 9 71 11 65 5 97 3 72 5 81 81 104 65 85 52 21 20 53 66 91 4 75 84 139 72 27 50 26 9 65 14 6 54 68 6 2 89 78 40 45 98 45 27 51 94 72 67 81 20 19 38 64 14 40 57 21 82 99 37 113 21 22 30 14 73 93 60 8 63 25 27 30 32 13\n"... | code_stdio |
[
{
"content": "Given is a rooted tree with N vertices numbered 1 to N.\nThe root is Vertex 1, and the i-th edge (1 \\leq i \\leq N - 1) connects Vertex a_i and b_i.\nEach of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.\nNow, the following Q operations will b... | [{"input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10\n", "output": "20 20 20 20 20 20\n"}, {"input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n2 10\n1 10", "output": "10 20 10 20 20 10\n"}, {"input": "6 1\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10", "output": "10 10 10 10 10 10\n"}, {"input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 14\n1 10",... | code_stdio |
[
{
"content": "We have N camels numbered 1,2,\\ldots,N. Snuke has decided to make them line up in a row.\n\nThe happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.\n\nSnuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of t... | [{"input": "3\n2\n1 3 10\n2 15 10\n3\n2 93 78\n1 71 59\n3 57 129\n19\n19 22 16\n5 90 13\n12 85 70\n19 67 78\n18 16 16\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n18 91 74\n18 100 76\n12 31 11\n9 100 57\n3 76 73\n6 84 93\n1 6 139\n11 75 120\n19 15 3\n12 11 34", "output": "25\n221\n1335\n"}, {"input": "3\n2\n1 3 10\n2 15 10\n3... | code_stdio |
[
{
"content": "When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conv... | [{"input": "get^user_name L\ngetTserNbme U\nemaNresUteG D\nEndOfInput X", "output": "get^userName\nGetTserNbme\nema_nres_ute_g\n"}, {"input": "get^user_name L\nembNresTteg U\nemaNresUteG D\nEndOfInput X", "output": "get^userName\nEmbNresTteg\nema_nres_ute_g\n"}, {"input": "get_user_nbme L\ngetUserOame U\nemaNresUteG D\... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$). \n\nYou want to make the median of the array the largest possible us... | [{"input": "23 290352079\n162011045 845692742 774584765 103906675 222286673 251540072 1067675108 30856336 71306611 790640347 835976636 327687572 387722548 48938195 769656348 341889962 393959831 928029640 320443541 248114937 798473713 159552755 814528707\n", "output": "471308140\n"}, {"input": "23 290352079\n285170966 3... | code_stdio |
[
{
"content": "Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with. \n\nNicholas has n sticks whose lengths equal a1, a2, ... an. Nicholas d... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Polycarp's workday lasts exactly $n$ minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has $k$ bars at the beginning of the workday.\n\nIn some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In ... | [{"input": "100 19\n0011011110011111111010111101101100101111111111011011111111110111101111101111111101111011111011101110\n", "output": "10\n"}, {"input": "100 19\n0011011110011111111010111101101100101111111111011011111111110111101111101111111101111011111011101110\n", "output": "10\n"}, {"input": "100 89\n00110111100111... | code_stdio |
[
{
"content": "The executive chef is trying to bring some competitive spirit into his kitchen. He wants to split the chefs into two teams based on their age - he'll form the young and the old team. To make it fair, he will split them evenly or give the young team one person advantage when there is an odd number ... | [{"input": "5\n6 2\n4 -1\n0 28\n3 1\n0 76", "output": "2\n3\n25\n28\n104\n"}, {"input": "5\n0 2\n0 -1\n12 11\n4 1\n5 25", "output": "2\n3\n10\n11\n34\n"}, {"input": "5\n0 2\n2 1\n12 20\n4 0\n13 11", "output": "2\n1\n17\n17\n28\n"}, {"input": "5\n6 1\n4 -1\n0 28\n0 1\n0 76", "output": "1\n2\n26\n29\n105\n"}, {"input": "... | code_stdio |
[
{
"content": "You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong.\n\nInna and Dima are now in one room. Inna tells Dima off for everything he does in her presence. After Inna tells him off for something, she goes to anoth... | [{"input": "50 10\n1 2 3 4 5 6 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1\n", "output": "2\n"}, {"input": "50 10\n1 2 3 4 5 4 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1\n", "output": "2\n"}, {"input": "50 10\n1 2 3 4 5 1... | code_stdio |
[
{
"content": "The Fair Nut lives in $n$ story house. $a_i$ people live on the $i$-th floor of the house. Every person uses elevator twice a day: to get from the floor where he/she lives to the ground (first) floor and to get from the first floor to the floor where he/she lives, when he/she comes back home in th... | [{"input": "100\n95 81 40 82 80 78 4 86 37 94 1 46 85 6 41 87 100 69 100 87 12 61 55 81 81 32 40 54 22 32 24 73 61 68 76 16 83 76 73 77 41 37 88 46 72 63 2 37 14 49 45 81 75 56 10 101 73 85 41 17 5 2 16 75 28 53 35 77 66 53 69 82 50 95 2 12 35 62 84 46 29 95 91 49 78 14 88 75 58 52 49 31 56 43 55 39 10 72 23 60\n", "ou... | code_stdio |
[
{
"content": "Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.\nGiven are two integers A and B.\nIf Takahashi can calculate A \\times B, print the result; if he cannot, print -1 instead.\n\n-----Constraints----... | [{"input": "20 20\n", "output": "-1\n"}, {"input": "33 106", "output": "-1\n"}, {"input": "5 10\n", "output": "-1\n"}, {"input": "1 11\n", "output": "-1\n"}, {"input": "20 1\n", "output": "-1\n"}, {"input": "11 3\n", "output": "-1\n"}, {"input": "3 14\n", "output": "-1\n"}, {"input": "16 4\n", "output": "-1\n"}, {"inpu... | code_stdio |
[
{
"content": "Three years have passes and nothing changed. It is still raining in London, and Mr. Black has to close all the doors in his home in order to not be flooded. Once, however, Mr. Black became so nervous that he opened one door, then another, then one more and so on until he opened all the doors in hi... | [{"input": "250\n1 0 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 1 0 1... | code_stdio |
[
{
"content": "C: Prayer (Pray)\n\nSome twins are famous for praying before the contest.\n\nThere are four integers $ H, W, X, Y $, and it seems unlucky if $ H \\ times W $ and $ x + y $ are both odd numbers.\n\ninput\n\nFour integers $ H, W, X, Y $ are given, separated by spaces.\n\noutput\n\nOutput \"No\" if y... | [{"input": "-1 -1 -3 -1", "output": "Yes\n"}, {"input": "-2 -1 -3 -1", "output": "Yes\n"}, {"input": "-2 -1 -4 -1", "output": "Yes\n"}, {"input": "0 -1 -4 -1", "output": "Yes\n"}, {"input": "0 -1 -3 -1", "output": "Yes\n"}, {"input": "-1 -1 -2 0", "output": "Yes\n"}, {"input": "0 -1 -5 -1", "output": "Yes\n"}, {"input"... | code_stdio |
[
{
"content": "After seeing the \"ALL YOUR BASE ARE BELONG TO US\" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.\n\nYou're given a number X represented in base b_{x} and a number Y represented in base b_{y}. Compare those two numbers.\n\n\n--... | [{"input": "10 40\n39 39 39 39 39 39 39 39 39 39\n10 39\n38 38 38 38 38 38 38 38 38 38\n", "output": ">\n"}, {"input": "10 40\n39 39 39 14 39 39 39 39 39 39\n10 39\n38 38 38 38 38 38 38 38 38 38\n", "output": ">\n"}, {"input": "10 38\n16 19 37 32 16 7 14 33 16 11\n10 39\n10 27 35 15 31 15 17 16 38 35\n", "output": ">\n... | code_stdio |
[
{
"content": "X and A are integers between 0 and 9 (inclusive).\nIf X is less than A, print 0; if X is not less than A, print 10.\n\n-----Constraints-----\n - 0 \\leq X, A \\leq 9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nX A\n\n-----O... | [{"input": "11 -1", "output": "10\n"}, {"input": "10 -1", "output": "10\n"}, {"input": "19 -1", "output": "10\n"}, {"input": "-1 -1", "output": "10\n"}, {"input": "10 -2", "output": "10\n"}, {"input": "14 -2", "output": "10\n"}, {"input": "14 -1", "output": "10\n"}, {"input": "-2 -2", "output": "10\n"}, {"input": "7 5\... | code_stdio |
[
{
"content": "Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his informatics teacher is going to have a birthday and the beaver has decided to prepare a present for her. He planted n flowers in a row on his windowsill and started waiting for them to grow. However, after som... | [{"input": "11 18 8\n4744 4993 1340 4982 4982 1437 2765 2200 6975 4989 10703\n", "output": "1358\n"}, {"input": "11 18 8\n4744 4993 7957 4982 4982 1437 2765 2200 6975 4989 10703\n", "output": "1455\n"}, {"input": "11 18 8\n4996 4993 4988 4982 4982 4982 4982 4982 4986 4989 4994\n", "output": "5000\n"}, {"input": "11 18 ... | code_stdio |
[
{
"content": "On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.\n\nThe toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must r... | [{"input": "10 30\n3 6 17 15 13 25 9 12 12 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n6 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n", "output": "211\n"}, {"input": "10 30\n3 6 25 15 13 25 9 12 12 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 ... | code_stdio |
[
{
"content": "Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.\n\nPaul has found a tolerable string s of length n. Help him find the lexicograph... | [{"input": "302 4\nabdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdc... | code_stdio |
[
{
"content": "Edo has got a collection of n refrigerator magnets!\n\nHe decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width o... | [{"input": "20 5\n1 12 21 22\n9 10 15 20\n10 12 12 20\n1 1 25 29\n5 10 21 22\n4 9 20 25\n12 10 14 24\n3 3 19 27\n3 4 23 28\n9 1 11 31\n9 14 17 18\n8 12 14 20\n8 11 18 19\n12 3 14 29\n7 8 13 22\n6 4 16 30\n11 3 13 27\n9 16 15 18\n6 13 14 21\n9 12 15 22\n", "output": "4\n"}, {"input": "20 5\n1 12 21 22\n9 10 15 20\n10 12... | code_stdio |
[
{
"content": "We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B ... | [{"input": "10 998244353\n10 10 10 9 5 12 0 4 7 0", "output": "559205848\n"}, {"input": "10 1051516890\n10 15 10 1 5 4 0 8 4 0", "output": "142815647\n"}, {"input": "10 918571889\n10 9 10 7 7 3 0 11 4 0", "output": "551061978\n"}, {"input": "10 1051516890\n10 9 10 7 5 5 0 4 4 0", "output": "818429624\n"}, {"input": "10... | code_stdio |
[
{
"content": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya wonders eagerly what minimum lucky number has the sum of digits equal ... | [{"input": "691900\n", "output": "4444477777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777... | code_stdio |
[
{
"content": "Problem G Rendezvous on a Tetrahedron\n\nOne day, you found two worms $P$ and $Q$ crawling on the surface of a regular tetrahedron with four vertices $A$, $B$, $C$ and $D$. Both worms started from the vertex $A$, went straight ahead, and stopped crawling after a while.\n\nWhen a worm reached one o... | [{"input": "CD 51 1\nDB 30 1", "output": "YES\n"}, {"input": "CD 51 1\nDB 55 1", "output": "YES\n"}, {"input": "CD 51 1\nDB 19 1", "output": "YES\n"}, {"input": "CD 30 1\nDB 30 2", "output": "YES\n"}, {"input": "CD 51 1\nDB 56 1", "output": "YES\n"}, {"input": "CD 20 1\nDB 103 0", "output": "NO\n"}, {"input": "CD 29 1\... | code_stdio |
[
{
"content": "Petya recieved a gift of a string s with length up to 10^5 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and appe... | [{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"input": "bababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaa... | code_stdio |
[
{
"content": "Zane the wizard is going to perform a magic show shuffling the cups.\n\nThere are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x = i.\n\nThe problematic bone is initially at the position x = 1. Zane w... | [{"input": "203948 2 14\n203948 203947\n39 47\n4959 3030\n1 203947\n2929 12381\n203944 203948\n203947 203944\n203944 203922\n203922 203948\n2495 20495\n29419 5959\n12949 12\n49 29292\n1 94\n1 203\n", "output": "203947\n"}, {"input": "203948 2 14\n203948 203947\n39 38\n4959 3030\n1 203947\n2929 9292\n203944 203948\n2039... | code_stdio |
[
{
"content": "Ayoub had an array $a$ of integers of size $n$ and this array had two interesting properties: All the integers in the array were between $l$ and $r$ (inclusive). The sum of all the elements was divisible by $3$. \n\nUnfortunately, Ayoub has lost his array, but he remembers the size of the array... | [{"input": "101149 1300011130 1476544836\n", "output": "156648241\n"}, {"input": "101149 686320621 1476544836\n", "output": "113944181\n"}, {"input": "120881 536336525 585696606\n", "output": "915864703\n"}, {"input": "121382 445163929 988375913\n", "output": "594431176\n"}, {"input": "126028 622192701 881885560\n", "o... | code_stdio |
[
{
"content": "Captain Fint is involved in another treasure hunt, but have found only one strange problem. The problem may be connected to the treasure's location or may not. That's why captain Flint decided to leave the solving the problem to his crew and offered an absurdly high reward: one day off. The proble... | [{"input": "10\n-18 -1 2 3 5 -2 -3 -1 2 -11\n-1 -1 2 2 -1 5 5 7 7 9\n", "output": "-17\n3 4 2 9 5 7 10 8 6 1 "}, {"input": "10\n-10 -1 2 1 5 -2 -3 -3 2 -6\n-1 -1 2 2 -1 5 5 10 7 9\n", "output": "-10\n3 4 2 9 5 7 10 8 6 1 "}, {"input": "10\n-10 -1 2 2 5 -2 -3 -4 2 -6\n-1 -1 2 2 -1 5 5 7 7 9\n", "output": "-9\n3 4 2 9 5 ... | code_stdio |
[
{
"content": "Alice received a set of Toy Trainβ’ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one station at a time and travels around the network of stations in a circular manner. More precisely, the immediate station th... | [{"input": "5000 1\n4008 1126\n", "output": "6125 6124 6123 6122 6121 6120 6119 6118 6117 6116 6115 6114 6113 6112 6111 6110 6109 6108 6107 6106 6105 6104 6103 6102 6101 6100 6099 6098 6097 6096 6095 6094 6093 6092 6091 6090 6089 6088 6087 6086 6085 6084 6083 6082 6081 6080 6079 6078 6077 6076 6075 6074 6073 6072 6071 ... | code_stdio |
[
{
"content": "There is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n - Remove one of the characters in s, excluding both ends. Howe... | [{"input": "fzezbxdbwzbqzxdlkqpcheqlhlfkohdekflklzxpxodqexwewpfbobcdlxowlqzxkqdobwodoxdhcohfdzhlfzbzhcobhewxzodzqfxfbokxkqexwzdfxwhwfeocxobxkocphcofwlkzkcqpblclblbecbwozldhxfdekpwxocfhbzkxqwhkofcxzqlwhpdzkdcedxwkqpqpfchfeclcxeqxfcbzfkophefxkqclxwfoxdfpbeowxpxfdwpolkczlpcdhkhkhohplbfzkolqlzfbhfzldowfqkqczklkqhdqwzoxzwlp... | code_stdio |
[
{
"content": "We have N integers. The i-th integer is A_i.\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).What is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\n - When A \\mbox{ XOR } B is written in base two, the digit in the 2^k'... | [{"input": "10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n", "output": "103715602\n"}, {"input": "10\n1 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820", "output": "103715608\n"}, {"input": "10\n1 14 159 2653 58979 376446 2643383 27950288 419716939 9375105820", "output": "10432892... | code_stdio |
[
{
"content": "Little Petya very much likes computers. Recently he has received a new \"Ternatron IV\" as a gift from his mother. Unlike other modern computers, \"Ternatron IV\" operates with ternary and not binary logic. Petya immediately wondered how the xor operation is performed on this computer (and whether... | [{"input": "274842194 1000000000\n", "output": "1162261466\n"}, {"input": "274842194 1000100000\n", "output": "1162105233\n"}, {"input": "922263603 387506683\n", "output": "1064907553\n"}, {"input": "1000000000 100000000\n", "output": "650219958\n"}, {"input": "440760623 316634331\n", "output": "1052493562\n"}, {"input... | code_stdio |
[
{
"content": "Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f_0 and f_1 are arbitrary f_{n} + 2 = f_{n} + 1 + f_{n} for all n β₯ 0. \n\nYou are given some sequence of integers a_1, a_2, .... | [{"input": "11\n-9 -1 -10 9 7 -4 0 -13 -3 3 5\n", "output": "4\n"}, {"input": "11\n-9 -1 -10 9 7 -4 0 -13 -2 3 5\n", "output": "5\n"}, {"input": "11\n-9 -1 -2 9 7 -4 -1 -13 -3 3 5\n", "output": "5\n"}, {"input": "11\n-9 -1 -10 9 7 -4 0 -8 -3 3 5\n", "output": "5\n"}, {"input": "11\n-9 -1 -10 9 7 -4 0 -8 -3 3 5\n", "out... | code_stdio |
[
{
"content": "There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.\n\nFor example, the Berland sound u can be written in the Latin alphabet as \"u\", and can be written as \"oo\". For this reason, two words \"ulyana\" and \"oolyana\" denote the same name.\n\nThe secon... | [{"input": "101\nukuu\nh\nouuo\no\nkkuo\nko\nu\nh\nhku\nh\nh\nhuo\nuhoh\nkuu\nhu\nhkko\nuhuk\nkoho\nh\nhukk\noohu\nkk\nkko\nou\noou\nh\nuuu\nuh\nkhuk\nokoo\nouou\nuo\nkk\noo\nhuok\no\nu\nhok\nhu\nhhuu\nkuu\nooho\noku\nhuoh\nhhkh\nuuuh\nouo\nhou\nhhu\nh\no\nokou\nuo\nh\nukk\nu\nhook\nh\noouk\nokuo\nkuuu\nk\nuvk\nu\nukk\... | code_stdio |
[
{
"content": "You are given an n Γ m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table\n\nabcd\n\nedfg\n\nhijk\n\n\n\... | [{"input": "4 100\ngdgmmejiigzsmlarrnfsypvlbutvoxazcigpcospgztqkowfhhbnnbxxrbmwbxwkvxlxzabjjjdtbebedukdelooqlxnadjwjpnp\ndmtsnsbsfdzqvydxcdcnkkfcbseicxhvclsligbhqlkccwujpirymoshkqcosbtlxdypsdqkqaolrqtiibymavcwmbfryttdckhw\njtdmpdljcpciuuoznvqqmafvoqychzfslmwqouuarxctunlzegxsucrwontjplkkxhgixgdbvnewphnatxnwqxqshcexpxlyj... | code_stdio |
[
{
"content": "Once Bob saw a string. It contained so many different letters, that the letters were marked by numbers, but at the same time each letter could be met in the string at most 10 times. Bob didn't like that string, because it contained repeats: a repeat of length x is such a substring of length 2x, th... | [{"input": "100\n8 43 55 27 70 81 66 10 49 67 24 61 53 0 2 76 96 16 16 1 78 1 69 69 4 59 6 87 98 14 98 20 12 48 20 41 67 90 20 96 44 8 77 94 84 2 61 27 90 42 66 84 5 19 68 13 5 53 13 87 70 41 48 40 19 61 72 31 4 4 59 100 50 64 84 10 96 16 73 3 63 85 67 91 74 63 22 34 6 96 78 42 61 85 3 95 98 84 66 78\n", "output": "31\... | code_stdio |
[
{
"content": "Write a program which reads $n$ items and sorts them. Each item has attributes $\\\\{value, weight, type, date, name\\\\}$ and they are represented by $\\\\{$ integer, integer, upper-case letter, integer, string $\\\\}$ respectively. Sort the items based on the following priorities.\n\n1. first by... | [{"input": "5\n105 24 C 1500000000000 white\n100 23 C 1500000000000 blue\n105 23 A 1480000000000 pink\n110 25 B 1500000000000 black\n110 20 A 1484487224415 gree", "output": "100 23 C 1500000000000 blue\n105 23 A 1480000000000 pink\n105 24 C 1500000000000 white\n110 20 A 1484487224415 gree\n110 25 B 1500000000000 black\... | code_stdio |
[
{
"content": "You are given two arrays $a_1, a_2, \\dots , a_n$ and $b_1, b_2, \\dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).\n\nYou have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the ... | [{"input": "77 22\n3 2 4 8 10 7 5 7 9 7 5 6 2 9 10 1 5 4 5 8 6 9 3 1 8 1 10 9 6 7 7 1 5 3 6 4 9 10 7 8 2 3 10 10 9 9 2 9 1 9 7 3 2 4 7 7 1 1 10 4 2 2 8 3 2 9 11 10 5 6 7 1 10 8 3 9 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22\n", "output": "0\n"}, {"input": "77 22\n3 2 4 8 10 7 5 7 9 7 5 6 2 9 10 1 5 4 5... | code_stdio |
[
{
"content": "After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four v... | [{"input": "4\n-474 -894\n-474 -833\n-446 -894\n-446 -833\n", "output": "1708\n"}, {"input": "4\n-474 -894\n-474 -833\n-446 -894\n-446 -833\n", "output": "1708\n"}, {"input": "4\n-414 -891\n-414 896\n346 -891\n346 896\n", "output": "1358120\n"}, {"input": "4\n-796 -330\n-796 758\n171 -330\n171 758\n", "output": "105209... | code_stdio |
[
{
"content": "\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared r... | [{"input": "15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000... | code_stdio |
[
{
"content": "Given an array $a_1, a_2, \\dots, a_n$, you need to handle a total of $q$ updates and queries of two types:\n\n$1$ $l$ $r$ β for each index $i$ with $l \\leq i \\leq r$, update the value of $a_i$ to the sum of the digits of $a_i$.\n\n$2$ $x$ β output $a_x$.\n\n\n-----Input-----\n\nThe first line o... | [{"input": "1\n8 35\n14 14 14 14 14 14 14 14\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 1 8\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n", "output": "5\n5\n5\n5\n5\n5\n5\n5\n"}, {"i... | code_stdio |
[
{
"content": "After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which gets most likes wins. If multiple photoes g... | [{"input": "40\n119631 119631 772776 119631 658661 119631 108862 524470 125132 700668 69196 844949 154577 108862 108862 108862 597344 940938 989698 108862 154577 69196 125132 687080 940938 125132 69196 69196 125132 566152 953083 406319 380068 119631 154577 125132 413984 69196 154577 154577\n", "output": "108862\n"}, {"... | code_stdio |
[
{
"content": "Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! \n\nEvery day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining... | [{"input": "718167999978848233 1000000000000000000 1000000000000000000\n", "output": "281832000021151766\n"}, {"input": "338654687020656675 999999999999999999 1000000000000000000\n", "output": "661345312979343324\n"}, {"input": "643704740517968615 299040014770868475 999999999999999999\n", "output": "1057255244711162906... | code_stdio |
[
{
"content": "A Martian boy is named s β he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he can obtain his name from some string by removing zero or more letters (at that, the remaining letters remain in the same... | [{"input": "mars\nsunvenusearthmarsjupitersaturnuranusneptune\n", "output": "0\n"}, {"input": "mars\nsunvenusearthmarsjupitersatuqnuranusneptune\n", "output": "0\n"}, {"input": "mars\nsunvenusearthmarsjupitersatuqnuranusnepttne\n", "output": "0\n"}, {"input": "mars\nsunvenusfarthmarsjupitersaturnuranusneptune\n", "outp... | code_stdio |
[
{
"content": "Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of L meters today.\n\n [Image] \n\nWillman and Bolt have exactly the same speed, so when they compete the result is always a tie. That is a problem for the organizers b... | [{"input": "5000000000000000000 4999999999999999837 4999999999999999963\n", "output": "1249999999999999959/1250000000000000000\n"}, {"input": "5000000000000000000 4999999999999999837 4999999999999999963\n", "output": "1249999999999999959/1250000000000000000\n"}, {"input": "5000000000000000000 2229502307241477700 499999... | code_stdio |
[
{
"content": "Array of integers is unimodal, if:\n\n it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing. \n\nThe first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.\n\nFor example, ... | [{"input": "100\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100... | code_stdio |
[
{
"content": "There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains a_{i} balls, all of which have color i. You have to write a program that will divide all balls into sets such that: each ball belongs to exactly one of the sets, there are no empty sets, there ... | [{"input": "200\n1 2 4 10 5 8 1 10 9 10 1 9 5 5 3 10 4 7 7 1 5 10 1 6 7 3 9 3 5 8 8 9 7 3 1 5 6 7 3 3 1 4 9 2 8 7 2 10 2 1 10 9 6 1 9 5 3 5 9 3 3 2 4 9 5 9 4 8 5 6 10 1 3 10 8 6 10 10 4 6 8 4 10 7 5 2 6 6 8 8 8 10 3 2 4 5 10 2 2 10 4 5 3 1 8 10 8 5 6 4 9 10 8 10 8 6 3 1 6 4 7 4 10 10 6 7 1 1 2 5 2 6 9 10 1 5 8 3 10 8 4... | code_stdio |
[
{
"content": "A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\n-----Constraints-----\n - All values in input... | [{"input": "1 20 20\n", "output": "400\n"}, {"input": "1 -7 15", "output": "-105\n"}, {"input": "1 -8 13", "output": "-104\n"}, {"input": "1 -7 21", "output": "-147\n"}, {"input": "1 -8 19", "output": "-152\n"}, {"input": "1 -5 30", "output": "-150\n"}, {"input": "1 -6 30", "output": "-180\n"}, {"input": "2 11 -16", "o... | code_stdio |
[
{
"content": "You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?\n\nConstraints\n\n* 1 \\leq N \\leq 10^5\n* 1 \... | [{"input": "7\n-1 -1 1 0 1 31150610 0000000101", "output": "3\n"}, {"input": "7\n1 2 3 2 1 999999999 1000000100", "output": "3\n"}, {"input": "7\n1 4 3 2 1 999999999 1000000100", "output": "3\n"}, {"input": "7\n1 4 3 4 1 999999999 1000000100", "output": "3\n"}, {"input": "7\n1 3 3 4 1 999999999 1000000100", "output": "... | code_stdio |
[
{
"content": "By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.\n\nIn 2312 there wa... | [{"input": "1 100\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+ 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+ 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+... | code_stdio |
[
{
"content": "Β«PolygonΒ» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the in... | [{"input": "10\n1 7 13 6 10 10 3 8 2 4\n", "output": "5\n"}, {"input": "10\n1 7 13 6 10 10 4 8 2 4\n", "output": "3\n"}, {"input": "10\n1 7 13 6 10 10 4 8 2 8\n", "output": "3\n"}, {"input": "10\n1 7 13 6 5 10 3 8 2 4\n", "output": "9\n"}, {"input": "10\n7 2 3 8 9 6 5 4 1 10\n", "output": "11\n"}, {"input": "10\n1 7 9 ... | code_stdio |
[
{
"content": "You are fighting with Zmei Gorynich β a ferocious monster from Slavic myths, a huge dragon-like reptile with multiple heads! \n\n $m$ \n\nInitially Zmei Gorynich has $x$ heads. You can deal $n$ types of blows. If you deal a blow of the $i$-th type, you decrease the number of Gorynich's heads by $m... | [{"input": "5\n4 807989196\n770312657 78181451\n624192034 690910298\n754831733 354913874\n519577171 400120478\n4 491297333\n546432637 76258441\n312107971 75446008\n767483254 958677299\n84044330 577526244\n2 177840791\n197738084 143071228\n23274563 597315796\n7 610054060\n858529462 646280969\n644068190 462783596\n820658... | code_stdio |
[
{
"content": "You are given a board of size $n \\times n$, where $n$ is odd (not divisible by $2$). Initially, each cell of the board contains one figure.\n\nIn one move, you can select exactly one figure presented in some cell and move it to one of the cells sharing a side or a corner with the current cell, i.... | [{"input": "3\n11\n11375\n5405\n", "output": "440\n490606116000\n52633933240\n"}, {"input": "3\n11\n22093\n2775\n", "output": "440\n3594535872088\n7123077200\n"}, {"input": "3\n21\n7511\n4623\n", "output": "3080\n141244655440\n32934449248\n"}, {"input": "3\n11\n7017\n9273\n", "output": "440\n115168355632\n265790540048\... | code_stdio |
[
{
"content": "You are given a set of points $x_1$, $x_2$, ..., $x_n$ on the number line.\n\nTwo points $i$ and $j$ can be matched with each other if the following conditions hold: neither $i$ nor $j$ is matched with any other point; $|x_i - x_j| \\ge z$. \n\nWhat is the maximum number of pairs of points you c... | [{"input": "100 13\n11 28 21 7 6 23 26 31 26 32 34 17 19 1 13 1 28 30 28 8 23 36 17 20 5 37 32 23 14 1 20 23 3 39 20 14 2 12 15 3 1 27 7 25 15 39 10 6 8 37 6 22 7 29 6 17 17 9 16 3 39 23 2 34 20 12 28 29 32 2 38 27 36 27 29 18 7 14 27 25 33 18 29 40 22 9 9 6 21 7 23 35 33 26 31 31 39 36 27 27\n", "output": "50\n"}, {"i... | code_stdio |
[
{
"content": "Teddy and Tracy like to play a game based on strings. The game is as follows. Initially, Tracy writes a long random string on a whiteboard. Then, each player starting with Teddy makes turn alternately. Each turn, the player must erase a contiguous substring that exists in the dictionary. The dicti... | [{"input": "3\ncodeehcf\n2\nbode\nfehd\nqng\n1\nbas\nippissirsim\n-1\njssiss\nmippi\nmi\nqip", "output": "Tracy\nTracy\nTracy\n"}, {"input": "3\ncodechef\n2\ncode\nchef\nfoo\n1\nbar\nmississippi\n4\nssissi\nmippi\nmi\nipp", "output": "Tracy\nTracy\nTracy\n"}, {"input": "3\ncodechef\n2\ncode\ndhef\nfoo\n1\nbar\nmississi... | code_stdio |
[
{
"content": "Given an array a_1, a_2, ..., a_{n} of n integers, find the largest number in the array that is not a perfect square.\n\nA number x is said to be a perfect square if there exists an integer y such that x = y^2.\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 β€ n β€ 1000)Β β the... | [{"input": "71\n908209 289 44521 240100 680625 274576 212521 91809 506944 499849 3844 15376 592900 58081 240100 984064 732736 257049 600625 180625 130321 580644 261121 75625 46225 853776 485809 700569 817216 268324 293764 528529 25921 399424 175561 99856 295936 20736 611524 13924 470596 574564 5329 15376 676 431649 145... | code_stdio |
[
{
"content": "Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). ... | [{"input": "10\n5 eeleGlOFWbcnIPPtnll\n55-55-55\n00-00-00\n98-65-32\n76-43-10\n98-76-54\n2 DMBiqRyQJkFvHPJNJp\n28-97-50\n87-64-10\n4 bAfmtnKHohIX\n61-58-93\n77-77-77\n53-17-51\n96-43-10\n3 cDX\n22-22-22\n77-77-77\n63-30-64\n1 HCeHJ\n44-44-44\n6 HgSpfAolwoaBQ\n96-93-53\n98-53-10\n33-33-33\n66-66-66\n87-54-32\n11-11-11\n... | code_stdio |
[
{
"content": "You are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an odd number of times. If there are multiple such strings, output any. It can be shown that such string always exists under the given constrai... | [{"input": "1\n99561\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "You are playing the game \"Arranging The Sheep\". The goal of this game is to make the sheep line up. The level in the game is described by a string of length $n$, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you can move any sheep one square to the left or one squa... | [{"input": "5\n6\n**.*..\n5\n*****\n3\n.*.\n3\n...\n10\n*.*...*.**\n", "output": "\n1\n0\n0\n0\n9\n"}, {"input": "5\n6\n**.*..\n5\n*****\n3\n.*.\n3\n...\n10\n*.*...*.**\n", "output": "1\n0\n0\n0\n9\n"}, {"input": "5\n6\n..*.**\n5\n*****\n3\n.*.\n3\n...\n10\n*.*...*.**\n", "output": "1\n0\n0\n0\n9\n"}, {"input": "5\n6\n... | code_stdio |
[
{
"content": "There is a stack of N cards, each of which has a non-negative integer written on it. The integer written on the i-th card from the top is A_i.\n\nSnuke will repeat the following operation until two cards remain:\n\n* Choose three consecutive cards from the stack.\n* Eat the middle card of the thre... | [{"input": "10\n1 -2 8 1 1 10 0 -1 0 2", "output": "43\n"}, {"input": "10\n1 -1 1 1 1 10 0 -1 0 2", "output": "21\n"}, {"input": "10\n3 1 4 1 5 9 2 11 5 3", "output": "130\n"}, {"input": "10\n3 1 4 1 5 2 2 11 5 3", "output": "110\n"}, {"input": "10\n3 1 4 1 5 2 2 11 5 4", "output": "111\n"}, {"input": "10\n7 1 4 0 5 2 ... | code_stdio |
[
{
"content": "Chef recently printed directions from his home to a hot new restaurant across the town, but forgot to print the directions to get back home. Help Chef to transform the directions to get home from the restaurant.\nA set of directions consists of several instructions. The first instruction is of the... | [{"input": "2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBegin on Old Madras daoR\nLeft on Domlur Flyover\nLeft on 100 Feet Road\nRight on Sarjapur Road\nRight on Hosur Road\nRight on Ganapathi Temple Road", "output": "Begin on Road D\nRight on Road C\nLeft on Road B\nLeft on Road A\nBegi... | code_stdio |
[
{
"content": "You are given two integers $A$ and $B$, calculate the number of pairs $(a, b)$ such that $1 \\le a \\le A$, $1 \\le b \\le B$, and the equation $a \\cdot b + a + b = conc(a, b)$ is true; $conc(a, b)$ is the concatenation of $a$ and $b$ (for example, $conc(12, 23) = 1223$, $conc(100, 11) = 10011$).... | [{"input": "3\n1 14\n4 2\n191 102469002\n", "output": "1\n0\n1528\n"}, {"input": "3\n1 14\n4 2\n131 176163142\n", "output": "1\n0\n1048\n"}, {"input": "3\n1 14\n4 2\n142 128000654\n", "output": "1\n0\n1136\n"}, {"input": "3\n1 14\n4 2\n191 176163142\n", "output": "1\n0\n1528\n"}, {"input": "3\n1 14\n4 2\n131 128000654\... | code_stdio |
[
{
"content": "For given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\\\{a,b,c,b,d,a,b\\\\}$ and $Y = \\\\{b,d,c,a,b,a\\\\}$, the sequence $\\\\{b,c,a\\\\}$ is a common subsequence of both $X$ and $Y$. On the ... | [{"input": "3\nabcbdab\nbdcaba\nabc\nabc\nacb\nbc", "output": "4\n3\n1\n"}, {"input": "3\nabcbdab\nbdcaba\nabc\nabc\nbcb\nbc", "output": "4\n3\n2\n"}, {"input": "3\nabcbdab\nbdcaba\n`bc\nabc\nbcb\nbc", "output": "4\n2\n2\n"}, {"input": "3\nbadbcba\nbdcaba\n`bc\nabc\nbcb\nbc", "output": "5\n2\n2\n"}, {"input": "3\nbadbd... | code_stdio |
[
{
"content": "Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.\n\nRecently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e.... | [{"input": "50\n48 37 47 50 46 43 42 46 36 40 45 41 40 50 35 49 37 42 44 45 49 44 31 47 45 49 48 41 45 45 48 20 34 43 43 41 47 50 41 48 38 48 43 48 46 48 32 37 47 45\n", "output": "31\n1 2 3 4 5 6 7 8 36 9 10 11 40 12 35 13 14 42 15 16 17 44 31 18 19 49 21 22 23 24 25 20 34 26 27 28 29 50 41 30 38 33 43 39 46 48 32 37 ... | code_stdio |
[
{
"content": "For a given array $a$ consisting of $n$ integers and a given integer $m$ find if it is possible to reorder elements of the array $a$ in such a way that $\\sum_{i=1}^{n}{\\sum_{j=i}^{n}{\\frac{a_j}{j}}}$ equals $m$? It is forbidden to delete elements as well as insert new elements. Please note that... | [{"input": "5\n4 10\n5 5 5 5\n3 5\n5 5 5\n3 4\n10 1 1\n4 5\n5 5 1 5\n5 5\n5 5 5 10 5\n", "output": "NO\nNO\nNO\nNO\nNO\n"}, {"input": "5\n4 10\n5 5 5 5\n3 5\n5 5 5\n3 4\n10 1 1\n4 5\n5 5 1 5\n5 5\n5 5 5 15 5\n", "output": "NO\nNO\nNO\nNO\nNO\n"}, {"input": "5\n4 10\n5 5 5 5\n3 5\n5 5 5\n3 4\n10 1 1\n4 5\n5 5 5 5\n5 5\n... | code_stdio |
[
{
"content": "Binary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either\n\n* contains no nodes, or\n* is composed of three disjoint sets of nodes:\n- a root node.\n- a binary tree called its left subtree.\n- a binary tree called its right subtree.\n\n\n\n\... | [{"input": "9\n0 2 4\n1 0 3\n2 -1 -1\n3 0 0\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1", "output": "Preorder\n 1 0 2 4 5 6 7 8 3 0 2 4 5 6 7 8 0 2 4 5 6 7 8\nInorder\n 2 0 6 5 7 4 8 1 2 0 6 5 7 4 8 3 2 0 6 5 7 4 8\nPostorder\n 2 6 7 5 8 4 0 2 6 7 5 8 4 0 2 6 7 5 8 4 0 3 1\n"}, {"input": "9\n0 2 4\n1 0 3\n2 -1 -1\n3 -1 0\... | code_stdio |
[
{
"content": "Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are not.\n\nYou are given current year in Berland. Your ... | [{"input": "1000000000\n", "output": "1000000000\n"}, {"input": "1000000000\n", "output": "1000000000\n"}, {"input": "100000000\n", "output": "100000000\n"}, {"input": "900000000\n", "output": "100000000\n"}, {"input": "100000000\n", "output": "100000000\n"}, {"input": "900000000\n", "output": "100000000\n"}, {"input":... | code_stdio |
[
{
"content": "The king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensils.\n\nAll types of utensils in the kingdom a... | [{"input": "100 100\n97 64 64 35 35 97 39 83 26 97 92 97 83 11 83 97 97 64 23 97 97 11 39 11 11 39 64 14 23 39 64 26 26 97 39 39 39 64 83 26 83 97 64 11 64 64 64 83 64 92 64 26 83 26 27 64 11 83 92 92 23 11 11 97 92 64 97 64 97 83 64 27 83 23 11 26 11 92 83 64 83 11 11 11 97 83 97 26 26 97 23 23 39 64 64 64 97 27 27 92... | code_stdio |
[
{
"content": "In 21XX, an annual programming contest, Japan Algorithmist GrandPrix (JAG) has become one of the most popular mind sports events.\n\nJAG is conducted as a knockout tournament. This year, $N$ contestants will compete in JAG. A tournament chart is represented as a string. '[[a-b]-[c-d]]' is an easy ... | [{"input": "[[r-i]-[m-e]]\nd -1\no 0\ng -1\nl 6", "output": "No\n"}, {"input": "[[m-y]-[a-o]]\nn 0\na 1\ny 2\nm 0", "output": "Yes\n"}, {"input": "[[r-i]-[m-e]]\nd -1\nr 1\ng 1\nm 3", "output": "No\n"}, {"input": "[[r-i]-[m-e]]\nf -1\nr 1\ni 2\nm 4", "output": "No\n"}, {"input": "[[r-i]-[m-e]]\nf -1\nr 1\ni 2\nm 5", "o... | code_stdio |
[
{
"content": "The new \"Die Hard\" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A \"Die Hard\" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially ... | [{"input": "14\n25 25 25 25 25 25 25 50 50 50 100 100 100 100\n", "output": "NO\n"}, {"input": "14\n25 25 25 25 25 25 25 50 50 50 100 100 100 100\n", "output": "NO\n"}, {"input": "10\n100 100 100 100 100 100 100 100 100 100\n", "output": "NO\n"}, {"input": "10\n100 100 100 100 100 100 100 100 100 100\n", "output": "NO\... | code_stdio |
[
{
"content": "problem\n\nJOI decided to play a game with his friends. N players participate in this game. The rules for a single game are as follows:\n\nEach player writes a favorite integer from 1 to 100 on the card and submits it. Each player gets the same score as he wrote if no one else wrote the same numbe... | [{"input": "5\n000 99 22\n100 97 92\n30 53 63\n99 99 99\n89 97 98", "output": "22\n192\n146\n198\n187\n"}, {"input": "5\n000 99 22\n100 97 92\n51 53 63\n99 99 99\n89 97 98", "output": "22\n192\n167\n198\n187\n"}, {"input": "5\n100 99 22\n100 13 92\n56 53 63\n99 99 99\n89 97 98", "output": "22\n105\n172\n198\n284\n"}, {... | code_stdio |
[
{
"content": "Once upon a time Petya and Gena gathered after another programming competition and decided to play some game. As they consider most modern games to be boring, they always try to invent their own games. They have only stickers and markers, but that won't stop them.\n\nThe game they came up with has... | [{"input": "110\n-256 -149 -136 -33 -253 -141 -170 -253 0 -107 -141 -236 -65 -158 -84 -180 -97 -97 -223 -44 -232 -255 -108 -25 -49 -48 -212 -3 -232 -172 -231 -158 -23 -206 -198 -55 -36 -11 -169 -94 -190 -115 -116 -231 -155 -201 -155 -103 -242 -119 -136 -8 -2 -11 -69 -250 -51 -129 -155 -216 -107 -102 -186 -13 -78 -2 -23... | code_stdio |
[
{
"content": "Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.\n\nIn Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.\n\nDu will chat in the group for $n$ days. On the $i$-th day: If Du can speak, ... | [{"input": "100 61 71\n11 18 0 47 33 37 91 13 8 30 73 64 50 97 62 50 2 36 68 32 64 74 32 77 81 41 23 44 40 18 45 33 21 68 57 79 107 23 21 37 99 27 30 56 75 62 75 63 1 15 79 42 18 66 21 25 2 12 89 48 75 7 57 85 80 14 82 29 66 47 29 10 1 84 79 39 33 81 135 26 80 67 52 25 38 68 57 53 38 83 83 3 86 29 50 46 3 68 88 10\n", ... | code_stdio |
[
{
"content": "In this problem you will meet the simplified model of game King of Thieves.\n\nIn a new ZeptoLab game called \"King of Thieves\" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way. [Image] \n\nAn interesting feature of the game is that yo... | [{"input": "100\n*****************************)**********************************************************************\n", "output": "yes\n"}, {"input": "100\n*.....................*.....................*.....................*......../............*...........\n", "output": "yes\n"}, {"input": "100\n*....................... | code_stdio |
[
{
"content": "Your task is to write a program which reads an expression and evaluates it.\n\n* The expression consists of numerical values, operators and parentheses, and the ends with '='.\n* The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n... | [{"input": "2\n4-2*3=\n8*(4+4*3)=", "output": "-2\n128\n"}, {"input": "2\n3-4*3=\n4*(8*4+3)=", "output": "-9\n140\n"}, {"input": "2\n4-2*3=\n4*(8*4+3)=", "output": "-2\n140\n"}, {"input": "2\n4-2*4=\n3*(8*4+4)=", "output": "-4\n108\n"}, {"input": "2\n4-2*3=\n8*(4+4+3)=", "output": "-2\n88\n"}, {"input": "2\n4-2*3=\n8*(... | code_stdio |
[
{
"content": "Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`.\n\nFind the number of permutations (p_1, p_2, \\ldots, p_N) of (1, 2, \\ldots, N) that satisfy the following condition, modulo 10^9 + 7:\n\n* For each i (1 \\leq i \\leq N - 1), p_i < p_{i + 1} if the... | [{"input": "20\n>><<>>><>><>>><>>>>", "output": "217136290\n"}, {"input": "20\n>><<>>><>>>>>><>>><", "output": "415929071\n"}, {"input": "20\n>>>><>>>>><<>>><<>>", "output": "784400335\n"}, {"input": "20\n<>>><>>><>>>>>><<>>", "output": "586939232\n"}, {"input": "20\n>><<>>><>>>><>>>>><", "output": "704760317\n"}, {"in... | code_stdio |
[
{
"content": "For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?\n\nOh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you'... | [{"input": "5\n2\n1 1\n2\n1 1000000000\n2\n1000000000 1\n2\n1000000000 1000000000\n2\n228 1337\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n2\n1 1\n2\n1 1000000000\n2\n1000000000 1\n2\n1000000000 1000000000\n2\n228 1337\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n2\n1 1\n2\n1 1000000000\n2\n100... | code_stdio |
[
{
"content": "Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him crazy. For example, yesterday he grew keen on counting how ma... | [{"input": "100000\n", "output": "879367333\n"}, {"input": "99925\n", "output": "414342728\n"}, {"input": "54904\n", "output": "917915735\n"}, {"input": "57500\n", "output": "540890446\n"}, {"input": "87440\n", "output": "926716958\n"}, {"input": "47504\n", "output": "469586508\n"}, {"input": "49948\n", "output": "1884... | code_stdio |
[
{
"content": "A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this point, at least one 'a' and one 'b' exist in... | [{"input": "aaaaabbbbbb\n", "output": "NO\n"}, {"input": "aaaaabbbbbb\n", "output": "NO\n"}, {"input": "aaaaabbabbb\n", "output": "NO\n"}, {"input": "bbbabbaaaaa\n", "output": "NO\n"}, {"input": "aabbaacccc\n", "output": "NO\n"}, {"input": "aabbaacccc\n", "output": "NO\n"}, {"input": "cabbaaccca\n", "output": "NO\n"}, ... | code_stdio |
[
{
"content": "A: A-Z-\n\nproblem\n\nThere is a circular board of 26 squares, each square with one capital letter of the alphabet written clockwise in alphabetical order. That is, the clockwise side of the'A'square is the'B' square, the next side of the'B'square is the'C'square, and ..., the clockwise side of th... | [{"input": "AIZV", "output": "2\n"}, {"input": "W\\AG", "output": "1\n"}, {"input": "[VIA", "output": "3\n"}, {"input": "BEW]", "output": "0\n"}, {"input": "VZIA", "output": "2\n"}, {"input": "V[IA", "output": "2\n"}, {"input": "W[IA", "output": "2\n"}, {"input": "AI[W", "output": "2\n"}, {"input": "AH[W", "output": "2... | code_stdio |
[
{
"content": "For an array a of integers let's denote its maximal element as max(a), and minimal as min(a). We will call an array a of k integers interesting if max(a) - min(a) β₯ k. For example, array [1, 3, 4, 3] isn't interesting as max(a) - min(a) = 4 - 1 = 3 < 4 while array [7, 3, 0, 4, 3] is as max(a) - mi... | [{"input": "1\n24\n1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 5 5 5 5 5 5\n", "output": "YES\n12 13\n"}, {"input": "1\n24\n1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 4 5 5 5 5 5\n", "output": "YES\n12 13\n"}, {"input": "1\n24\n1 1 2 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 4 5 5 5 5 5\n", "output": "YES\n12 13\n"}, {"input": "1\n24\n1 1 2 1 1 ... | code_stdio |
[
{
"content": "The only king stands on the standard chess board. You are given his position in format \"cd\", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.\n\nCheck the king's moves here https://en.wikipedia.org/wiki/King_(chess). [Image]... | [{"input": "e4\n", "output": "8\n"}, {"input": "a1\n", "output": "3\n"}, {"input": "h8\n", "output": "3\n"}, {"input": "a4\n", "output": "5\n"}, {"input": "g7\n", "output": "8\n"}, {"input": "e1\n", "output": "5\n"}, {"input": "b2\n", "output": "8\n"}, {"input": "c7\n", "output": "8\n"}, {"input": "h6\n", "output": "5\... | code_stdio |
[
{
"content": "You are given three integers $x, y$ and $n$. Your task is to find the maximum integer $k$ such that $0 \\le k \\le n$ that $k \\bmod x = y$, where $\\bmod$ is modulo operation. Many programming languages use percent operator % to implement it.\n\nIn other words, with given $x, y$ and $n$ you need ... | [{"input": "7\n7 5 12345\n5 0 4\n10 5 15\n17 8 54321\n499999993 9 1000000000\n10 5 187\n2 0 999999999\n", "output": "12339\n0\n15\n54306\n999999995\n185\n999999998\n"}, {"input": "7\n7 5 12345\n5 0 4\n10 5 15\n17 8 54321\n499999993 5 1000000000\n10 5 187\n2 0 999999999\n", "output": "12339\n0\n15\n54306\n999999991\n185... | code_stdio |
[
{
"content": "Karlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifically, there were $2n$ jars of strawberry and blueberry jam.\n\nAll the $2n$ jars are arranged in a row. The stairs to the basement are exactly in the middle of that row. So when Karlsson ente... | [{"input": "4\n6\n1 1 1 1 2 1 2 1 2 1 1 1\n2\n2 2 1 2\n3\n1 1 1 1 1 1\n2\n2 1 2 1\n", "output": "12\n2\n6\n0\n"}, {"input": "4\n6\n2 2 2 1 2 2 2 1 2 2 1 2\n2\n2 2 1 2\n3\n1 1 1 1 2 1\n2\n2 1 1 1\n", "output": "10\n2\n4\n2\n"}, {"input": "4\n6\n1 1 1 1 2 1 2 1 1 1 1 2\n2\n2 2 1 2\n3\n1 1 1 1 2 1\n2\n2 1 1 1\n", "output"... | code_stdio |
[
{
"content": "You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.\n\nConstraints\n\n* 1 \\leq w \\leq |S| \\leq 100... | [{"input": "dnuoodnuuuhs\n1", "output": "dnuoodnuuuhs\n"}, {"input": "shuuundoound\n1", "output": "shuuundoound\n"}, {"input": "dnuondouuuhs\n1", "output": "dnuondouuuhs\n"}, {"input": "siuuuodnound\n1", "output": "siuuuodnound\n"}, {"input": "dnuondouuuis\n1", "output": "dnuondouuuis\n"}, {"input": "dnuoocnuuuhs\n1", ... | code_stdio |
[
{
"content": "M-kun has the following three cards:\n\n* A red card with the integer A.\n* A green card with the integer B.\n* A blue card with the integer C.\n\n\n\nHe is a genius magician who can do the following operation at most K times:\n\n* Choose one of the three cards and multiply the written integer by ... | [{"input": "13 4 1\n10", "output": "Yes\n"}, {"input": "13 5 1\n10", "output": "Yes\n"}, {"input": "12 3 4\n9", "output": "Yes\n"}, {"input": "12 4 4\n9", "output": "Yes\n"}, {"input": "12 4 2\n9", "output": "Yes\n"}, {"input": "12 2 2\n9", "output": "Yes\n"}, {"input": "21 2 2\n9", "output": "Yes\n"}, {"input": "12 5 ... | code_stdio |
[
{
"content": "Read problems statements in Russian here \nThe Head Chef has been playing with Fibonacci numbers for long . He has learnt several tricks related to Fibonacci numbers . Now he wants to test his chefs in the skills . \n \nA fibonacci number is defined by the recurrence :\n \nf(n) = f(n-1) + f(n-2) f... | [{"input": "3\n5\n13\n13", "output": "YES\nYES\nYES\n"}, {"input": "3\n13\n15\n13", "output": "YES\nNO\nYES\n"}, {"input": "3\n13\n18\n21", "output": "YES\nNO\nYES\n"}, {"input": "3\n5\n13\n11", "output": "YES\nYES\nNO\n"}, {"input": "3\n13\n15\n15", "output": "YES\nNO\nNO\n"}, {"input": "3\n13\n18\n15", "output": "YES... | code_stdio |
[
{
"content": "We start with a permutation a_1, a_2, β¦, a_n and with an empty array b. We apply the following operation k times.\n\nOn the i-th iteration, we select an index t_i (1 β€ t_i β€ n-i+1), remove a_{t_i} from the array, and append one of the numbers a_{t_i-1} or a_{t_i+1} (if t_i-1 or t_i+1 are within th... | [{"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 3 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "output": "1\n0\n2\n0\n0\n4\n"}, {"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 4 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "out... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.