messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "There are $n$ warriors in a row. The power of the $i$-th warrior is $a_i$. All powers are pairwise distinct.\n\nYou have two types of spells which you may cast: Fireball: you spend $x$ mana and destroy exactly $k$ consecutive warriors; Berserk: you spend $y$ mana, choose two consecutive warrior...
[{"input": "23 5\n10 3 3\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 23\n", "output": "56\n"}, {"input": "23 5\n10 3 4\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 23\n", "output": "64\n"}, {"input": "23 5\n10 3 4\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 2...
code_stdio
[ { "content": "Alice and Bob are studying for their class test together. The topic of the test is Prime Numbers. The preparation is getting too boring for their liking. To make it interesting, they turn it into a game. The winner will get an ice-cream treat from the other.\n\nThe game is called Count K-Primes. A...
[{"input": "4\n3 0 1\n2 12 2\n22 12 2\n2 20 1", "output": "-1\n3\n-5\n12\n"}, {"input": "4\n3 0 1\n2 19 2\n22 12 2\n2 20 1", "output": "-1\n6\n-5\n12\n"}, {"input": "4\n3 0 1\n2 12 4\n22 12 2\n2 20 1", "output": "-1\n0\n-5\n12\n"}, {"input": "4\n2 2 1\n3 12 2\n1 15 2\n0 20 5", "output": "1\n3\n5\n-1816\n"}, {"input": "...
code_stdio
[ { "content": "Γ†sir - CHAOS Γ†sir - V.\n\n\"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.\n\nThe time right now...... 00:01:12......\n\nIt's time.\"\n\nThe emotion samples are now sufficient. After almost 3 years, it's time for Ivy to awake her bonded sister, Va...
[{"input": "87\n1120 1120 1120 872 1120 731 3583 2815 4019 1291 4568 973 1120 1705 1120 822 203 1120 1120 1120 1120 4196 3166 4589 3030 1120 1120 1120 711 1120 500 1120 1120 3551 1120 1120 1120 1700 1120 1120 2319 4554 1120 1312 1120 1120 4176 1120 1120 3661 1120 1120 1120 1120 142 63 4125 1120 4698 3469 1829 567 1120 ...
code_stdio
[ { "content": "There are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi and Aoki will arrange these integers in a row, as follows:\n\n* First, Takahashi will arrange the integers as he wishes.\n* Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as h...
[{"input": "5\n1 12 6 0 5", "output": "1 0 6 12 5 "}, {"input": "5\n1 12 2 0 5", "output": "1 0 5 2 12 "}, {"input": "5\n1 12 3 0 5", "output": "1 0 5 3 12 "}, {"input": "5\n1 17 3 0 5", "output": "1 0 17 5 3 "}, {"input": "5\n1 4 10 0 5", "output": "1 0 4 10 5 "}, {"input": "5\n1 13 6 0 5", "output": "1 0 13 6 5 "}, {...
code_stdio
[ { "content": "Polycarp found under the Christmas tree an array $a$ of $n$ elements and instructions for playing with it:\n\nAt first, choose index $i$ ($1 \\leq i \\leq n$) β€” starting position in the array. Put the chip at the index $i$ (on the value $a_i$).\n\nWhile $i \\leq n$, add $a_i$ to your score and mov...
[{"input": "4\n5\n6 5 2 2 8\n3\n2 1 12\n6\n2 1111 2 3 995 1\n5\n1 1 1 1 4\n", "output": "10\n14\n1111\n8\n"}, {"input": "4\n5\n6 5 2 2 8\n3\n2 1 15\n6\n2 1111 2 3 995 1\n5\n1 1 1 1 4\n", "output": "10\n17\n1111\n8\n"}, {"input": "4\n5\n12 3 1 2 3\n3\n2 1 4\n6\n5 1101 2 5 613 1\n5\n2 1 1 1 1\n", "output": "12\n6\n1101\n...
code_stdio
[ { "content": "You are given an array a with n elements. Each element of a is either 0 or 1.\n\nLet's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).\n\n\n-----Input-----\n\nThe first...
[{"input": "10 5\n0 0 1 0 0 1 1 0 1 1\n", "output": "10\n1 1 1 1 1 1 1 1 1 1 "}, {"input": "10 2\n1 0 0 1 0 1 0 1 0 1\n", "output": "5\n1 0 0 1 1 1 1 1 0 1\n"}, {"input": "10 3\n0 0 1 0 0 1 0 0 1 1\n", "output": "6\n0 0 1 0 1 1 1 1 1 1\n"}, {"input": "10 3\n0 0 1 0 0 1 0 0 1 1\n", "output": "6\n0 0 1 0 1 1 1 1 1 1 "}, ...
code_stdio
[ { "content": "You are given n positive integers a_1, …, a_n, and an integer k β‰₯ 2. Count the number of pairs i, j such that 1 ≀ i < j ≀ n, and there exists an integer x such that a_i β‹… a_j = x^k.\n\nInput\n\nThe first line contains two integers n and k (2 ≀ n ≀ 10^5, 2 ≀ k ≀ 100).\n\nThe second line contains n ...
[{"input": "100 4\n94 94 83 27 80 73 61 38 34 95 72 96 59 36 52 15 122 78 39 22 21 57 54 59 9 32 81 64 51 90 67 41 18 58 93 76 44 62 77 61 31 70 39 73 111 57 43 31 27 85 36 26 58 48 35 23 124 53 3 14 40 67 53 19 70 81 98 12 91 15 92 90 89 86 58 30 67 73 72 69 68 47 30 7 89 41 17 97 45 6 4 23 13 36 10 35 73 74 45 52\n",...
code_stdio
[ { "content": "Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.\n\nBear Limak was once in a city a and he wanted to go to a city b. There was no direct connection so he decided to take ...
[{"input": "1000 1577\n698 459 326 404\n", "output": "698 326 1 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 ...
code_stdio
[ { "content": "You are given $n$ blocks, each of them is of the form [color$_1$|value|color$_2$], where the block can also be flipped to get [color$_2$|value|color$_1$]. \n\nA sequence of blocks is called valid if the touching endpoints of neighboring blocks have the same color. For example, the sequence of thre...
[{"input": "40\n2 99891 4\n1 29593 4\n4 12318 1\n1 40460 3\n1 84340 2\n3 33349 4\n3 2121 4\n3 50068 3\n2 72029 4\n4 52319 3\n4 60726 2\n1 30229 1\n3 1887 2\n2 56145 4\n3 53121 1\n2 54227 4\n2 70016 3\n1 93754 4\n4 68567 3\n1 70373 2\n4 52983 3\n2 27467 2\n4 56860 2\n2 12665 2\n3 11282 3\n2 18731 4\n1 69767 4\n2 51820 4...
code_stdio
[ { "content": "You are given two strings $s$ and $t$ both of length $n$ and both consisting of lowercase Latin letters.\n\nIn one move, you can choose any length $len$ from $1$ to $n$ and perform the following operation: Choose any contiguous substring of the string $s$ of length $len$ and reverse it; at the ...
[{"input": "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "output": "NO\nYES\nNO\nYES\n"}, {"input": "4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "output": "NO\nYES\nNO\nYES\n"}, {"input": "4\n4\ndabb\nabdb\n5\nababa\nababa\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "output": "YES\n...
code_stdio
[ { "content": "Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he built kept falling apart.\n\nLet us consider the building process. Vasya takes a brick and puts it on top of the already built tower so that the sides of the brick ar...
[{"input": "20\n-10 17 -4 11\n1 22 -15 6\n-5 12 -9 16\n-9 16 -5 12\n-2 19 -12 9\n-10 17 -4 11\n-8 13 -6 15\n-5 12 -9 16\n-3 18 -11 10\n-1 20 -13 8\n29 9 -12 50\n29 50 -11 10\n29 9 -12 50\n29 50 -10 11\n-14 50 29 7\n-9 12 29 50\n-14 7 29 50\n29 9 -12 50\n-11 10 29 50\n-11 50 29 10\n", "output": "10"}, {"input": "20\n-1 ...
code_stdio
[ { "content": "For a positive integer n let's define a function f:\n\nf(n) = - 1 + 2 - 3 + .. + ( - 1)^{n}n \n\nYour task is to calculate f(n) for a given integer n.\n\n\n-----Input-----\n\nThe single line contains the positive integer n (1 ≀ n ≀ 10^15).\n\n\n-----Output-----\n\nPrint f(n) in a single line.\n\n...
[{"input": "1000000000000000\n", "output": "500000000000000\n"}, {"input": "999999999999999\n", "output": "-500000000000000\n"}, {"input": "1000000000000000\n", "output": "500000000000000\n"}, {"input": "999999999999999\n", "output": "-500000000000000\n"}, {"input": "1000000000000100\n", "output": "500000000000050\n"},...
code_stdio
[ { "content": "Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5Β·i min...
[{"input": "10 135\n", "output": "6\n"}, {"input": "10 136\n", "output": "5\n"}, {"input": "10 240\n", "output": "0\n"}, {"input": "10 165\n", "output": "5\n"}, {"input": "10 166\n", "output": "4\n"}, {"input": "10 164\n", "output": "5\n"}, {"input": "10 240\n", "output": "0\n"}, {"input": "10 235\n", "output": "1\n"},...
code_stdio
[ { "content": "Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\n\n\nInput\n\nA...
[{"input": "291", "output": "158467928000\n"}, {"input": "188", "output": "1040975000\n"}, {"input": "214", "output": "3701387000\n"}, {"input": "190", "output": "1147676000\n"}, {"input": "143", "output": "115848000\n"}, {"input": "170", "output": "432541000\n"}, {"input": "149", "output": "155251000\n"}, {"input": "1...
code_stdio
[ { "content": "Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!\n\nThis contest consists of n problems, and Pasha solves ith problem in a_{i} time units (his solutions are always correct). At any moment of time he...
[{"input": "44\n750 672 846 969 981 698 380 587 813 587 156 28 446 917 1550 449 142 764 226 1406 349 622 236 782 416 689 113 325 452 265 585 217 707 50 520 712 1869 275 423 123 175 160 415 528\n4\n869 1568\n1353 1354\n1683 1685\n2532 2540\n", "output": "-1\n"}, {"input": "44\n750 672 846 969 981 698 380 587 813 587 156...
code_stdio
[ { "content": "Karen has just arrived at school, and she has a math test today! [Image] \n\nThe test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is w...
[{"input": "19\n519879446 764655030 680293934 914539062 744988123 317088317 653721289 239862203 605157354 943428394 261437390 821695238 312192823 432992892 547139308 408916833 829654733 223751525 672158759\n", "output": "\n265109293\n"}, {"input": "19\n519879446 764655030 680293934 914539062 744988123 317088317 6537212...
code_stdio
[ { "content": "There are $n$ rectangles in a row. You can either turn each rectangle by $90$ degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can turn all or none of them. You can not change ...
[{"input": "10\n706794178 103578427\n431808055 641644550\n715688799 406274173\n767234853 345348548\n241724251 408945969\n808703176 213953908\n185314264 16672343\n1017427585 152702033\n105991807 76314740\n61409204 244301685\n", "output": "YES\n"}, {"input": "10\n706794178 103578427\n431808055 641644550\n715688799 406274...
code_stdio
[ { "content": "There are two rival donut shops.\n\nThe first shop sells donuts at retail: each donut costs a dollars.\n\nThe second shop sells donuts only in bulk: box of b donuts costs c dollars. So if you want to buy x donuts from this shop, then you have to buy the smallest number of boxes such that the total...
[{"input": "20\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 10...
code_stdio
[ { "content": "The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n Γ— n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: \n\n * Elements of the main diagonal. \n * Elements of the secondary diagonal. \n * Elements of the \"middle\" ...
[{"input": "15\n0 2 1 2 1 0 2 0 2 2 2 2 2 0 2\n2 0 1 0 1 1 2 2 0 2 2 0 3 0 1\n3 3 2 2 2 1 2 3 2 3 1 2 3 3 2\n0 3 0 3 3 3 2 1 0 2 3 2 3 3 2\n3 0 0 2 1 2 3 1 1 1 2 2 2 1 0\n1 3 2 3 3 0 3 2 0 3 1 2 3 0 3\n2 2 3 2 0 0 2 3 0 1 2 1 1 2 1\n2 1 3 2 3 3 2 2 2 0 3 3 1 1 3\n0 2 1 3 1 2 0 0 1 0 0 2 0 0 0\n3 1 2 1 2 3 2 3 2 1 0 2 2...
code_stdio
[ { "content": "Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.\n\nBut she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is a_{i}. If some free ...
[{"input": "100 1000000\n0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 1 0 0 1 -1 -1 0 0 0 0 0 0 0 1 0 0 0 0 0 -1 -1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 -1 0 0 0\n", "output": "12\n"}, {"input": "100 1000000\n0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ...
code_stdio
[ { "content": "One day Alice was cleaning up her basement when she noticed something very curious: an infinite set of wooden pieces! Each piece was made of five square tiles, with four tiles adjacent to the fifth center tile: [Image] By the pieces lay a large square wooden board. The board is divided into $n^2...
[{"input": "21\n##.######.###.#####.#\n#...##.#.......#.#...\n##..#...#.....#.....#\n#....#..###.###.....#\n....#....####....#.##\n#..#....##.#....#.###\n#...#.###...#.##....#\n#..#.##.##.##.##.....\n..........##......#.#\n#.##.#......#.#..##.#\n#.##.............#...\n..........#.....##..#\n#.#..###..###.##....#\n#.......
code_stdio
[ { "content": "RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in Figure B-1.\n\n<image>\nFigure B-1: Layout of the exchange lines\n\nA freight train consists of 2 to 72 freight cars. There are 26 types o...
[{"input": "4\n_e\na`ba\nebbf\neddea", "output": "2\n12\n12\n13\n"}, {"input": "4\ne]\na`ba\nebbf\needea", "output": "2\n12\n12\n14\n"}, {"input": "4\n_f\n`db_\nfecf\nhaefg", "output": "2\n12\n12\n18\n"}, {"input": "4\naa\ndc^b\neagb\nbfghh", "output": "1\n12\n12\n14\n"}, {"input": "4\nab\nd^ca\neagb\n_fhhh", "output":...
code_stdio
[ { "content": "Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared pa...
[{"input": "15\nrxeeeeeeeeeeeer\nereeeeeeeeeeere\needeeeeeeeeeoee\neeereeeeeeeewee\neeeereeeeebeeee\nqeeeereeejedyee\neeeeeerereeeeee\neeeeeeereeeeeee\neeeeeerereeeeze\neeeeereeereeeee\neeeereeeeegeeee\neeereeeeeeereee\neereeeeeeqeeved\ncreeeeeeceeeere\nreeerneeeeeeeer\n", "output": "NO\n"}, {"input": "15\nrxeeeeeeeeee...
code_stdio
[ { "content": "Chef has recently learnt some new facts about the famous number Ο€. For example, he was surprised that ordinary fractions are sometimes used to represent this number approximately. For example, 22/7, 355/113 or even 103993/33102.\nSoon, by calculating the value of 22/7 and 355/113 on paper Chef bec...
[{"input": "3\n3\n6\n82", "output": "3.141\n3.141592\n3.1415926530119026040722614947737296840070086399613316415926530119026040722614947737\n"}, {"input": "3\n3\n5\n82", "output": "3.141\n3.14159\n3.1415926530119026040722614947737296840070086399613316415926530119026040722614947737\n"}, {"input": "3\n2\n53\n4", "output":...
code_stdio
[ { "content": "Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. [Image] \n\nThere are n banks, numbered from 1 to n. There are also n -...
[{"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\n10 3\n7 4\n2 6\n9 2\n5 10\n1 8\n7 8\n7 2\n10 6\n", "output": "-999999998\n"}, {"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -10000...
code_stdio
[ { "content": "In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.\n\nHe is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing i...
[{"input": "89946\n", "output": "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaab...
code_stdio
[ { "content": "In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. \nIn this country, a date is called Takahashi when the month and the day...
[{"input": "-13 438", "output": "-13\n"}, {"input": "-18 766", "output": "-18\n"}, {"input": "-143 0", "output": "-143\n"}, {"input": "-212 0", "output": "-212\n"}, {"input": "-106 5", "output": "-106\n"}, {"input": "148 -1", "output": "147\n"}, {"input": "146 -1", "output": "145\n"}, {"input": "-12 -2", "output": "-12...
code_stdio
[ { "content": "You are given a set of strings S. Each string consists of lowercase Latin letters.\n\nFor each string in this set, you want to calculate the minimum number of seconds required to type this string. To type a string, you have to start with an empty string and transform it into the string you want to...
[{"input": "10\n0 i\n1 q\n2 g\n0 k\n1 e\n5 r\n4 m\n5 h\n3 o\n3 e\n5\n8 9 1 10 6\n", "output": "2 4 1 3 3\n"}, {"input": "10\n0 i\n1 q\n2 g\n0 k\n1 e\n5 r\n4 m\n4 g\n3 o\n3 e\n5\n8 9 1 10 6\n", "output": "2 4 1 3 2\n"}, {"input": "10\n0 i\n1 q\n2 g\n1 k\n1 e\n5 r\n4 m\n4 g\n3 o\n3 e\n5\n8 9 1 10 6\n", "output": "3 4 1 3...
code_stdio
[ { "content": "Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.\n\nThere are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turn...
[{"input": "4\n-1 3 3 3\n6 -1 3 -1\n2 3 -1 3\n3 3 3 -1\n", "output": "0\n\n"}, {"input": "4\n-1 3 3 3\n6 -1 3 -1\n2 1 -1 3\n3 3 3 -1\n", "output": "0\n\n"}, {"input": "4\n-1 3 3 3\n6 -1 3 -1\n2 3 -1 2\n3 3 3 -1\n", "output": "0\n\n"}, {"input": "4\n-1 3 3 3\n6 -1 3 -1\n0 3 -1 3\n3 3 3 -1\n", "output": "0\n\n"}, {"input...
code_stdio
[ { "content": "You are given a string and a number k. You are suggested to generate new strings by swapping any adjacent pair of characters in the string up to k times. Write a program to report the lexicographically smallest string among them.\n\n\n\nInput\n\nThe input is given in the following format.\n\n\ns\n...
[{"input": "pckoshien\n16", "output": "cehikposn\n"}, {"input": "pckoshien\n30", "output": "cehiknops\n"}, {"input": "pckosiien\n26", "output": "ceiiknops\n"}, {"input": "pckoshien\n14", "output": "cehkopisn\n"}, {"input": "kcposhien\n3", "output": "ckophsien\n"}, {"input": "pckoshien\n9", "output": "cekopshin\n"}, {"i...
code_stdio
[ { "content": "Artem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets min(a, b) points, where a and b are numbers that were adjacent with the removed number. If the...
[{"input": "10\n96 106 8 18 36 48 34 11 37 42\n", "output": "305\n"}, {"input": "10\n96 106 8 18 58 48 34 11 37 42\n", "output": "337\n"}, {"input": "10\n96 66 8 18 30 48 34 11 37 42\n", "output": "299\n"}, {"input": "10\n96 66 8 18 58 48 34 11 37 42\n", "output": "337\n"}, {"input": "10\n96 66 8 18 30 48 34 11 37 42\n...
code_stdio
[ { "content": "The statement of this problem shares a lot with problem A. The differences are that in this problem, the probability is introduced, and the constraint is different.\n\nA robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The r...
[{"input": "10\n44317 2 42112 2 19660 2 49\n48930 2 47499 1 27225 2 43\n48392 2 28544 2 34152 2 97\n43473 2 185 2 4950 1 94\n41685 2 38469 1 6333 1 18\n45137 2 29286 1 28293 2 34\n43584 2 41743 1 28092 2 83\n47658 2 33552 2 8862 1 27\n46379 2 4528 2 2818 2 58\n46926 2 14781 1 7952 1 59\n", "output": "795918375\n7827068...
code_stdio
[ { "content": "a is an array of n positive integers, all of which are not greater than n.\n\nYou have to process q queries to this array. Each query is represented by two numbers p and k. Several operations are performed in each query; each operation changes p to p + ap + k. There operations are applied until p ...
[{"input": "50\n49 21 50 31 3 19 10 40 20 5 47 12 12 30 5 4 5 2 11 23 5 39 3 30 19 3 23 40 4 14 39 50 45 14 33 37 1 15 43 30 45 23 32 3 9 17 9 5 14 12\n50\n36 29\n44 24\n38 22\n30 43\n15 19\n39 2\n13 8\n29 50\n37 18\n32 19\n42 39\n20 41\n14 11\n4 25\n14 35\n17 23\n1 29\n3 19\n8 6\n26 31\n9 46\n36 31\n21 49\n17 38\n47 2...
code_stdio
[ { "content": "JOI has a stove in your room. JOI himself is resistant to the cold, so he doesn't need to put on the stove when he is alone in the room, but he needs to put on the stove when there are visitors.\n\nOn this day, there are N guests under JOI. The ith (1 \\ leq i \\ leq N) visitor arrives at time T_i...
[{"input": "2 1\n-10\n31\n0", "output": "42\n"}, {"input": "3 1\n-1\n4\n11", "output": "13\n"}, {"input": "3 1\n-1\n0\n23", "output": "25\n"}, {"input": "3 2\n-2\n6\n21", "output": "10\n"}, {"input": "3 1\n-1\n1\n20", "output": "22\n"}, {"input": "3 2\n1\n14\n1", "output": "-11\n"}, {"input": "3 1\n-1\n1\n28", "output"...
code_stdio
[ { "content": "Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins... nothing happened.\n\nOri was very surprised, but Sein gave the explanation quickly: clever Gumon decided ...
[{"input": "20 7\n18525 35038\n15816 31586\n18641 46864\n35863 38632\n13563 35915\n41614 98684\n13573 35863\n25851 35985\n41687 55831\n31583 80871\n18525 35038\n15816 31586\n18641 46864\n35863 38632\n13563 35915\n41614 98684\n13573 35863\n25851 35985\n41687 55831\n31583 80871\n", "output": "4112\n"}, {"input": "20 7\n1...
code_stdio
[ { "content": "It is the easy version of the problem. The difference is that in this version, there are no 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 ...
[{"input": "010\n", "output": "153616455\n"}, {"input": "011\n", "output": "217549120\n"}, {"input": "60\n", "output": "937481864\n"}, {"input": "50\n", "output": "902552662\n"}, {"input": "59\n", "output": "950618124\n"}, {"input": "58\n", "output": "166788441\n"}, {"input": "10\n", "output": "153616455\n"}, {"input":...
code_stdio
[ { "content": "You are given a positive integer x. Find any such 2 positive integers a and b such that GCD(a,b)+LCM(a,b)=x.\n\nAs a reminder, GCD(a,b) is the greatest integer that divides both a and b. Similarly, LCM(a,b) is the smallest integer such that both a and b divide it.\n\nIt's guaranteed that the solut...
[{"input": "100\n3\n4\n5\n6\n7\n10\n9\n10\n11\n12\n13\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n28\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n111\n69\n70\n71\n72\n117\n74\n75\n76\n77\n78\n79\n80\...
code_stdio
[ { "content": "What are you doing at the end of the world? Are you busy? Will you save us?\n\n\n\n[Image]\n\nNephren is playing a game with little leprechauns.\n\nShe gives them an infinite array of strings, f_{0... ∞}.\n\nf_0 is \"What are you doing at the end of the world? Are you busy? Will you save us?\".\n\...
[{"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\n"}, {"inp...
code_stdio
[ { "content": "Artem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets min(a, b) points, where a and b are numbers that were adjacent with the removed number. If the...
[{"input": "10\n96 66 8 18 30 48 34 11 37 42\n", "output": " 299\n"}, {"input": "9\n72 49 39 50 68 35 75 94 56\n", "output": " 435\n"}, {"input": "8\n77 84 26 34 17 56 76 3\n", "output": " ...
code_stdio
[ { "content": "Alice and Brown are brothers in a family and each receives pocket money in celebration of the coming year. They are very close and share the total amount of the money fifty-fifty. The pocket money each receives is a multiple of 1,000 yen.\n\nWrite a program to calculate each one’s share given the ...
[{"input": "1001 20263", "output": "10632\n"}, {"input": "1011 20263", "output": "10637\n"}, {"input": "0010 12073", "output": "6041\n"}, {"input": "0000 12073", "output": "6036\n"}, {"input": "0001 12073", "output": "6037\n"}, {"input": "0011 12073", "output": "6042\n"}, {"input": "0111 12073", "output": "6092\n"}, {"...
code_stdio
[ { "content": "An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared $n$ problems; and since the platform is very popular, $998244351$ coder from all over the world is going to solve them.\n\nFor each problem, the authors estimated the number of p...
[{"input": "50\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n...
code_stdio
[ { "content": "One very important person has a piece of paper in the form of a rectangle a Γ— b.\n\nAlso, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size x_{i} Γ— y_{i}. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated b...
[{"input": "30 100 101\n60 34\n29 82\n89 77\n39 1\n100 100\n82 12\n57 87\n93 43\n78 50\n38 55\n37 9\n67 5\n100 100\n100 100\n82 47\n3 71\n100 100\n19 26\n25 94\n89 5\n100 100\n32 1\n100 100\n34 3\n40 99\n100 100\n36 12\n100 100\n100 100\n100 100\n", "output": "10039\n"}, {"input": "30 100 101\n60 34\n29 82\n89 77\n39 1...
code_stdio
[ { "content": "It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.\n\nToday he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws n sticks in a row. Af...
[{"input": "251656215122324104 164397544865601257\n", "output": "YES\n"}, {"input": "669038685745448997 501718093668307460\n", "output": "YES\n"}, {"input": "255787422422806632 146884995820359999\n", "output": "YES\n"}, {"input": "545668929424440387 508692735816921376\n", "output": "YES\n"}, {"input": "5481476546637233...
code_stdio
[ { "content": "How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\n-----Constraints-----\n - 1≀M≀23\n - M is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nM\n\n-----Output-----\nIf we have x hours until New Year at M o'cloc...
[{"input": "182", "output": "-134\n"}, {"input": "339", "output": "-291\n"}, {"input": "-117", "output": "165\n"}, {"input": "467", "output": "-419\n"}, {"input": "-155", "output": "203\n"}, {"input": "324", "output": "-276\n"}, {"input": "-263", "output": "311\n"}, {"input": "349", "output": "-301\n"}, {"input": "-414...
code_stdio
[ { "content": "Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?\n\n\n-----Input-----\n\nThe input contains a single integer n (0 ≀ n ≀ 2000000000).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n11\n\nOutput\n2\n\nInput\n14\n\nOutput\n0\n\nInput\n614...
[{"input": "1215860145\n", "output": "10\n"}, {"input": "2000000000\n", "output": "4\n"}, {"input": "143165576\n", "output": "14\n"}, {"input": "1919020031\n", "output": "3\n"}, {"input": "1795248373\n", "output": "5\n"}, {"input": "1818960378\n", "output": "5\n"}, {"input": "1285316221\n", "output": "3\n"}, {"input": ...
code_stdio
[ { "content": "On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represent...
[{"input": "6 5\n-1330303216 -293179180 212428642 418379342 586260100 802780784\n-116893124 193944314 556319375 1032972003 1322749268", "output": "988916105\n"}, {"input": "6 5\n-1330303216 -293179180 122359065 418379342 586260100 802780784\n-116893124 193944314 556319375 1032972003 1322749268", "output": "494088334\n"...
code_stdio
[ { "content": "You are given a tree consisting of $n$ vertices. A tree is an undirected connected acyclic graph. [Image] Example of a tree. \n\nYou have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every color.\n\nYou have to paint the vertices so that any p...
[{"input": "15\n10 34 69 39 82 49 57 22 50 25 82 37 33 62 69\n35 14 68 31 26 8 33 98 33 95 19 22 89 18 67\n80 24 10 5 26 85 69 21 29 38 89 24 78 68 88\n13 1\n6 12\n8 4\n11 9\n14 11\n15 5\n3 15\n1 10\n13 9\n7 12\n14 6\n3 2\n2 7\n4 5\n", "output": "620\n2 3 2 2 3 3 1 1 3 3 2 2 1 1 1 \n"}, {"input": "15\n10 34 69 39 82 49...
code_stdio
[ { "content": "Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \\leq i \\leq H, 1 \\leq j \\leq W) by (i,j). There is no obstacle at (1...
[{"input": "10 10 14\n4 3\n2 2\n9 4\n9 10\n7 7\n10 2\n10 10\n5 4\n3 4\n2 8\n6 4\n5 4\n5 8\n9 0", "output": "8\n"}, {"input": "10 10 14\n4 3\n2 1\n7 3\n9 10\n7 7\n8 1\n10 10\n5 4\n2 4\n2 8\n6 4\n4 4\n9 6\n9 -1", "output": "1\n"}, {"input": "10 10 14\n6 3\n2 2\n9 10\n9 10\n7 7\n8 2\n10 10\n5 6\n2 5\n2 8\n6 4\n5 4\n5 8\n9...
code_stdio
[ { "content": "While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: [Image] \n\nTogether with his old pho...
[{"input": "9\n123456789\n", "output": "YES\n"}, {"input": "9\n103481226\n", "output": "YES\n"}, {"input": "9\n246112056\n", "output": "YES\n"}, {"input": "9\n289887167\n", "output": "YES\n"}, {"input": "9\n722403540\n", "output": "YES\n"}, {"input": "9\n722403540\n", "output": "YES\n"}, {"input": "9\n246112056\n", "ou...
code_stdio
[ { "content": "Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald de...
[{"input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"input": "718 466 729 470 714 481\n", "output": "2102808\n"}, {"input": "677 303 685 288 692 296\n", "output": "1365807\n"}, {"input": "1000 1000 1 1000 1000 1\n", "output": "2004000\n"}, {"input": "888 888 888 887 889 887\n", "output": "4729487\n"}...
code_stdio
[ { "content": "Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.\n\nA block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total...
[{"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "999999993700000\n", "output": "18 999999993541753\n"}, {"input": "385925923480002\n", "output": "17 3859259...
code_stdio
[ { "content": "The only difference between easy and hard versions is constraints.\n\nYou are given a sequence $a$ consisting of $n$ positive integers.\n\nLet's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are $a$ and $b$, $a$ can be equal $b$) ...
[{"input": "6\n8\n1 1 2 10 3 2 1 1\n3\n2 4 3\n4\n2 10 11 1\n1\n26\n2\n1 1\n3\n2 1 1\n", "output": "6\n1\n1\n1\n2\n2\n"}, {"input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n", "output": "7\n2\n4\n1\n1\n3\n"}, {"input": "6\n8\n1 1 2 2 3 3 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 ...
code_stdio
[ { "content": "We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.\n\nYou want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.\...
[{"input": "10000000000000000 10000000000000000 1\n", "output": "588235294117647\n"}, {"input": "10000000000000000 10000000000000000 1000000000\n", "output": "588235\n"}, {"input": "10000000000000000 10000000000000000 1\n", "output": "588235294117647\n"}, {"input": "10000000000000000 10000000000000000 1000000000\n", "o...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n3:33\nIt's possible for all the digits displayed on a digital clock in the hours:minutes format to be identical. The time shown above (3:33) is an example of such a situation. Other examples are 2:2 and 1:11. Note that...
[{"input": "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 2", "output": "19\n20\n10\n11\n10\n1\n"}, {"input": "6\n24 60\n34 50\n10 11\n10 12\n13 11\n1 2", "output": "19\n20\n10\n11\n11\n1\n"}, {"input": "6\n24 60\n34 50\n10 11\n15 12\n11 11\n1 1", "output": "19\n20\n10\n13\n10\n1\n"}, {"input": "6\n24 60\n34 88\n10 11\n10 12...
code_stdio
[ { "content": "Little Elephant likes lemonade.\n\nWhen Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all.\n\nThere are n rooms (numbered from 0 to n-1), each contains C_{i} bottles. Each bottle has a volume ...
[{"input": "2\n3 3\n0 2 0\n3 1 2 3\n1 11\n2 4 13\n4 7\n0 2 2 0 1 0 0\n1 14\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 2", "output": "18\n36\n"}, {"input": "2\n3 3\n0 2 0\n3 1 2 3\n1 11\n2 4 13\n4 7\n0 2 2 0 1 0 0\n1 19\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 2", "output": "18\n41\n"}, {"input": "2\n3 3\n0 2 1\n3 1 2 3\n1 11\n2 4 7\n4 7\n0 1 2 ...
code_stdio
[ { "content": "B: Twice as own\n\nproblem\n\nYou will be given Q queries. Since one positive integer N is given for each query, find the number of positive integers M that satisfy the following two conditions.\n\n* 2 Satisfy \\ leq M \\ leq N\n* Of the divisors of M, excluding M, the total product is more than t...
[{"input": "3\n3\n2233\n2", "output": "0\n1254\n0\n"}, {"input": "3\n3\n3148\n2", "output": "0\n1810\n0\n"}, {"input": "3\n2\n1144\n1", "output": "0\n614\n0\n"}, {"input": "3\n2\n1079\n1", "output": "0\n576\n0\n"}, {"input": "3\n2\n1651\n0", "output": "0\n911\n0\n"}, {"input": "3\n2\n1215\n1", "output": "0\n653\n0\n"},...
code_stdio
[ { "content": "This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn't matter). No two segments connect the same pair of points, and no segment connects the point to itself. Masha wants to color some segment...
[{"input": "100 50\n66 3\n92 79\n9 44\n84 45\n30 63\n30 20\n33 86\n8 83\n40 75\n7 36\n91 4\n76 88\n77 76\n28 27\n6 52\n41 57\n8 23\n34 75\n50 15\n86 68\n36 98\n30 84\n37 62\n22 4\n6 45\n72 80\n98 74\n78 84\n1 54\n99 27\n84 91\n78 7\n80 61\n67 48\n51 52\n36 72\n97 87\n25 17\n20 80\n20 39\n72 5\n21 77\n48 1\n63 21\n92 45...
code_stdio
[ { "content": "The ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n - 1 ≀ i < j < k ≀ |T| (|T| is the length of T.)\n - T_i = A (T_i is the i-th character of T from the beginning.)\n - T_j = B\n - T_k = C\nFor example, when T = ABCBC, there a...
[{"input": "BACAB?BABBACBBCAC??AABA?BAA??BA?AAA?A??A?AACC?C??A??B?A?CABC?CA?BB??BBAABB?C??AA??A??AABBAC??B?B?ABA?BAB???AAB?A??BAACA?BAAA?ACCCA?C?BA?AAABABAA?BCCC?BAAB??ABBACCBAACCAACBCBA?CA?CC?????ABBCA?BAB?BC?ACABBA??????CCA?ACCBABA???AACBBBBA?BACAAA?BBABACC?CACA?BBCC?A?ABBCAAAAC?BCBBBCA?ABB?BCABACA??A?A?AA?BACC??AA?A...
code_stdio
[ { "content": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of can...
[{"input": "100\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 3...
code_stdio
[ { "content": "You are given two positive integers $n$ and $s$. Find the maximum possible median of an array of $n$ non-negative integers (not necessarily distinct), such that the sum of its elements is equal to $s$.\n\nA median of an array of integers of length $m$ is the number standing on the $\\lceil {\\frac...
[{"input": "8\n1 1\n1 10\n3 5\n2 2\n14 33\n4 23\n1 1010001000\n1000100000 1\n", "output": "1\n10\n2\n1\n4\n7\n1010001000\n0\n"}, {"input": "8\n1 1\n1 10\n3 5\n2 1\n14 33\n4 23\n1 1010001000\n1000100000 1\n", "output": "1\n10\n2\n0\n4\n7\n1010001000\n0\n"}, {"input": "8\n1 1\n1 10\n3 5\n2 1\n14 33\n4 44\n2 1010001000\n1...
code_stdio
[ { "content": "An n Γ— n square matrix is special, if: it is binary, that is, each cell contains either a 0, or a 1; the number of ones in each row and column equals 2. \n\nYou are given n and the first m rows of the matrix. Print the number of special n Γ— n matrices, such that the first m rows coincide with th...
[{"input": "7 4 100501\n0100010\n0000101\n0100100\n0000011\n", "output": "6\n"}, {"input": "7 4 100501\n0100010\n0000101\n0100100\n0000011\n", "output": "6\n"}, {"input": "6 4 100501\n100010\n100100\n010100\n000011\n", "output": "2\n"}, {"input": "6 4 100501\n100010\n100100\n010100\n000011\n", "output": "2\n"}, {"input...
code_stdio
[ { "content": "Two integer sequences existed initially, one of them was strictly increasing, and another one β€” strictly decreasing.\n\nStrictly increasing sequence is a sequence of integers $[x_1 < x_2 < \\dots < x_k]$. And strictly decreasing sequence is a sequence of integers $[y_1 > y_2 > \\dots > y_l]$. Note...
[{"input": "12\n12 8 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1 \n"}, {"input": "12\n12 8 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1 \n"}, {"input": "12\n12 10 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1\n"}, {"input": "12\n12 10 1 3 7 5 9 6 4 10 22 2\...
code_stdio
[ { "content": "Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.\n\nThere are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a special basket, where he puts exactly q_{i} it...
[{"input": "48\n14 2 5 3 10 10 5 6 14 8 19 13 4 4 3 13 18 19 9 16 3 1 14 9 13 10 13 4 12 11 8 2 18 20 14 11 3 11 18 11 4 2 7 2 18 19 2 8\n70\n9497 5103 1001 2399 5701 4053 3557 8481 1736 4139 5829 1107 6461 4089 5936 7961 6017 1416 1191 4635 4288 5605 8857 1822 71 1435 2837 5523 6993 2404 2840 8251 765 5678 7834 8595 3...
code_stdio
[ { "content": "You're given an integer N. Write a program to calculate the sum of all the digits of N. \n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N. \n\n-----Output-----\nFor each test case, calculate the sum of d...
[{"input": "3 \n36926\n147301\n1688", "output": "26\n16\n23\n"}, {"input": "3 \n36926\n168223\n1688", "output": "26\n22\n23\n"}, {"input": "3 \n36926\n168223\n2811", "output": "26\n22\n12\n"}, {"input": "3 \n17364\n141737\n8146", "output": "21\n23\n19\n"}, {"input": "3 \n36926\n213494\n1688", "output": "26\n23\n23\n"},...
code_stdio
[ { "content": "There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.\n\nMerlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices...
[{"input": "113\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 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\n", "output": "YES\n"}, {"input": "100\n1 0 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 0...
code_stdio
[ { "content": "There are N Snukes lining up in a row. You are given a string S of length N. The i-th Snuke from the front has two red balls if the i-th character in S is `0`; one red ball and one blue ball if the i-th character in S is `1`; two blue balls if the i-th character in S is `2`.\n\nTakahashi has a seq...
[{"input": "12001021211100201020", "output": "543589959"}, {"input": "2100", "output": "21\n"}, {"input": "101", "output": "14\n"}, {"input": "111", "output": "20\n"}, {"input": "011", "output": "10\n"}, {"input": "110", "output": "15\n"}, {"input": "102", "output": "16\n"}, {"input": "202", "output": "10\n"}, {"input"...
code_stdio
[ { "content": "You are given a string $s$ of length $n$ consisting of lowercase Latin letters. You may apply some operations to this string: in one operation you can delete some contiguous substring of this string, if all letters in the substring you delete are equal. For example, after deleting substring bbbb f...
[{"input": "500\nbbababaabaabaabbbbbbaabbabbabbaabababababbbbabaaabbbbaaabbbbbbbabababaaaaabbbbabaababbababbaaaaaabbaaabbaabaaababbbbbabbaabaabaabbbaaabaabbaaabbaabababbaaabaaabaaaaabbbababaabbbbabbbbbababbbaabaabbabaabbabbababbbbbaababbaabbbbbbbbaabbabbbabababaaaaaaaaaabababaaabbaabbbabbabbbbabbbaabaaabbbaabbabbbbbbba...
code_stdio
[ { "content": "One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know tha...
[{"input": "50 207\n50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100\n", "output": "55\n833060250"}, {"input": "50 125\n50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 10...
code_stdio
[ { "content": "Fox Ciel studies number theory.\n\nShe thinks a non-empty set S contains non-negative integers is perfect if and only if for any $a, b \\in S$ (a can be equal to b), $(a \\text{xor} b) \\in S$. Where operation xor means exclusive or operation (http://en.wikipedia.org/wiki/Exclusive_or).\n\nPlease ...
[{"input": "1000000000\n", "output": "866215044\n"}, {"input": "1000000000\n", "output": "866215044\n"}, {"input": "1059916422\n", "output": "691290739\n"}, {"input": "1000001000\n", "output": "214567917\n"}, {"input": "1001707390\n", "output": "183716036\n"}, {"input": "1063854616\n", "output": "710920454\n"}, {"input...
code_stdio
[ { "content": "You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, y...
[{"input": "8\nABBBAAABBBAABABAAAABAABAABBABABBABABBBBBAABBAABBBAABBBBAAABBABAABBBBBAAABBABAABAABBBBBAABBBABAAAAAAABBAAABBAABBABABABABBAABBAAABBBBBAAAABBBBAAAABAABABAABBBAABBBAABBAAABBABAABAAABBBAAAABBAAABABBBABAAAAABBABBABAABBBBBAAABBBBBBAABABBAAABBABBABABAAABBABBABABA\n", "output": "479173089\n"}, {"input": "8\nAAAAB...
code_stdio
[ { "content": "Johnny has just found the new, great tutorial: \"How to become a grandmaster?\". The tutorial tells many strange and unexpected for Johnny things, such as you have to be patient or that very important is solving many harder and harder problems. \n\nThe boy has found an online judge with tasks divi...
[{"input": "1\n71 4\n100 99 98 97 96 95 94 93 92 91 90 87 86 82 79 78 76 71 70 69 68 66 64 63 62 56 55 53 52 51 50 46 43 42 39 38 37 35 33 31 30 29 22 20 19 18 11 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "862166308\n"}, {"input": "1\n71 2\n100 99 98 97 96 95 94 93 92 91 90 87 86 82 79 78 76 71 70 ...
code_stdio
[ { "content": "Vasya plays Robot Bicorn Attack.\n\nThe game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one by one (without leading zeros) into the st...
[{"input": "123456789123456789123456789123\n", "output": "-1\n"}, {"input": "111111111111111111111111111111\n", "output": "-1\n"}, {"input": "349967407479541078587181768161\n", "output": "-1\n"}, {"input": "429496729742949672974294967297\n", "output": "-1\n"}, {"input": "999999999999999999999999999999\n", "output": "-1...
code_stdio
[ { "content": "Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.\n\nThere is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can...
[{"input": "45\n45 44 40 43 27 29 41 39 30 34 28 26 25 42 38 19 32 24 9 37 23 21 20 18 33 36 16 22 35 17 7 4 15 31 13 11 2 3 10 12 14 6 8 5 1\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\n", "output": "22\n"}, {"input": "40\n40 27 29 39 3...
code_stdio
[ { "content": "You are given two integers $n$ and $m$. Calculate the number of pairs of arrays $(a, b)$ such that:\n\n the length of both arrays is equal to $m$; each element of each array is an integer between $1$ and $n$ (inclusive); $a_i \\le b_i$ for any index $i$ from $1$ to $m$; array $a$ is sorted in ...
[{"input": "1000 10\n", "output": "414070642\n"}, {"input": "1000 10\n", "output": "414070642\n"}, {"input": "1000 2\n", "output": "917124963\n"}, {"input": "1000 2\n", "output": "917124963\n"}, {"input": "379 10\n", "output": "181813681\n"}, {"input": "723 9\n", "output": "157557417\n"}, {"input": "678 7\n", "output":...
code_stdio
[ { "content": "There are $n$ points on the plane, $(x_1,y_1), (x_2,y_2), \\ldots, (x_n,y_n)$.\n\nYou need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of th...
[{"input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n61 86\n22 91\n82 91\n8 41\n", "output": "173\n"}, {"input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n51 86\n22 91\n82 91\n8 41\n", "output": "173\n"}, {"input": "10\n110 34\n27 17\n17 73\n12 60\n53 25\n46 31\n51 86\n22 91\n82 91\n8 41\n", "output": "173\...
code_stdio
[ { "content": "A super computer has been built in the Turtle Academy of Sciences. The computer consists of nΒ·mΒ·k CPUs. The architecture was the paralellepiped of size n Γ— m Γ— k, split into 1 Γ— 1 Γ— 1 cells, each cell contains exactly one CPU. Thus, each CPU can be simultaneously identified as a group of three num...
[{"input": "100 1 1\n0\n\n1\n\n1\n\n1\n\n0\n\n0\n\n0\n\n1\n\n1\n\n0\n\n0\n\n1\n\n0\n\n1\n\n1\n\n1\n\n1\n\n0\n\n0\n\n1\n\n1\n\n1\n\n0\n\n0\n\n0\n\n0\n\n0\n\n1\n\n1\n\n0\n\n1\n\n1\n\n1\n\n0\n\n1\n\n0\n\n0\n\n1\n\n0\n\n1\n\n1\n\n0\n\n0\n\n0\n\n0\n\n1\n\n0\n\n1\n\n0\n\n0\n\n1\n\n1\n\n1\n\n0\n\n1\n\n1\n\n0\n\n1\n\n1\n\n1\n\...
code_stdio
[ { "content": "Once upon a time there were several little pigs and several wolves on a two-dimensional grid of size n Γ— m. Each cell in this grid was either empty, containing one little pig, or containing one wolf.\n\nA little pig and a wolf are adjacent if the cells that they are located at share a side. The li...
[{"input": "10 10\n..P..WWP.W\nPP.WPPPPPP\nWWPP.PPWPP\nPPPPW..PPW\nPP.PW.P.PW\nWW..PPWWP.\n..PW...PP.\n.PPPP.PPPW\nPP.PWP..P.\nPWPPP..WWP\n", "output": "20\n"}, {"input": "10 10\nWPPPPWPPWP\nPPPWPPPPPP\nPWPPPPWPPP\nPPPPWPPPWP\nWPPPPPPPPP\nPPPWPPWPPP\nPWPPPPPPWP\nPPPPWPPPPP\nWPPPPPWPPP\nPPPWPPPPWP\n", "output": "18\n"},...
code_stdio
[ { "content": "In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifierΒ β€” an integer from 1 to 10^9.\n\nAt some moment, robots decided to play the game \"Snowball\". Below there are the rules of this game. First, all robots stand in a row. Then the first rob...
[{"input": "4 6\n5 1000000000 1790978867 12\n", "output": "1790978867\n"}, {"input": "4 9\n5 1000000000 1766326397 19\n", "output": "1766326397\n"}, {"input": "4 9\n5 1000000000 1204240164 12\n", "output": "1204240164\n"}, {"input": "4 6\n6 1000000000 1790978867 12\n", "output": "1790978867\n"}, {"input": "4 9\n5 10001...
code_stdio
[ { "content": "Polycarp has n dice d_1, d_2, ..., d_{n}. The i-th dice shows numbers from 1 to d_{i}. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values d_1, d_2, ..., d_{n}. However, she finds it enoug...
[{"input": "10 20\n1 1 1 1 5 100 1 1 1 1\n", "output": "0 0 0 0 0 95 0 0 0 0 "}, {"input": "10 20\n1 1 1 1 5 100 1 1 1 1\n", "output": "0 0 0 0 0 95 0 0 0 0\n"}, {"input": "10 20\n1 1 1 1 10 100 1 1 1 1\n", "output": "0 0 0 0 0 90 0 0 0 0"}, {"input": "10 20\n1 1 1 1 11 100 1 1 1 1\n", "output": "0 0 0 0 0 89 0 0 0 0"}...
code_stdio
[ { "content": "There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced amon...
[{"input": "3,4,5\n5,5,8\n4,5,4\n5,4,3", "output": "1\n1\n"}, {"input": "3,3,5\n5,5,8\n4,4,4\n5,4,3", "output": "0\n3\n"}, {"input": "3,4,5\n5,5,8\n4,5,4\n3,4,5", "output": "2\n1\n"}, {"input": "3,4,5\n8,5,5\n4,5,4\n3,4,5", "output": "2\n0\n"}, {"input": "3,5,5\n6,5,8\n4,4,5\n5,4,3", "output": "0\n1\n"}, {"input": "3,3...
code_stdio
[ { "content": "As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:\n\n<image>\n\nA swap operation is the following sequence of actions:\n\n * choose two indexes i, j (i β‰  j); \n * perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp. \n\n\n\nWhat maximum...
[{"input": "116 10\n477 -765 -756 376 -48 -75 768 -658 263 -207 362 -535 96 -960 630 -686 609 -830 889 57 -239 346 -298 -18 -107 853 -607 -443 -517 371 657 105 479 498 -47 432 503 -917 -656 610 -466 216 -747 -587 -163 -174 493 -882 853 -582 -774 -477 -386 610 -58 557 968 196 69 610 -38 366 -79 574 170 317 332 189 158 -...
code_stdio
[ { "content": "You have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n - Extension Magic: Consu...
[{"input": "8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n", "output": "243\n"}, {"input": "8 1000 898 567\n737\n433\n926\n825\n780\n516\n964\n299\n", "output": "115\n"}, {"input": "8 1000 328 262\n854\n364\n362\n544\n270\n235\n209\n353\n", "output": "65\n"}, {"input": "8 1100 800 100\n300\n333\n400\n444\n500...
code_stdio
[ { "content": "Ayrat has number n, represented as it's prime factorization p_{i} of size m, i.e. n = p_1Β·p_2Β·...Β·p_{m}. Ayrat got secret information that that the product of all divisors of n taken modulo 10^9 + 7 is the password to the secret data base. Now he wants to calculate this value.\n\n\n-----Input-----...
[{"input": "67\n98929 19079 160079 181891 17599 91807 19079 98929 182233 92647 77477 98929 98639 182233 181891 182233 160079 98929 19079 98639 114941 98929 161341 91807 160079 22777 132361 92647 98929 77477 182233 103913 160079 77477 55711 77477 77477 182233 114941 91807 98929 19079 104393 182233 182233 131009 132361 1...
code_stdio
[ { "content": "One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said \"lala.\" at the end of her sentences, while Rainbow always said \"mi...
[{"input": "10\nmiao.vyscfysAtWcPkpFHdwZqAQ,UPPcjhKQTlala.\nmiao.KESqus DybUuYFoWVpo..LWZh.UqEdUsTHFlKfzqkThAUPklala.\nUNoE vfZIAdxkiWKhsHPfsqRPTNQoHgAxooVLYxRzugHjo jaEHWQFF\nCCmdIwr.UkoiYWK.Z,,ZesMpISTXNgnpYnJaWquCyL,gO\n.JvOayhXK_bgoYbfAtnXg\nbvdSzRrXoGxVgWvdXnsjEnEfxDzIQo_aZVGDGrzwuAMtzVAHioMBx_DHuTxyieGbGuSRNUojOR...
code_stdio
[ { "content": "You are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\n-----Constraints-----\n - -1000 \\leq A,B \\leq 1000\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA B\n\n-----Output-----\nPrint ...
[{"input": "-17 -10", "output": "170\n"}, {"input": "-10 -10", "output": "100\n"}, {"input": "-156 -1", "output": "156\n"}, {"input": "-156 -2", "output": "312\n"}, {"input": "-156 -3", "output": "468\n"}, {"input": "-115 1", "output": "-114\n"}, {"input": "297 -1", "output": "298\n"}, {"input": "-34 15", "output": "-1...
code_stdio
[ { "content": "After Misha's birthday he had many large numbers left, scattered across the room. Now it's time to clean up and Misha needs to put them in a basket. He ordered this task to his pet robot that agreed to complete the task at certain conditions. Before the robot puts a number x to the basket, Misha s...
[{"input": "10\n3035890458\n12148270198\n3004213265\n248593357\n5644084048\n14918970762\n8120649160\n4828464769\n183848555\n8135845959\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "10\n3035890458\n12148270198\n5256278021\n248593357\n5644084048\n14918970762\n8120649160\n4828464769\n183848555\n8135845959\n"...
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 [10...
[{"input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"input": "6\n300000000 200000000 173776099 200000000 1000000000 300000000\n", "output": "4\n"}, {"input": "6\n300000000 200000000 173776099 200000000 1000000000 42712044\n", "output": "4\n"}, {"input": "6\n300000000 59981...
code_stdio
[ { "content": "Create a program that reads the sales unit price and sales quantity and outputs the total sales amount and the average sales quantity.\n\n\n\nInput\n\nThe input is given in the following format:\n\n\nSales unit price, sales quantity\nSales unit price, sales quantity\n::\n::\n\n\nA comma-separated ...
[{"input": "02,001\n50,10\n8,531", "output": "4750\n181\n"}, {"input": "0,1000\n01,05\n134,8", "output": "1077\n338\n"}, {"input": "0,1000\n01,05\n134,9", "output": "1211\n338\n"}, {"input": "0,1000\n11,05\n134,9", "output": "1261\n338\n"}, {"input": "0,1000\n12,05\n134,9", "output": "1266\n338\n"}, {"input": "0,1000\n...
code_stdio
[ { "content": "Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \\leq A_i,B_i \\leq N).\nNow, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph...
[{"input": "7\n4 7\n3 1\n2 6\n5 2\n7 1\n2 7\n", "output": "570312505\n"}, {"input": "7\n4 7\n3 1\n2 6\n5 4\n7 1\n2 7", "output": "835937507\n"}, {"input": "7\n4 7\n3 1\n3 6\n5 4\n7 1\n2 7", "output": "679687506\n"}, {"input": "7\n4 7\n3 1\n2 6\n5 1\n7 1\n2 7", "output": "570312505\n"}, {"input": "7\n4 7\n3 1\n3 6\n5 1\...
code_stdio
[ { "content": "Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not by the fear of the wolf, but by a strange, in his opinion, pattern of the for...
[{"input": "1000000\n", "output": "958220352\n"}, {"input": "972408\n", "output": "377259665\n"}, {"input": "956022\n", "output": "864671299\n"}, {"input": "941322\n", "output": "359985814\n"}, {"input": "908550\n", "output": "307673807\n"}, {"input": "635758\n", "output": "524558133\n"}, {"input": "992164\n", "output"...
code_stdio
[ { "content": "In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.\n\nFor example, for n = 4 the sum is equal to - 1 - 2 + 3 - 4 = - 4, because 1, 2 and 4 are 2^0, 2^1 and 2^2 respectively.\n\nCalculate the answer for t values o...
[{"input": "60\n536870912\n536870911\n536870913\n1000000000\n999999999\n1\n2\n3\n4\n268435456\n268435455\n268435457\n536870912\n536870911\n536870913\n1000000000\n999999999\n1\n2\n3\n4\n268435456\n268435455\n268435457\n536870912\n536870911\n536870913\n1000000000\n999999999\n1\n2\n3\n4\n268435456\n268435455\n268435457\n5...
code_stdio
[ { "content": "Berland scientists know that the Old Berland language had exactly n words. Those words had lengths of l1, l2, ..., ln letters. Every word consisted of two letters, 0 and 1. Ancient Berland people spoke quickly and didn’t make pauses between the words, but at the same time they could always underst...
[{"input": "100\n17 18 22 15 14 18 9 21 14 19 14 20 12 15 9 23 19 20 19 22 13 22 17 11 21 22 8 17 23 18 21 23 22 23 15 18 21 17 17 9 13 21 23 19 18 23 15 14 17 19 22 23 12 16 23 16 20 9 12 17 18 11 10 17 16 21 8 21 16 19 21 17 12 20 14 16 17 10 22 20 17 13 15 19 9 22 12 20 20 13 19 16 18 7 15 18 6 18 19 21\n", "output"...
code_stdio
[ { "content": "Leo has developed a new programming language C+=. In C+=, integer variables can only be changed with a \"+=\" operation that adds the right-hand side value to the left-hand side variable. For example, performing \"a += b\" when a = $2$, b = $3$ changes the value of a to $5$ (the value of b does no...
[{"input": "16\n1 1 1\n3 4 6\n4 5 16\n456 123 7890123\n1 1 1000000000\n45 12 782595420\n1 1000000000 1001000000\n1 999999999 1000000100\n1 99999 676497416\n5 6 1409378894\n8 9 1376775908\n500000000 500000000 1000000000\n1000000000 1000000000 1000000000\n999999999 1000000000 1000000000\n1066 1487360 987405273\n12116 537...
code_stdio
[ { "content": "You are given a sorted array $a_1, a_2, \\dots, a_n$ (for each index $i > 1$ condition $a_i \\ge a_{i-1}$ holds) and an integer $k$.\n\nYou are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. \n\nLet $max(i...
[{"input": "7 6\n-3 0 -1 -2 -2 -4 -1\n", "output": "-2\n"}, {"input": "8 1\n1 1 2 3 5 8 13 21\n", "output": "20\n"}, {"input": "5 3\n99 101 103 105 107\n", "output": "4\n"}, {"input": "5 3\n99 101 103 105 107\n", "output": "4\n"}, {"input": "8 2\n1 1 2 3 5 8 13 21\n", "output": "12\n"}, {"input": "8 4\n1 1 2 3 5 8 22 1...
code_stdio
[ { "content": "Alice is playing a game with her good friend, Marisa.\n\nThere are n boxes arranged in a line, numbered with integers from 1 to n from left to right. Marisa will hide a doll in one of the boxes. Then Alice will have m chances to guess where the doll is. If Alice will correctly guess the number of ...
[{"input": "8000 100\n7990 4432 5901 5019 423 1200 7760 5752 7422 4337 4802 2570 7354 4912 2185 2344 6538 2783 1473 5311 3987 4739 7159 1677 3438 502 2800 1318 5223 4518 4448 6451 3455 5012 1588 814 4971 5847 3849 6248 6420 3607 2610 6852 1045 3730 757 6905 5248 3738 2382 7251 1305 7380 2476 7346 5721 5946 7599 5321 62...
code_stdio
[ { "content": "In Ancient Berland there were n cities and m two-way roads of equal length. The cities are numbered with integers from 1 to n inclusively. According to an ancient superstition, if a traveller visits three cities ai, bi, ci in row, without visiting other cities between them, a great disaster awaits...
[{"input": "4 4 4\n1 2\n2 3\n3 4\n1 3\n1 2 3\n1 3 4\n1 2 4\n1 3 2\n", "output": "-1\n"}, {"input": "4 4 2\n1 2\n2 3\n3 4\n1 3\n1 2 3\n1 3 4\n", "output": "4\n1 3 2 3 4\n"}, {"input": "4 4 1\n1 2\n2 3\n3 4\n1 3\n1 3 4\n", "output": "3\n1 2 3 4\n"}, {"input": "4 4 1\n1 2\n2 3\n3 4\n2 3\n1 3 4\n", "output": "3\n1 2 3 4 "}...
code_stdio
[ { "content": "Takahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\nNow, he will choose one square and place the piece on that square. Then, he will make ...
[{"input": "5000 1000000000\n2736 2472 4235 589 1974 2469 3229 2748 1350 1280 163 2424 391 784 3174 608 3060 2125 3128 1366 1374 4193 4562 2456 2118 1870 2581 879 3424 3886 1917 847 4646 4880 4407 3527 252 770 3405 1122 4272 3227 4221 802 2571 3857 4554 3275 3243 3903 2258 401 2292 1447 1014 1 4210 4719 3693 3181 4044 ...
code_stdio
[ { "content": "You have initially a string of N characters, denoted by A1,A2...AN. You have to print the size of the largest subsequence of string A such that all the characters in that subsequence are distinct ie. no two characters in that subsequence should be same.\n\nA subsequence of string A is a sequence t...
[{"input": "2\nabd\naba", "output": "3\n2\n"}, {"input": "2\nabc\naaa", "output": "3\n1\n"}, {"input": "2\ncca\naaa", "output": "2\n1\n"}, {"input": "2\nccb\naab", "output": "2\n2\n"}, {"input": "2\nccb\ncba", "output": "2\n3\n"}, {"input": "2\nbbb\nbaa", "output": "1\n2\n"}, {"input": "2\nbbb\naaa", "output": "1\n1\n"...
code_stdio
[ { "content": "You talked to Polycarp and asked him a question. You know that when he wants to answer \"yes\", he repeats Yes many times in a row.\n\nBecause of the noise, you only heard part of the answer β€” some substring of it. That is, if he answered YesYes, then you could hear esY, YesYes, sYes, e, but you c...
[{"input": "12\nYES\nesYes\ncodeforces\nes\nse\nYesY\nesYesYesYesYesYesYe\nseY\nYess\nsY\no\nYes\n", "output": "NO\nYES\nNO\nYES\nNO\nYES\nYES\nNO\nNO\nYES\nNO\nYES\n"}, {"input": "1\nsYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesY\n", "output": "YES\n"}, {"input": "1\nYesYesYesYesYesYesa\n", "output": "NO\n"}, {"in...
code_stdio
[ { "content": "There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. \n\nYou're giv...
[{"input": "100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n", "output...
code_stdio