messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally and one square vertically, or two squares vertically and one square horizontall... | [{"input": "3\n29 5\n2 2\n16 7", "output": "20112\n12\n11796\n"}, {"input": "3\n16 3\n4 3\n12 4", "output": "2084\n104\n2048\n"}, {"input": "3\n29 3\n2 2\n16 7", "output": "7154\n12\n11796\n"}, {"input": "3\n16 2\n4 3\n12 3", "output": "936\n104\n1136\n"}, {"input": "3\n16 2\n4 3\n12 4", "output": "936\n104\n2048\n"}, ... | code_stdio |
[
{
"content": "You are given a positive decimal number x.\n\nYour task is to convert it to the \"simple exponential notation\".\n\nLet x = a·10^{b}, where 1 ≤ a < 10, then in general case the \"simple exponential notation\" looks like \"aEb\". If b equals to zero, the part \"Eb\" should be skipped. If a is an in... | [{"input": "2206815224318443962208128404511577750057653265995300414539703580103256087275661997018352502651118684\n", "output": "2.206815224318443962208128404511577750057653265995300414539703580103256087275661997018352502651118684E99\n"}, {"input": "22068152243184439622081284045115777500576532659953004145397035801032560... | code_stdio |
[
{
"content": "After learning a lot about space exploration, a little girl named Ana wants to change the subject.\n\nAna is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tir... | [{"input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\num\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\nmu\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"input": "20\niw\nix\nudb\nbg\nni\nuo\njsm\nmu\ns\nquy\nqo\nbxct\nng\nrmr\nnu\np... | code_stdio |
[
{
"content": "A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.\n\nThe Little Elephant has K favorite lucky strings A_{1}, A_{2}, ..., A_{K}. He thinks that the lucky string S is good if either |S| ≥ 47 or for some j from 1 to K we have ... | [{"input": "2 4\n2\n752\n25003\n1329\n10896\n39952297003683893618248919566249112695937429123", "output": "Good\nGood\nBad\nGood\n"}, {"input": "2 4\n1\n752\n28466\n1329\n10896\n95142413585696281004906476796906063037090967865", "output": "Bad\nGood\nGood\nGood\n"}, {"input": "2 4\n24\n501\n16429\n1329\n10896\n9514241358... | code_stdio |
[
{
"content": "\"Search\" is an operation to obtain the desired information from a large amount of information. Familiar examples include \"finding your own exam number from a large number of exam numbers\" when announcing your success, or \"finding Taro Aizu's phone number\" from your phone book. This search op... | [{"input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n1\n2\n3\n10\n-1\n0", "output": "3\n2\n"}, {"input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n1\n2\n3\n10\n-2\n0", "output": "3\n2\n"}, {"input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n2\n2\n3\n10\n-2\n0", "output": "3\n2\n"}, {"input": "7\n11\n15\n-1\n53\n51\n56\n109\n... | code_stdio |
[
{
"content": "Given is a string S. Each character in S is either a digit (0, ..., 9) or ?.\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\nSince the answer can be enormous, print the count modulo 10^9+7... | [{"input": "???????????????2?????????????8???????????6????????5?6?5????1???8????1???????????????????????????????????3??????9????????????3??6???????????6???????????????????3???????????9???????3????6?5?????????????????2???????????5418??????????8????????9????????????0????????????????????????9????????????????????9??????8??... | code_stdio |
[
{
"content": "You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.\n\nThe i-th edge (1 \\leq i \\leq M) connects Vertex a_i and Vertex b_i. \nAn edge whose removal disconnects the graph is called a bridge.\n\nFind the number of the edges tha... | [{"input": "7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\n", "output": "4\n"}, {"input": "7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7", "output": "4"}, {"input": "6 5\n1 2\n2 3\n3 4\n4 5\n5 6\n", "output": "5\n"}, {"input": "6 5\n1 2\n2 3\n3 4\n3 5\n5 6", "output": "5\n"}, {"input": "6 5\n1 2\n2 3\n3 4\n4 5\n2 6", "output": "5\n"... | code_stdio |
[
{
"content": "Taro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connected by a single grid. First, the pieces are placed in the square at the starti... | [{"input": "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n1\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 32\n0 0 0", "output": "0\n101\n100\n50\n22\n"}, {"input": "1 2 0\n1\n1 2 1\n1\n1 2 100\n1 2 1\n1\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 32\n0 0 0", "output": "0\n100\n100\n50\... | code_stdio |
[
{
"content": "Let's start from some definitions.\n\nStrings A and B are called anagrams if it's possible to rearrange the letters of string A using all the original letters exactly once and achieve string B; in other words A and B are permutations of each other. For example, remote and meteor are anagrams, race... | [{"input": "3\nmpei\nelepgaot\nitco", "output": "no such string\n"}, {"input": "3\nmpei\nglepeaot\nitco", "output": "no such string\n"}, {"input": "3\niepm\nglepeaot\nitco", "output": "no such string\n"}, {"input": "3\niepm\ngleoeaot\nitco", "output": "no such string\n"}, {"input": "3\niepm\ngleoeaot\nhtco", "output": ... | code_stdio |
[
{
"content": "Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"a\", \"o\", \"u\", \"i\", and \"e\". Other letters are consonant.\n\nIn Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel.... | [{"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"}, {"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"}, {"input": "auuaoonntanonnuewannnopuuinniwoonenn... | code_stdio |
[
{
"content": "The Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem:\n\nGiven a number m, how many polynomials P with coefficient... | [{"input": "100\n751 557 779 329 39 213 844 289 137 50 951 284 671 474 829 906 736 395 366 22 133 418 552 649 636 109 974 775 852 971 384 945 335 961 472 651 335 543 560 135 85 952 558 838 147 644 688 727 940 978 309 705 409 27 774 951 92 277 835 804 589 103 529 11 304 171 655 378 792 876 1161 36 125 378 152 958 746 98... | code_stdio |
[
{
"content": "Bob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water units per second from 0 to x1, inclusive. Similarly... | [{"input": "1000000 1000000 1000000 1000000 1000000\n", "output": "1000000 1000000\n"}, {"input": "1000000 1000000 999999 999998 1000000\n", "output": "999999 999998\n"}, {"input": "129630 805489 631548 761110 577559\n", "output": "227930 447929\n"}, {"input": "581106 975502 703094 487920 637713\n", "output": "675578 1... | code_stdio |
[
{
"content": "You are given four integers $a$, $b$, $x$ and $y$. Initially, $a \\ge x$ and $b \\ge y$. You can do the following operation no more than $n$ times:\n\n Choose either $a$ or $b$ and decrease it by one. However, as a result of this operation, value of $a$ cannot become less than $x$, and value of $... | [{"input": "7\n10 10 8 5 3\n12 8 8 7 2\n12343 43 4543 39 123212\n1000000000 1000000000 1 1 1\n1000000000 1000000000 1 1 1000000000\n10 11 2 1 5\n10 11 9 1 10\n", "output": "70\n77\n177177\n999999999000000000\n999999999\n55\n10\n"}, {"input": "7\n10 10 8 5 3\n12 8 0 7 2\n12343 43 4543 39 123212\n1000000000 1000000000 1 ... | code_stdio |
[
{
"content": "Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with t humps, representing them as polylines in the plane. Each polyline consists of n vertices with coordinates (x1, y1), (x2, y2), ..., ... | [{"input": "19 7\n", "output": "197939352\n"}, {"input": "20 8\n", "output": "503245466\n"}, {"input": "19 8\n", "output": "109824208\n"}, {"input": "20 7\n", "output": "468541040\n"}, {"input": "20 9\n", "output": "90700276\n"}, {"input": "19 6\n", "output": "69183464\n"}, {"input": "20 6\n", "output": "96046590\n"}, ... | code_stdio |
[
{
"content": "The grasshopper is located on the numeric axis at the point with coordinate $x_0$.\n\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate $x$ with a distance $d$ to the left moves the grasshopper to a point with a coordinate $x... | [{"input": "9\n0 1\n0 2\n10 10\n10 197\n177 25\n10000000000 1895528572\n-433494437 87178291199\n1 0\n-1 1\n", "output": "-1\n1\n11\n-187\n202\n10000000000\n-87611785637\n1\n0\n"}, {"input": "9\n0 1\n0 2\n10 11\n10 197\n177 25\n10000000000 1895528572\n-433494437 87178291199\n1 0\n-1 1\n", "output": "-1\n1\n22\n-187\n202... | code_stdio |
[
{
"content": "Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i.\n\nHe will play Q rounds of a game using this graph. In the i-th round, two vertices S_i and T_i are specified, an... | [{"input": "4 6\n1 3 10\n4 1 10\n2 4 8\n3 2 2\n3 4 8\n2 1 3\n1\n2 3", "output": "11\n"}, {"input": "4 6\n1 3 10\n4 1 10\n2 4 6\n3 2 2\n3 4 8\n2 2 3\n1\n2 3", "output": "16\n"}, {"input": "4 6\n2 1 10\n4 1 23\n2 4 6\n2 2 4\n3 4 4\n3 2 6\n1\n2 3", "output": "14\n"}, {"input": "4 6\n2 1 10\n4 1 10\n2 4 6\n3 2 2\n3 4 5\n2 ... | code_stdio |
[
{
"content": "Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.\n\nThat element can store information about the matrix of inte... | [{"input": "13 21 1\n2 11\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0... | code_stdio |
[
{
"content": "We will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be o... | [{"input": "akasakaakasakasakaakas\n", "output": "14\n"}, {"input": "akasakaakasakasaka`kas", "output": "14\n"}, {"input": "akasakaakasakasakb`kas", "output": "14\n"}, {"input": "akakasaakasakasakaakas", "output": "4\n"}, {"input": "akakasaakasakas`kaakas", "output": "4\n"}, {"input": "akakasaakasakbs`kaakas", "output"... | code_stdio |
[
{
"content": "Alex decided to go on a touristic trip over the country.\n\nFor simplicity let's assume that the country has $n$ cities and $m$ bidirectional roads connecting them. Alex lives in city $s$ and initially located in it. To compare different cities Alex assigned each city a score $w_i$ which is as hig... | [{"input": "30 30\n81 86 81 91 90 100 98 89 96 97 88 99 68 23 82 107 94 80 99 67 70 90 81 74 91 100 92 89 74 98\n16 26\n20 3\n23 16\n17 27\n30 22\n18 23\n14 30\n25 4\n3 8\n18 9\n29 26\n27 21\n26 6\n10 7\n28 5\n1 30\n28 30\n12 15\n17 25\n26 15\n30 2\n5 15\n14 20\n10 4\n24 16\n8 7\n11 30\n19 8\n21 9\n13 15\n2\n", "output... | code_stdio |
[
{
"content": "Given is a string S of length N-1. Each character in S is `<` or `>`.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\n* If S_i= `<`: a_i<a_{i+1}\n* If S_i= `>`: a_i>a_{i+1}\n\n\n\nFind t... | [{"input": "<>>><<<<<><<>>><", "output": "29\n"}, {"input": "<>>>><<<<><<<>><", "output": "28\n"}, {"input": "<>><<<><<<<>>>><", "output": "26\n"}, {"input": "<<>><<><<<<>>>><", "output": "24\n"}, {"input": "<>>>><<<<><<>><<", "output": "27\n"}, {"input": "<>>>>><<<><<<><<", "output": "30\n"}, {"input": "<>>><>><<><<<>... | code_stdio |
[
{
"content": "A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, \"abcba\", \"a\", and \"abba\" are palindromes, while \"abab\" and \"xy\" are not.\n\nA string is called a substring of another string, if it can be obtained from t... | [{"input": "21\narozaupalanalapuazora\n", "output": "aaaaaaaallnoopprruuzz\n"}, {"input": "16\ngagadbcgghhchbdf\n", "output": "aabbccddfgggghhh\n"}, {"input": "15\nabacabadabacaba\n", "output": "aaaaaaaabbbbccd\n"}, {"input": "10\nmsunonames\n", "output": "aemmnnossu\n"}, {"input": "9\nabcabcabc\n", "output": "aaabbbcc... | code_stdio |
[
{
"content": "You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.\n\nLet's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a. \n\nYou can apply the following operations any number of times:\n\n * Choose some substring of string a (for example,... | [{"input": "25 999999998 999999999\n1011001110101010100110001\n", "output": "7999999985\n"}, {"input": "25 999999998 999999999\n1011001110101010100110101\n", "output": "8999999983\n"}, {"input": "25 999999998 999999999\n1011001110101010100111001\n", "output": "7999999985"}, {"input": "4 360253575 1080814150\n1101\n", "... | code_stdio |
[
{
"content": "Gildong is playing a video game called Block Adventure. In Block Adventure, there are $n$ columns of blocks in a row, and the columns are numbered from $1$ to $n$. All blocks have equal heights. The height of the $i$-th column is represented as $h_i$, which is the number of blocks stacked in the $... | [{"input": "1\n30 0 0\n-1 1 0 -1 1 0 0 0 0 0 0 -1 2 1 -1 -1 0 -1 0 0 0 1 1 -2 2 0 -1 2 0 -1 -2 -1 0 1 0 0 1 1 -1 1 0 0 1 1 0 0 1 0 0 0 0 1 0 -1 2 0 1 1 1 0 0 1 -1 0 1 -1 1 -1 -2 -1 0 0 0 0 -1 0 2 0 0 0 -1 -2 0 1 1 -1 1 1 0 1 -1 -1 -1 -4 -2 0 0\n", "output": "NO\n"}, {"input": "1\n30 0 0\n-1 1 0 -1 1 0 0 0 0 0 0 -1 2 1 ... | code_stdio |
[
{
"content": "Nezzar's favorite digit among $1,\\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.\n\nGiven $q$ integers $a_1,a_2,\\ldots,a_q$, for each $1 \\le i \\le q$ Nezzar would like to know if $a_i$ can be equal to a sum of several (one or more)... | [{"input": "2\n3 3\n24 21 27\n10 4\n74 13 26 95 102 51 34 58 42 60\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "2\n3 3\n27 21 27\n10 4\n74 13 26 95 102 51 34 58 42 60\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "2\n3 3\n27... | code_stdio |
[
{
"content": "Given a complete binary tree with the height of H, we index the nodes respectively top-down and left-right from 1. The i-th node stores a positive integer V_{i}. Define P_{i} as follows: P_{i}=V_{i} if the i-th node is a leaf, otherwise P_{i}=max(V_{i}*P_{L}, V_{i}*P_{R}), where L and R are the in... | [{"input": "2\n2 1 6\n3\n7 2 26 2 16 8 13\n0", "output": "12\n2366\n"}, {"input": "2\n1 2 3\n3\n6 2 10 2 12 20 13\n0", "output": "3\n1200\n"}, {"input": "2\n1 2 3\n3\n6 2 10 2 12 9 17\n0", "output": "3\n1020\n"}, {"input": "2\n2 1 3\n3\n7 2 14 2 16 8 13\n0", "output": "6\n1274\n"}, {"input": "2\n2 1 3\n3\n7 2 26 2 16 8... | code_stdio |
[
{
"content": "Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.\n\nLet we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. T... | [{"input": "5 3 10000 3241\n5 12 2\n", "output": "58892\n"}, {"input": "5 3 3521 10000\n5 12 2\n", "output": "58168\n"}, {"input": "5 3 10000 2737\n5 12 2\n", "output": "52844\n"}, {"input": "5 3 3521 10010\n5 12 2\n", "output": "58198\n"}, {"input": "5 3 3521 10000\n6 12 2\n", "output": "58168\n"}, {"input": "5 3 1000... | code_stdio |
[
{
"content": "Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift $X[i]$ grams on day $i$. In order to improve his workout performance at the gym, he can buy exactly one pre-workout drink at t... | [{"input": "5 00000\n10000 30000 30000 40000 19505\n27261\n14 2 8 5 6\n", "output": "16\n"}, {"input": "5 00000\n10000 30000 30000 40000 19505\n27261\n14 0 8 5 6\n", "output": "14\n"}, {"input": "5 10000\n10000 40000 30000 30000 20000\n10000\n5 2 8 3 6\n", "output": "-1\n"}, {"input": "5 10000\n10000 37530 30000 30000 ... | code_stdio |
[
{
"content": "You are given a following process. \n\nThere is a platform with $n$ columns. $1 \\times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest ... | [{"input": "1000 10\n999 999 998 34 454 546 343 35 34 1000\n", "output": "0\n"}, {"input": "1000 10\n999 999 998 34 454 546 343 35 34 1000\n", "output": "0\n"}, {"input": "1000 10\n999 999 998 34 454 546 343 69 34 1000\n", "output": "0\n"}, {"input": "1000 10\n999 999 998 34 454 546 343 67 34 1000\n", "output": "0\n"},... | code_stdio |
[
{
"content": "Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove t... | [{"input": "43 959134961 -868367850 142426380\n921743429 63959718 -797293233 122041422 -407576197 700139744 299598010 168207043 362252658 591926075 941946099 812263640 -76679927 -824267725 89529990 -73303355 83596189 -982699817 -235197848 654773327 125211479 -497091570 -2301804 203486596 -126652024 309810546 -581289415... | code_stdio |
[
{
"content": "Polycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such a_{i}, where a_{i} is the number of candie... | [{"input": "100 100\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "100 100\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "In Byteland they have a very strange monetary system.\n\nEach Bytelandian gold coin has an integer number written on it. A coin n\ncan be exchanged in a bank into three coins: n/2, n/3 and n/4.\nBut these numbers are all rounded down (the banks have to make a profit).\n\nYou can also sell Byteland... | [{"input": "12\n10", "output": "13\n10\n"}, {"input": "12\n19", "output": "13\n19\n"}, {"input": "12\n11", "output": "13\n11\n"}, {"input": "12\n21", "output": "13\n22\n"}, {"input": "12\n27", "output": "13\n28\n"}, {"input": "12\n12", "output": "13\n13\n"}, {"input": "12\n15", "output": "13\n15\n"}, {"input": "12\n14"... | code_stdio |
[
{
"content": "Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they ne... | [{"input": "12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 1... | code_stdio |
[
{
"content": "You have $2n$ integers $1, 2, \\dots, 2n$. You have to redistribute these $2n$ elements into $n$ pairs. After that, you choose $x$ pairs and take minimum elements from them, and from the other $n - x$ pairs, you take maximum elements.\n\nYour goal is to obtain the set of numbers $\\{b_1, b_2, \\do... | [{"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "\n1\n3\n1\n"}, {"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "1\n3\n1\n"}, {"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n1 4\n", "output": "1\n3\n1\n"}, {"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n2 4\n", "output": "1\n3\n2\n"}, {"input": "3\n1\n1\n5\n1 4 5 7 10\n2\... | code_stdio |
[
{
"content": "On a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than tha... | [{"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n6 3\n-1 4\n8 4\n14 17", "output": "3\n"}, {"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n6 3\n-1 4\n8 4\n9 17", "output": "3\n"}, {"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n8 3\n-1 4\n14 4\n9 4", "output": "2\n"}, {"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n3 3\n1 4\n8... | code_stdio |
[
{
"content": "Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n* 1\\leq N \\leq 10^{16}\n* N is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN\n\n\nOutput\n\nPrint the maximum possible sum of the digi... | [{"input": "1265641936938969", "output": "135\n"}, {"input": "2005985506723837", "output": "136\n"}, {"input": "5193523582167964", "output": "139\n"}, {"input": "4944180382968715", "output": "138\n"}, {"input": "7493811264493993", "output": "141\n"}, {"input": "813322357948504", "output": "133\n"}, {"input": "127248513... | code_stdio |
[
{
"content": "Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer.\n\nOnce a year the President visited his historic home town t, for which ... | [{"input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1100000\n1 2 1000000\n1 2 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 1000000\n", "output": "CAN 999999\nCAN 999999\nCAN 1099999\nCAN 999999\nYES\nCAN 999999\nCAN 999999\nCAN 999999\nCAN 999999\n"}, {"input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 10000... | code_stdio |
[
{
"content": "You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily con... | [{"input": "32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n", "output": "32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n19... | code_stdio |
[
{
"content": "A tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:\n\na60bcb8e9e8f22e3af51049eda063392.png\n\nSnuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-te... | [{"input": "10 1 2 0 0 -1 0", "output": "11\n"}, {"input": "1 13 1 0 1 -1 2", "output": "13\n"}, {"input": "10 2 0 0 4 -1 0", "output": "16\n"}, {"input": "1 26 1 0 1 -1 2", "output": "26\n"}, {"input": "10 3 0 0 4 -1 0", "output": "17\n"}, {"input": "1 26 1 0 2 -1 2", "output": "28\n"}, {"input": "10 1 0 0 4 -1 0", "o... | code_stdio |
[
{
"content": "YouKn0wWho has an integer sequence $a_1, a_2, \\ldots a_n$. Now he will split the sequence $a$ into one or more consecutive subarrays so that each element of $a$ belongs to exactly one subarray. Let $k$ be the number of resulting subarrays, and $h_1, h_2, \\ldots, h_k$ be the lengths of the longes... | [{"input": "4\n7\n1 12 3 0 1 1 5\n3\n2 2 5\n5\n1 3 2 4 4\n4\n4 5 -1 1\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n7\n1 11 3 2 1 1 5\n3\n2 2 5\n5\n1 3 2 4 4\n4\n4 5 -2 1\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n7\n1 4 3 2 -1 1 -1\n3\n1 6 0\n3\n1 4 2 4 2\n4\n4 2 1 1\n", "output": "YES\nYES\nYES\nYES\... | code_stdio |
[
{
"content": "You have a large rectangular board which is divided into $n \\times m$ cells (the board has $n$ rows and $m$ columns). Each cell is either white or black.\n\nYou paint each white cell either red or blue. Obviously, the number of different ways to paint them is $2^w$, where $w$ is the number of whi... | [{"input": "5 4\noooo\no*oo\noooo\n**oo\nooo*\n", "output": "239616\n"}, {"input": "5 4\noooo\no*oo\noooo\n**oo\nooo*\n", "output": "239616\n"}, {"input": "5 4\noooo\no*oo\noooo\n**oo\n*ooo\n", "output": "249856\n"}, {"input": "5 4\noooo\no*oo\noooo\no*o*\nooo*\n", "output": "233472\n"}, {"input": "5 4\noooo\no*oo\nooo... | code_stdio |
[
{
"content": "You are given an array $d_1, d_2, \\dots, d_n$ consisting of $n$ integer numbers.\n\nYour task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and each of the parts forms a consecutive cont... | [{"input": "5\n2 3 5 4 10\n", "output": "10\n"}, {"input": "1\n1000000000\n", "output": "0\n"}, {"input": "1\n1000000000\n", "output": "0\n"}, {"input": "1\n1000000100\n", "output": "0\n"}, {"input": "5\n1 15 4 2 1\n", "output": "1\n"}, {"input": "1\n1000000110\n", "output": "0\n"}, {"input": "5\n2 3 5 4 6\n", "output"... | code_stdio |
[
{
"content": "There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type a_{i}.\n\nLet's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.\n\nSplit the row of the pea... | [{"input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451\n", "output": "5\n1 2\n3 4\n5 6\n7 8\n9 10\n"}, {"input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451\n", "output": "5\n1 2\n3 4\n5 6\n7 8\n9 1... | code_stdio |
[
{
"content": "Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: A $\\rightarrow$ BC B $\\rightarrow$ AC C $\\rightarrow$ AB AAA $\\rightarrow$ empty string \n\nNote that a substring is one or ... | [{"input": "AAAAAA\nAAAAAA\n30\n3 4 1 2\n3 3 4 4\n5 6 3 4\n3 3 2 3\n6 6 1 5\n2 4 4 6\n1 6 2 5\n6 6 3 4\n3 5 1 4\n4 5 3 6\n2 3 2 4\n3 4 4 4\n6 6 4 6\n3 3 2 5\n1 5 3 3\n4 6 1 2\n6 6 6 6\n3 3 3 4\n6 6 6 6\n5 6 4 4\n6 6 5 5\n2 3 1 4\n3 6 4 5\n3 5 6 6\n4 5 2 6\n5 6 6 6\n1 4 2 5\n4 5 2 5\n4 5 1 3\n2 2 4 6\n", "output": "1110... | code_stdio |
[
{
"content": "Let's call left cyclic shift of some string $t_1 t_2 t_3 \\dots t_{n - 1} t_n$ as string $t_2 t_3 \\dots t_{n - 1} t_n t_1$.\n\nAnalogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \\dots t_{n - 1}$.\n\nLet's say string $t$ is good if its left cyclic shift is equal ... | [{"input": "3\n142345\n100120013\n253858690946\n", "output": "4\n5\n8\n"}, {"input": "3\n175995\n155501496\n289014129764\n", "output": "4\n6\n8\n"}, {"input": "3\n142345\n100120013\n339309424207\n", "output": "4\n5\n8\n"}, {"input": "3\n142345\n186796866\n339309424207\n", "output": "4\n5\n8\n"}, {"input": "3\n180899\n1... | code_stdio |
[
{
"content": "N people are arranged in a row from left to right.\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\nYou will give the following d... | [{"input": "98351 25613\n1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101... | code_stdio |
[
{
"content": "Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.\n\nThen Borya came and said that the new string contained a tandem repeat of length l as a substring. How large could l be?\n\nSee notes for definit... | [{"input": "jhfwjyyzwrjiyrrgveiqkoltivghgkontrqragikttxxuwszjwqhwxindyrdqhucnbwgwrppgqmsasrzohezjlfmkzsqptwpratprcrxyxecnlsaiqrvimihmhjfgzwdtvmfhgbuonpsblphyoxzclkrwbwrkasahiirzqlfjdoomlosltldbpomyyhmdwfchzxnmwlh\n200\n", "output": "400\n"}, {"input": "nemtbujbscvkgxnbqboeohzfozihjvhcllfseiouggzojhqcoqrvtdsgkubiophnhah... | code_stdio |
[
{
"content": "You are given an array of integers $a_1,a_2,\\ldots,a_n$. Find the maximum possible value of $a_ia_ja_ka_la_t$ among all five indices $(i, j, k, l, t)$ ($i<j<k<l<t$).\n\n\n-----Input-----\n\nThe input consists of multiple test cases. The first line contains an integer $t$ ($1\\le t\\le 2 \\cdot 10... | [{"input": "4\n5\n-1 -1 -4 -1 -5\n6\n-4 -4 -3 1 2 -1\n6\n0 -1 -1 -1 -1 -1\n6\n-12 -7 -10 -3 -2 1\n", "output": "-20\n96\n0\n2520\n"}, {"input": "4\n5\n-1 -1 -4 -1 -5\n6\n-4 -4 -3 1 2 -1\n6\n0 -1 -1 -1 -1 -1\n6\n-9 -7 -10 -3 -2 1\n", "output": "-20\n96\n0\n1890\n"}, {"input": "4\n5\n-1 -1 -3 -4 -5\n6\n-1 -2 -3 1 2 -1\n6... | code_stdio |
[
{
"content": "Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to do smoothly when he buys something.\n\nOne day, however, he doubt if this way is really efficient. When he pays more number of coins, a clerk consumes longer time to f... | [{"input": "123 3 0 2 0 2 0\n1263 14 10 9 3 18 1\n0 0 0 0 0 0 0", "output": "6\n13\n"}, {"input": "167 3 1 2 1 2 1\n1826 9 9 9 1 15 10\n0 0 0 0 0 0 0", "output": "6\n10\n"}, {"input": "123 6 1 2 1 1 2\n999 17 15 9 2 16 10\n0 0 0 0 0 0 0", "output": "6\n3\n"}, {"input": "123 6 1 2 1 1 2\n999 17 15 9 2 14 10\n0 0 0 0 0 0... | code_stdio |
[
{
"content": "You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n_1 washing machines, n_2 drying machines and n_3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a piece of laundry before it is washed, and y... | [{"input": "10000 1000 1000 1000 1000 1000 1000\n", "output": "12000\n"}, {"input": "10000 1000 1000 1000 1010 1000 1000\n", "output": "12100\n"}, {"input": "10000 1000 1000 1000 1010 1001 1000\n", "output": "12101\n"}, {"input": "10000 1000 1000 1000 1000 1000 1000\n", "output": "12000"}, {"input": "10000 1 1 1 1000 1... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nFor positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). \n\"k!\" means factorial: k! = 1 * 2 * .. * k \n\nChef wants to calculate F(p_{1}) + F(p_{2}) + ... + F(p_{n}). \nAs answer could be lar... | [{"input": "1 20\n1 17 2 0 6", "output": "18\n"}, {"input": "1 19\n1 12 0 6 5", "output": "15\n"}, {"input": "5 22\n0 27 0 4 2", "output": "13\n"}, {"input": "8 34\n1 3 3 4 10", "output": "28\n"}, {"input": "15 23\n2 3 3 4 3", "output": "17\n"}, {"input": "0 27\n2 26 2 0 1", "output": "23\n"}, {"input": "15 23\n2 3 0 4... | code_stdio |
[
{
"content": "Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.\n\nYou are a new applicant for his company. Boboniu will test you with the following chess question:\n\nConsider a $n\\times m$ grid (rows are number... | [{"input": "95 147 67 82\n", "output": "67 82\n1 82\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n... | code_stdio |
[
{
"content": "Multiplication of Big Integers\n\nGiven two integers $A$ and $B$, compute the product, $A \\times B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the product in a line.\n\nConstraints\n\n* $-1 \\times 10^{1000} \\leq A, B \\leq 10^{10... | [{"input": "2 -134", "output": "-268\n"}, {"input": "3 -134", "output": "-402\n"}, {"input": "6 -134", "output": "-804\n"}, {"input": "-124 4", "output": "-496\n"}, {"input": "-103 -1", "output": "103\n"}, {"input": "2 -67", "output": "-134\n"}, {"input": "6 -51", "output": "-306\n"}, {"input": "7 -51", "output": "-357... | code_stdio |
[
{
"content": "Railroad Trip\n\nThere are N cities in the JOI country, numbered 1, 2, ..., and N, respectively. In addition, there are N − 1 railroads, which are numbered 1, 2, ..., and N − 1, respectively. The railroad i (1 ≤ i ≤ N − 1) connects the city i and the city i + 1 in both directions.\n\nThere are two... | [{"input": "4 4\n1 3 2 4\n147 131 100\n100 50 80\n250 70 130", "output": "577\n"}, {"input": "4 4\n1 3 3 4\n147 131 100\n100 50 80\n250 70 130", "output": "447\n"}, {"input": "4 4\n1 3 2 4\n120 90 100\n110 50 96\n250 138 130", "output": "616\n"}, {"input": "4 4\n1 3 2 4\n120 90 100\n110 50 111\n115 75 130", "output": "... | code_stdio |
[
{
"content": "Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration $\\frac{a_{i}}{1000}$. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concent... | [{"input": "971 108\n706 706 991 706 988 997 996 997 991 996 706 706 996 706 996 984 1000 991 996 1000 724 724 997 991 997 984 997 1000 984 996 996 997 724 997 997 1000 997 724 984 997 996 988 997 706 706 997 1000 991 706 988 997 724 988 706 996 706 724 997 988 996 991 1000 1000 724 988 996 1000 988 984 996 991 724 706... | code_stdio |
[
{
"content": "Genos needs your help. He was asked to solve the following programming problem by Saitama:\n\nThe length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as $\\sum_{i = 1}^{|s|}|s_{i} - t_{i}|$, where s_{i} is the i-th character of s and ... | [{"input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", "output": "321\n"}, {"input": "1110010001000101001011111\n00011011000000100001010000010100110011010001111010\n", "output": "316\n"}, {"input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", ... | code_stdio |
[
{
"content": "After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A part of the game is turn-based fights of big squadrons of enemies on infinit... | [{"input": "1000000000\n", "output": "3000000003000000001\n"}, {"input": "1147564610\n", "output": "3950713605816050131\n"}, {"input": "1000010000\n", "output": "3000060003300030001\n"}, {"input": "1065935402\n", "output": "3408654846908511019\n"}, {"input": "1000010010\n", "output": "3000060063300630331\n"}, {"input":... | code_stdio |
[
{
"content": "<image>\n\n\nArrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the top and proceeding to the bottom according to the ... | [{"input": "7\n3,8\n8,1,0\n2,9,5,4\n4,5,2,6,5\n2,7,4,4\n8,1,1\n8,3\n10", "output": "65\n"}, {"input": "7\n8,3\n8,1,0\n4,4,7,1\n5,6,2,5,4\n2,7,4,4\n8,1,0\n8,3\n15", "output": "71\n"}, {"input": "7\n8,3\n8,1,0\n4,4,7,1\n5,6,2,5,4\n2,7,4,4\n8,1,0\n8,3\n24", "output": "80\n"}, {"input": "7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n... | code_stdio |
[
{
"content": "A bracket sequence is a string, containing only characters \"(\", \")\", \"[\" and \"]\".\n\nA correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"+\" between the original characters of the sequence. For ex... | [{"input": "[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[[(())]]][]()(([([])(([[[]]()])(()))]((())))([()]([()[[[]([][[[[][(())([[]()])]]][[(())]([])]()][[](())]()[])]()[][]]([[]])[]])[(()[()((()[][()]))][])[]()()([]())](()[][][])()()[]()))[]()[]\n", "output": "61\n[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[... | code_stdio |
[
{
"content": "problem\n\nThere are the following games.\n\nN characters are lined up in a vertical row. The color of these characters is red, blue, or yellow, and in the initial state, four or more characters of the same color are not lined up in a row. The player can select a character at a certain position an... | [{"input": "12\n3\n2\n1\n1\n1\n3\n2\n1\n2\n1\n1\n5\n2\n3\n2\n1\n2\n2\n5\n0\n0\n3\n2\n-1\n0\n0", "output": "8\n2\n1\n2\n"}, {"input": "12\n3\n2\n1\n1\n1\n3\n2\n2\n2\n2\n1\n5\n2\n3\n2\n1\n2\n2\n5\n1\n0\n3\n2\n-1\n0\n0", "output": "3\n2\n1\n2\n"}, {"input": "12\n3\n1\n0\n1\n0\n3\n2\n2\n3\n1\n1\n3\n12\n4\n4\n2\n1\n2\n5\n2\... | code_stdio |
[
{
"content": "There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possib... | [{"input": "5\n29\n0", "output": "5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n29\n28 1\n27 2\n27 1 1\n26 3\n26 2 1\n26 1 1 1\n25 4\n25 3 1\n25 2 2\n25 2 1 1\n25 1 1 1 1\n24 5\n24 4 1\n24 3 2\n24 3 1 1\n24 2 2 1\n24 2 1 1 1\n24 1 1 1 1 1\n23 6\n23 5 1\n23 4 2\n23 4 1 1\n23 3 3\n23 3 2 1\n23 3 1 1 1\n23 2 2 2\n23 2 2 ... | code_stdio |
[
{
"content": "Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are n mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mounds in one day; besides, he wants to visit each one e... | [{"input": "10000\n", "output": "1 10000 2 9999 3 9998 4 9997 5 9996 6 9995 7 9994 8 9993 9 9992 10 9991 11 9990 12 9989 13 9988 14 9987 15 9986 16 9985 17 9984 18 9983 19 9982 20 9981 21 9980 22 9979 23 9978 24 9977 25 9976 26 9975 27 9974 28 9973 29 9972 30 9971 31 9970 32 9969 33 9968 34 9967 35 9966 36 9965 37 9964... | code_stdio |
[
{
"content": "You have $a$ coins of value $n$ and $b$ coins of value $1$. You always pay in exact change, so you want to know if there exist such $x$ and $y$ that if you take $x$ ($0 \\le x \\le a$) coins of value $n$ and $y$ ($0 \\le y \\le b$) coins of value $1$, then the total value of taken coins will be $S... | [{"input": "6\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "6\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n... | code_stdio |
[
{
"content": "For given two circles $c1$ and $c2$, print\n\n\n4\n\n\nif they do not cross (there are 4 common tangent lines),\n\n\n3\n\n\nif they are circumscribed (there are 3 common tangent lines),\n\n\n2\n\n\nif they intersect (there are 2 common tangent lines),\n\n\n1\n\n\nif a circle is inscribed in anothe... | [{"input": "-26 -2 -2\n15 2 -1", "output": "4\n"}, {"input": "-26 -2 -2\n15 2 -2", "output": "4\n"}, {"input": "-26 -2 -1\n15 2 -2", "output": "4\n"}, {"input": "-26 -2 -1\n21 2 -2", "output": "4\n"}, {"input": "-35 -1 -1\n46 3 0", "output": "4\n"}, {"input": "-35 -1 -2\n46 3 0", "output": "4\n"}, {"input": "-35 -1 -2\... | code_stdio |
[
{
"content": "Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a_1, a_2, ..., a_{n} in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sor... | [{"input": "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23 95 32 55 47\n", "output... | code_stdio |
[
{
"content": "You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if th... | [{"input": "5\n-1 -1 1 1 321", "output": "APPROVED\n"}, {"input": "5\n-1 -1 1 1 337", "output": "APPROVED\n"}, {"input": "5\n-1 -1 1 1 200", "output": "APPROVED\n"}, {"input": "5\n-1 -1 1 1 385", "output": "APPROVED\n"}, {"input": "5\n0 -1 5 1 252", "output": "APPROVED\n"}, {"input": "5\n6 7 3 10 31", "output": "APPROV... | code_stdio |
[
{
"content": "In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:\n\n In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the s... | [{"input": "10000\n", "output": "12471\n"}, {"input": "9999\n", "output": "12467\n"}, {"input": "10000\n", "output": "12471"}, {"input": "9999\n", "output": "12467"}, {"input": "1000\n", "output": "881\n"}, {"input": "1201\n", "output": "1096"}, {"input": "1590\n", "output": "1520"}, {"input": "1195\n", "output": "1091... | code_stdio |
[
{
"content": "Takahashi the Jumbo will practice golf.\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\n-----Constraints-----\n - All values in input ar... | [{"input": "1000\n2 1000\n", "output": "OK\n"}, {"input": "279\n691 872\n", "output": "OK\n"}, {"input": "379\n400 757\n", "output": "NG\n"}, {"input": "1000\n1 999\n", "output": "NG\n"}, {"input": "17\n629 629\n", "output": "OK\n"}, {"input": "48\n888 912\n", "output": "OK\n"}, {"input": "23\n391 404\n", "output": "OK... | code_stdio |
[
{
"content": "As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters \"(\" and \")\" (without quotes)).\n\nOn the last lesson Anton learned about ... | [{"input": "((((()())))())((((((()(()())(()())()((()()))(((())()()()(())))))()())())))(()()(()))))()(((()(((())()))())())))))(()()()((((((())(()())())()())(()))))()(()))(((()()()))())()(((()(()(((()))(()))()(()))((((((((())))))()))())(())))))()(()(()(((()((()()()())(((())())((()())(((((()()(())()()(()())()()))((()()())... | code_stdio |
[
{
"content": "You are given $n$ integers $a_1, a_2, \\ldots, a_n$. Find the maximum value of $max(a_l, a_{l + 1}, \\ldots, a_r) \\cdot min(a_l, a_{l + 1}, \\ldots, a_r)$ over all pairs $(l, r)$ of integers for which $1 \\le l < r \\le n$.\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 ... | [{"input": "4\n3\n2 3 3\n4\n3 0 10 1\n2\n359 139\n6\n229275 372495 402638 1125346 388084 422281\n", "output": "9\n10\n49901\n453107062748\n"}, {"input": "4\n3\n2 5 3\n4\n3 0 12 1\n2\n359 80\n6\n229275 718820 272407 1125346 388084 775159\n", "output": "15\n12\n28720\n436728777064\n"}, {"input": "4\n3\n2 3 3\n4\n3 0 6 1\... | code_stdio |
[
{
"content": "Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.\n\nConsider that m (m ≤ 4n) people occupy the seats in the bus. The passengers entering the bus are numbered f... | [{"input": "100 400\n", "output": "201 1 202 2 203 3 204 4 205 5 206 6 207 7 208 8 209 9 210 10 211 11 212 12 213 13 214 14 215 15 216 16 217 17 218 18 219 19 220 20 221 21 222 22 223 23 224 24 225 25 226 26 227 27 228 28 229 29 230 30 231 31 232 32 233 33 234 34 235 35 236 36 237 37 238 38 239 39 240 40 241 41 242 42 ... | code_stdio |
[
{
"content": "Dolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n\nHe does not have any stock of chemicals, however, so he will purchase some ... | [{"input": "40 3 8\n9 1 80\n7 8 13\n1 4 64\n5 2 60\n10 10 84\n5 6 64\n2 10 43\n9 2 73\n8 3 43\n8 2 53\n10 10 26\n4 4 20\n4 10 82\n9 7 96\n4 6 15\n1 3 45\n6 7 53\n3 3 92\n7 7 74\n4 2 62\n8 4 68\n3 7 7\n5 4 73\n5 10 22\n3 5 37\n2 10 88\n3 9 74\n1 7 80\n3 6 20\n7 9 5\n6 2 79\n9 9 20\n1 10 100\n9 7 39\n1 3 33\n8 8 39\n5 1 ... | code_stdio |
[
{
"content": "One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0, 0, 0), and the opposite o... | [{"input": "-827584 -680412 -103147\n897186 313672 388429\n892050 717946 505625 200144 311983 606037\n", "output": "1709658\n"}, {"input": "-827584 -680412 -103147\n897186 313672 388429\n892050 717946 505625 278931 311983 606037\n", "output": "1709658\n"}, {"input": "-827584 -680412 -103147\n897186 313672 388429\n89205... | code_stdio |
[
{
"content": "Polycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. Cap (aj, bj) can close marker (xi, yi) only if their diameters match, that is,... | [{"input": "6 7\n2 1\n1 1\n2 2\n1 2\n1 1\n1 2\n2 1\n1 1\n1 1\n1 1\n1 2\n2 2\n1 1\n", "output": "5 5\n"}, {"input": "6 7\n1 1\n1 1\n1 2\n1 2\n2 2\n1 2\n2 1\n2 1\n2 1\n2 1\n1 1\n1 1\n1 2\n", "output": "3 3\n"}, {"input": "6 7\n2 1\n2 2\n2 1\n1 1\n2 1\n1 2\n2 2\n2 2\n2 2\n1 2\n2 2\n1 1\n1 2\n", "output": "3 3\n"}, {"input... | code_stdio |
[
{
"content": "This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more elements from the sequence a ... | [{"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"input": "5\n3 1 4 2 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n2\n4\n1\n3\n2\n2\n4\n3\n2\n4\n3... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \nYour friend Сhef has prepared a rectangular cake for you. Both of you want to divide the cake among yourselves. Your friend is generous enough to let you choose your share first. You have decided to take two pieces.\n\nFor the fir... | [{"input": "2\n1 1 10 32\n11 11 20 20\n1 1 20 20\n11 11 30 76", "output": "360\n1515\n"}, {"input": "2\n1 1 10 10\n11 7 20 20\n1 1 20 20\n11 11 30 55", "output": "198\n1116\n"}, {"input": "2\n1 1 10 20\n11 7 20 20\n1 1 20 20\n11 11 30 55", "output": "288\n1116\n"}, {"input": "2\n1 1 10 4\n11 11 20 20\n1 1 20 20\n11 11 ... | code_stdio |
[
{
"content": "A country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by these roads. According to some Super Duper Documents, Berland is protected by t... | [{"input": "10 45 9\n2 1 428\n3 1 610\n3 2 357\n4 1 855\n4 2 528\n4 3 508\n5 1 425\n5 2 185\n5 3 349\n5 4 845\n6 1 206\n6 2 969\n6 3 153\n6 4 854\n6 5 640\n7 1 87\n7 2 250\n7 3 953\n7 4 456\n7 5 742\n7 6 588\n8 1 641\n8 2 898\n8 3 396\n8 4 960\n8 5 654\n8 6 410\n8 7 640\n9 1 707\n9 2 707\n9 3 707\n9 4 707\n9 5 707\n9 6... | code_stdio |
[
{
"content": "You are given $n$ elements numbered from $1$ to $n$, the element $i$ has value $a_i$ and color $c_i$, initially, $c_i = 0$ for all $i$.\n\nThe following operation can be applied:\n\nSelect three elements $i$, $j$ and $k$ ($1 \\leq i < j < k \\leq n$), such that $c_i$, $c_j$ and $c_k$ are all equal... | [{"input": "13\n1 2 3 2 1 3 3 4 5 5 5 4 7\n", "output": "7\n"}, {"input": "7\n1 2 1 2 7 4 7\n", "output": "2\n"}, {"input": "3\n1 1 2\n", "output": "0\n"}, {"input": "3\n1 1 1\n", "output": "1\n"}, {"input": "3\n1 2 1\n", "output": "1\n"}, {"input": "3\n1 2 2\n", "output": "0\n"}, {"input": "3\n1 2 3\n", "output": "0\n... | code_stdio |
[
{
"content": "You are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from 1 to n, in clockwise order.\n\nWe define the distance betwe... | [{"input": "20\n-2967010 48581504\n-2967318 48581765\n-2967443 48581988\n-2967541 48582265\n-2967443 48582542\n-2967318 48582765\n-2967010 48583026\n-2966691 48583154\n-2966252 48583234\n-2965813 48583154\n-2965494 48583026\n-2965186 48582765\n-2965061 48582542\n-2964963 48582265\n-2965061 48581988\n-2965186 48581765\n... | code_stdio |
[
{
"content": "We have N bricks arranged in a row from left to right.\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\nAmong them, you can break at most N-1 bricks of your choice.\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq... | [{"input": "10\n3 1 4 1 10 17 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 4 1 10 17 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 4 1 10 31 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 5 1 10 31 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 5 1 10 31 2 11 0 3", "output": "7\n"}, {"input": "10\n4 1 5 1 11 31 ... | code_stdio |
[
{
"content": "Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:\n\n * a12 + a22 + ... + an2 ≥ x\n * a1 + a2 + ... + an ≤ y\n\nInput\n\nThe first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ ... | [{"input": "45678 1409926355077 1564465\n", "output": "1518788\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\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": "It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors.\n\nTheofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem?\n\nYou have a per... | [{"input": "5\n9\n31 yellow\n30 green\n26 yellow\n13 red\n2 red\n22 white\n12 red\n6 orange\n29 blue\n", "output": "0\n"}, {"input": "5\n9\n31 yellow\n30 green\n26 yellow\n13 red\n2 red\n22 white\n12 red\n6 orange\n29 blue\n", "output": "0\n"}, {"input": "5\n9\n31 yellow\n30 green\n26 yellow\n25 red\n2 red\n22 white\n1... | code_stdio |
[
{
"content": "There is an easy way to obtain a new task from an old one called \"Inverse the problem\": we give an output of the original task, and ask to generate an input, such that solution to the original problem will produce the output we provided. The hard task of Topcoder Open 2014 Round 2C, InverseRMQ, ... | [{"input": "5\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "output": "NO\n"}, {"input": "4\n0 3 7 6\n3 -1 4 9\n7 4 0 2\n11 9 2 0\n", "output": "NO\n"}, {"input": "4\n0 3 7 6\n3 -1 4 9\n7 4 0 2\n16 9 2 0\n", "output": "NO\n"}, {"input": "4\n0 3 3 6\n3 -1 4 9\n7 4 0 2\n16 9 2 0\n", "output": "NO\n"}, {"inpu... | code_stdio |
[
{
"content": "Snuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging... | [{"input": "001010 001011", "output": "931093537\n"}, {"input": "000101 000101", "output": "414723868\n"}, {"input": "000110 000111", "output": "399920258\n"}, {"input": "001111 001110", "output": "292820538\n"}, {"input": "010010 010011", "output": "475486457\n"}, {"input": "010100 010100", "output": "449134091\n"}, {... | code_stdio |
[
{
"content": "On a chessboard with a width of 10^9 and a height of 10^9, the rows are numbered from bottom to top from 1 to 10^9, and the columns are numbered from left to right from 1 to 10^9. Therefore, for each cell of the chessboard you can assign the coordinates (x,y), where x is the column number and y is... | [{"input": "0 5\n-1 96762320 34608098\n243235878 312125306 50510976\n326016273 498514053 50510976\n614560077 445224816 25950222\n1077021507 901150398 37242747\n", "output": "0\n"}, {"input": "0 5\n-1 96762320 34608098\n243235878 312125306 50510976\n326016273 498514053 90733839\n614560077 445224816 25950222\n1077021507 ... | code_stdio |
[
{
"content": "Polycarp, Arkady's friend, prepares to the programming competition and decides to write a contest. The contest consists of $n$ problems and lasts for $T$ minutes. Each of the problems is defined by two positive integers $a_i$ and $p_i$ — its difficulty and the score awarded by its solution.\n\nPol... | [{"input": "2\n4\n1.9585346052548882 31.000\n12 0\n11 6\n30 1\n5 1\n3\n1.360280845492949 30.337801087585063\n0 10\n10 8\n20 8\n", "output": "7\n18\n"}, {"input": "2\n4\n1.557488533293537 31.000\n12 0\n11 6\n30 1\n5 1\n3\n1.360280845492949 30.337801087585063\n0 10\n10 8\n20 8\n", "output": "7\n18\n"}, {"input": "2\n4\n1... | code_stdio |
[
{
"content": "Professor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.\n\nTheir algorithm will be tested on an array of integers, where the $i$-th integer represents the color of the $i$-th pixel in the image. The image is in... | [{"input": "100 10\n39 242 238 155 95 30 129 132 72 59 22 91 203 113 99 81 253 204 160 109 92 187 11 227 145 211 100 42 78 14 113 91 140 197 123 182 4 185 208 27 182 207 63 146 102 39 159 195 26 100 72 127 157 159 152 53 0 117 101 125 19 188 179 145 240 50 205 207 113 246 42 56 161 13 188 244 159 222 119 204 26 182 212... | code_stdio |
[
{
"content": "In the city of Ultima Thule job applicants are often offered an IQ test. \n\nThe test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the o... | [{"input": "####\n.#..\n####\n....\n", "output": "YES\n"}, {"input": "....\n....\n....\n....\n", "output": "YES\n"}, {"input": "#..#\n.##.\n####\n####\n", "output": "YES\n"}, {"input": "#.#.\n.###\n#.#.\n.###\n", "output": "YES\n"}, {"input": "#..#\n.##.\n.##.\n#..#\n", "output": "YES\n"}, {"input": ".##.\n.#..\n##.#\n... | code_stdio |
[
{
"content": "Nobody knows, but $N$ frogs live in Chef's garden.\nNow they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to $K$.\nChef knows all $P$ pairs of frogs, which want to send messages. Help him to defin... | [{"input": "5 6 3\n0 3 8 8 12\n1 2\n1 3\n2 5", "output": "Yes\nYes\nYes\n"}, {"input": "5 3 3\n0 3 15 8 12\n1 2\n1 3\n3 5", "output": "Yes\nNo\nYes\n"}, {"input": "5 4 3\n0 3 2 4 23\n1 2\n1 3\n2 1", "output": "Yes\nYes\nYes\n"}, {"input": "5 4 3\n0 3 3 4 23\n1 2\n1 3\n2 1", "output": "Yes\nYes\nYes\n"}, {"input": "5 6 ... | code_stdio |
[
{
"content": "[0, 0]\n[0, 1] [1, 1]\n[0, 2] [1, 2] [2, 2]\n[0, 3] [1, 3] [2, 3] [3, 3]\n[0, 4] [1, 4] [2, 4] [3, 4] [4, 4]\n[0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5]\n[0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6]\n\n\nConsider the standard set of 28 western dominoes as shown in the above... | [{"input": "6\n16 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "output": "Yes\nYes\n"}, {"input": "6\n13 23 14 16 15 25\n10\n00 01 11 02 12 30 03 13 36 33", "output": "Yes\nYes\n"}, {"input": "6\n11 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "output": "Yes\nYes\n"}, {"input": "6\n13 23 14 16 15 25\n10\n... | code_stdio |
[
{
"content": "Jack loved his house very much, because his lovely cats take a nap on the wall of his house almost every day. Jack loved cats very much.\n\nJack decided to keep an observation diary of the cats as a free study during the summer vacation. After observing for a while, he noticed an interesting featu... | [{"input": "4 6\ns 0 1\ns 2 3\ns 2 1\nw 0\ns 5 2\ns 5 2\n2 3\ns 0 2\ns 1 1\ns 0 1\n0 0", "output": "0\n1\nimpossible\nimpossible\nimpossible\nEND\n0\nimpossible\nimpossible\nEND\n"}, {"input": "4 6\ns 0 2\ns 1 2\ns 2 2\nw 0\ns 3 4\ns 8 4\n2 3\ns 1 1\ns 1 2\ns 2 2\n0 0", "output": "0\n2\nimpossible\nimpossible\nimpossib... | code_stdio |
[
{
"content": "The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\n1. Get out of the nest with N acorns in his hands.\n2. Go to Exchange A and do some trades.\n3. Go to Exchange B and do some trades.\n4.... | [{"input": "23\n1 2 1\n20 1 10", "output": "920\n"}, {"input": "23\n1 2 4\n10 1 4", "output": "460\n"}, {"input": "23\n1 12 1\n1 1 1", "output": "276\n"}, {"input": "23\n2 11 1\n2 1 2", "output": "506\n"}, {"input": "23\n2 2 4\n10 1 4", "output": "222\n"}, {"input": "23\n2 2 1\n20 1 2", "output": "444\n"}, {"input": "2... | code_stdio |
[
{
"content": "Petya has a simple graph (that is, a graph without loops or multiple edges) consisting of $n$ vertices and $m$ edges.\n\nThe weight of the $i$-th vertex is $a_i$.\n\nThe weight of the $i$-th edge is $w_i$.\n\nA subgraph of a graph is some set of the graph vertices and some set of the graph edges. ... | [{"input": "20 10\n487490574 766859182 860731945 956220596 584871933 815478522 698429627 781975977 485357256 396825095 566947997 680691964 834523631 323163346 665972495 5503804 738797202 410201497 91359028 708811641\n16 15 598574211\n8 7 332007499\n11 1 942159718\n3 1 24779817\n20 4 192862192\n16 6 965177283\n20 5 2673... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nTuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things that coins are. He knows that for every coin he can get very tasty bone from his master. He believes that some day he will find a ... | [{"input": "2\n10 16\n14 18", "output": "10\n14\n"}, {"input": "2\n130 45\n4 17", "output": "42\n4\n"}, {"input": "2\n10 4\n21 19", "output": "2\n10\n"}, {"input": "2\n44 45\n2 17", "output": "44\n2\n"}, {"input": "2\n10 22\n4 16", "output": "10\n4\n"}, {"input": "2\n12 22\n4 16", "output": "12\n4\n"}, {"input": "2\n10... | 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": "333 9\nedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedce... | code_stdio |
[
{
"content": "In some other world, today is Christmas.\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n - A level-0 burger is a patty.\n - A level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a pa... | [{"input": "50 4321098765432109\n", "output": "2160549382716056\n"}, {"input": "50 2251799813685246\n", "output": "1125899906842623\n"}, {"input": "50 2251799813685247\n", "output": "1125899906842624\n"}, {"input": "50 2251799813685297\n", "output": "1125899906842625\n"}, {"input": "50 4503599627370442\n", "output": "2... | code_stdio |
[
{
"content": "You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right.\n\nTo cyclically shift a table row one cell to the righ... | [{"input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000110000\n0000001001\n", "output": "-1\n"}, {"input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000100000\n0000001001\n", "output": "-1"}, {... | code_stdio |
[
{
"content": "Learn, learn and learn again — Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this love in children. That's why she always gives her students large and difficul... | [{"input": "100\n-88 -5 -96 -45 -11 -81 -68 -58 -73 -91 -27 -23 -89 -34 -51 -46 -70 -95 -9 -77 -99 -61 -74 -98 -88 -44 -61 -88 -35 -71 -43 -23 -25 -98 -23 0 -1 -80 -52 -47 -26 -92 -82 -73 -45 -37 -15 -49 -9 -7 -47 0 -6 -76 -91 -20 -58 -46 -74 -57 -54 -39 -61 -18 -65 -61 -19 -64 -93 -29 -82 -25 -100 -89 -90 -68 -36 -91 ... | code_stdio |
[
{
"content": "In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. \n\nTotally in Berland there are n citizens, the welfare of each of them is estimated as the integer in a_{i} burles (burle is... | [{"input": "70\n644488 5444 150441 714420 602059 335330 510670 196555 546346 740011 509449 850947 692874 524857 750434 952985 223744 533151 896124 609694 367352 679050 560202 172728 569291 778616 332116 286927 843598 372698 244906 498046 900681 709791 420904 724593 864493 813094 791377 39998 296710 1033347 403891 57923... | code_stdio |
[
{
"content": "Polycarp has prepared $n$ competitive programming problems. The topic of the $i$-th problem is $a_i$, and some problems' topics may coincide.\n\nPolycarp has to host several thematic contests. All problems in each contest should have the same topic, and all contests should have pairwise distinct t... | [{"input": "55\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3\n", "output": "49\n"}, {"input": "55\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3\n", "output": "49"}, {"input": "18\n2 1 2 10 2... | code_stdio |
[
{
"content": "Hongcow likes solving puzzles.\n\nOne day, Hongcow finds two identical puzzle pieces, with the instructions \"make a rectangle\" next to them. The pieces can be described by an n by m grid of characters, where the character 'X' denotes a part of the puzzle and '.' denotes an empty part of the grid... | [{"input": "1 500\n.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.