messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Mr. Morishita was in trouble ... I had Mr. Anehara write a program, but the program crashed.\n\nMr. Anehara wrote a program that reads the formula in Reverse Polish Notation and outputs the calculation result. According to the crash log, it seems that the cause was that it was divided by 0. This m...
[{"input": "2\na 1 5\na 1 10\n5\n1 a a - -1", "output": "correct\n"}, {"input": "2\na 1 5\nb 1 10\n5\n1 a a - -1", "output": "correct\n"}, {"input": "2\na 1 5\na 0 10\n5\n1 a a - -1", "output": "correct\n"}, {"input": "2\na 1 5\nb 1 10\n5\n1 a b - -1", "output": "correct\n"}, {"input": "2\na 1 8\na 0 10\n5\n1 a a - -1"...
code_stdio
[ { "content": "A class of students wrote a multiple-choice test.\n\nThere are $n$ students in the class. The test had $m$ questions, each of them had $5$ possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question $i$ worth $a_i$ points. Incorrect an...
[{"input": "10 10\nCBBBBBBBBB\nABBBBEBBBB\nBDBBBBBBBB\nBCBBBBBBBB\nBABBBBBEBB\nEBBBBBBBBB\nBBBCBDCBBB\nBEBBEBBBBB\nBBBBBBBBBB\nBBBDBBBACB\n840 678 490 153 1118 84 256 405 468 856\n", "output": "45122\n"}, {"input": "10 10\nCBBBBBBBBB\nABBBBEBBBB\nBDBBBBBBBB\nBBBBBBBBBB\nBABBBBBEBB\nEBBBBBBBBB\nBBBCBDCBBB\nBEBBEBBBBB\nB...
code_stdio
[ { "content": "In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.\n\nMost damage those strange creatures inflicted upon the kingdom was that they loved high precision numb...
[{"input": "7002108534951820589946967018226114921984364117669853212254634761258884835434844673935047882480101006606512119541798298905598015607366335061012709906661245805358900665571472645463994925687210711492820804158354236327017974683658305043146543214454877759341394.202118562635032813887482826821207122147112325980213...
code_stdio
[ { "content": "You are given three multisets of pairs of colored sticks: $R$ pairs of red sticks, the first pair has length $r_1$, the second pair has length $r_2$, $\\dots$, the $R$-th pair has length $r_R$; $G$ pairs of green sticks, the first pair has length $g_1$, the second pair has length $g_2$, $\\dots...
[{"input": "16 26 8\n13 13 0 24 56 74 72 4 172 98 43 4 6 30 82 12\n31 6 76 15 88 37 22 64 44 55 18 67 12 65 10 24 83 23 27 101 198 2 58 59 34 38\n31 61 138 21 67 86 63 6\n", "output": "101183\n"}, {"input": "16 26 8\n13 13 0 24 56 74 88 4 172 98 43 4 6 30 82 12\n31 6 76 15 88 37 22 64 44 55 18 67 12 65 10 24 83 23 27 1...
code_stdio
[ { "content": "To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-lite...
[{"input": "10000 5000 5000 5000\n", "output": "6253751\n"}, {"input": "10000 4534 2345 4231\n", "output": "2069003\n"}, {"input": "8765 2432 2789 4993\n", "output": "1697715\n"}, {"input": "8987 4000 2534 4534\n", "output": "2536267\n"}, {"input": "7777 4444 3333 2222\n", "output": "1236544\n"}, {"input": "2500 5000 5...
code_stdio
[ { "content": "One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series \"Tufurama\". He was pretty surprised when he got results only for season 7 episode 3 with his search query of \"Watch Tufurama season 3 episode 7 online full hd free\". This got Polycarp confused — what if ...
[{"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "45\n"}, {"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "45\n"}, {"input": "8\n13 2 7 6 ...
code_stdio
[ { "content": "You are given a permutation p = (p_1, \\ldots, p_N) of \\\\{ 1, \\ldots, N \\\\}. You can perform the following two kinds of operations repeatedly in any order:\n\n* Pay a cost A. Choose integers l and r (1 \\leq l < r \\leq N), and shift (p_l, \\ldots, p_r) to the left by one. That is, replace p_...
[{"input": "4 1000000000 1000000000\n4 3 2 1", "output": "3000000000"}, {"input": "9 29 154\n2 3 6 7 6 1 2 12 8", "output": "174"}, {"input": "9 67 124\n5 3 4 7 6 1 3 24 8", "output": "402"}, {"input": "9 59 165\n5 4 4 5 8 1 2 12 7", "output": "354"}, {"input": "9 50 87\n16 2 4 7 6 1 3 12 8", "output": "300"}, {"input"...
code_stdio
[ { "content": "Consider an N \\times N matrix. Let us denote by a_{i, j} the entry in the i-th row and j-th column. For a_{i, j} where i=1 or j=1 holds, its value is one of 0, 1 and 2 and given in the input. The remaining entries are defined as follows:\n - a_{i,j} = \\mathrm{mex}(a_{i-1,j}, a_{i,j-1}) (2 \\leq ...
[{"input": "902\n0 1 1 2 0 2 0 2 2 0 2 0 0 1 0 2 1 0 0 1 1 1 2 0 0 2 0 2 1 2 0 2 2 0 1 2 0 0 2 1 1 0 2 0 0 1 2 0 0 1 0 0 1 1 2 0 0 0 2 2 0 2 1 0 0 2 2 0 0 2 2 1 0 2 2 2 2 0 0 0 1 1 2 0 2 0 1 2 1 1 0 0 1 2 2 2 1 0 2 0 1 2 2 1 2 2 0 0 2 0 1 0 1 0 2 0 0 2 0 0 2 1 2 1 0 2 2 1 1 2 0 2 1 0 1 2 0 0 2 0 0 1 1 2 0 1 2 2 0 0 0 1...
code_stdio
[ { "content": "You are given a set S of strings consisting of `0` and `1`, and an integer K.\n\nFind the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically smallest such string.\n\nHere, S is given in the...
[{"input": "4 1\n1\n01\n1101\n01011110\n1101110011011100", "output": "0000\n"}, {"input": "4 1\n1\n01\n1111\n00111110\n0101110011111101", "output": "0001\n"}, {"input": "4 4\n-1\n01\n1111\n10111010\n1101100011111101", "output": "000\n"}, {"input": "4 6\n1\n01\n1111\n10111010\n1101110011111101", "output": "100\n"}, {"in...
code_stdio
[ { "content": "Extended Euclid Algorithm\n\n\n\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nConstraints\n\n* 1 ≤ a, b ≤ 109\n\nInput\n\n\na b\n\n\nTwo positive integers a and b are given separated by a s...
[{"input": "810 11", "output": "-3 221\n"}, {"input": "277 5", "output": "-2 111\n"}, {"input": "195 10", "output": "1 -19\n"}, {"input": "174 10", "output": "-2 35\n"}, {"input": "41 52", "output": "-19 15\n"}, {"input": "789 7", "output": "3 -338\n"}, {"input": "383 5", "output": "2 -153\n"}, {"input": "41 59", "outp...
code_stdio
[ { "content": "T is playing a game with his friend, HL.\n\nThere are n piles of stones, the i-th pile initially has a_i stones. \n\nT and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile ...
[{"input": "4\n5\n1 3 1 3 4\n1\n4\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n3\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n1\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 2 3 1\n1\n1\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"},...
code_stdio
[ { "content": "Ziota found a video game called \"Monster Invaders\".\n\nSimilar to every other shooting RPG game, \"Monster Invaders\" involves killing monsters and bosses with guns.\n\nFor the sake of simplicity, we only consider two different types of monsters and three different types of guns.\n\nNamely, the ...
[{"input": "100 4 8 9 2\n1 8 0 8 7 8 1 8 7 4 0 9 4 2 1 7 3 7 3 7 1 8 7 14 4 10 11 7 3 5 9 7 4 9 6 10 4 5 5 2 5 2 8 4 5 3 1 6 8 8 10 6 7 2 1 6 2 8 3 9 7 4 18 6 7 8 5 2 5 16 3 8 4 11 0 3 5 10 6 1 4 8 14 17 2 2 9 3 7 3 3 3 10 19 3 5 3 1 3 3\n", "output": "1584\n"}, {"input": "100 4 8 9 2\n1 8 0 8 7 8 1 8 7 4 7 9 4 2 1 7 3...
code_stdio
[ { "content": "Computer graphics uses polygon models as a way to represent three-dimensional shapes. A polygon model is a model that creates a surface by giving the coordinates of vertices and how to connect those vertices.\n\nA general polygon model can handle any polygon, but this time we will consider a polyg...
[{"input": "6\n3 3 1\n1 2 4\n1 4 3\n-1 3 4\n5 -1 1\n2 3 1", "output": "0\n"}, {"input": "6\n3 3 1\n1 2 4\n1 4 3\n-1 4 4\n10 0 1\n2 3 1", "output": "0\n"}, {"input": "6\n3 1 1\n2 0 4\n0 4 1\n-1 4 4\n9 -1 2\n2 3 1", "output": "0\n"}, {"input": "6\n3 3 1\n1 2 4\n1 4 3\n-1 3 4\n5 0 1\n2 3 1", "output": "0\n"}, {"input": "6...
code_stdio
[ { "content": "F: Miko Mi String-\n\nstory\n\nMikko Mikkomi ~! Everyone's idol, Miko Miko Tazawa! Today ~, with Mikoto ~, practice the string algorithm, let's do it ☆\n\nMiko's special ~~ character making ~~ The slogan \"MikoMikomi\" becomes \"MikoMikoMi\" in Roman letters! In other words, if A = “Mi” and B = “K...
[{"input": "iNobiNociN", "output": "mitomerarenaiWA\n"}, {"input": "iNoaiNociN", "output": "mitomerarenaiWA\n"}, {"input": "iNoaiNochN", "output": "mitomerarenaiWA\n"}, {"input": "NhcoNiaoNi", "output": "mitomerarenaiWA\n"}, {"input": "NhcoNiNoai", "output": "mitomerarenaiWA\n"}, {"input": "NhcoNjNoai", "output": "mito...
code_stdio
[ { "content": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nO...
[{"input": "MDJivQRiOIVRcCdkSuUlNbMEOkIVJRMTAnHbkVaOmOblLfignh\n25\n", "output": "MDJIVQRIOIVRCCDKSUULNBMEOKIVJRMTANHBKVAOMOBLLFIGNH\n"}, {"input": "aaaaaaAAAaaaaAaaAaaAaaaaAAaAAAaaAAaaaAAaaaaaAaaAAa\n2\n", "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"}, {"input": "aaaaAaaaaaaAAaaAaaAaAaaaAaaaaaAAaaA...
code_stdio
[ { "content": "On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.\n\nThere are $n$ bricks lined in a row on the ground. Chouti has got $m$ paint buckets of different colors at hand, so he painted each brick in one of those $m$ colors.\n\nHaving finished p...
[{"input": "1411 1081 1082\n", "output": "238077838\n"}, {"input": "1841 1185 1765\n", "output": "773828348\n"}, {"input": "2000 1234 1800\n", "output": "550745740\n"}, {"input": "2000 2000 1999\n", "output": "694730459\n"}, {"input": "1411 1081 1082\n", "output": "238077838\n"}, {"input": "2000 1234 1800\n", "output":...
code_stdio
[ { "content": "On a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper.\n\nA permutation $p$ is written from left to right on the paper. First Qingshan chooses an integer index $x$ ($1\\le x\\le n$) a...
[{"input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 23 18 15 4 2 1\n", "output": "1\n"}, {"input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 ...
code_stdio
[ { "content": "Two coordinates (a1, a2) and (b1, b2) on a two-dimensional grid of r × c are given. The cost of moving from a cell (e, f) to one of the cells (e + 1, f), (e-1, f), (e, f + 1), (e, f-1) is 1. And. You can also move between (e, c-1) and (e, 0), and between (r-1, f) and (0, f) at a cost of 1. At this...
[{"input": "1226 500 1 0 107 129", "output": "14190866\n"}, {"input": "912 500 2 -1 107 239", "output": "98025026\n"}, {"input": "500 500 -1 0 107 239", "output": "68765037\n"}, {"input": "1174 500 0 0 107 298", "output": "74076242\n"}, {"input": "1226 500 1 0 107 168", "output": "37811899\n"}, {"input": "272 500 -1 0 ...
code_stdio
[ { "content": "There are 3N participants in AtCoder Group Contest. The strength of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength...
[{"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1100000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...
code_stdio
[ { "content": "We have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\nWe will cut the bar some number of times to divide it into some numbe...
[{"input": "10 1000 10000\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.\n\nConstraints\n\n* 1 ≤ length of T ≤ 1000\n* 1 ≤ length of P ≤ 1000\n* The input consists of alphabetical characters and digits\n\nInput\n\nIn the first line, a text T is gi...
[{"input": "aaaaaa\naa", "output": "0\n1\n2\n3\n4\n"}, {"input": "aaaaab\naa", "output": "0\n1\n2\n3\n"}, {"input": "`aaaaa\naa", "output": "1\n2\n3\n4\n"}, {"input": "aaabaa\naa", "output": "0\n1\n4\n"}, {"input": "aaaaba\naa", "output": "0\n1\n2\n"}, {"input": "abaaaa\naa", "output": "2\n3\n4\n"}, {"input": "aa`aaa\n...
code_stdio
[ { "content": "Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.\n\nAri draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then starting from the vertex 1 she draws a ray in the direct...
[{"input": "54321\n", "output": "2950553761\n"}, {"input": "54320\n", "output": "2950445124\n"}, {"input": "54319\n", "output": "2950336489\n"}, {"input": "54318\n", "output": "2950227856\n"}, {"input": "54317\n", "output": "2950119225\n"}, {"input": "54316\n", "output": "2950010596\n"}, {"input": "54315\n", "output": ...
code_stdio
[ { "content": "You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1.\n\nA substring of $s$ is a contiguous subsequence of its characters.\n\nYou have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two subs...
[{"input": "7\n1110010\n", "output": "1111110\n"}, {"input": "5\n11010\n", "output": "11111\n"}, {"input": "5\n10110\n", "output": "11111\n"}, {"input": "5\n10111\n", "output": "11111\n"}, {"input": "5\n11011\n", "output": "11111\n"}, {"input": "5\n11000\n", "output": "11110\n"}, {"input": "5\n10000\n", "output": "1100...
code_stdio
[ { "content": "-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane.\n\nEach of the next n lines contains two real coordinates x_{i} and y_{i} of the $i^{\\text{th}}$ point, specified with exactly 2 fractional digits. All coordinates are between - 1000 a...
[{"input": "14\n99.19 -882.27\n468.09 310.41\n-539.17 665.55\n-355.65 -90.01\n490.35 -966.88\n-102.77 252.81393817771362\n981.63 -976.33\n-362.0898056216629 -435.09\n-43.98678039025838 -37.28\n948.1448687933764 530.68\n49.38 -299.65\n503.33 684.17\n199.7398403612267 328.89\n31.24 65.36\n", "output": "-55.688"}, {"input...
code_stdio
[ { "content": "Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them ...
[{"input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"input": "1000100 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"input": "1000000 500000 1000000\n500000 1000000 500000\n", "outpu...
code_stdio
[ { "content": "Lindsey Buckingham told Stevie Nicks \"Go your own way\". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.\n\nConsider a hexagonal tiling of the plane as on the picture below. [Image] \n\nNicks wishes to go from the cell marked $(0, 0)$ to a cert...
[{"input": "2\n-3 1\n1 3 5 7 9 11\n1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "18\n1000000000000000000\n"}, {"input": "2\n-3 1\n1 3 5 7 9 11\n1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000 1100000000 1000000000\n", "output": "18\n1000000000...
code_stdio
[ { "content": "How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?\n - The n-th and subsequent elements are all equal. That is, if n \\leq i,j, a_i = a_j.\n - For every integer i, the a_i elements immediately following the i-th element are all equal. That is, i...
[{"input": "1000000\n", "output": "267909856\n"}, {"input": "654321\n", "output": "968545283\n"}, {"input": "999745\n", "output": "371558098\n"}, {"input": "999880\n", "output": "488039603\n"}, {"input": "999999\n", "output": "373070711\n"}, {"input": "380467\n", "output": "858853071\n"}, {"input": "407774\n", "output"...
code_stdio
[ { "content": "Tanya wants to go on a journey across the cities of Berland. There are $n$ cities situated along the main railroad line of Berland, and these cities are numbered from $1$ to $n$. \n\nTanya plans her journey as follows. First of all, she will choose some city $c_1$ to start her journey. She will vi...
[{"input": "15\n10 10 10 1 2 3 4 5 6 7 8 9 10 11 12\n", "output": "78\n"}, {"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "9\n18 11 24 7 18 10 1 20 17\n", "output": "24\n"}, {"input": "9\n4 10 21 7 23 9 15 11 12\n", "output": "44\n"}, {"input": "10\n12 14 1 2 3 4 5 6 7 8\n", "output": "...
code_stdio
[ { "content": "There are n wizards. They are numbered from 1 to n, and the i-th wizard has the magical power ri (1 ≤ i ≤ n). Now they are confronting a powerful wizard, whose enemy's magical power is S. n Wizards are good at fighting together, especially two people. When two wizards cooperate, the magical power ...
[{"input": "3 11\n0\n3\n10\n0 0", "output": "1\n"}, {"input": "3 11\n0\n3\n18\n0 0", "output": "2\n"}, {"input": "3 11\n0\n3\n20\n0 0", "output": "2\n"}, {"input": "3 13\n1\n3\n10\n0 0", "output": "0\n"}, {"input": "3 11\n0\n3\n17\n0 0", "output": "2\n"}, {"input": "3 22\n1\n3\n10\n0 0", "output": "0\n"}, {"input": "3 ...
code_stdio
[ { "content": "Sereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in other words, a string s of length n, consisting of characters \"(\" and \")\".\n\nSereja needs to answer m queries, each of them is described by two integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The answer to the i-th query is the length ...
[{"input": "(()((((()(())((((((((()((((((()((((\n71\n15 29\n17 18\n5 26\n7 10\n16 31\n26 35\n2 30\n16 24\n2 24\n7 12\n15 18\n12 13\n25 30\n1 30\n12 13\n16 20\n6 35\n20 28\n18 23\n9 31\n12 35\n14 17\n8 16\n3 10\n12 33\n7 19\n2 33\n7 17\n21 27\n10 30\n29 32\n9 28\n18 32\n28 31\n31 33\n4 26\n15 27\n10 17\n8 14\n11 28\n8 2...
code_stdio
[ { "content": "You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n - Choose two among A, B and C, then increase both by 1.\n - Choose one among A, B and C, then increase...
[{"input": "27 39 17\n", "output": "17\n"}, {"input": "19 43 41\n", "output": "13\n"}, {"input": "39 49 21\n", "output": "19\n"}, {"input": "26 37 19\n", "output": "16\n"}, {"input": "13 48 20\n", "output": "33\n"}, {"input": "31 41 5\n", "output": "23\n"}, {"input": "50 50 50\n", "output": "0\n"}, {"input": "50 50 49\...
code_stdio
[ { "content": "Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.\n\nThe only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segme...
[{"input": "3 2\n1000000000000000 1000000000000000\n3000000000000000 4000000000000000\n6000000000000000 7000000000000000\n2000000000000000 4000000000000000\n", "output": "Yes\n1 2 \n"}, {"input": "3 2\n1000000000000000 1000000000000000\n3000000000000000 4000000000000000\n6000000000000000 7000000000000000\n2000000000000...
code_stdio
[ { "content": "There are $n$ pillars aligned in a row and numbered from $1$ to $n$.\n\nInitially each pillar contains exactly one disk. The $i$-th pillar contains a disk having radius $a_i$.\n\nYou can move these disks from one pillar to another. You can take a disk from pillar $i$ and place it on top of pillar ...
[{"input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "output...
code_stdio
[ { "content": "Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m.\n\nYou are given a positive integer n.\n\nYour task is to find a quadratic subset of a set 1, 2, ..., n o...
[{"input": "17027\n", "output": "17024\n1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...
code_stdio
[ { "content": "Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him n subjects, the i^{th} subject has c_{i} chapters. When you teach him, you are supposed to teach all the chapters of a subject continuously.\n\nLet us say that his initial per chapter learning power of a subject is ...
[{"input": "20 8\n6 16 0 2 6 10 1 4 1 5 3 5 9 2 2 8 0 2 3 3\n", "output": "109\n"}, {"input": "20 8\n6 16 0 2 6 13 1 4 6 5 3 5 9 2 2 8 0 2 3 3\n", "output": "121\n"}, {"input": "20 8\n6 16 0 2 6 10 1 4 6 5 3 5 9 2 2 8 0 2 3 3\n", "output": "118\n"}, {"input": "20 10\n6 6 1 2 6 4 5 3 6 5 4 5 6 5 4 6 6 2 3 3\n", "output"...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \nSpring is interesting season of year. Chef is thinking about different things, but last time he thinks about interesting game - \"Strange Matrix\". \nChef has a matrix that consists of n rows, each contains m elements. Initially, the ele...
[{"input": "18 6 1\n0 3\n-1 7 \n3 2 \n4 1\n6 3\n7 2", "output": "5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n"}, {"input": "15 2 6\n3 0\n3 4 \n5 0 \n4 1\n4 0\n7 3", "output": "1\n1\n1\n0\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "13 4 6\n3 2\n3 4 \n5 0 \n4 0\n4 0\n7 3", "output": "3\n3\n4\n-1\n3\n3\n3\n...
code_stdio
[ { "content": "Little Dima has two sequences of points with integer coordinates: sequence (a_1, 1), (a_2, 2), ..., (a_{n}, n) and sequence (b_1, 1), (b_2, 2), ..., (b_{n}, n).\n\nNow Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that...
[{"input": "100\n2 2 10 3 5 6 4 7 9 8 2 7 5 5 1 7 5 9 2 2 10 3 6 10 9 9 10 7 3 9 7 8 8 3 9 3 9 3 3 6 3 7 9 9 7 10 9 1 1 3 6 2 9 5 9 9 6 2 6 5 6 8 2 10 1 1 6 8 8 4 5 2 6 8 8 5 9 2 3 3 7 7 10 5 4 2 10 6 7 6 5 4 10 6 10 3 9 9 1 5\n3 5 6 4 2 3 2 9 3 8 3 1 10 7 4 3 6 9 3 5 9 5 3 10 4 7 9 7 4 3 3 6 9 8 1 1 10 9 1 6 8 8 8 2 1...
code_stdio
[ { "content": "Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.\n\nLet's call a positive number special if it can be written as a sum of different non-negative powers of $n$. For example, for $n = 4$ n...
[{"input": "3\n6 10\n4 20\n105 276\n", "output": "222\n272\n456030397\n"}, {"input": "3\n6 11\n2 17\n105 194\n", "output": "223\n17\n136912005\n"}, {"input": "3\n6 7\n4 20\n105 276\n", "output": "43\n272\n456030397\n"}, {"input": "3\n6 7\n2 12\n105 276\n", "output": "43\n12\n456030397\n"}, {"input": "3\n2 26\n0 10\n105...
code_stdio
[ { "content": "You have decided to give an allowance to your child depending on the outcome of the game that he will play now.\nThe game is played as follows:\n - There are three \"integer panels\", each with a digit between 1 and 9 (inclusive) printed on it, and one \"operator panel\" with a + printed on it.\n ...
[{"input": "-1 12 1", "output": "120\n"}, {"input": "9 9 9\n", "output": "108\n"}, {"input": "9 2 8\n", "output": "100\n"}, {"input": "7 9 7\n", "output": "104\n"}, {"input": "9 9 4\n", "output": "103\n"}, {"input": "1 11 1", "output": "112\n"}, {"input": "1 21 1", "output": "212\n"}, {"input": "2 21 1", "output": "213...
code_stdio
[ { "content": "Levian works as an accountant in a large company. Levian knows how much the company has earned in each of the n consecutive months — in the i-th month the company had income equal to a_i (positive income means profit, negative income means loss, zero income means no change). Because of the general...
[{"input": "17\n-542470641 -617247806 1649173051 111521800 509758067 -860452587 447120886 234437807 707835273\n5\n", "output": "17\n"}, {"input": "17\n-542470641 -617247806 998970243 699622219 732907519 -860452587 447120886 203125491 707835273\n5\n", "output": "17\n"}, {"input": "17\n-542470641 -617247806 998970243 699...
code_stdio
[ { "content": "A breakthrough among computer games, \"Civilization XIII\", is striking in its scale and elaborate details. Let's take a closer look at one of them.\n\nThe playing area in the game is split into congruent cells that are regular hexagons. The side of each cell is equal to 1. Each unit occupies exac...
[{"input": "1000000\n", "output": "1209197264797\n"}, {"input": "1010000\n", "output": "1233502153639\n"}, {"input": "1010100\n", "output": "1233746427001\n"}, {"input": "999811\n", "output": "1208740231393\n"}, {"input": "999998\n", "output": "1209192430093\n"}, {"input": "999999\n", "output": "1209194850235\n"}, {"in...
code_stdio
[ { "content": "You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.\n\nYou want to find a subset of items to put such that:\n\n* The total value of the items is as large as possible.\n* The items have combined weight at most $W$, that is capac...
[{"input": "5 1000001100\n3 1 1000000010\n7 10 1000100110\n7 3 1000000000\n11 27 1100000000\n2 7 1000000000", "output": "3000002572\n"}, {"input": "5 1000000000\n1 1 1000000000\n7 11 1000100000\n4 4 1000000000\n6 20 1000000100\n3 5 1000000000", "output": "1000000000\n"}, {"input": "5 1000000000\n4 1 1000000000\n11 2 10...
code_stdio
[ { "content": "One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of...
[{"input": "1001000000 10\n", "output": "900900002\n"}, {"input": "1000010000 10\n", "output": "900009002\n"}, {"input": "1000100000 10\n", "output": "900090002\n"}, {"input": "1000101000 10\n", "output": "900090903\n"}, {"input": "1000000000 10\n", "output": "900000001"}, {"input": "177583558 15\n", "output": "1657446...
code_stdio
[ { "content": "Polycarp lives on the coordinate axis $Ox$ and travels from the point $x=a$ to $x=b$. It moves uniformly rectilinearly at a speed of one unit of distance per minute.\n\nOn the axis $Ox$ at the point $x=c$ the base station of the mobile operator is placed. It is known that the radius of its coverag...
[{"input": "9\n4 17 0 0\n0 6 0 0\n5 0 7 3\n52 2 20 010\n-11 20 -40 0\n2 2 0 0\n-2 0 1 4\n-1 4 0 2\n0 4 -10 0\n", "output": "13\n6\n4\n30\n31\n0\n0\n2\n4\n"}, {"input": "9\n1 10 7 1\n3 3 1 0\n8 2 10 4\n10 2 10 100\n-10 20 -17 2\n-3 1 0 0\n-3 1 2 0\n2 3 0 3\n-1 1 -2 2\n", "output": "7\n0\n4\n0\n30\n4\n4\n0\n1\n"}, {"inpu...
code_stdio
[ { "content": "You are given a string $s$ consisting of lowercase Latin letters and $q$ queries for this string.\n\nRecall that the substring $s[l; r]$ of the string $s$ is the string $s_l s_{l + 1} \\dots s_r$. For example, the substrings of \"codeforces\" are \"code\", \"force\", \"f\", \"for\", but not \"code...
[{"input": "dfcbbcfeeedbaea\n15\n1 1 e\n1 4 b\n2 10 15\n1 7 b\n1 12 c\n2 6 8\n2 1 6\n1 7 c\n1 2 f\n1 10 a\n2 7 11\n1 10 a\n1 14 b\n1 1 f\n2 1 11\n", "output": "4\n3\n4\n4\n6\n"}, {"input": "decbbcfeeedbafa\n15\n1 1 e\n1 4 b\n2 10 15\n1 7 b\n1 12 c\n2 6 8\n2 1 6\n1 7 c\n1 2 f\n1 10 a\n2 7 11\n1 10 a\n1 14 b\n1 1 f\n2 1 ...
code_stdio
[ { "content": "Taro Aizu's company has a boss who hates being indivisible. When Taro goes out to eat with his boss, he pays by splitting the bill, but when the payment amount is not divisible by the number of participants, his boss always pays for it.\n\nOne day, Taro became the secretary of the dinner party. Mr...
[{"input": "4 15000\n520\n41\n129\n500\n3 1047\n6\n20\n25\n3 359208\n5\n14\n17\n0 0", "output": "14983\n1039\n359207\n"}, {"input": "4 15000\n305\n260\n136\n500\n3 400\n10\n23\n30\n3 599838\n5\n1\n12\n0 0", "output": "14983\n397\n599831\n"}, {"input": "4 29657\n305\n131\n129\n500\n3 400\n10\n20\n30\n3 337371\n1\n14\n12...
code_stdio
[ { "content": "A great king of a certain country suddenly decided to visit the land of a friendly country. The country is famous for trains, and the king visits various stations.\n\nThere are 52 train stations, each with a single uppercase or lowercase alphabetic name (no overlapping names). The line of this tra...
[{"input": "2\n1 2\nadd\n3\n12 4 0\nDDDA\n5\n3 1 3 5 2\ndcdkIlkP\n0", "output": "Zbc\nrzDo\nabafGijM\n"}, {"input": "2\n1 2\nadd\n3\n12 4 1\nDDDA\n5\n3 1 3 5 2\ndcdkIlkP\n0", "output": "Zbc\nrzCo\nabafGijM\n"}, {"input": "2\n1 0\nadd\n3\n12 4 1\nDDDA\n5\n3 1 3 5 2\ndcdkIlkP\n0", "output": "Zdc\nrzCo\nabafGijM\n"}, {"in...
code_stdio
[ { "content": "Professor GukiZ makes a new robot. The robot are in the point with coordinates (x_1, y_1) and should go to the point (x_2, y_2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find t...
[{"input": "-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "2000000000\n"}, {"input": "-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "2000000000\n"}, {"input": "-1000000000 -1000000000\n1000000000 1000000000\n", "output": "2000000000\n"}, {"input": "-1000000000 1000000000\n1000000000 -100...
code_stdio
[ { "content": "Given is a string S of length N.\nFind the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.\nMore formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \\leq l_1, l_2 \\leq N - len + 1 ) that ...
[{"input": "5000\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "One day Nikita found the string containing letters \"a\" and \"b\" only. \n\nNikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters \"a\" and the 2-nd contains only lett...
[{"input": "bbabbbbbaaba\n", "output": "10\n"}, {"input": "bbbbbbabaaaa\n", "output": "11\n"}, {"input": "bbabbbbabbbb\n", "output": "10\n"}, {"input": "baabbbbbaaba\n", "output": "10\n"}, {"input": "baabaaaabbaa\n", "output": "10\n"}, {"input": "baabbbbbabba\n", "output": "10\n"}, {"input": "bbabbbabbbbb\n", "output":...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nThe following is an easy game that the setter of this problem played when he was 8:\n\nA boatman, a wolf, a sheep, and a cabbage are on the bank of a river. They have a small boat that is capable of carrying the boatman and at most one...
[{"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n2 3\n2 4", "output": "YES\nYES\n"}, {"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n2 1\n2 4", "output": "YES\nYES\n"}, {"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n2 1\n2 2", "output": "YES\nYES\n"}, {"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n0 1\n2 2", "output": "YES\nYES\n"}, {"input": "...
code_stdio
[ { "content": "Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information.\n\nZhorik knows that each of the messages is an archive containing one or more files. Zhorik knows how each of these ...
[{"input": "50 50\n5733 740 547 3647 5382 5109 6842 7102 5879 1502 3574 1628 7905 4357 8569 9564 8268 3542 2487 8532 425 7713 2585 925 6458 2697 2844 69 324 9030 495 4428 6724 3524 3304 4874 1303 2098 1136 1048 2464 7316 274 9586 534 2450 2368 8060 7795 70692\n1918 4122 6806 4914 6517 6278 9842 9480 6609 4221 9373 1728...
code_stdio
[ { "content": "There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is h_{i} meters, distinct planks can have distinct heights. [Image] Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] \n\nPolycar...
[{"input": "10 5\n1 2 3 1 2 2 3 1 4 5\n", "output": "1\n"}, {"input": "10 2\n3 1 4 1 4 6 2 1 4 6\n", "output": "7\n"}, {"input": "10 4\n1 1 1 4 4 4 4 4 4 3\n", "output": "1\n"}, {"input": "10 2\n3 1 4 1 4 6 2 1 4 6\n", "output": "7\n"}, {"input": "10 4\n1 1 1 4 4 4 4 4 4 3\n", "output": "1\n"}, {"input": "10 5\n1 2 3 1...
code_stdio
[ { "content": "You are given an array a_1, a_2, ..., a_n and an array b_1, b_2, ..., b_n.\n\nFor one operation you can sort in non-decreasing order any subarray a[l ... r] of the array a.\n\nFor example, if a = [4, 2, 2, 1, 3, 1] and you choose subbarray a[2 ... 5], then the array turns into [4, 1, 2, 2, 3, 1]. ...
[{"input": "10\n3\n1 2 1\n3 1 2\n1\n1\n1\n19\n15 10 19 11 6 16 1 5 1 14 8 6 8 7 1 8 1 5 13\n7 13 18 9 16 11 1 2 17 13 1 16 13 19 4 3 9 7 3\n15\n9 3 2 15 8 4 10 10 2 12 1 9 5 7 8\n4 5 6 15 1 7 9 10 3 2 1 2 14 6 12\n16\n5 6 11 12 8 2 3 12 2 4 6 15 2 8 15 7\n15 5 3 12 14 2 9 11 14 13 13 14 14 1 7 7\n17\n8 10 4 6 11 7 14 4...
code_stdio
[ { "content": "Two players play a game.\n\nInitially there are $n$ integers $a_1, a_2, \\ldots, a_n$ written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. $n - 1$ turns are made. The first player makes the ...
[{"input": "10\n58 26 65 15 13 81 111 48 22 50\n", "output": "48\n"}, {"input": "10\n58 26 65 15 13 81 111 48 22 55\n", "output": "48\n"}, {"input": "10\n58 26 77 15 53 81 68 48 22 65\n", "output": "53\n"}, {"input": "10\n58 26 77 15 13 81 68 48 22 65\n", "output": "48\n"}, {"input": "10\n58 26 77 15 13 81 68 48 22 50\...
code_stdio
[ { "content": "First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. \n\nFor ex...
[{"input": "prntaxhysjfcfmrjngdsitlguahtpnwgbaxptubgpwcfxqehrulbxfcjssgocqncscduvyvarvwxzvmjoatnqfsvsilubexmwugedtzavyamqjqtkxzuslielibjnvkpvyrbndehsqcaqzcrmomqqwskwcypgqoawxdutnxmeivnfpzwvxiyscbfnloqjhjacsfnkfmbhgzpujrqdbaemjsqphokkiplblbflvadcyykcqrdohfasstobwrobslaofbasylwiizrpozvhtwyxtzl\n", "output": "505\nac\nacs...
code_stdio
[ { "content": "An ant moves on the real line with constant speed of $1$ unit per second. It starts at $0$ and always moves to the right (so its position increases by $1$ each second).\n\nThere are $n$ portals, the $i$-th of which is located at position $x_i$ and teleports to position $y_i < x_i$. Each portal can...
[{"input": "5\n370534603 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n1000000000 500000000 0\n", "output": "444580501\n"}, {"input": "5\n370534603 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n1010000000 500000000 0\n", "output": "454580501\n"}, {...
code_stdio
[ { "content": "The full exploration sister is a very talented woman. Your sister can easily count the number of routes in a grid pattern if it is in the thousands. You and your exploration sister are now in a room lined with hexagonal tiles. The older sister seems to be very excited about the hexagon she sees fo...
[{"input": "-2 1 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n2 5", "output": "-1\n"}, {"input": "-2 1 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n3 5", "output": "-1\n"}, {"input": "-2 0 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n3 5", "output": "-1\n"}, {"input": "-4 0 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n...
code_stdio
[ { "content": "Ksusha is a beginner coder. Today she starts studying arrays. She has array a_1, a_2, ..., a_{n}, consisting of n positive integers.\n\nHer university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help her and find the number!\n\n\n-----Input-...
[{"input": "5\n506904227 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"input": "5\n506904227 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"input": "5\n238711016 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"input": "5\n310947607 214303304 136194869 838256937 1839...
code_stdio
[ { "content": "Someone gave Alyona an array containing n positive integers a_1, a_2, ..., a_{n}. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. ...
[{"input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "output": "9\n"}, {"input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "output": "9\n"}, {"input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 11000000\n", "output": "9\n"}, {...
code_stdio
[ { "content": "A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.\n\nThe number is called beautiful if it consists of at least one digit, ...
[{"input": "53684795681792590016697187295561462737810600000146840941336328677293748561247888801665863139922929397968535048060292988802347668853531069156825523164438370977880256909710958836918627008217572514193873141535365258436916984535972865113877338591947508645026570682995314540038481160747606741045307222213966802022...
code_stdio
[ { "content": "An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\nYou can do the following two kinds of operations any number of times in any order:\n - Choos...
[{"input": "8\nWRWWRWRR\n", "output": "3\n"}, {"input": "8\nRRWRWWRW", "output": "1\n"}, {"input": "8\nRRWWWRRW", "output": "2\n"}, {"input": "8\nWRWWWRRR", "output": "3\n"}, {"input": "8\nWWWWRRRR", "output": "4\n"}, {"input": "8\nRRWRVWRW", "output": "1\n"}, {"input": "8\nWRRWWWRR", "output": "2\n"}, {"input": "8\nRR...
code_stdio
[ { "content": "While playing with geometric figures Alex has accidentally invented a concept of a $n$-th order rhombus in a cell grid.\n\nA $1$-st order rhombus is just a square $1 \\times 1$ (i.e just a cell).\n\nA $n$-th order rhombus for all $n \\geq 2$ one obtains from a $n-1$-th order rhombus adding all cel...
[{"input": "100\n", "output": "19801\n"}, {"input": "100\n", "output": "19801"}, {"input": "72\n", "output": "10225\n"}, {"input": "94\n", "output": "17485\n"}, {"input": "77\n", "output": "11705\n"}, {"input": "86\n", "output": "14621\n"}, {"input": "98\n", "output": "19013\n"}, {"input": "75\n", "output": "11101\n"},...
code_stdio
[ { "content": "Tired of boring office work, Denis decided to open a fast food restaurant.\n\nOn the first day he made $a$ portions of dumplings, $b$ portions of cranberry juice and $c$ pancakes with condensed milk.\n\nThe peculiarity of Denis's restaurant is the procedure of ordering food. For each visitor Denis...
[{"input": "7\n1 4 1\n0 0 0\n16 0 1\n2 2 2\n2 3 2\n3 2 2\n0 4 4\n", "output": "3\n0\n2\n4\n5\n5\n3\n"}, {"input": "7\n0 1 1\n0 0 0\n11 1 1\n2 2 4\n3 3 3\n4 2 3\n0 6 1\n", "output": "2\n0\n3\n5\n6\n5\n2\n"}, {"input": "7\n1 2 1\n0 0 0\n16 1 1\n2 2 2\n2 3 2\n3 2 2\n0 4 4\n", "output": "3\n0\n3\n4\n5\n5\n3\n"}, {"input": ...
code_stdio
[ { "content": "M-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i ...
[{"input": "8\n285 224 U\n130 175 R\n111 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"input": "8\n285 224 U\n130 175 R\n101 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"input": "8\n285 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n11...
code_stdio
[ { "content": "Shell Sort\n\nShell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$.\n\n\n1 insertionSort(A, n, g)\n2 for i = g to n-1\n3 v = A[i]\n4 j = i - g\n5 while j >= 0 && A[j] > v\n6 A[j+g] = A[j]\n7 j = j - g\n8 ...
[{"input": "5\n10\n1\n5\n9\n1", "output": "2\n4 1\n1\n1\n1\n5\n9\n10\n"}, {"input": "5\n10\n1\n5\n7\n1", "output": "2\n4 1\n1\n1\n1\n5\n7\n10\n"}, {"input": "5\n6\n1\n10\n7\n1", "output": "2\n4 1\n4\n1\n1\n6\n7\n10\n"}, {"input": "5\n6\n1\n1\n13\n2", "output": "2\n4 1\n4\n1\n1\n2\n6\n13\n"}, {"input": "5\n6\n1\n2\n13\n...
code_stdio
[ { "content": "Monocarp is playing a computer game. In this game, his character fights different monsters.\n\nA fight between a character and a monster goes as follows. Suppose the character initially has health $h_C$ and attack $d_C$; the monster initially has health $h_M$ and attack $d_M$. The fight consists o...
[{"input": "2\n1000000000000000 1\n1000000000000000 200000\n0 1 1\n1000000000000000 200000\n1000000000000000 1\n0 1 1\n", "output": "NO\nYES\n"}, {"input": "2\n1000000000000000 1\n1000000000000000 1000000000\n1000 10000 10000000000\n9 2\n16 4\n0 10 10\n", "output": "NO\nNO\n"}, {"input": "4\n25 4\n9 20\n1 1 10\n25 4\n1...
code_stdio
[ { "content": "The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the condition: for all i (1 ≤ i < n), a_{i} + 1 - a_{i} = k, ...
[{"input": "50 5\n232 6 17 6 21 26 27 36 41 88 665 56 61 66 71 76 602 86 28 712 101 106 111 116 121 126 131 136 141 146 151 156 161 166 755 176 181 186 191 196 201 206 211 216 5 226 172 236 241 246\n", "output": "12\n- 1 231\n- 3 6\n+ 4 10\n+ 7 4\n- 10 42\n- 11 614\n- 17 521\n+ 19 63\n- 20 616\n- 35 584\n+ 45 216\n+ 47...
code_stdio
[ { "content": "VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.\n\nThe latest A/B test suggests that users are reading recommended pub...
[{"input": "40\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 6 4 4 12 5 4 11 8 1 2 8 11 19 18 4\n52258 5648 46847 9200 101064 79328 64407 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 19254 81295 9711 72350 1...
code_stdio
[ { "content": "You are given three strings A, B and C. Check whether they form a word chain.\nMore formally, determine whether both of the following are true:\n - The last character in A and the initial character in B are the same.\n - The last character in B and the initial character in C are the same.\nIf both...
[{"input": "aaaaaaaaab aaaaaaaaaa aaaaaaaaab\n", "output": "NO\n"}, {"input": "baaaa`aaaa aabaaaaaaa aaaaa`aaab", "output": "YES\n"}, {"input": "baaaaaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"input": "baaabaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"input": "baaabaaa`` `aaabaabaa aaaaa`aaab", "output"...
code_stdio
[ { "content": "This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decided to pursue a fighter's career. He decided to begin with an ongoing tourname...
[{"input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n18 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35852\n9 107522\n10 54717\...
code_stdio
[ { "content": "Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert. \n\nOn the day of the party, the Chef was over-seeing all the food arrangements as well, ensuring that every item wa...
[{"input": "4\n38\n13\n31\n2", "output": "17\n12\n30\n1\n"}, {"input": "4\n38\n13\n16\n2", "output": "17\n12\n0\n1\n"}, {"input": "4\n131\n14\n1\n4", "output": "130\n5\n0\n0\n"}, {"input": "4\n19\n13\n16\n2", "output": "18\n12\n0\n1\n"}, {"input": "4\n131\n14\n1\n8", "output": "130\n5\n0\n2\n"}, {"input": "4\n34\n13\n1...
code_stdio
[ { "content": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya encountered a tree with n vertexes. Besides, the tree was weig...
[{"input": "10\n4 7 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 1310915575\n8 10 838073755\n5 10 547050646\n2 1 12607780\n", "output": "0\n"}, {"input": "10\n4 7 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 1310915575\n8 10 838073755\n5 10 508595582\n2 1 126077...
code_stdio
[ { "content": "Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched o...
[{"input": "62 74 119\n116 74 189\n2 47 95\n", "output": "101\n110\n010\n"}, {"input": "68 79 52\n51 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"input": "68 79 52\n51 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"input": "68 79 52\n67 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"input": "13 148 ...
code_stdio
[ { "content": "problem\n\nThe island where JOI lives has been invaded by zombies. JOI decided to escape to the shelter, which is set as the safest shelter on the island.\n\nThe island where JOI lives consists of N towns from town 1 to town N, and the towns are connected by roads. There are M roads on the island,...
[{"input": "13 21 1 1\n1001 6000\n11\n4 2\n3 7\n2 4\n8 8\n8 4\n2 10\n3 4\n6 7\n7 10\n10 11\n5 9\n11 10\n3 6\n4 5\n1 6\n13 12\n6 7\n8 11\n6 13\n7 8\n2 12", "output": "1001\n"}, {"input": "13 21 1 1\n1010 10247\n7\n1 2\n3 7\n2 4\n5 8\n8 9\n2 5\n3 4\n4 7\n9 10\n10 11\n9 9\n7 12\n3 6\n5 5\n1 3\n11 12\n6 7\n8 11\n6 13\n7 8\...
code_stdio
[ { "content": "Vasya decided to go to the grocery store. He found in his wallet $a$ coins of $1$ burle and $b$ coins of $2$ burles. He does not yet know the total cost of all goods, so help him find out $s$ ($s > 0$): the minimum positive integer amount of money he cannot pay without change or pay at all using o...
[{"input": "7\n1 1\n4 0\n0 2\n0 0\n2314 2374\n0 0\n1 1\n", "output": "4\n5\n1\n1\n7063\n1\n4\n"}, {"input": "5\n1 1\n4 0\n0 2\n0 0\n2314 2374\n", "output": "4\n5\n1\n1\n7063\n"}, {"input": "1\n1123112 1221133\n", "output": "3565379\n"}, {"input": "1\n1223111 133212\n", "output": "1489536\n"}, {"input": "1\n112311 11332...
code_stdio
[ { "content": "You have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n - YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n - MMYY format: the two-digit representation of t...
[{"input": "0112\n", "output": "AMBIGUOUS\n"}, {"input": "0101\n", "output": "AMBIGUOUS\n"}, {"input": "1211", "output": "AMBIGUOUS\n"}, {"input": "1204", "output": "AMBIGUOUS\n"}, {"input": "0112", "output": "AMBIGUOUS"}, {"input": "1905\n", "output": "YYMM\n"}, {"input": "1312\n", "output": "YYMM\n"}, {"input": "0348...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nRupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A_{1}, A_{2}, ..., A_{N} respectively to store it. But as she is lazy to arrange them she puts them all in a storage box.\n\nChef comes...
[{"input": "2\n-1\n3 111\n-1\n9", "output": "113\n2\n"}, {"input": "2\n-1\n3 101\n-1\n9", "output": "103\n2\n"}, {"input": "2\n-2\n2 25\n-2\n16", "output": "27\n2\n"}, {"input": "2\n-1\n3 12\n-1\n9", "output": "14\n2\n"}, {"input": "2\n-1\n2 24\n0\n1", "output": "26\n-1\n"}, {"input": "2\n-1\n2 32\n0\n1", "output": "34...
code_stdio
[ { "content": "In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage.\n\nA Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules:\n\n* A Snuke Chameleon that is blue...
[{"input": "29001 234567", "output": "246712986\n"}, {"input": "29001 137176", "output": "790285595\n"}, {"input": "18209 234567", "output": "750285457\n"}, {"input": "24437 137176", "output": "159086230\n"}, {"input": "123456 234567", "output": "857617983"}, {"input": "25732 234567", "output": "80550073\n"}, {"input":...
code_stdio
[ { "content": "According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should ...
[{"input": "20 19\n1111111111111111111\n8247715032316286876\n0000001000000000000\n4784876473600342372\n1111111111111111111\n2222222222222222222\n4444444444444444444\n5555555555555555555\n0000000000000000010\n4444444444444444444\n0000000000000000000\n5555555555555555555\n11500026576261848309\n9999999999999999999\n222222...
code_stdio
[ { "content": "After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one ...
[{"input": "1000000 1000000\n", "output": "200000000000\n"}, {"input": "1000000 1000000\n", "output": "200000000000\n"}, {"input": "1000010 1000000\n", "output": "200002000000\n"}, {"input": "1000000 1892547\n", "output": "378509400000\n"}, {"input": "1000000 999999\n", "output": "199999800000\n"}, {"input": "1000000 9...
code_stdio
[ { "content": "When you play the game of thrones, you win, or you die. There is no middle ground.\n\nCersei Lannister, A Game of Thrones by George R. R. Martin\n\nThere are n nobles, numbered from 1 to n. Noble i has a power of i. There are also m \"friendships\". A friendship between nobles a and b is always mu...
[{"input": "20 53\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 20\n2 3\n2 6\n2 16\n2 17\n3 6\n3 18\n3 20\n4 6\n4 7\n4 8\n4 18\n4 14\n4 18\n5 11\n5 16\n5 17\n2 18\n5 19\n6 8\n6 13\n7 8\n7 10\n7 15\n7 17\n14 18\n8 15\n8 16\n4 10\n17 15\n10 11\n10 17\n10 20\n11 15\n11 17\n12 14\n12 15\n12 16\n16 19\n14 16\n14 19\n16 17\n16 19\n16 20\...
code_stdio
[ { "content": "You are given strings $S$ and $T$, consisting of lowercase English letters. It is guaranteed that $T$ is a permutation of the string abc.\n\nFind string $S'$, the lexicographically smallest permutation of $S$ such that $T$ is not a subsequence of $S'$.\n\nString $a$ is a permutation of string $b$ ...
[{"input": "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabc\nac\nabc\n", "output": "aaaacbb\nabccc\nbcdis\naaaaacbbdrr\ndddddddddddd\nbbc\nac\n"}, {"input": "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabd\nac\nabc\n", "output": "aaaacbb\nabc...
code_stdio
[ { "content": "Create a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface distance between two points is the shortest distance along this sphere. Also,...
[{"input": "35.997652258458864 139.77 51.15 361.449066466584\n1.6512558665331527 105.35573273382599 41.78 272.61282853754\n51.62303215206055 360.59086045680647 -34.03891385785915 302.61951676416413\n-1 -1 -1 -1", "output": "9516\n15035\n11082\n"}, {"input": "36.419905643051294 140.79075983005347 51.9267392966014 359.97...
code_stdio
[ { "content": "Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.\n\nNow he tries to solve a quest. The task is to come t...
[{"input": "10 5\n1 6 2 11 3 8 4 9 5 10\n1 2\n3 5\n5 6\n7 10\n9 10\n", "output": "27\n"}, {"input": "10 3\n1 6 2 27 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n", "output": "45\n"}, {"input": "10 3\n1 6 2 17 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n", "output": "35\n"}, {"input": "10 3\n1 6 2 17 1 8 1 9 5 1\n1 2\n3 1\n10 ...
code_stdio
[ { "content": "Given are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are mult...
[{"input": "51 100\n70 94 98 62 63 19 59 50 36 48 97 82 53 5 3 96 51 13 64 79 65 23 75 72 74 87 100 43 81 42 71 34 57 88 60 77 31 12 10 52 29 92 66 1 61 90 21 55 22 30 14 35 41 2 78 37 15 73 69 58 25 67 28 16 99 38 85 33 20 95 32 24 80 40 4 45 11 83 7 17 91 89 54 18 26 56 9 27 68 47 76 93 39 84 8 49 86 6 44 46\n", "out...
code_stdio
[ { "content": "Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \\ge i$).\n\nIvan wants to read the whole book. Each day,...
[{"input": "17\n15 4 3 6 5 11 8 8 9 10 15 12 13 14 17 16 17\n", "output": "1\n"}, {"input": "17\n16 4 3 6 7 6 10 8 9 10 11 12 13 14 15 16 17\n", "output": "2\n"}, {"input": "17\n9 4 3 6 7 6 10 8 9 10 11 12 13 14 15 16 17\n", "output": "8\n"}, {"input": "17\n15 4 3 6 7 6 8 8 9 10 15 12 13 14 17 16 17\n", "output": "1\n"...
code_stdio
[ { "content": "Let x be a string of length at least 1.\nWe will call x a good string, if for any string y and any integer k (k \\geq 2), the string obtained by concatenating k copies of y is different from x.\nFor example, a, bbc and cdcdc are good strings, while aa, bbbb and cdcdcd are not.\nLet w be a string o...
[{"input": "bcbc\n", "output": "2\n3\n"}, {"input": "aab\n", "output": "1\n1\n"}, {"input": "ddd\n", "output": "3\n1\n"}, {"input": "adad", "output": "2\n3\n"}, {"input": "bbcc", "output": "1\n1\n"}, {"input": "ccbb", "output": "1\n1\n"}, {"input": "ccbc", "output": "1\n1\n"}, {"input": "cbbc", "output": "1\n1\n"}, {"i...
code_stdio
[ { "content": "problem\n\nThere is one bar-shaped candy with a length of N mm (where N is an even number). Two JOI officials decided to cut this candy into multiple pieces and divide them into a total of N / 2 mm. did.\n\nFor unknown reasons, this candy has different ease of cutting depending on the location. Th...
[{"input": "6\n-1\n0\n14\n-1\n6", "output": "-2\n"}, {"input": "6\n-1\n0\n14\n-2\n6", "output": "-3\n"}, {"input": "6\n0\n0\n14\n-4\n6", "output": "-4\n"}, {"input": "6\n0\n0\n5\n-1\n1", "output": "-1\n"}, {"input": "6\n1\n14\n11\n3\n2", "output": "4\n"}, {"input": "6\n2\n12\n11\n7\n3", "output": "9\n"}, {"input": "6\n...
code_stdio
[ { "content": "Kolya got an integer array $a_1, a_2, \\dots, a_n$. The array can contain both positive and negative integers, but Kolya doesn't like $0$, so the array doesn't contain any zeros.\n\nKolya doesn't like that the sum of some subsegments of his array can be $0$. The subsegment is some consecutive segm...
[{"input": "100\n-6 2 8 -9 -9 3 -3 -2 7 3 2 -2 -9 -7 -10 -9 10 4 5 -9 8 -5 7 -2 6 -2 4 4 -2 -5 6 4 8 -8 9 7 -4 2 -3 7 4 -10 -7 -4 8 2 10 -8 -3 -8 -5 -5 -10 -6 -8 -5 7 -1 7 -5 9 10 3 5 10 -7 -3 -7 1 -5 -8 5 1 -1 4 10 2 6 -4 9 3 10 -5 -10 -10 -2 1 9 10 1 10 2 8 -3 -3 -1 7 -5 8 -4\n", "output": "11\n"}, {"input": "100\n-6...
code_stdio
[ { "content": "All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats themselves. Formerly the choice was made by a cashier, but ...
[{"input": "100 67\n66 12 2 49 62 63 59 14 13 26 15 25 22 16 33 17 15 14 13 33 9 10 53 28 17 27 18 39 35 64 1 59 33 24 66 64 4 2 4 5 22 9 52 36 44 57 62 3 52 21 62 55 25 2 65 18 20 40 8 30 27 28 47 19 67 67 42 6 53 17 36 38 57 37 45 13 58 12 31 24 15 67 9 18 56 20 34 8 20 31 13 19 42 12 16 15 54 35 20 33\n", "output": ...
code_stdio
[ { "content": "It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..\n\nThere is a glob pattern in the statements (a string consisting of lowercase English letters, characters...
[{"input": "k\n*\n89\nb\ncbbbc\ncabac\nbccbb\nccc\ncabaa\nabbaa\nccbaa\nccccb\ncabbb\nbbcbc\nbac\naaac\nabb\nbcbb\ncb\nbacc\nbbaba\nb\nacc\nbaac\naaba\nbcbba\nbaa\nbc\naaccb\nb\nab\nc\nbbbb\nabbcb\nacbb\ncba\nc\nbac\nc\nac\ncc\nb\nbbc\nbaab\nc\nbbc\nab\nb\nc\naa\naab\nab\naccbc\nacbaa\na\nccc\ncba\nb\nb\nbcccb\nca\naca...
code_stdio
[ { "content": "Alice and Bob like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed for the player to consume it, is known (Alice...
[{"input": "13\n4 18 16 10 10 13 24 2 4 9 2 10 13\n", "output": "6 7\n"}, {"input": "13\n4 18 16 10 10 13 17 2 4 9 2 9 13\n", "output": "5 8\n"}, {"input": "13\n4 18 16 10 10 13 24 2 4 9 2 9 13\n", "output": "6 7\n"}, {"input": "13\n4 18 16 10 10 14 24 2 4 9 2 9 13\n", "output": "6 7\n"}, {"input": "13\n4 18 16 10 7 14...
code_stdio
[ { "content": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding fo...
[{"input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"input": "10\n5 20 18 1 12 17 22 20 26 4\n", "output": "21\n"}, {"input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"input": "10\n5 20 18 1 12 17 22 20 26 4\n", "output": "21\n"}, {"input": "10\n9 16 19 23 7 14 21 15 1 6\n", "output": "20\...
code_stdio
[ { "content": "Given is an integer sequence of length N: A_1, A_2, \\cdots, A_N.\nAn integer sequence X, which is also of length N, will be chosen randomly by independently choosing X_i from a uniform distribution on the integers 1, 2, \\ldots, A_i for each i (1 \\leq i \\leq N).\nCompute the expected value of t...
[{"input": "6\n680824625 680824626 680824626 680824624 680824626 680824624\n", "output": "655804632\n"}, {"input": "6\n612348318 612348320 612348320 612348319 612348318 612348317\n", "output": "110656261\n"}, {"input": "6\n101617840 101617840 101617841 101617840 101617843 101617842\n", "output": "943012313\n"}, {"input...
code_stdio
[ { "content": "Oleg the bank client checks share prices every day. There are n share prices he is interested in. Today he observed that each second exactly one of these prices decreases by k rubles (note that each second exactly one price changes, but at different seconds different prices can change). Prices can...
[{"input": "100 18\n489 42 300 366 473 105 220 448 70 488 201 396 168 281 67 235 324 291 313 387 407 223 39 144 224 233 72 318 229 377 62 171 448 119 354 282 147 447 260 384 172 199 67 326 311 431 337 142 281 202 404 468 38 120 90 437 33 420 249 372 367 253 255 411 309 333 103 176 162 120 203 41 352 478 216 498 224 31 ...
code_stdio
[ { "content": "The only difference between easy and hard versions is the number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \\lfloor\\frac{a_i}{2}\\rflo...
[{"input": "50 25\n199970 199997 199998 199988 199999 199981 200000 199990 199974 199985 199932 200000 199966 199999 199999 199951 199983 199975 199974 199996 199974 199992 199979 199995 199955 199989 199960 199975 199983 199990 199950 199952 199999 199999 199962 199939 199979 199977 199962 199996 199910 199997 199976 ...
code_stdio
[ { "content": "The courier charges for a courier company are set according to size and weight as shown in the table below.\n\nA size | B size | C size | D size | E size | F size\n--- | --- | --- | --- | --- | --- | ---\nSize | 60 cm or less | 80 cm or less | 100 cm or less | 120 cm or less | 140 cm or less | 160...
[{"input": "2\n86 25 5 5\n135 60 10 30\n3\n10 8 25 24\n5 16 13 9\n30 30 30 14\n0", "output": "1200\n3800\n"}, {"input": "2\n51 0 5 15\n107 60 3 30\n3\n10 15 25 47\n2 12 12 3\n30 30 11 11\n0", "output": "1200\n2000\n"}, {"input": "2\n50 34 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0", "output": "1000\n380...
code_stdio
[ { "content": "Carving the cake 2 (Cake 2)\n\nJOI-kun and IOI-chan are twin brothers and sisters. JOI has been enthusiastic about making sweets lately, and JOI tried to bake a cake and eat it today, but when it was baked, IOI who smelled it came, so we decided to divide the cake. became.\n\nThe cake is round. We...
[{"input": "5\n-1\n3\n2\n132\n24", "output": "134\n"}, {"input": "5\n2\n27\n-1\n12\n87", "output": "113\n"}, {"input": "5\n2\n27\n-1\n12\n88", "output": "114\n"}, {"input": "5\n-1\n6\n2\n101\n27", "output": "106\n"}, {"input": "5\n3\n16\n-1\n18\n35", "output": "50\n"}, {"input": "5\n3\n16\n-2\n15\n35", "output": "49\n"...
code_stdio
[ { "content": "Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.\n\nFirst of all, Vlad assigned individual indices to all cafes. Then, he wrote...
[{"input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"input": "5\n100 1000 1000 1000 1000\n", "output": "100\n"}, {"input": "5\n100 1000 1000 1000 1000\n", "output": "100\n"}, {"input": "5\n100 1000 1000 1100 1000\n", "output":...
code_stdio