messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "What are you doing at the end of the world? Are you busy? Will you save us?\n\n<image>\n\nNephren is playing a game with little leprechauns.\n\nShe gives them an infinite array of strings, f0... β.\n\nf0 is \"What are you doing at the end of the world? Are you busy? Will you save us?\".\n\nShe wan... | [{"input": "10\n100000 873326525630182716\n100000 620513733919162415\n100000 482953375281256917\n100000 485328193417229962\n100000 353549227094721271\n100000 367447590857326107\n100000 627193846053528323\n100000 243833127760837417\n100000 287297493528203749\n100000 70867563577617188\n", "output": "o W rlot"}, {"input... | code_stdio |
[
{
"content": "The cows have just learned what a primitive root is! Given a prime p, a primitive root $\\operatorname{mod} p$ is an integer x (1 β€ x < p) such that none of integers x - 1, x^2 - 1, ..., x^{p} - 2 - 1 are divisible by p, but x^{p} - 1 - 1 is. \n\nUnfortunately, computing primitive roots can be tim... | [{"input": "1583\n", "output": "672\n"}, {"input": "1987\n", "output": "660\n"}, {"input": "1993\n", "output": "656\n"}, {"input": "1997\n", "output": "996\n"}, {"input": "1999\n", "output": "648\n"}, {"input": "1297\n", "output": "432\n"}, {"input": "1259\n", "output": "576\n"}, {"input": "1949\n", "output": "972\n"},... | code_stdio |
[
{
"content": "Problem Statement\n\nIn the headquarter building of ICPC (International Company of Plugs & Connectors), there are $M$ light bulbs and they are controlled by $N$ switches. Each light bulb can be turned on or off by exactly one switch. Each switch may control multiple light bulbs. When you operate a... | [{"input": "3 10 3\n000 0000000000\n110 0000001011\n101 1111111100\n2 6 0\n1 2 0\n2 1 1\n01 1\n11 11 10\n10000000000 10000000000\n11000000000 00000000000\n01100000000 00100000000\n00110000000 00010000000\n00011000000 00001000000\n00001100000 00000100000\n01000110000 00000010000\n00000011000 00000001000\n00000001100 000... | code_stdio |
[
{
"content": "Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly $1$ problem, during the second day β exactly $2$ problems, during the third day β exactly $3$ problems, and so on. During the $k$-th day he should solve $k$ problems.\n\nPol... | [{"input": "5\n200000 200000 200000 200000 200000\n", "output": "5\n"}, {"input": "5\n200000 200000 200000 200000 200000\n", "output": "5\n"}, {"input": "5\n200000 200000 200000 200000 329398\n", "output": "5\n"}, {"input": "5\n330358 200000 200000 200000 200000\n", "output": "5\n"}, {"input": "5\n200000 201888 200000 ... | code_stdio |
[
{
"content": "We have a string S consisting of lowercase English letters.\nIf the length of S is at most K, print S without change.\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\n-----Constraints-----\n - K is an integer between 1 and ... | [{"input": "99\nlbyhybgfptdyuqnlszvxoggbjhrjopbevyrzytfhiabtoozntnxxcvmhckjlwxnzniwzzxzvmfiztyirssfeauzncyosgrmsgull\n", "output": "lbyhybgfptdyuqnlszvxoggbjhrjopbevyrzytfhiabtoozntnxxcvmhckjlwxnzniwzzxzvmfiztyirssfeauzncyosgrmsgul...\n"}, {"input": "100\nvefcekrnrodmjprtifxrvjtjgzvuidhbtadwuqxctuwqfxhiuuupmsggdrmpswcq... | code_stdio |
[
{
"content": "You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side.\n\nUnfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level u... | [{"input": "6\n2 3\n0 0\n2 3\n0 3\n2 3\n3 0\n3 3\n4 0 4\n3 3\n4 0 5\n3 3\n5 0 4\n", "output": "YES\nNO\nNO\nYES\nNO\nNO\n"}, {"input": "6\n2 3\n0 0\n2 3\n0 3\n2 3\n3 0\n3 3\n4 0 4\n3 3\n4 0 5\n3 3\n5 0 4\n", "output": "YES\nNO\nNO\nYES\nNO\nNO\n"}, {"input": "6\n2 3\n0 0\n2 3\n0 3\n2 3\n3 0\n3 3\n4 0 4\n3 3\n4 0 5\n3 3... | code_stdio |
[
{
"content": "Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.\n\nKavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:\n\nConsider n segments with ends at the points in correspondent pairs. The pai... | [{"input": "1000000\n", "output": "126330412"}, {"input": "372544\n", "output": "214345447\n"}, {"input": "315936\n", "output": "256195953\n"}, {"input": "446167\n", "output": "461428149\n"}, {"input": "797112\n", "output": "121466915\n"}, {"input": "119444\n", "output": "553363384\n"}, {"input": "916542\n", "output": ... | code_stdio |
[
{
"content": "You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.\n\nFor instance, if we are given an array $[1... | [{"input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"input": "6\n506233607 200000000 300000000 200000000 1000000000 300000000\n", "output": "4\n"}, {"input": "6\n144373768 2000... | code_stdio |
[
{
"content": "Have you ever tasted Martian food? Well, you should.\n\nTheir signature dish is served on a completely black plate with the radius of R, flat as a pancake.\n\nFirst, they put a perfectly circular portion of the Golden Honduras on the plate. It has the radius of r and is located as close to the edg... | [{"input": "2\n4 3 1\n5 2 2\n", "output": "0.9230769231\n0.6521739130\n"}, {"input": "2\n8 3 1\n4 2 2\n", "output": "2.4489795918\n0.6666666667\n"}, {"input": "2\n9 3 1\n4 2 2\n", "output": "2.5714285714\n0.6666666667\n"}, {"input": "2\n8 5 1\n4 2 2\n", "output": "2.4489795918\n0.6666666667\n"}, {"input": "2\n4 3 1\n4 ... | code_stdio |
[
{
"content": "Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.\n\nConsider a set consisting of k (0 β€ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that ... | [{"input": "100\n0 0 2 2 0 3 5 0 6 2 0 4 0 2 3 7 8 3 15 19 13 8 18 19 3 14 23 9 6 3 6 17 26 24 20 4 4 27 8 5 14 5 35 31 27 3 41 25 20 14 25 31 49 40 0 1 10 5 50 13 29 58 1 6 8 1 40 52 30 15 50 8 66 52 29 71 25 68 36 12 80 60 6 2 11 43 62 27 84 86 71 38 14 50 88 4 8 95 53\n1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0... | code_stdio |
[
{
"content": "You are a given an array $a$ of length $n$. Find a subarray $a[l..r]$ with length at least $k$ with the largest median.\n\nA median in an array of length $n$ is an element which occupies position number $\\lfloor \\frac{n + 1}{2} \\rfloor$ after we sort the elements in non-decreasing order. For ex... | [{"input": "100 16\n14 94 97 89 73 165 11 78 10 30 54 57 88 57 44 6 33 40 17 26 69 100 92 67 22 59 80 67 17 29 76 69 133 7 86 45 1 98 99 25 65 102 94 91 7 24 53 40 53 91 59 32 67 24 25 157 55 46 68 53 2 15 92 5 53 37 76 40 49 94 4 8 76 12 50 2 54 86 49 95 81 5 34 28 21 47 97 73 96 56 32 78 71 38 49 24 64 78 35 18\n", "... | code_stdio |
[
{
"content": "Snuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\nHere, the distance ... | [{"input": "1 999 1000\n", "output": "A\n"}, {"input": "1 1455 0000", "output": "B\n"}, {"input": "1 1200 0101", "output": "B\n"}, {"input": "1 999 0000", "output": "B\n"}, {"input": "1 381 1110", "output": "A\n"}, {"input": "1 999 0100", "output": "B\n"}, {"input": "1 999 0101", "output": "B\n"}, {"input": "1 999 0001... | code_stdio |
[
{
"content": "You have received data from a Bubble bot. You know your task is to make factory facilities, but before you even start, you need to know how big the factory is and how many rooms it has. When you look at the data you see that you have the dimensions of the construction, which is in rectangle shape:... | [{"input": "4 5\n9 14 11 12 13\n5 15 11 6 7\n5 8 14 9 14\n3 2 14 3 14\n", "output": "9 4 4 2 1 \n"}, {"input": "4 5\n9 14 9 12 13\n5 15 11 6 7\n5 9 14 9 14\n3 2 14 3 14\n", "output": "9 4 4 2 1 \n"}, {"input": "4 5\n9 14 11 12 13\n5 15 3 6 7\n5 9 14 9 14\n3 2 14 3 14\n", "output": "9 4 4 2 1 \n"}, {"input": "4 5\n9 14 ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n2 2 2 1\n0 0 0\n\n\nOutput\n\n24\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "26 2 22 0\n-1 2 0", "output": "1336\n"}, {"input": "36 2 22 0\n-1 2 0", "output": "1816\n"}, {"input": "36 2 43 0\n-1 2 0", "output": "3412\n"}, {"input": "3 8 88 0\n-2 8 -1", "output": "1984\n"}, {"input": "3 9 88 0\n-2 8 -1", "output": "2166\n"}, {"input": "3 9 82 0\n-2 8 -1", "output": "2022\n"}, {"input... | code_stdio |
[
{
"content": "Recently Vova found $n$ candy wrappers. He remembers that he bought $x$ candies during the first day, $2x$ candies during the second day, $4x$ candies during the third day, $\\dots$, $2^{k-1} x$ candies during the $k$-th day. But there is an issue: Vova remembers neither $x$ nor $k$ but he is sure... | [{"input": "53\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\... | code_stdio |
[
{
"content": "You are given a string of length N. Calculate the number of distinct substrings of S.\n\nConstraints\n\n* 1 \\leq N \\leq 500,000\n* S consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nS\n\n\nOutput\n\nPrint the answer.\n\nExamples\... | [{"input": "mjssissippi", "output": "57\n"}, {"input": "mjssisrippi", "output": "61\n"}, {"input": "mjssisripph", "output": "62\n"}, {"input": "hppirsitsjm", "output": "63\n"}, {"input": "mjsthspiroh", "output": "64\n"}, {"input": "hnripohtqgm", "output": "65\n"}, {"input": "hppirsissjm", "output": "62\n"}, {"input": "... | code_stdio |
[
{
"content": "Snuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line. The i-th piece from the left is at position x_i. We would like to put all of them in a trash bin at position 0.\n\nFor the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \\leq 10^{9}... | [{"input": "16 10\n1 12 12 27 52 132 731 18298 395504 534840 1276551 903860 9384806 19108104 82684732 535447408", "output": "3248775590\n"}, {"input": "16 10\n0 12 12 27 52 132 731 18298 395504 534840 1276551 903860 9384806 19108104 82684732 535447408", "output": "3248775585\n"}, {"input": "16 10\n0 12 12 27 52 132 731... | code_stdio |
[
{
"content": "The winner of the card game popular in Berland \"Berlogging\" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one.... | [{"input": "12\natrtthfpcvishmqbakprquvnejr 185\natrtthfpcvishmqbakprquvnejr -699\natrtthfpcvishmqbakprquvnejr -911\natrtthfpcvishmqbakprquvnejr -220\nfcgslzkicjrpbqaifgweyzreajjfdo 132\nfcgslzkicjrpbqaifgweyzreajjfdo -242\nm 177\nm -549\natrtthfpcvishmqbakprquvnejr -242\nm 38\natrtthfpcvishmqbakprquvnejr -761\nfcgslzk... | code_stdio |
[
{
"content": "Problem statement\n\n2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},β¦, a_ {Nβ1}.\n\nNow, 2D's refrigerator doesn't contain any ingredients, so I have to go to the supermarket to buy it. At the supermarket, you can buy the material a_ {i} for ... | [{"input": "2\npaks 0\naxii -1\n-1\nnkua hx`j", "output": "-1\n"}, {"input": "2\ntako -1\njiay -1\n0\npuja yakh", "output": "-2\n"}, {"input": "2\npaks -2\nayhi -1\n0\nmauk j`xh", "output": "-3\n"}, {"input": "2\npaks 1\naxii -1\n-3\nokua hx`j", "output": "0\n"}, {"input": "2\npaks 1\naxii -1\n-1\nokua hx`j", "output":... | code_stdio |
[
{
"content": "Your friend gave you a dequeue D as a birthday present.\nD is a horizontal cylinder that contains a row of N jewels.\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\nIn the beginning, you have no jewel in your hands.\nYou can perform a... | [{"input": "50 100\n-10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 ... | code_stdio |
[
{
"content": "A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.\n\nLet's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 β€ i β€ n) such that p_{i} = i.\n\nYour task is to count the number of almost identity p... | [{"input": "1000 4\n", "output": "373086956251\n"}, {"input": "1000 4\n", "output": "373086956251\n"}, {"input": "800 4\n", "output": "152620985001\n"}, {"input": "800 4\n", "output": "152620985001\n"}, {"input": "792 4\n", "output": "146597632567\n"}, {"input": "850 4\n", "output": "194577888126\n"}, {"input": "600 4\... | code_stdio |
[
{
"content": "problem\n\nYou are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n.\n\nYou ... | [{"input": "7 5\n2\n0\n1\n1\n2\n-1\n2\n-1\n2\n2\n-3", "output": "10\n"}, {"input": "7 0\n1\n-1\n1\n3\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"input": "7 0\n1\n-1\n1\n2\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"input": "7 5\n2\n0\n1\n-1\n2\n-1\n2\n-1\n1\n2\n-3", "output": "2\n"}, {"input": "7 5\n4\n0\n1\n0\n2\n... | code_stdio |
[
{
"content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a mask of a positive integer n the number that is obtained aft... | [{"input": "100000 77777\n", "output": "177777\n"}, {"input": "150234 77777\n", "output": "177777\n"}, {"input": "77777 77777\n", "output": "177777\n"}, {"input": "47774 47774\n", "output": "147774\n"}, {"input": "145251 7474\n", "output": "157474\n"}, {"input": "100832 7474\n", "output": "107474\n"}, {"input": "56081 ... | code_stdio |
[
{
"content": "You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\n* Let L be the length of X. L is divisible by both N and M.\n* Concatenating the 1-st, (\\f... | [{"input": "15 16\ndnausrayukusiia\ndujrunuma", "output": "240\n"}, {"input": "16 9\ndnsusrayukuaiia\ndujrunuma", "output": "144\n"}, {"input": "15 8\ndnausrayukusii`\ndujrunuma", "output": "120\n"}, {"input": "12 10\ndnsusrayukuaiia\nrujdunuma", "output": "-1\n"}, {"input": "12 10\ndnsussayukuaiia\nrujdunuma", "output... | code_stdio |
[
{
"content": "Kilani is playing a game with his friends. This game can be represented as a grid of size $n \\times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two castles in one cell).\n\nThe game is played in rounds. In each round players... | [{"input": "4 7 2\n13 1\n....###\n.#..1..\n.#.###.\n2#.....\n", "output": "18 1 \n"}, {"input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 1 \n"}, {"input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 1 \n"}, {"input": "4 7 2\n13 1\n....###\n.#..1..\n.#.###.\n2#.....\n", "... | code_stdio |
[
{
"content": "Our master carpenter is designing a condominium called Bange Hills Mansion. The condominium is constructed by stacking up floors of the same height. The height of each floor is designed so that the total height of the stacked floors coincides with the predetermined height of the condominium. The h... | [{"input": "000 12 208", "output": "197\n"}, {"input": "000 9 208", "output": "200\n"}, {"input": "000 4 120", "output": "117\n"}, {"input": "000 16 106", "output": "91\n"}, {"input": "000 26 106", "output": "81\n"}, {"input": "000 1 165", "output": "165\n"}, {"input": "000 1 120", "output": "120\n"}, {"input": "000 1 ... | code_stdio |
[
{
"content": "Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:\n\nVladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already lined up in some order, and for each of them ... | [{"input": "100\n931 4584 2116 3004 3813 62 2819 2998 2080 4906 3198 2443 2952 3793 1958 3864 3985 3169 3134 4011 4525 995 4163 308 4362 1148 4906 3092 1647 244 1370 1424 2753 84 2997 1197 2606 425 3501 2606 683 4747 3884 4787 2166 3017 3080 4303 3352 1667 2636 3994 757 2388 870 1788 988 1303 0 1230 1455 4213 2113 2908... | code_stdio |
[
{
"content": "The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles (a > 1). Note that the Beaver must use all t... | [{"input": "1000000000\n", "output": "1998535156\n"}, {"input": "999161856\n", "output": "1998319610\n"}, {"input": "999936000\n", "output": "1999743134\n"}, {"input": "999999948\n", "output": "1833697140\n"}, {"input": "999999000\n", "output": "1936337207\n"}, {"input": "999989760\n", "output": "1998828039\n"}, {"inpu... | code_stdio |
[
{
"content": "Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.\nThe capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.\nOne day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and ... | [{"input": "99 99 -22 62\n-9 -54 -13 -39 -79 -88 -6 -14 -41 -29 -2 -69 -30 -20 -33 -8 -24 -80 -19 -87 -32 -60 -40 -59 -44 -52 -3 -67 -18 -51 -56 -12 -7 -31 -48 -27 -68 -78 -21 -11 -49 -93 -1 -64 -82 -66 -70 -58 -84 -26 -57 -37 -53 -89 -50 -34 -61 -46 -92 -95 -99 -63 -65 -28 -10 -16 -73 -55 -98 -94 -77 -75 -62 -74 -42 -... | code_stdio |
[
{
"content": "There is a river of width $n$. The left bank of the river is cell $0$ and the right bank is cell $n + 1$ (more formally, the river can be represented as a sequence of $n + 2$ cells numbered from $0$ to $n + 1$). There are also $m$ wooden platforms on a river, the $i$-th platform has length $c_i$ (... | [{"input": "1000 232 105\n4 3 4 4 6 1 4 3 4 1 4 1 4 2 2 3 2 6 3 2 6 1 1 4 1 2 4 2 3 2 5 2 3 4 3 3 3 2 5 4 2 5 4 2 4 4 4 2 4 1 3 5 4 4 5 3 6 5 3 3 4 4 2 3 3 3 1 4 4 3 2 3 2 5 4 3 2 4 3 1 2 5 6 2 4 6 3 2 2 2 2 2 6 4 4 5 5 1 4 2 5 1 6 4 3 2 3 7 2 3 3 2 4 4 2 3 2 3 3 4 1 3 2 3 2 7 7 3 3 3 4 2 2 3 2 3 4 2 8 3 4 3 3 5 2 3 1 ... | code_stdio |
[
{
"content": "Berland State University invites people from all over the world as guest students. You can come to the capital of Berland and study with the best teachers in the country.\n\nBerland State University works every day of the week, but classes for guest students are held on the following schedule. You... | [{"input": "3\n4\n0 1 0 0 0 0 0\n100000000\n1 0 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n", "output": "22\n233333332\n1\n"}, {"input": "3\n4\n0 1 0 0 0 0 0\n100000000\n1 1 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n", "output": "22\n174999998\n1\n"}, {"input": "3\n4\n0 1 0 0 0 0 0\n100010000\n1 1 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n", "output": "22\n1... | code_stdio |
[
{
"content": "Let's call an array $a$ consisting of $n$ positive (greater than $0$) integers beautiful if the following condition is held for every $i$ from $1$ to $n$: either $a_i = 1$, or at least one of the numbers $a_i - 1$ and $a_i - 2$ exists in the array as well.\n\nFor example:\n\nthe array $[5, 3, 1]$ ... | [{"input": "4\n1\n12\n13\n35\n", "output": "1\n4\n4\n6\n"}, {"input": "4\n1\n12\n11\n14\n", "output": "1\n4\n4\n4\n"}, {"input": "4\n1\n12\n22\n35\n", "output": "1\n4\n5\n6\n"}, {"input": "4\n2\n12\n11\n14\n", "output": "2\n4\n4\n4\n"}, {"input": "4\n2\n5\n13\n87\n", "output": "2\n3\n4\n10\n"}, {"input": "4\n1\n12\n7\n... | code_stdio |
[
{
"content": "Alice guesses the strings that Bob made for her.\n\nAt first, Bob came up with the secret string $a$ consisting of lowercase English letters. The string $a$ has a length of $2$ or more characters. Then, from string $a$ he builds a new string $b$ and offers Alice the string $b$ so that she can gues... | [{"input": "11\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\n", "output": "abac\nabac\nabac\nabac\nabac\nabac\nabac\nabac\nac\nbcdaf\nzzzzzz\n"}, {"input": "10\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nbccddaaf\nzzzzzzzzzz\n", "output": "abac\nac\n... | code_stdio |
[
{
"content": "Nicholas has an array a that contains n distinct integers from 1 to n. In other words, Nicholas has a permutation of size n.\n\nNicholas want the minimum element (integer 1) and the maximum element (integer n) to be as far as possible from each other. He wants to perform exactly one swap in order ... | [{"input": "100\n76 70 67 54 40 1 48 63 64 36 42 90 99 27 47 17 93 7 13 84 16 57 74 5 83 61 19 56 52 92 38 91 82 79 34 66 71 28 37 98 35 94 77 53 73 10 26 80 15 32 8 81 3 95 44 46 72 6 33 11 21 85 4 30 24 51 49 96 87 55 14 31 12 60 45 9 29 22 58 18 88 2 50 59 20 86 23 41 100 39 62 68 69 97 78 43 25 89 65 75\n", "output... | code_stdio |
[
{
"content": "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... | [{"input": "2000 2000\n", "output": "585712681"}, {"input": "1544 1794\n", "output": "933285446"}, {"input": "1639 1056\n", "output": "467464129"}, {"input": "2000 1000\n", "output": "228299266"}, {"input": "1903 1612\n", "output": "620810276"}, {"input": "1707 1117\n", "output": "237674323"}, {"input": "1722 1474\n", ... | code_stdio |
[
{
"content": "Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it.\n\nUnfortunately, it is not possible to make such a decision for any program in the programming lang... | [{"input": "6\n10 SET d 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n124 HALT", "output": "c=0\nd=1\nh=5\ni=0\ns=0\n"}, {"input": "6\n10 SET c 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n209 IF j 100\n200 HALT", "output": "c=1\nh=5\ni=0\nj=0\ns=0\n"}, {"input": "6\n10 SET c 1\n20 SET h 7\n100 ADD s s j\n... | code_stdio |
[
{
"content": "Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. $2 \\cdot n$ students have come to Demid's exercise session, and he lined up them into two rows of the same size (there are exactly $n$ people in each row). Students are numbered from $1... | [{"input": "100\n4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1\n1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 ... | code_stdio |
[
{
"content": "There is a rectangular grid of n rows of m initially-white cells each.\n\nArkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows R_{i} and a non-empty subset of columns C_{i} are chosen. For each row r in R_{i} and each column c in ... | [{"input": "50 8\n.....#..\n........\n........\n.....#..\n.....#..\n........\n........\n........\n........\n...#....\n...#....\n........\n...#....\n#.#.#...\n...#....\n...#....\n........\n...#....\n...#....\n...#....\n........\n#.#.#...\n.....#..\n........\n#.#.#...\n#.#.#...\n#.#.#...\n...#....\n........\n........\n..... | code_stdio |
[
{
"content": "Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\n* Go one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nCon... | [{"input": "1329", "output": "120\n"}, {"input": "1162", "output": "180\n"}, {"input": "1369", "output": "360\n"}, {"input": "1527", "output": "120\n"}, {"input": "1874", "output": "180\n"}, {"input": "2383", "output": "360\n"}, {"input": "2579", "output": "360\n"}, {"input": "643", "output": "360\n"}, {"input": "1780"... | code_stdio |
[
{
"content": "Number of tanka\n\nWishing to die in the spring under the flowers\n\nThis is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and thirty-one sounds of 5, 7, 5, 7, and 7.\n\nBy... | [{"input": "1\n1\n3\n1531\n2317\n714\n225725068861419081\n0", "output": "10\n10\n13\n55955\n155155\n7277\n3223333233333322222322232232233222323233333233223332\n"}, {"input": "1\n1\n4\n1531\n2317\n714\n225725068861419081\n0", "output": "10\n10\n14\n55955\n155155\n7277\n322333323333332222232223223223322232323333323322333... | code_stdio |
[
{
"content": "Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair of settlements and is bidirectional. Moreove... | [{"input": "50 2 5\n9 14\n46 34\n40 35\n44 30\n32 16\n1 38\n48 2\n17 14\n50 25\n6 1\n45 19\n21 15\n22 11\n15 33\n8 28\n2 32\n10 22\n37 3\n43 39\n25 16\n9 19\n16 3\n28 32\n20 45\n24 32\n4 18\n49 39\n13 45\n26 4\n11 33\n14 37\n42 19\n31 45\n38 3\n34 8\n18 29\n35 34\n29 16\n7 46\n19 28\n27 33\n30 9\n33 16\n36 45\n47 1\n41... | code_stdio |
[
{
"content": "Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from $1$, starting from the topmost one. The columns are numbered from $1$, starting from the leftmost one.\n\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers fr... | [{"input": "100\n1\n2\n2\n3\n4\n5\n6\n13\n15\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n35\n20\n21\n22\n23\n24\n25\n26\n27\n28\n23\n30\n31\n32\n33\n34\n35\n36\n19\n38\n60\n40\n41\n42\n43\n44\n119\n46\n47\n77\n49\n44\n51\n45\n53\n54\n55\n56\n57\n58\n87\n60\n61\n42\n63\n64\n65\n66\n67\n68\n69\n70\n124\n72\n73\n74\n75\n76\n2... | code_stdio |
[
{
"content": "The Little Elephant loves chess very much. \n\nOne day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8 Γ 8 checkered board, each square is painted either black or white. The Little Elephant and his friend know that... | [{"input": "WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\n", "output": "YES\n"}, {"input": "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\n", "output": "YES\n"}, {"input": "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\n... | code_stdio |
[
{
"content": "The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every c... | [{"input": "8\n", "output": "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+... | code_stdio |
[
{
"content": "Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance... | [{"input": "50\n67 1\n89 2\n83 1\n-26 1\n88 2\n-22 2\n-98 2\n-83 1\n58 2\n26 2\n-37 1\n-51 2\n29 1\n47 2\n-70 1\n81 2\n36 1\n52 2\n93 2\n-12 2\n-12 1\n5 2\n91 1\n3 1\n-27 1\n18 1\n-60 1\n-15 1\n17 1\n-33 1\n-74 2\n5 2\n-62 2\n72 1\n-22 1\n-58 1\n-9 1\n57 1\n-18 2\n-11 1\n-103 2\n74 2\n-20 2\n21 1\n-19 2\n-77 1\n50 2\n9... | code_stdio |
[
{
"content": "Reca company makes monitors, the most popular of their models is AB999 with the screen size a Γ b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce mo... | [{"input": "2000000000 2000000000 1999999998 1999999999\n", "output": "1999999998 1999999999"}, {"input": "2000000000 2000000000 1999999999 1999999998\n", "output": "1999999999 1999999998"}, {"input": "1688112099 1875662241 198852947 116042960\n", "output": "1590823576 928343680\n"}, {"input": "1143276347 1875662241 17... | code_stdio |
[
{
"content": "Recall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the ar... | [{"input": "250000 993244853\n", "output": "872048421\n"}, {"input": "244435 994838543\n", "output": "634651929\n"}, {"input": "234324 994631069\n", "output": "720229385\n"}, {"input": "249996 997202249\n", "output": "633673455\n"}, {"input": "249998 990040613\n", "output": "108188702\n"}, {"input": "249999 992509109\n... | code_stdio |
[
{
"content": "The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen.\n\nAfter the fighting stopped, Heidi gave them another task to waste their time on.\n\nThere are $n$ points on a plane. Given a radius $r$, f... | [{"input": "5 0\n2 1\n-2 -1\n-1 1\n-2 -2\n2 2\n", "output": "1\n"}, {"input": "5 1\n1 1\n-1 -1\n-1 1\n-2 -2\n2 0\n", "output": "2\n"}, {"input": "5 1\n2 1\n-1 -1\n-1 1\n-2 -2\n2 0\n", "output": "2\n"}, {"input": "5 1\n2 1\n-1 -1\n-1 1\n-2 -2\n2 1\n", "output": "2\n"}, {"input": "5 1\n2 1\n-2 -1\n-1 1\n-2 -2\n2 1\n", "o... | code_stdio |
[
{
"content": "Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in <image>, which Sasha coped with. For Sasha not to think that he had learned all, Stas gave him a new task. For each segment of the fixed le... | [{"input": "10 3\n-20\n-63\n-64\n45\n-84\n-13\n79\n-31\n70\n-100\n", "output": "-20\n45\n45\n45\n79\n79\n79\n70\n"}, {"input": "10 3\n-20\n-52\n-64\n45\n-139\n-13\n79\n-31\n89\n-100\n", "output": "-20\n45\n45\n45\n79\n79\n89\n89"}, {"input": "10 3\n-20\n-35\n-64\n45\n-139\n-20\n24\n-31\n89\n-100\n", "output": "-20\n45\... | code_stdio |
[
{
"content": "Division of Big Integers\n\nGiven two integers $A$ and $B$, compute the quotient, $\\frac{A}{B}$. Round down to the nearest decimal.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the quotient in a line.\n\nConstraints\n\n* $-1 \\times 1... | [{"input": "12 -1", "output": "-12\n"}, {"input": "10 -1", "output": "-10\n"}, {"input": "20 -1", "output": "-20\n"}, {"input": "11 -1", "output": "-11\n"}, {"input": "15 -1", "output": "-15\n"}, {"input": "16 -1", "output": "-16\n"}, {"input": "14 -1", "output": "-14\n"}, {"input": "23 -1", "output": "-23\n"}, {"input... | code_stdio |
[
{
"content": "Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights wi kilograms.\n\nVasya needs to collect all these items, however he won't... | [{"input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"input": "2 110 100 10000 10000\n100 100\n", "output": "21000\n"}, {"input": "2 110 100 10000 11101\n100 000\n", "output": "11000\n"}, {"input": "2 110 100 00000 11101\n110 000\n", "output": "12100\n"}, {"input": "2 110 100 10000 11000\n100 100\n", "... | code_stdio |
[
{
"content": "Rng is going to a festival.\n\nThe name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: \"Rng is going to a festival of what?\" Output the answer.\n\nHere, assume that the name of \"a festival of s\" is a string obtained by appending `FES... | [{"input": "CODEFESTIVALFERTIVAL", "output": "CODEFESTIVAL\n"}, {"input": "CODEFESTIWALFESTIWAL", "output": "CODEFESTIWAL\n"}, {"input": "LAWITSEFLAWITSEFEDOC", "output": "LAWITSEFLAWI\n"}, {"input": "CODEFWSTIWALFESTIEAL", "output": "CODEFWSTIWAL\n"}, {"input": "COCEFWSTIWALFESTIEAL", "output": "COCEFWSTIWAL\n"}, {"in... | code_stdio |
[
{
"content": "problem\n\nI want to put as many rectangular tiles as possible on a rectangular wall with a size of $ h $ in height and $ w $ in width, and a size of $ a $ in height and $ b $ in width.\n\nThe following conditions must be met when attaching tiles.\n\n\n* Do not stack tiles.\n* Do not apply tiles d... | [{"input": "87 15\n12 66", "output": "1305\n"}, {"input": "87 29\n12 66", "output": "2523\n"}, {"input": "27 27\n16 16", "output": "473\n"}, {"input": "27 32\n16 16", "output": "352\n"}, {"input": "-1 18\n10 49", "output": "-18\n"}, {"input": "27 32\n20 16", "output": "224\n"}, {"input": "27 18\n20 16", "output": "166\... | code_stdio |
[
{
"content": "You are given three integers $a$, $b$, and $c$. Determine if one of them is the sum of the other two.\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\leq t \\leq 9261$) β the number of test cases.\n\nThe description of each test case consists of three integers $a$, $b$, ... | [{"input": "47\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1... | code_stdio |
[
{
"content": "As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.\n\nElections are coming. You know the number of voters and the number of parties β n and m res... | [{"input": "10 10\n7 29\n10 31\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"input": "10 10\n5 81\n7 68\n7 48\n1 10\n5 37\n7 97\n8 54\n7 41\n7 56\n5 21\n", "output": "110\n"}, {"input": "10 10\n7 29\n10 54\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"input": "10 10... | code_stdio |
[
{
"content": "You are given a rectangular board of M Γ N squares. Also you are given an unlimited number of standard domino pieces of 2 Γ 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:\n\n1. Each domino co... | [{"input": "14 16\n", "output": "112\n"}, {"input": "15 16\n", "output": "120\n"}, {"input": "16 16\n", "output": "128\n"}, {"input": "14 15\n", "output": "105\n"}, {"input": "15 15\n", "output": "112\n"}, {"input": "11 13\n", "output": "71\n"}, {"input": "14 14\n", "output": "98\n"}, {"input": "10 16\n", "output": "80... | code_stdio |
[
{
"content": "Ringo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of juice remaining in stock every night. If there are C... | [{"input": "24\n2 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1", "output": "Yes\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo... | code_stdio |
[
{
"content": "Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.\n\nMunhattan consists of n streets and m avenues. There is exactly one restaurant on the intersection of each street a... | [{"input": "10 10\n256 72 455 45 912 506 235 68 951 92\n246 305 45 212 788 621 449 876 459 899\n732 107 230 357 370 610 997 669 61 192\n131 93 481 527 983 920 825 540 435 54\n777 682 984 20 337 480 264 137 249 502\n51 467 479 228 923 752 714 436 199 973\n3 91 612 571 631 212 751 84 886 948\n252 130 583 23 194 985 234 9... | code_stdio |
[
{
"content": "Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tige... | [{"input": "178\nTTTTTTHTHHHTHHTHHHHTTTHTHTTHTHHHTHTTTTHHTTHHHTTHHTTHHTTHHHHHTHHTTHTHHTTHHTTTTTTTTTHTHTTHTHHTHHHHHHTTTHTHHHHTHHTTHHHHTTTTTTTTHHHTHHHTHTHHHTTTTTHTHTTTHTHHTTHTTTHHHHHTTHTTHTTTHTHHHT\n", "output": "40\n"}, {"input": "178\nTTTTTTHTHHHTHHTHHHHTTTHTHTTHTHHHTHTTTTHHTTHHHTTHHTTHHTTHHTHHTHHTTHTHHTTHHTTTTTTTTTHTH... | code_stdio |
[
{
"content": "A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt.\n\nCreate a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the... | [{"input": "6\n1 14\n2 17\n3 131\n4 11\n4 61\n6 66", "output": "3 131\n"}, {"input": "6\n1 14\n2 25\n3 126\n4 11\n4 40\n6 66", "output": "3 126\n"}, {"input": "6\n1 14\n2 17\n3 169\n4 11\n4 61\n6 66", "output": "3 169\n"}, {"input": "6\n1 12\n4 25\n3 72\n0 11\n2 101\n6 29", "output": "2 101\n"}, {"input": "6\n1 12\n4 2... | code_stdio |
[
{
"content": "We have a string S of length N consisting of A, T, C, and G.\nStrings T_1 and T_2 of the same length are said to be complementary when, for every i (1 \\leq i \\leq l), the i-th character of T_1 and the i-th character of T_2 are complementary. Here, A and T are complementary to each other, and so ... | [{"input": "5000 GCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCG... | code_stdio |
[
{
"content": "You have a garden consisting entirely of grass and weeds. Your garden is described by an n Γ m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c. Each cell m... | [{"input": "3 150\nGGGWGGGGWWGGGGGGGGGGGGGWGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGWGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGW\nGGGGGGGGGGGGWGGGGGGGGGWGGGGGGGGGGGGWGGGGGWGGGGGGGWGGGGGGGWGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGWGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGWGG... | code_stdio |
[
{
"content": "Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function ... | [{"input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -121 -34 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 30 96 79 -25 49 -59 -89 -75 14 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 24 70 36 -38 8 92 -63 -5 ... | code_stdio |
[
{
"content": "Your task is to calculate the distance between two $n$ dimensional vectors $x = \\\\{x_1, x_2, ..., x_n\\\\}$ and $y = \\\\{y_1, y_2, ..., y_n\\\\}$.\n\nThe Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance.\n\\\\[ D_... | [{"input": "3\n109 25 10\n-1 -3 -3", "output": "151.000000\n114.249726\n110.661278\n110.000000\n"}, {"input": "3\n109 25 10\n0 -3 -3", "output": "150.000000\n113.287246\n109.673356\n109.000000\n"}, {"input": "3\n109 25 10\n-1 -3 0", "output": "148.000000\n113.947356\n110.628687\n110.000000\n"}, {"input": "3\n198 141 20... | code_stdio |
[
{
"content": "Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price.\n\nAt every moment of time, every SELL offer has higher price than ... | [{"input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944938\nACCEPT 40032655\nADD 79373162\nACCEPT 79373162\nADD 55424250\nACCEPT 55424250\nADD 67468892\nACCEPT 67468892\nADD 51815959\nADD 13976252\nADD 2040654\nADD 74300637\nACCEPT 51815959\n", "output": "32\n"}, {"input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944... | code_stdio |
[
{
"content": "Alice and Bob are playing a game of coins. N coins are placed on the table in a row. \n\nThe game begins with Alice and afterwards they alternate the moves.\n\nA valid move is defined as follows:\n\nYou pick one coin or two adjacent coins and remove them.\n\nThe game is over if anyone is not able ... | [{"input": "100\n90287615\n75096686\n621537351\n337906787\n932379178\n576368174\n614524887\n381393352\n683734903\n357312092\n45953951\n11885544\n659581459\n649281842\n360919237\n468202152\n348705142\n433071763\n766393082\n957639054\n492279795\n441607546\n238769590\n287864255\n240825138\n413652652\n556513880\n942947637\... | code_stdio |
[
{
"content": "The cat Snuke wants to play a popular Japanese game called Γ
tCoder, so Iroha has decided to teach him Japanese.\nWhen counting pencils in Japanese, the counter word \"ζ¬\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"ζ¬\" in ... | [{"input": "183\n", "output": "bon\n"}, {"input": "999\n", "output": "hon\n"}, {"input": "440\n", "output": "pon\n"}, {"input": "438\n", "output": "pon\n"}, {"input": "575\n", "output": "hon\n"}, {"input": "16\n", "output": "pon\n"}, {"input": "73\n", "output": "bon\n"}, {"input": "24\n", "output": "hon\n"}, {"input": ... | code_stdio |
[
{
"content": "There are 3^N people dancing in circle. We denote with 0,1,\\dots, 3^{N}-1 the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.\n\nThe people are going to dance on two kinds of songs: salsa and... | [{"input": "3\nRRRRSRRRSRRSRS", "output": "23 9 4 8 3 16 20 24 1 5 18 13 17 12 25 2 6 10 14 0 22 26 21 7 11 15 19 "}, {"input": "3\nRSRRSRRRSRRSRR", "output": "17 12 7 11 24 19 5 9 4 26 21 16 20 6 1 14 18 13 8 3 25 2 15 10 23 0 22 "}, {"input": "3\nRRRRSRRRRRRSRS", "output": "13 0 11 10 15 26 25 21 5 4 18 2 1 6 17 16 1... | code_stdio |
[
{
"content": "You are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \\le a_2 \\le a_3 \\le \\dots \\le a_n$ holds).\n\nTo make the sequence sorted, you may perform the follo... | [{"input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "\n3\n0\n0\n-1\n1\n3\n"}, {"input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "3\n0\n0\n-1\n1\n3\n"}, {"input": "6\n4 1\n2 3 5 4\n5 6\n1 ... | code_stdio |
[
{
"content": "[Image] \n\nIt's the end of JulyΒ β the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the informatio... | [{"input": "433 3\nFZDDHMJGBZCHFUXBBPIEBBEFDWOMXXEPOMDGSMPIUZOMRZQNSJAVNATGIWPDFISKFQXJNVFXPHOZDAEZFDAHDXXQKZMGNSGKQNWGNGJGJZVVITKNFLVCPMZSDMCHBTVAWYVZLIXXIADXNYILEYNIQHKMOGMVOCWGHCWIYMPEPADSJAAKEGTUSEDWAHMNYJDIHBKHVUHLYGNGZDBULRXLSAJHPCMNWCEAAPYMHDTYWPADOTJTXTXUKLCHWKUSZRHEKQEFPVJEJJHRWCKYOIWALRTIBUMNOCRXLSIKQCJVQXEPG... | code_stdio |
[
{
"content": "To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that this operation is not repeated, that is, the... | [{"input": "5 10 15\nDdunkjly\n13 12 4\n83 26 1\n63 42 3\n83 22 2\n57 33 0\n59 10 1\n89 31 1\n57 17 2\n98 79 5\n46 41 3\nFbpbc\n28 21 0\n93 66 5\n66 21 0\n68 58 0\n59 17 3\n57 23 1\n72 71 1\n55 51 2\n58 40 5\n70 67 2\nKeiotmh\n73 44 4\n98 14 0\n19 7 0\n55 10 5\n30 25 4\n66 48 2\n66 51 4\n82 79 3\n73 63 4\n87 46 5\nNksd... | code_stdio |
[
{
"content": "You are given a table consisting of n rows and m columns.\n\nNumbers in each row form a permutation of integers from 1 to m.\n\nYou are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are allowed to pick two columns and swap th... | [{"input": "20 8\n4 3 2 1 5 6 7 8\n1 2 3 4 8 7 6 5\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7... | code_stdio |
[
{
"content": "You have an array $a_1, a_2, \\dots, a_n$. \n\nLet's call some subarray $a_l, a_{l + 1}, \\dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [2, 2, 1, 3, 2, 3, 1]$ contains $6$ subarrays which are subpermutations: $[a_2... | [{"input": "99\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99\n", "output": "9... | code_stdio |
[
{
"content": "Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train route... | [{"input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 3 948187054\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output": "6\n"}, {"input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 2 999999999\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output":... | code_stdio |
[
{
"content": "In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to city b, or from city b to city a. The road network ... | [{"input": "10 11\n1 3\n2 3\n3 8\n4 5\n4 6\n3 7\n3 8\n4 9\n4 10\n7 9\n8 10\n1 5 3\n6 2 3\n", "output": "-1\n"}, {"input": "10 11\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7\n3 8\n4 9\n4 10\n7 9\n8 10\n1 5 3\n6 2 3\n", "output": "6\n"}, {"input": "9 9\n1 2\n2 3\n2 4\n4 5\n5 7\n5 6\n4 8\n8 9\n9 6\n1 7 4\n3 6 3\n", "output": "-1\n"}, {... | code_stdio |
[
{
"content": "Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.\n\nConstraints\n\n* $ 1 \\leq N \\leq 100000 $\n* $ 0 \\leq x1_i < x2_i \\leq 1000 $\n* $ 0 \\leq y1_i < y2_i \\leq 1000 $\n* $ x1_i, y1_i, x2_i, y... | [{"input": "3\n0 0 1 2\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 2 4\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 1 2\n0 0 2 3\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 1 2 4\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 1 2\n0 0 2 6\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 0... | code_stdio |
[
{
"content": "The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. [Image] \n\nThe event coordinator has a list of k participants who should be p... | [{"input": "001\n", "output": "+------------------------+\n|O.#.#.#.#.#.#.#.#.#.#.|D|)\n|#.#.#.#.#.#.#.#.#.#.#.|.|\n|#.......................|\n|#.#.#.#.#.#.#.#.#.#.#.|.|)\n+------------------------+\n"}, {"input": "011\n", "output": "+------------------------+\n|O.O.O.O.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n... | code_stdio |
[
{
"content": "Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The $k$-th layer of the triangle contains $k$ points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers $(... | [{"input": "4\n3\n1 10 2\n1 3 1\n2\n4 7\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 8\n2 4 2 4\n", "output": "3\n2\n999999999\n7\n"}, {"input": "4\n3\n1 10 2\n1 3 1\n2\n3 2\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 9\n2 4 2 4\n", "output": "3\n1\n999999999\n7\n"}, {"input": "4\n3\n1 10 2\n1 3 1\n2\n5 7\n2 2\n2\... | code_stdio |
[
{
"content": "Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-c... | [{"input": "314159265 7\n35438742\n77271666\n139044510\n156626166\n160332356\n331169608\n453863319", "output": "1023255587\n"}, {"input": "314159265 7\n35438742\n77271666\n122238627\n156626166\n160332356\n331169608\n453863319", "output": "1040061470\n"}, {"input": "314159265 7\n21662711\n77271666\n89022761\n156626166\n... | code_stdio |
[
{
"content": "Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one.\n\nVasya drew several distinct points with integer coordinates on ... | [{"input": "5\n1 0\n1 -1\n0 -1\n-1 0\n-1 -1\n", "output": "1\n"}, {"input": "1\n-751115 -16747294\n", "output": "0\n"}, {"input": "1\n-751115 -11499666\n", "output": "0\n"}, {"input": "1\n-751115 -14990265\n", "output": "0\n"}, {"input": "1\n-867280 -14990265\n", "output": "0\n"}, {"input": "1\n-867280 -20447796\n", "o... | code_stdio |
[
{
"content": "You are given a string $s$. You have to reverse it β that is, the first letter should become equal to the last letter before the reversal, the second letter should become equal to the second-to-last letter before the reversal β and so on. For example, if your goal is to reverse the string \"abddea... | [{"input": "500\npqmpmpqmppqqmmmqppqmpqqmmmppmmqmqmqpqmmpmmpmqpmqpppmppmqqmmmpmqqqppqpmpqpmppppqqqqpmppqppqpqmpmpmqqmmpmqmmpqqmqpmqpmpmqpmpmmqppmqmpqmmmmmmpmmqmmqmmqqmmqqpmppqmppmpppmmmmppmmpqqqqmppqqqqqmpqpmpqmmpqmqpqpmmqqqqpmqqqppmmppmppppppmmpmqpmqmpmqmmpqqmqqmpqppqpmqqmpqqmpmmmpqmqmqmpqmpppqqmqmpmqmmpqmpqqmmqqpqpqm... | code_stdio |
[
{
"content": "Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. \n\nIn total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from ... | [{"input": "70\n11 54 37 62 1 46 13 17 38 47 28 29 63 5 61 34 49 66 32 59 3 41 58 28 23 62 41 64 20 5 14 41 10 37 51 32 65 46 61 8 15 19 16 44 31 42 19 46 66 25 26 58 60 5 19 18 69 53 20 40 45 27 24 41 32 23 57 56 62 10\n", "output": "62 18 35 7 70 23 61 57 34 22 43 42 6 66 10 37 21 2 38 13 69 29 14 43 49 7 29 5 51 66 ... | code_stdio |
[
{
"content": "In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i, respectively.\n\nRingo is hosting a game of stacking zabuton (cushions).\n\nThe participants will line up in a row in some order, and they will in turn try to add zabuton to ... | [{"input": "10\n1 3\n8 4\n8 3\n10 1\n12 4\n2 3\n4 2\n9 2\n8 3\n0 1", "output": "6\n"}, {"input": "10\n1 3\n0 4\n15 3\n10 1\n8 4\n2 3\n4 2\n9 1\n8 3\n0 1", "output": "7\n"}, {"input": "10\n2 3\n0 4\n15 3\n10 1\n8 4\n2 1\n4 2\n9 1\n8 0\n0 1", "output": "8\n"}, {"input": "10\n2 3\n0 0\n15 3\n10 1\n8 4\n2 1\n4 2\n9 1\n8 0\... | code_stdio |
[
{
"content": "Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be consid... | [{"input": "-2 2 -3 -1 461 1\n3 0 4 0 13 -1", "output": "No\n"}, {"input": "-1 2 -3 -1 461 1\n3 0 4 0 13 -1", "output": "No\n"}, {"input": "-1 2 -3 -1 461 1\n3 0 6 0 13 -1", "output": "No\n"}, {"input": "-1 2 -3 -1 461 2\n3 0 6 0 13 -1", "output": "No\n"}, {"input": "0 1 0 -1 197 -1\n10 0 1 1 16 4", "output": "No\n"}, ... | code_stdio |
[
{
"content": "Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.\n\nSummer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have to read some amount of books before all entertainme... | [{"input": "27 5 1\n232 0 1\n72 0 1\n235 0 1\n2 0 1\n158 0 -1\n267 0 0\n242 1 1\n1 0 0\n64 0 0\n139 1 1\n250 0 1\n208 0 1\n127 0 1\n29 0 0\n53 0 1\n100 0 1\n52 0 1\n229 0 0\n1 0 1\n29 0 0\n17 0 1\n74 0 1\n211 0 1\n248 0 1\n15 0 0\n252 0 0\n159 0 1\n", "output": "-1\n"}, {"input": "27 5 1\n232 0 1\n72 0 1\n235 0 1\n2 0 ... | code_stdio |
[
{
"content": "Polycarp has a checkered sheet of paper of size n Γ m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's \"Black Square\", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.\n\nYou are to deter... | [{"input": "20 10\nWWBWWWBBWW\nWWWWWBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWBBBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWBWWWWWBWW\nWBWWBWWWBW\nWWBWBWWWWW\nWWWBWWBBWW\nWWBBWBWBWW\nBBWWWWWBWW\nWWBWWBBBWW\nWWWBWBBWWW\nWWWBBWBWWW\nWWWWWWWWWW\nWWWBWWWWWW\nWWWWWWWWWW\n", "output": "-1\n"}, {"input": "20 10\nWWWWWWWWWW\nWWWWWWWWW... | code_stdio |
[
{
"content": "Amr bought a new video game \"Guess Your Way Out!\". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node. \n\nLet's index all the le... | [{"input": "50 1125899906842624\n", "output": "2251799813685246\n"}, {"input": "50 1125899906842624\n", "output": "2251799813685246"}, {"input": "50 905353992267944\n", "output": "1871650493613618\n"}, {"input": "50 844424930131968\n", "output": "1407374883553280\n"}, {"input": "50 865276010242491\n", "output": "190973... | code_stdio |
[
{
"content": "You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.\n\nThe boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$. You may play some of... | [{"input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 100\n1 1\n1 1\n", "output": "211\n"}, {"input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 100\n1 1\n1 1\n", "output": "211\n"}, {"input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1... | code_stdio |
[
{
"content": "Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.\n\nCodesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneo... | [{"input": "1122 54\n2 1031\n1 363 364\n1 14 15\n1 902 903\n1 1052 1053\n2 170\n2 36\n2 194\n1 340 341\n1 1018 1019\n1 670 671\n1 558 559\n2 431\n2 351\n2 201\n1 1104 1105\n2 1056\n2 823\n1 274 275\n2 980\n1 542 543\n1 807 808\n2 157\n2 895\n1 505 506\n2 658\n1 484 485\n1 533 534\n1 384 385\n2 779\n2 888\n1 137 138\n1 ... | code_stdio |
[
{
"content": "This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.\n\nAfter struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.\n\... | [{"input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza\nzz\n3\nabc\nbca\n16\naajjhdsjfdsfkadf\naajjhjsjfdsfkajf\n2\nix\nii\n2\noo\nqo\n2\npp\npa\n", "output": "Yes\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\n"}, {"input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza... | code_stdio |
[
{
"content": "You are given a permutation $p_1, p_2, \\ldots, p_n$ of integers from $1$ to $n$ and an integer $k$, such that $1 \\leq k \\leq n$. A permutation means that every number from $1$ to $n$ is contained in $p$ exactly once.\n\nLet's consider all partitions of this permutation into $k$ disjoint segment... | [{"input": "100 77\n59 92 18 16 45 82 63 43 50 68 19 13 53 79 48 28 94 49 25 77 54 8 61 66 40 100 99 20 35 14 52 56 22 17 57 36 23 90 4 65 84 42 30 27 3 15 87 32 93 74 46 91 41 9 34 12 11 7 10 86 78 72 81 73 51 55 58 97 39 31 5 24 29 88 95 6 44 37 60 62 83 33 47 21 2 38 26 98 71 75 96 70 76 69 64 89 67 1 80 85\n", "out... | code_stdio |
[
{
"content": "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.\n\nThe teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to co... | [{"input": "50\n384672 661179 -775591 -989608 611120 442691 601796 502406 384323 -315945 -934146 873993 -156910 -94123 -930137 208544 816236 466922 473696 463604 794454 -872433 -149791 -858684 -467655 -555239 623978 -217138 -408658 493342 -733576 -350871 711210 884148 -426172 519986 -356885 527171 661680 977247 141654 ... | code_stdio |
[
{
"content": "Natasha's favourite numbers are $n$ and $1$, and Sasha's favourite numbers are $m$ and $-1$. One day Natasha and Sasha met and wrote down every possible array of length $n+m$ such that some $n$ of its elements are equal to $1$ and another $m$ elements are equal to $-1$. For each such array they co... | [{"input": "2000 2000\n", "output": "674532367\n"}, {"input": "1134 1092\n", "output": "134680101\n"}, {"input": "1087 1050\n", "output": "973930225\n"}, {"input": "1994 1981\n", "output": "596939902\n"}, {"input": "1891 1294\n", "output": "696966158\n"}, {"input": "1132 1727\n", "output": "878164775\n"}, {"input": "10... | code_stdio |
[
{
"content": "Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction. \n\nFrom the window in your room, you see the sequence of n hills, where i-th of them has height a_{i}. The Innopolis administration wants to build some houses on the hills. However,... | [{"input": "100\n1777 339 1249 1644 785 810 228 549 1892 464 1067 639 65 1653 981 1858 863 1980 1174 427 1710 345 309 826 31 1898 255 661 1836 443 802 195 177 752 979 1842 1689 399 568 1906 129 1571 1263 696 911 810 1877 1932 1389 1128 112 619 184 434 22 1269 386 324 1635 1440 705 300 455 1635 1069 1660 1174 572 1237 4... | code_stdio |
[
{
"content": "We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, \"aabba\" is good, because after the merging step it will become \"aba\".\n\nGiven a string, you have to find two values: the number of good substrings of even length; t... | [{"input": "bbabaaabaaaabaabbababbbabababaabaaaaabbaabbbbbaababaabbbaabaabaaaababaabaabbabaaabaabbbabbaaaaaaabaabababaaabaaabbbabbabbaabaaabaabbbbbabbababbbbbbbababbababbbabbbbbababaaaababaabbabaaabbaaabaabbbbabbaaababbbbbbaaabbaaabbaaabaaaaaababaabababaabaaabaaaabaabbabbabbbbabbaaabaabbaababaaabbbbbaabbbbabbbabaabaaab... | code_stdio |
[
{
"content": "Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.\n\nA molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number β the number of bonds the atom must form with other ato... | [{"input": "1000000 1000000 1000000\n", "output": "500000 500000 500000\n"}, {"input": "1000000 1000000 1000000\n", "output": "500000 500000 500000\n"}, {"input": "688348 726472 442198\n", "output": "486311 240161 202037\n"}, {"input": "602752 645534 784262\n", "output": "232012 413522 370740\n"}, {"input": "602752 645... | code_stdio |
[
{
"content": "A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycleΒ β a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The center of each island contains an identical pedes... | [{"input": "12\n0 1 2 3 4 5 6 7 8 9 10 11\n1 2 9 8 6 4 5 10 3 7 0 11\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7\n3 8\n8 9\n9 10\n2 11\n11 12\n", "output": "NO\n"}, {"input": "12\n0 1 2 3 4 5 6 7 8 9 10 11\n1 2 9 8 6 4 5 10 3 7 0 11\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7\n3 8\n8 9\n9 10\n8 11\n11 12\n", "output": "NO"}, {"input": "10\n2 7 4 ... | code_stdio |
[
{
"content": "One day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of \"x y\" are there, such that x is a substring of string s, y is a subsequence of string t, and the con... | [{"input": "pfdempfohomnpgbeegikfmflnalbbajpnpgeacaicoehopgnabnklheepnlnflohjegcciflmfjhachnhekckfjgoffhkblncidn\nidlhklpclcghngeggpjdgefccihndpoikojdjnbkdfjgaanoolfmnifnmbpeeghpicehjdiipnlfnjpglidpnnnjfmjfhbcogojkcfflmmfcgajbjbfaikhmjofbnjnaolbcdkelcieeodbfjcfiblhhmeelmpcmmcdhjcnnfklgedjjbaljndjonanlojclboeelkab\n", "... | code_stdio |
[
{
"content": "Michael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\\le i\\le n$) row and $j$-th ($1\\le j\\le m$) column by $(i, j)$ and the number there by $a_{ij}$.\n\nMichael starts by saying two ... | [{"input": "18\n1 1\n-37\n1 2\n47 0\n1 2\n-48 -7\n2 1\n37\n-8\n2 1\n-3\n27\n2 2\n46 36\n-33 -9\n2 2\n-20 24\n-6 -33\n2 2\n-50 -45\n50 10\n2 2\n-38 -12\n1 8\n3 3\n42 4 -29\n-27 28 -16\n-35 -13 26\n3 3\n-46 40 -27\n-32 28 -24\n37 13 -13\n3 3\n-38 -17 30\n22 -50 7\n-26 18 -3\n3 3\n-2 26 29\n41 11 28\n-31 -16 1\n3 3\n-25 1... | code_stdio |
[
{
"content": "During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impo... | [{"input": "183\n", "output": "8372\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n1 99\n1 100\n1 101\n1 102\n1 103\n1 104\n1 105\n1 106\n1 107\n1 108\n1 109\n1 110\n1 111\n1 112\n1 113\n1 114\n1 115\n1 116\n1 117\n1 118\n1 119\n1 120\n1 121\n1 122\n1 123\n1 124\n1 125\n1 126\n1 127\n1 128\n1 129\n1 130\n1 131\n1 132\n1 13... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.