messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Problem:\n\nYou are given n natural numbers a1,a2,a3…… an. Let SOD of a number be defined as the Sum of Digits of that number. Compute the value of\n\n{ [ SOD(a1) + SOD(a2) + …….. SOD(an) ] % 9 } – { [ SOD( a1 + a2 + ….. an ) ] % 9 }\n\nInput:\n\nThe first line consists of the value of n. Next n l... | [{"input": "975\n83120057411220087360668125140646348919041806702329314488483800118463434852377449595\n9717806464488721715522935873810745984496672189178897548\n96811324979237301769049529676571\n1036276136291119718301618513101612705490251717930737781164655306138110273308573272031338\n43586\n666957580799011908835864604532... | code_stdio |
[
{
"content": "Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.\n\nA k-tree is an infinite rooted tree where:\n\n each vertex has exactly k children; each edge has some weight; if we look at the ... | [{"input": "100 100 1\n", "output": "988185646\n"}, {"input": "100 50 50\n", "output": "661237556\n"}, {"input": "100 13 11\n", "output": "883875774\n"}, {"input": "90 100 30\n", "output": "697322870\n"}, {"input": "100 50 50\n", "output": "661237556\n"}, {"input": "100 100 1\n", "output": "988185646\n"}, {"input": "90... | code_stdio |
[
{
"content": "You are given a string $t$ consisting of $n$ lowercase Latin letters and an integer number $k$.\n\nLet's define a substring of some string $s$ with indices from $l$ to $r$ as $s[l \\dots r]$.\n\nYour task is to construct such string $s$ of minimum possible length that there are exactly $k$ positio... | [{"input": "50 68\npyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvncea\n", "output": "pyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruld... | code_stdio |
[
{
"content": "problem\n\nOne day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In addition, there are sections with and without thi... | [{"input": "3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0", "output": "5\n5\n"}, {"input": "3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0", "output": "3\n5\n"}, {"input": "3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 1 1 0 1\n0\n0", "output": "3\n7\n"}, {"in... | code_stdio |
[
{
"content": "[Image] \n\nAs some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore. \n\nA famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more im... | [{"input": "53\n1014364 40727 75774 243769 314 406417 5272684 14138 10640282 64955 2763 5667043 2121887 204672692 567643 60183 5183 11361359 2792918 199155 174809 16182540 21 392221 19434423 9140891 159733 15438 67903 3816799 616 429181 30392293 413992581 10847741 20771 16366654 1163 414283 156163 55907108 310278 95949... | code_stdio |
[
{
"content": "Create a program that reads poker hand data and outputs the role for each. However, this issue follows the rules below.\n\n* Poker is a competition with 5 playing cards.\n* No more than 5 cards with the same number.\n* There is no joker.\n* Suppose you only consider the following poker roles: (The... | [{"input": "1,2,4,3,1\n3,3,1,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,13,11,1,13\n11,12,13,1,1", "output": "one pair\nthree card\nthree card\nfull house\nfour card\nstraight\ntwo pair\none pair\n"}, {"input": "1,2,3,4,1\n2,3,1,3,12\n12,13,11,12,12\n7,6,7,6,6\n3,3,2,4,3\n6,7,8,9,10\n11,13,10,1,13\n11,1... | code_stdio |
[
{
"content": "Description\n\nTHE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this month.\nThis game is a game in which members ... | [{"input": "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 0 2 1\ndop\n1 7 11 21\n2 300\nBydp System ahplA\n2 11 4 7\nGreen Inferno\n300 300 300 300", "output": "210\n1650\n"}, {"input": "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n1 7 11 14\n2 300\nBydp System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300", "ou... | code_stdio |
[
{
"content": "Tokitsukaze and CSL are playing a little game of stones.\n\nIn the beginning, there are $n$ piles of stones, the $i$-th pile of which has $a_i$ stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty pile and removes exactly one stone fr... | [{"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "output": "sjfnb\n"}, {"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125477\n", "output": "cslnb\n"}, {"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "outp... | code_stdio |
[
{
"content": "You are given two integers $n$ and $k$. Your task is to find if $n$ can be represented as a sum of $k$ distinct positive odd (not divisible by $2$) integers or not.\n\nYou have to answer $t$ independent test cases.\n\n\n-----Input-----\n\nThe first line of the input contains one integer $t$ ($1 \\... | [{"input": "11\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "11\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "11\n4 2\n4 2\n4 2\n4 2... | code_stdio |
[
{
"content": "Little girl Susie went shopping with her mom and she wondered how to improve service quality. \n\nThere are n people in the queue. For each person we know time t_{i} needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person... | [{"input": "26\n1000 4110030 64221 131521030 942374833 1003 2055015 32110 770511 16440130 263042057 32880256 128439 557559573 16051 8220066 469240078 65760513 256878 790176315 4012 2005 1027508 928528684 8030 1005954322\n", "output": "20\n"}, {"input": "26\n1000 4110030 64221 131521030 942374833 1003 2055015 32110 5137... | code_stdio |
[
{
"content": "Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve unsolved problems because upsolving is very useful.\n\nT... | [{"input": "6\n3 2 2 10 13 8\n", "output": "1\n"}, {"input": "6\n3 2 2 12 13 8\n", "output": "1\n"}, {"input": "6\n3 2 2 12 13 2\n", "output": "2\n"}, {"input": "6\n3 2 4 12 13 2\n", "output": "0\n"}, {"input": "6\n3 2 4 12 13 3\n", "output": "0\n"}, {"input": "6\n0 2 4 12 13 3\n", "output": "0\n"}, {"input": "6\n0 2 4... | code_stdio |
[
{
"content": "This is yet another problem on regular bracket sequences.\n\nA bracket sequence is called regular, if by inserting \"+\" and \"1\" into it we get a correct mathematical expression. For example, sequences \"(())()\", \"()\" and \"(()(()))\" are regular, while \")(\", \"(()\" and \"(()))(\" are not.... | [{"input": "(?(((???))(??)?)?))))(?)????(()()???(?)????(??(??????)()(????(?)))))??(???(??)?(??)????????(????(?()\n39 78\n1 83\n2 35\n28 89\n53 53\n96 67\n16 46\n43 28\n25 73\n8 97\n57 41\n15 25\n47 49\n23 18\n97 77\n38 33\n68 80\n38 98\n62 8\n61 79\n84 50\n71 48\n12 16\n97 95\n16 70\n72 58\n55 85\n88 42\n49 56\n39 122\... | code_stdio |
[
{
"content": "The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any two of them are connected by an edge in graph G. Sounds ... | [{"input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n30 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6\n"}, {"input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n30 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6"}, {"input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n4 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6"}, {"inpu... | code_stdio |
[
{
"content": "You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').\n\nYou can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace \"01\" with \"10\" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace \"12\" wi... | [{"input": "100022202\n", "output": "000122202\n"}, {"input": "100022202\n", "output": "000122202\n"}, {"input": "11222121\n", "output": "11112222\n"}, {"input": "11222121\n", "output": "11112222\n"}, {"input": "2112120\n", "output": "1112220\n"}, {"input": "2112120\n", "output": "1112220\n"}, {"input": "100210\n", "ou... | code_stdio |
[
{
"content": "Yaroslav likes algorithms. We'll describe one of his favorite algorithms.\n\n 1. The algorithm receives a string as the input. We denote this input string as a. \n 2. The algorithm consists of some number of command. Сommand number i looks either as si >> wi, or as si <> wi, where si and wi are ... | [{"input": "10\n448\n727\n1418\n278\n870\n913\n2072\n300\n36\n1312\n", "output": "0??<>1\n1??<>2\n2??<>3\n3??<>4\n4??<>5\n5??<>6\n6??<>7\n7??<>8\n8??<>9\n9??>>??0\n??<>1\n?0>>0?\n?1>>1?\n?2>>2?\n?3>>3?\n?4>>4?\n?5>>5?\n?6>>6?\n?7>>7?\n?8>>8?\n?9>>9?\n?>>??\n>>?\n"}, {"input": "10\n1429\n605\n903\n154\n293\n383\n422\n71... | code_stdio |
[
{
"content": "You are given two integers $a$ and $b$. You may perform any number of operations on them (possibly zero).\n\nDuring each operation you should choose any positive integer $x$ and set $a := a - x$, $b := b - 2x$ or $a := a - 2x$, $b := b - x$. Note that you may choose different values of $x$ in diff... | [{"input": "3\n0 0\n2 1\n2 -1\n", "output": "YES\nYES\nNO\n"}, {"input": "3\n11 2\n-1 0\n1 2\n", "output": "NO\nNO\nYES\n"}, {"input": "3\n2 14\n2 1\n-1 0\n", "output": "NO\nYES\nNO\n"}, {"input": "3\n0 0\n2 1\n-1 0\n", "output": "YES\nYES\nNO\n"}, {"input": "3\n0 0\n2 1\n-2 0\n", "output": "YES\nYES\nNO\n"}, {"input":... | code_stdio |
[
{
"content": "Not to be confused with chessboard.\n\n [Image] \n\n\n-----Input-----\n\nThe first line of input contains a single integer N (1 ≤ N ≤ 100) — the number of cheeses you have.\n\nThe next N lines describe the cheeses you have. Each line contains two space-separated strings: the name of the cheese and... | [{"input": "42\nquxukow soft\nwcn soft\npbwg soft\nlrp hard\nphdvfz soft\nidkvymji soft\nobq soft\nyhx soft\nijygw soft\nztzz soft\nuwdhnwu soft\ndgnuuej hard\nhntyyzr soft\nqxf hard\nztg soft\nhnpq soft\nuhznu soft\nitelgl hard\nggceadhw hard\nrxq soft\nkznmshem hard\nlri hard\ndalh soft\ngyzzuht hard\nzvx soft\nbjffl... | code_stdio |
[
{
"content": "Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.\n\nThe logo of Nanosoft can be described as four squares of the same size merged together into one large square. The top ... | [{"input": "8 8 8\nRRRRGGGG\nRRRRGGGG\nRRRRGGGG\nRRRRGGGG\nYYYYBBBB\nYYYYBBBB\nYYYYBBBB\nYYYYBBBB\n1 1 8 8\n5 2 5 7\n3 1 8 6\n2 3 5 8\n1 2 6 8\n2 1 5 5\n2 1 7 7\n6 5 7 5\n", "output": "64\n0\n16\n4\n16\n4\n36\n0\n"}, {"input": "8 8 8\nRRRRGGGG\nRRRRGGGG\nRRRRGGGG\nRRRRGGGG\nYYYYBBBB\nYYYYBBBB\nYYYYBBBB\nYYYYBBBB\n1 1 8... | code_stdio |
[
{
"content": "Let us call two integers $x$ and $y$ adjacent if $\\frac{lcm(x, y)}{gcd(x, y)}$ is a perfect square. For example, $3$ and $12$ are adjacent, but $6$ and $9$ are not.\n\nHere $gcd(x, y)$ denotes the greatest common divisor (GCD) of integers $x$ and $y$, and $lcm(x, y)$ denotes the least common mult... | [{"input": "1\n40\n1 1 5 6 2 10 12 10 4 2 17 18 6 3 1 4 1 1 7 2 9 10 3 2 4 1 9 1 1 4 2 7 8 1 7 9 2 17 7 2\n40\n1\n10\n1\n9\n0\n12\n9\n2\n1\n5\n13\n7\n3\n10\n4\n5\n0\n9\n0\n8\n5\n5\n3\n0\n6\n9\n1\n10\n13\n8\n3\n1\n2\n2\n7\n2\n2\n8\n4\n1\n", "output": "24\n24\n24\n24\n16\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n16\n2... | code_stdio |
[
{
"content": "Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is a_{i}, and after a week of discounts its price will be b_{i}.\n\nNot all of sellers are honest, so now some products could be more expensi... | [{"input": "50 45\n80 125 152 122 85 62 123 195 157 73 8 127 47 193 70 132 131 38 98 115 185 98 68 166 114 53 144 106 141 106 191 123 44 199 35 18 84 169 46 52 129 102 155 130 63 169 116 145 154 41\n155 187 79 106 136 173 17 146 9 47 173 21 37 183 110 74 185 14 82 156 147 25 162 195 26 25 22 80 171 180 7 92 53 18 100 1... | code_stdio |
[
{
"content": "You are given two arrays of length $n$: $a_1, a_2, \\dots, a_n$ and $b_1, b_2, \\dots, b_n$.\n\nYou can perform the following operation any number of times:\n\nChoose integer index $i$ ($1 \\le i \\le n$);\n\nSwap $a_i$ and $b_i$.\n\nWhat is the minimum possible sum $|a_1 - a_2| + |a_2 - a_3| + \\... | [{"input": "3\n4\n3 3 10 10\n10 10 3 3\n5\n1 2 3 4 5\n6 7 8 9 10\n6\n72 101 108 108 111 44\n10 87 111 114 108 100\n", "output": "0\n8\n218\n"}, {"input": "1\n10\n12345 12345 12345 12345 12345 12345 12345 12345 12345 12345\n1 1 1 1 11 1 1 1 11 1\n", "output": "40\n"}, {"input": "1\n10\n123 123 123 123 123 123 123 123 12... | code_stdio |
[
{
"content": "We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\n-----Constraints-----\n - All values in input are integ... | [{"input": "206383196 349216559 1444400245 1999999999\n", "output": "-1238017048\n"}, {"input": "206383196 349216559 1444400245 2000000000\n", "output": "-1238017049\n"}, {"input": "1000000000 199342280 739321284 1199342280\n", "output": "1000000000\n"}, {"input": "1000000000 199342280 739321284 1199342281\n", "output"... | code_stdio |
[
{
"content": "There are $n$ seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from $1$ to $n$ from left to right. The trip is long, so each passenger will become hungry at some moment of time and will go to take boiled water for his noodles. The person at s... | [{"input": "100 1000000000\n12 803 439 1031 435 300 497 520 718 573 782 523 328 88 275 159 128 389 920 869 503 80 490 289 22 889 353 799 29 131 1138 123 405 221 727 135 248 348 299 833 19 943 471 410 635 626 784 1205 213 724 550 437 860 536 718 173 406 832 520 748 512 29 466 982 574 848 11 693 915 965 177 479 122 498 4... | code_stdio |
[
{
"content": "Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.\n\nThere are $n$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is,... | [{"input": "1000000000 1000000000\n", "output": "751201557\n"}, {"input": "1000000000 1000000000\n", "output": "751201557"}, {"input": "534571158 222043261\n", "output": "212941625\n"}, {"input": "922338645 900544285\n", "output": "187784871\n"}, {"input": "188186551 379116090\n", "output": "655244255\n"}, {"input": "8... | code_stdio |
[
{
"content": "You are given several queries. Each query consists of three integers $p$, $q$ and $b$. You need to answer whether the result of $p/q$ in notation with base $b$ is a finite fraction.\n\nA fraction in notation with base $b$ is finite if it contains finite number of numerals after the decimal point. ... | [{"input": "11\n1 1000000000000000000 10000000\n4 692 9\n1 2272 333111\n1 9 7\n25 31 1\n13 906830565560158478 22\n1971402979058461 750473176484995605 54\n14 19 23\n4 42409608949005314 23\n3 21914624432020321 46\n3 21914624432020321 47\n", "output": "Finite\nInfinite\nInfinite\nInfinite\nInfinite\nInfinite\nInfinite\nIn... | code_stdio |
[
{
"content": "You know that the Martians use a number system with base k. Digit b (0 ≤ b < k) is considered lucky, as the first contact between the Martians and the Earthlings occurred in year b (by Martian chronology).\n\nA digital root d(x) of number x is a number that consists of a single digit, resulting af... | [{"input": "11 1 199\n10 1 2 1 6 2 0 1 9 9 0 5 5 4 0 1 8 7 7 5 2 5 6 10 7 1 6 8 0 8 10 9 1 8 1 6 1 3 6 1 9 0 5 3 6 8 7 5 10 1 1 10 1 6 10 8 10 10 9 1 3 10 2 3 8 10 6 1 7 7 10 5 2 2 7 2 0 2 1 8 6 5 9 6 7 10 2 9 1 4 2 4 5 4 1 5 6 1 1 1 5 2 6 8 8 3 8 6 5 4 2 1 6 5 0 6 5 4 3 7 4 7 6 8 6 6 6 4 10 4 6 5 5 7 10 1 9 2 4 8 4 1 ... | code_stdio |
[
{
"content": "Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet.\n\n... | [{"input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n5 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output": " 8"}, {"input": "7 6\n1 2 1\n1 3 2\n2 4 3\n2 5 4\n3 5 6\n3 6 7\n0\n3 1 2 3\n2 2 3\n0\n2 7 8\n0\n0\n", "output": " ... | code_stdio |
[
{
"content": "You are given integers N and M.\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq N... | [{"input": "000001 1010001101", "output": "1010001101\n"}, {"input": "000001 1010011101", "output": "1010011101\n"}, {"input": "000001 1110110010", "output": "1110110010\n"}, {"input": "000001 1110111010", "output": "1110111010\n"}, {"input": "000100 1010000101", "output": "10000001\n"}, {"input": "001000 1000110000", ... | code_stdio |
[
{
"content": "Let's define $S(x)$ to be the sum of digits of number $x$ written in decimal system. For example, $S(5) = 5$, $S(10) = 1$, $S(322) = 7$.\n\nWe will call an integer $x$ interesting if $S(x + 1) < S(x)$. In each test you will be given one integer $n$. Your task is to calculate the number of integers... | [{"input": "5\n1\n10\n16\n178\n276008776\n", "output": "0\n1\n1\n17\n27600877\n"}, {"input": "5\n0\n16\n16\n178\n164382836\n", "output": "0\n1\n1\n17\n16438283\n"}, {"input": "5\n0\n27\n3\n128\n880055535\n", "output": "0\n2\n0\n12\n88005553\n"}, {"input": "5\n0\n27\n3\n128\n629030259\n", "output": "0\n2\n0\n12\n6290302... | code_stdio |
[
{
"content": "Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least $3$ (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself $k$-multihedgehog.\n\nLet us d... | [{"input": "33 2\n3 13\n17 3\n2 6\n5 33\n4 18\n1 2\n31 5\n4 19\n3 16\n1 3\n9 2\n10 3\n5 1\n5 28\n21 4\n7 2\n1 4\n5 24\n30 5\n14 3\n3 11\n27 5\n8 2\n22 4\n12 3\n20 4\n26 5\n4 23\n32 5\n25 5\n15 3\n29 5\n", "output": "Yes\n"}, {"input": "33 2\n3 13\n17 3\n2 6\n5 33\n4 18\n1 2\n31 5\n4 19\n3 16\n1 3\n9 2\n10 3\n5 1\n5 28\... | code_stdio |
[
{
"content": "You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar. \n\nIn one move you can break any single rectangular piece of chocolate in two rectangular pieces. You can break only by lines between squares: ho... | [{"input": "4\n2 2 1\n2 2 3\n2 2 2\n2 2 4\n", "output": " 5\n 5\n 4\n 0\... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers. In one move, you can jump from the position $i$ to the position $i - a_i$ (if $1 \\le i - a_i$) or to the position $i + a_i$ (if $i + a_i \\le n$).\n\nFor each position $i$ from $1$ to $n$ you want to know the minimum the number of moves requi... | [{"input": "150\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 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 2\n",... | code_stdio |
[
{
"content": "You have an array a with length n, you can perform operations. Each operation is like this: choose two adjacent elements from a, say x and y, and replace one of them with gcd(x, y), where gcd denotes the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor).\n\nWhat is t... | [{"input": "15\n10 10 10 10 10 10 21 21 21 21 21 21 21 21 21\n", "output": "15\n"}, {"input": "15\n10 10 10 10 10 10 10 10 10 10 10 10 15 15 21\n", "output": "17\n"}, {"input": "15\n10 10 10 10 10 10 21 21 21 21 21 30 21 21 21\n", "output": "15\n"}, {"input": "15\n10 10 10 10 10 10 21 21 20 21 21 30 21 21 21\n", "outpu... | code_stdio |
[
{
"content": "Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a... | [{"input": "1000000000 1000000000 1290529127\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "999999991\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "999999991\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "999999991\n"}, {"input": "1000000000 ... | code_stdio |
[
{
"content": "In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i a... | [{"input": "7 3\n2 16\n4 2\n5 -1\n1 4\n-1 7", "output": "IMPOSSIBLE\n"}, {"input": "7 3\n2 16\n4 2\n5 -1\n1 1\n-1 7", "output": "IMPOSSIBLE\n"}, {"input": "7 3\n2 16\n4 2\n5 -1\n1 4\n0 7", "output": "IMPOSSIBLE\n"}, {"input": "10 5\n1 1\n4 5\n2 3\n2 4\n1 -1", "output": "IMPOSSIBLE\n"}, {"input": "10 5\n1 1\n4 5\n2 5\n2... | code_stdio |
[
{
"content": "Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. \n\nKefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot d... | [{"input": "15 1234\n2738 322313356\n1160 970909702\n2594 902749351\n3126 324754476\n3151 177963947\n3424 396145897\n5578 737768323\n3423 687640543\n381 848813098\n1058 197211286\n936 650181776\n1025 776492538\n3598 142176544\n3595 680519527\n1191 32199940\n", "output": "3634263641\n"}, {"input": "15 1234\n2738 3653703... | code_stdio |
[
{
"content": "A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.\n\nFirst, he wants to construct the running track with coating t. On planet AMI-151... | [{"input": "jjjbjjbjbbbbbbjbjbbjbjbbbjbjbbjbbjbbjjbjbjjjbbbbjbjjjjbbbjbjjjjjbjbjbjjjbjjjjjjjjbbjbjbbjbbjbbbbbjjjbbjjbjjbbbbjbbjbbbbbjbbjjbjjbbjjjbjjbbbbjbjjbjbbjbbjbjbjbbbjjjjbjbjbbjbjjjjbbjbjbbbjjjjjbjjbjbjjjbjjjbbbjbjjbbbbbbbjjjjbbbbj\njjbbjbbjjjbjbbjjjjjbjbjjjbjbbbbjbbjbjjbjbbjbbbjjbjjbjbbbjbbjjbbjjjbbbjbbjbjjbbjjjj... | code_stdio |
[
{
"content": "A little boy Laurenty has been playing his favourite game Nota for quite a while and is now very hungry. The boy wants to make sausage and cheese sandwiches, but first, he needs to buy a sausage and some cheese.\n\nThe town where Laurenty lives in is not large. The houses in it are located in two ... | [{"input": "50\n31 80 40 85 12 38 30 97 51 18 45 81 56 82 91 94 95 13 26 93 98 35 44 69 98 39 83 77 38 68 13 71 80 41 21 80 81 17 88 46 61 67 65 49 29 55 37 74 88\n71 8 42 74 14 70 100 96 25 56 95 38 41 88 45 43 46 16 55 77 100 68 51 30 73 51 25 88 64 26 22 50 4 57 88 85 45 32 11 96 94 19 9 12 10 66 24 8 60\n46 55 55 9... | 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 a3. A tower consisting of blocks with sides a1, a2, ..., ak has the total volum... | [{"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "409477218238717\n", "output": "17 409477218238717\n"}, {"input": "419477218238718\n", "output": "18 419466459294818\n"}, {"input": "999088000000000\n", "output": "18 999087986204952\n"}, {"input": "415000000238718\n", "output": "18 414993991... | code_stdio |
[
{
"content": "Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus.\n\nShe has $n$ friends who are also grannies (Maria is not included in this number). The $i$-th granny is ready to attend the ceremony, provided that at the... | [{"input": "4\n5\n1 1 0 2 1\n6\n2 3 4 4 12 7\n6\n2 5 4 5 0 11\n5\n1 2 1 5 6\n", "output": "6\n5\n6\n4\n"}, {"input": "4\n5\n1 1 2 2 1\n6\n2 3 4 4 6 7\n6\n2 5 4 5 0 11\n5\n1 2 1 5 6\n", "output": "6\n5\n6\n4\n"}, {"input": "4\n5\n2 0 2 2 -1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6\n", "output": "6\n1\n6\n4\n"}, {"i... | code_stdio |
[
{
"content": "You like the card board game \"Set\". Each card contains $k$ features, each of which is equal to a value from the set $\\{0, 1, 2\\}$. The deck contains all possible variants of cards, that is, there are $3^k$ different cards in total.\n\nA feature for three cards is called good if it is the same ... | [{"input": "37 5\n0 2 0 1 0\n2 2 0 2 2\n2 0 2 0 0\n2 2 2 2 2\n1 2 0 0 2\n0 1 1 1 2\n0 2 0 2 2\n0 0 1 2 2\n2 0 0 1 0\n0 2 2 2 1\n0 2 2 2 0\n2 0 2 2 1\n0 0 2 0 1\n2 1 1 1 2\n1 2 0 1 0\n1 0 1 0 1\n1 2 1 0 0\n1 2 2 2 2\n2 2 1 2 1\n1 0 2 1 2\n2 1 1 2 1\n0 1 0 2 2\n1 0 1 1 1\n0 0 1 0 2\n0 1 0 0 1\n2 0 1 0 1\n1 2 2 1 2\n2 1 1... | code_stdio |
[
{
"content": "You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters).\n\nIn one move, you can choose any character of s and replace it with any lowercase Latin letter. More formally, you choose some i and replace s_i (the ... | [{"input": "200 150\neabadadbeaeddccaabddacabacbaeecdbcdaadceaaaaacbabeaadbbcdbdabaeedbcaacdcecababaceeecddcbcabdcddedecccbcdcdeddacebbaacebbeccceeccabcedbdcdcdecadcebcaeeddbbdcebabdccbaddcbdacebaccececdadabdebcbcbbaedace\ncc\n", "output": "19503\n"}, {"input": "200 200\naaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaaaaaaaaaaaabaaaa... | code_stdio |
[
{
"content": "ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K ... | [{"input": "1110010000100001010 -1 -2", "output": "2220020000200002023\n"}, {"input": "1110010000100001010 -1 -3", "output": "1110010000100001013\n"}, {"input": "1100000010001000010 -1 -10", "output": "244444446666888893\n"}, {"input": "1100010010100001010 0 -2", "output": "1100010010100001011\n"}, {"input": "111001001... | code_stdio |
[
{
"content": "A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the pare... | [{"input": "5\n7\n1 2\n1 3\n1 7\n1 5\n2 6\n4 7\n6\n1 2\n1 3\n2 4\n2 5\n3 6\n2\n1 2\n7\n6 3\n1 5\n1 3\n4 6\n4 7\n2 1\n5\n2 1\n2 3\n4 5\n3 4\n3 11\n", "output": "2\n2\n1\n2\n1\n"}, {"input": "5\n7\n1 2\n1 3\n1 4\n2 5\n2 6\n4 7\n6\n1 2\n1 3\n2 4\n2 5\n3 6\n2\n1 2\n7\n6 3\n1 5\n1 6\n4 6\n4 7\n2 1\n5\n2 1\n1 3\n3 5\n3 4\n5 ... | code_stdio |
[
{
"content": "You have been assigned to develop a filter for bad messages in the in-game chat. A message is a string $S$ of length $n$, consisting of lowercase English letters and characters ')'. The message is bad if the number of characters ')' at the end of the string strictly greater than the number of rema... | [{"input": "5\n2\n))\n12\ngl))hf))))))\n9\ngege)))))\n14\n)aa))b))))))))\n1\n)\n", "output": "Yes\nNo\nYes\nYes\nYes\n"}, {"input": "2\n6\naaaaa)\n6\n))))))\n", "output": "No\nYes\n"}, {"input": "1\n10\nsa)ttttttt\n", "output": "No\n"}, {"input": "1\n7\nabcd)))\n", "output": "No\n"}, {"input": "1\n5\naaaaa\n", "output"... | code_stdio |
[
{
"content": "You are given n integers a_1, a_2, ..., a_{n}. Find the number of pairs of indexes i, j (i < j) that a_{i} + a_{j} is a power of 2 (i. e. some integer x exists so that a_{i} + a_{j} = 2^{x}).\n\n\n-----Input-----\n\nThe first line contains the single positive integer n (1 ≤ n ≤ 10^5) — the number ... | [{"input": "100\n3 6 12 1 16 4 9 5 4 4 5 8 12 4 6 14 5 1 2 2 2 1 7 1 9 10 1 13 7 8 3 11 8 11 7 5 15 6 14 10 4 2 10 9 1 8 14 10 5 11 3 4 1 12 6 14 13 4 8 5 4 13 13 1 3 9 14 7 14 10 7 3 12 8 9 8 6 15 9 10 12 14 15 4 16 8 8 4 8 7 5 10 16 4 10 13 6 16 16 5\n", "output": "536\n"}, {"input": "100\n3 6 12 1 16 4 9 5 4 4 5 8 1... | code_stdio |
[
{
"content": "Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\n* Operati... | [{"input": "86483718001", "output": "15724312364\n"}, {"input": "79402108049", "output": "14436746918\n"}, {"input": "59146214190", "output": "10753857126\n"}, {"input": "149696127901", "output": "27217477801"}, {"input": "14885609983", "output": "2706474543\n"}, {"input": "19238477126", "output": "3497904932\n"}, {"in... | code_stdio |
[
{
"content": "A pair of positive integers $(a,b)$ is called special if $\\lfloor \\frac{a}{b} \\rfloor = a mod b$. Here, $\\lfloor \\frac{a}{b} \\rfloor$ is the result of the integer division between $a$ and $b$, while $a mod b$ is its remainder.\n\nYou are given two integers $x$ and $y$. Find the number of spe... | [{"input": "9\n3 6\n1 101\n11 6\n50 3\n12 4\n69 420\n12345 6789\n123456 789\n29238676 9\n", "output": "1\n0\n7\n3\n5\n141\n53384\n160909\n36\n"}, {"input": "9\n3 4\n1 100\n4 6\n20 3\n19 4\n69 420\n12345 10703\n123456 789\n16177647 9\n", "output": "1\n0\n2\n3\n6\n141\n57298\n160909\n36\n"}, {"input": "9\n3 4\n2 100\n4 6... | code_stdio |
[
{
"content": "Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their assault? This must not happen! Quickly, she fetches her HC^2 (Handbook of Crazy Constructions) and looks for the right chapter:\n\nHow to build a wall: Take a set of bricks. Select on... | [{"input": "350000 140000\n", "output": "453366\n"}, {"input": "350000 160000\n", "output": "155549\n"}, {"input": "350000 180000\n", "output": "708073\n"}, {"input": "350000 200000\n", "output": "504934\n"}, {"input": "400000 140000\n", "output": "956370\n"}, {"input": "400000 160000\n", "output": "480365\n"}, {"input... | code_stdio |
[
{
"content": "One day n friends gathered together to play \"Mafia\". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. Wha... | [{"input": "100\n1 555 876 444 262 234 231 598 416 261 206 165 181 988 469 123 602 592 533 149 864 716 831 156 962 341 207 377 892 51 866 96 757 317 832 476 549 472 770 1000 887 145 956 515 992 653 972 677 973 527 1384 559 280 346 580 30 372 547 209 929 492 520 446 726 47 170 699 560 814 206 688 955 308 287 26 102 77 4... | code_stdio |
[
{
"content": "Chef Al Gorithm was reading a book about climate and oceans when he encountered the word “glaciological”. He thought it was quite curious, because it has the following interesting property: For every two letters in the word, if the first appears x times and the second appears y times, then |x - y|... | [{"input": "4\naaiigcloocllg 0\nmf`mtate 0\noosseisspnt 11\ndffensdmesrlesr 5", "output": "1\n2\n0\n0\n"}, {"input": "4\nglbciological 0\nuebmm`se 0\nsnoissessop 10\nelsfnsdeesenets 0", "output": "3\n2\n0\n7\n"}, {"input": "4\nglbciological 1\nuebmm`se 0\nsnoissessop 10\nelsfnsdeesenets 0", "output": "1\n2\n0\n7\n"}, {... | code_stdio |
[
{
"content": "Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of super... | [{"input": "100 100 1 1 100 100\n", "output": "Second\n"}, {"input": "100 100 10 10 13 14\n", "output": "Second\n"}, {"input": "110 100 1 1 100 100\n", "output": "Second\n"}, {"input": "99 100 24 1 24 100\n", "output": "Second\n"}, {"input": "37 100 33 13 32 30\n", "output": "Second\n"}, {"input": "89 100 54 1 55 100\n... | code_stdio |
[
{
"content": "Generalized leap year\n\nNormally, whether or not the year x is a leap year is defined as follows.\n\n1. If x is a multiple of 400, it is a leap year.\n2. Otherwise, if x is a multiple of 100, it is not a leap year.\n3. Otherwise, if x is a multiple of 4, it is a leap year.\n4. If not, it is not a... | [{"input": "3 295 2014\n695\n100\n4\n1 1000 1999\n1\n2 1111 4526\n1\n2\n6 2000 3409\n5\n11\n21\n9\n3\n13\n0 0 0", "output": "414\n1000\n3416\n1159\n"}, {"input": "3 295 2014\n695\n100\n4\n1 1000 1999\n1\n2 1111 4526\n1\n2\n6 2000 3409\n9\n11\n21\n9\n3\n13\n0 0 0", "output": "414\n1000\n3416\n1230\n"}, {"input": "3 1221... | code_stdio |
[
{
"content": "A Hitachi string is a concatenation of one or more copies of the string `hi`.\n\nFor example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\n* The length of S is between 1 and 10 (inclusive).\n* S i... | [{"input": "hhhi", "output": "No\n"}, {"input": "hhhj", "output": "No\n"}, {"input": "jhhh", "output": "No\n"}, {"input": "hjhh", "output": "No\n"}, {"input": "gjhh", "output": "No\n"}, {"input": "hjgh", "output": "No\n"}, {"input": "gjgh", "output": "No\n"}, {"input": "gkgh", "output": "No\n"}, {"input": "hgjg", "outp... | code_stdio |
[
{
"content": "Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages.\n\nAt first day Mister B read v_0 pages, but after that he started to speed up. Every day, starting from the second, he read a pages more than on the previous day (at first day he r... | [{"input": "1000 500 500 1000 499\n", "output": "501\n"}, {"input": "1000 500 500 1000 499\n", "output": "501\n"}, {"input": "1000 999 1000 1000 998\n", "output": "2\n"}, {"input": "1000 999 1000 1000 998\n", "output": "2\n"}, {"input": "1000 500 500 1000 475\n", "output": "21\n"}, {"input": "1000 999 1000 1000 948\n",... | code_stdio |
[
{
"content": "Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original problem is in the following paragraph.\n\nPeople don't u... | [{"input": "100000\n", "output": "199998 2\n1 2"}, {"input": "99971\n", "output": "199940 2\n1 2\n"}, {"input": "65535\n", "output": "131068 2\n1 2\n"}, {"input": "65537\n", "output": "131072 2\n1 2\n"}, {"input": "99991\n", "output": "199980 2\n1 2\n"}, {"input": "65888\n", "output": "131774 2\n1 2\n"}, {"input": "604... | code_stdio |
[
{
"content": "There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.\... | [{"input": "10\n7 9 4 4 7 6 3 7 9 8\n10\n1 3 2\n1 10 5\n1 5 3\n1 5 2\n1 2 9\n1 2 9\n1 2 10\n1 5 7\n1 6 10\n1 10 9\n", "output": "7 10 2 4 7 10 3 7 9 9\n"}, {"input": "10\n7 9 4 4 7 6 3 7 9 8\n10\n1 3 2\n1 10 5\n1 5 3\n1 5 2\n1 2 9\n1 2 7\n1 2 10\n1 5 7\n1 6 10\n1 10 9\n", "output": "7 10 2 4 7 10 3 7 9 9\n"}, {"input":... | code_stdio |
[
{
"content": "One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won.\n\nAlex has grown up since then, so he easi... | [{"input": "21 10\n62637783*1\n23*51**531\n35*7*6.**.\n.*3***581*\n2.32*745**\n83*7*6*6*5\n*74.**6**3\n323*6**7*6\n3454*67.*1\n**63265*6*\n3725*4553*\n24****5**4\n23.34****4\n55257*1*4*\n4*3253*456\n**.3*45488\n*7318**4*5\n234.*4557*\n12..21*.*3\n286.235*4*\n834*11*.3*\n", "output": "NO\n"}, {"input": "21 10\n62637783*... | code_stdio |
[
{
"content": "A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x < y) from the set, such that y = x·k.\n\nYou're given a set of n distinct positive integers. Your task is to find the s... | [{"input": "100 2\n191 17 61 40 77 95 128 88 26 69 79 10 131 106 142 152 68 39 182 53 83 81 6 89 65 148 33 22 5 47 107 121 52 163 150 158 189 118 75 180 177 176 112 167 140 184 29 166 25 46 169 145 187 123 196 18 115 126 155 100 63 58 159 19 173 113 133 60 130 161 76 157 93 199 50 97 15 67 109 164 99 149 3 137 153 136 ... | code_stdio |
[
{
"content": "You are given N integers. The i-th integer is a_i. Find the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:\n\n* Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a tri... | [{"input": "20\n3\n1\n1\n1\n5\n14\n1\n2\n5\n3\n5\n8\n10\n1\n9\n3\n2\n3\n18\n4", "output": "100507388\n"}, {"input": "20\n3\n1\n1\n1\n5\n14\n1\n2\n5\n3\n5\n8\n10\n2\n9\n3\n3\n3\n18\n4", "output": "139231148\n"}, {"input": "20\n3\n1\n2\n1\n5\n9\n3\n2\n6\n2\n0\n8\n14\n1\n16\n3\n0\n3\n1\n4", "output": "883576933\n"}, {"inp... | code_stdio |
[
{
"content": "<image>\n\nInput\n\nThe input contains a single integer a (1 ≤ a ≤ 18257).\n\nOutput\n\nPrint a single integer output (1 ≤ output ≤ 2·109).\n\nExamples\n\nInput\n\n2\n\n\nOutput\n\n13\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to ... | [{"input": "15000\n", "output": "1349910001\n"}, {"input": "16344\n", "output": "1602659953\n"}, {"input": "13170\n", "output": "1040614381\n"}, {"input": "15302\n", "output": "1404815413\n"}, {"input": "16331\n", "output": "1600111381\n"}, {"input": "18257\n", "output": "1999798753\n"}, {"input": "15479\n", "output": ... | code_stdio |
[
{
"content": "We have N+M balls, each of which has an integer written on it.\n\nIt is known that: \n - The numbers written on N of the balls are even.\n - The numbers written on M of the balls are odd.\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers w... | [{"input": "100 100\n", "output": "9900\n"}, {"input": "-1 -173", "output": "15052\n"}, {"input": "-1 -295", "output": "43661\n"}, {"input": "560 1", "output": "156520\n"}, {"input": "-1 -118", "output": "7022\n"}, {"input": "0 -295", "output": "43660\n"}, {"input": "91 59\n", "output": "5806\n"}, {"input": "85 60\n", ... | code_stdio |
[
{
"content": "You are given an array $a$ of length $n$, and an integer $x$. You can perform the following operation as many times as you would like (possibly zero): replace two adjacent elements of the array by their sum. For example, if the initial array was $[3, 6, 9]$, in a single operation one can replace t... | [{"input": "1\n20 1\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "20000000000 20000000000\n"}, {"input": "1\n20 1\n1000000000 1000... | code_stdio |
[
{
"content": "By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.\n\nIn 2312 there wa... | [{"input": "1 100\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+... | code_stdio |
[
{
"content": "Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbies, one can quit something as well.\n\nThis time Igor... | [{"input": "446237720 920085248 296916273 439113596\n", "output": "1\n"}, {"input": "491259590 529594367 305425951 326414536\n", "output": "1\n"}, {"input": "960442940 572344654 77422042 406189391\n", "output": "1\n"}, {"input": "609162932 300548167 21640850 411089609\n", "output": "2\n"}, {"input": "191971162 30611272... | code_stdio |
[
{
"content": "Find the intersection of two sets $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}\\\\}$.\n\nConstraints\n\n* $1 \\leq n, m \\leq 200,000$\n* $0 \\leq a_0 < a_1 < ... < a_{n-1} \\leq 10^9$\n* $0 \\leq b_0 < b_1 < ... < b_{m-1} \\leq 10^9$\n\nInput\n\nThe input is given i... | [{"input": "4\n-1 3 10 3\n8\n-1 1 10 13 14", "output": "-1\n10\n"}, {"input": "4\n0 2 5 12\n5\n0 3 5 10 12", "output": "0\n5\n12\n"}, {"input": "4\n0 3 10 8\n8\n0 1 10 16 14", "output": "0\n10\n"}, {"input": "4\n-1 2 5 12\n5\n0 3 5 10 12", "output": "5\n12\n"}, {"input": "4\n0 2 5 8\n5\n0 2 5 29 14", "output": "0\n2\n5... | code_stdio |
[
{
"content": "Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n number... | [{"input": "100\n44 40 6 40 56 90 98 8 36 64 76 86 98 76 36 92 6 30 98 70 24 98 96 60 24 82 88 68 86 96 34 42 58 10 40 26 56 10 88 58 70 32 24 28 14 82 52 12 62 36 70 60 52 34 74 30 78 76 10 16 42 94 66 90 70 38 52 12 58 22 98 96 14 68 24 70 4 30 84 98 8 50 14 52 66 34 100 10 28 100 56 48 38 12 38 14 91 80 70 86\n", "o... | code_stdio |
[
{
"content": "You had $n$ positive integers $a_1, a_2, \\dots, a_n$ arranged in a circle. For each pair of neighboring numbers ($a_1$ and $a_2$, $a_2$ and $a_3$, ..., $a_{n - 1}$ and $a_n$, and $a_n$ and $a_1$), you wrote down: are the numbers in the pair equal or not.\n\nUnfortunately, you've lost a piece of p... | [{"input": "1\nNEEEEEEEEEEEEEEEEEEEEEEEEEEEEENNNNEENNE\n", "output": "YES\n"}, {"input": "1\nNEEEEEEEEEEEEEEEEEEEEEEEEEEEEENNNNEENNE\n", "output": "YES\n"}, {"input": "1\nNEEEEEEEFEEEEEEEEEEEEEEEEEEEEENNNNEENNE\n", "output": "YES\n"}, {"input": "1\nNEEFEEEEFEEEEEEEEEEEEEEEEEEEEENNNNEENNE\n", "output": "YES\n"}, {"input... | code_stdio |
[
{
"content": "You still have partial information about the score during the historic football match. You are given a set of pairs $(a_i, b_i)$, indicating that at some point during the match the score was \"$a_i$: $b_i$\". It is known that if the current score is «$x$:$y$», then after the goal it will change to... | [{"input": "11\n1 100000000\n200000000 100000000\n200000000 300000000\n400000000 300000000\n400000000 500000000\n600000000 639960479\n618182416 700000000\n800000000 700000000\n800000000 900000000\n1000000000 900000000\n1000000000 1000000000\n", "output": "100000011\n"}, {"input": "11\n1 100000000\n200000000 100000100\n... | code_stdio |
[
{
"content": "How many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq L \\leq R \\leq 100\n* 1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nL R d\n\n\nOutput\n\nPrint the ... | [{"input": "-1 110 1", "output": "112\n"}, {"input": "-1 111 1", "output": "113\n"}, {"input": "-1 101 1", "output": "103\n"}, {"input": "12 139 1", "output": "128\n"}, {"input": "12 152 1", "output": "141\n"}, {"input": "12 191 1", "output": "180\n"}, {"input": "11 191 1", "output": "181\n"}, {"input": "11 167 1", "ou... | code_stdio |
[
{
"content": "You are given an array $a$, consisting of $n$ positive integers.\n\nLet's call a concatenation of numbers $x$ and $y$ the number that is obtained by writing down numbers $x$ and $y$ one right after another without changing the order. For example, a concatenation of numbers $12$ and $3456$ is a num... | [{"input": "100 3\n14717 1461 5753 7023 6804 1826 8793 9148 9920 240 8768 15059 11439 2732 794 959 9744 2253 3273 4685 4730 6873 11982 2875 1303 2535 4901 147 8587 339 4792 154 3104 6020 10358 5537 2686 6208 9494 1826 8083 1269 1841 6210 538 3105 4092 5163 9696 9013 2153 3985 2787 4471 1170 4991 4059 6047 7181 14053 48... | code_stdio |
[
{
"content": "Andrii is good in Math, but not in Programming. He is asking you to solve following problem: Given an integer number N and two sets of integer A and B. Let set A contain all numbers from 1 to N and set B contain all numbers from N + 1 to 2N. Multiset C contains all sums a + b such that a belongs t... | [{"input": "17 5\n5\n4\n9\n32\n1", "output": "0\n0\n0\n14\n0\n"}, {"input": "10 5\n19\n-1\n2\n0\n0", "output": "8\n0\n0\n0\n0\n"}, {"input": "12 5\n5\n4\n14\n18\n1", "output": "0\n0\n1\n5\n0\n"}, {"input": "21 5\n5\n4\n9\n32\n1", "output": "0\n0\n0\n10\n0\n"}, {"input": "12 5\n1\n4\n17\n32\n0", "output": "0\n0\n4\n5\n0... | code_stdio |
[
{
"content": "A bracket sequence is a string that is one of the following:\n - An empty string;\n - The concatenation of (, A, and ) in this order, for some bracket sequence A ;\n - The concatenation of A and B in this order, for some non-empty bracket sequences A and B /\nGiven are N strings S_i. Can a bracket... | [{"input": "4\n((()))\n((((((\n))))))\n()()()\n", "output": "Yes\n"}, {"input": "4\n((()))\n((((((\n))))))\n)()()(", "output": "Yes\n"}, {"input": "4\n)))(((\n((((((\n))))))\n)()()(", "output": "Yes\n"}, {"input": "4\n((())(\n(()(()\n))))))\n)((()(", "output": "Yes\n"}, {"input": "4\n())(((\n(()(()\n))))))\n()((()", "o... | code_stdio |
[
{
"content": "D: Sontaku (Surmise)\n\nSome twins like even numbers.\n\nCount how many even numbers are in $ N $ integers $ A_1, A_2, A_3, \\ dots, A_N $.\n\ninput\n\nThe integer $ N $ is given on the first line.\n\nOn the second line, $ N $ integers $ A_1, A_2, A_3, \\ dots, A_N $ are given, separated by blanks... | [{"input": "5\n5 12 0 2 18", "output": "4\n"}, {"input": "5\n2 12 0 2 18", "output": "5\n"}, {"input": "5\n5 12 1 2 12", "output": "3\n"}, {"input": "5\n5 12 1 2 18", "output": "3\n"}, {"input": "5\n4 12 0 2 18", "output": "5\n"}, {"input": "5\n5 12 1 0 18", "output": "3\n"}, {"input": "5\n1 12 0 2 18", "output": "4\n"... | code_stdio |
[
{
"content": "Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite \"Le Hamburger de Polycarpus\" as a... | [{"input": "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\n100 100 100\n100 100 100\n1000000000000\n", "output": "100000001\n"}, {"input": "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\n100 100 100\n100 100 10... | code_stdio |
[
{
"content": "You are given a string $s$. Each character is either 0 or 1.\n\nYou want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 0101, 100001 or 11111111111101, then this condition... | [{"input": "7\n0\n0\n0\n0\n0\n0\n0\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"input": "7\n0\n0\n0\n0\n0\n0\n0\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"input": "7\n0\n0\n0\n0\n1\n0\n0\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"input": "3\n010011\n0\n1111000\n", "output": "2\n0\n0\n"}, {"input": "3\n010011\n0\n1101000\n",... | code_stdio |
[
{
"content": "A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.\n\nVasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must cho... | [{"input": "109\n8800880880088088880888808880888088800880888088088088888080880000080000800000808008008800080008000888000808880\n", "output": "YES\n"}, {"input": "109\n8800880880088088880888808880888088800880888088088088888080880000080000800000808008008800080008000888000808880\n", "output": "YES\n"}, {"input": "109\n194... | code_stdio |
[
{
"content": "There is data that records the customer number of the business partner and the trading date on a monthly basis. Please create a program that reads this month's data and last month's data and outputs the customer number of the company with which you have transactions and the number of transactions ... | [{"input": "123,10\n56,12\n35,14\n\n123,3\n56,4\n123,5", "output": "56 2\n123 3\n"}, {"input": "123,10\n56,12\n45,13\n\n113,4\n56,4\n123,5", "output": "56 2\n123 2\n"}, {"input": "123,10\n57,12\n35,14\n\n123,3\n57,4\n123,5", "output": "57 2\n123 3\n"}, {"input": "213,10\n56,02\n35,14\n\n213,4\n56,4\n113,5", "output": "... | code_stdio |
[
{
"content": "Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:\n\n* Remove the two characters at the beginning of S, erase one of them, and reinsert the other somewhere in S. This operation... | [{"input": "11101111011111000000000110000001111100011111000000001101111110000000111111111", "output": "323558395\n"}, {"input": "11101111011101000000000110000001111100011111000000001101111110000000111111111", "output": "979142942\n"}, {"input": "11101111011100000000000110000001110100011111000000001101111110000000111111... | code_stdio |
[
{
"content": "Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\nA game is played by N players, numbered 1 to N. At the beginning of a game,... | [{"input": "1000 993 1000\n176\n400\n733\n753\n822\n429\n929\n697\n176\n191\n80\n247\n40\n891\n773\n889\n453\n777\n451\n40\n120\n222\n697\n906\n441\n251\n324\n193\n970\n558\n824\n390\n824\n36\n209\n120\n849\n548\n393\n668\n561\n289\n560\n970\n575\n53\n154\n931\n750\n404\n478\n120\n542\n98\n551\n390\n614\n822\n600\n238\... | code_stdio |
[
{
"content": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n I Aqua Fortis\n\n I Aqua Regia\n\n II Amalgama\n\n VII Minium\n\n IV Vitriol\n\nMisce in vitro et æstus, et nil ad... | [{"input": "100 100 100 100 100\n", "output": "14\n"}, {"input": "100 100 100 100 100\n", "output": "14\n"}, {"input": "100 110 100 100 100\n", "output": "14\n"}, {"input": "100 110 100 110 100\n", "output": "15\n"}, {"input": "60 120 82 71 53\n", "output": "10\n"}, {"input": "64 134 69 96 92\n", "output": "13\n"}, {"i... | code_stdio |
[
{
"content": "There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that\n\n1. 1 ≤ i, j ≤ N\n\n2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.\n\nInput\n\nThe single input line contains S, consisting of lowercase La... | [{"input": "abcdefghijklmnopqrstuvwxyz0987654321abcdefghijklmnopqrstuvwxyz0987654321abcdefghijklmnopqrstuvwxyz0987654321\n", "output": "324\n"}, {"input": "1234567890zyxwvutsrqponmlkjihgfedcba1234567890zyxwvutsrqponmlkjihgfedcba1234567890zyxwvutsrqponmlkjihgfedcba\n", "output": "324\n"}, {"input": "abcdeffhijklmnopqsst... | code_stdio |
[
{
"content": "You are given a binary string $s$.\n\nFind the number of distinct cyclical binary strings of length $n$ which contain $s$ as a substring.\n\nThe cyclical string $t$ contains $s$ as a substring if there is some cyclical shift of string $t$, such that $s$ is a substring of this cyclical shift of $t$... | [{"input": "40\n1111110111111111111111011111111111111110\n", "output": "40\n"}, {"input": "40\n0000000000100000100000000000000000000000\n", "output": "40\n"}, {"input": "40\n0000010010000000000001000110000001010100\n", "output": "40\n"}, {"input": "40\n1111111111111011111111101111111111111111\n", "output": "40\n"}, {"i... | code_stdio |
[
{
"content": "The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this park. Pyonkichi is not good at hot weather, and on summe... | [{"input": "10 1\n10\n2 6 6 3 1 2 -1 2 4 0 1 8 5 9 7 9 8 9 6 3\n6 1\n10\n10 2 5 3 1 2 0 12 4 6 1 4 9 9 11 12 8 6 14 0\n0 0", "output": "NA\nNA\n"}, {"input": "10 1\n10\n2 6 6 3 1 2 -1 2 4 0 1 8 5 9 7 9 8 9 6 3\n6 1\n10\n10 2 5 3 1 2 0 12 4 6 1 4 9 9 17 12 8 6 14 0\n0 0", "output": "NA\nNA\n"}, {"input": "10 1\n10\n2 6 ... | code_stdio |
[
{
"content": "Vus the Cossack has two binary strings, that is, strings that consist only of \"0\" and \"1\". We call these strings $a$ and $b$. It is known that $|b| \\leq |a|$, that is, the length of $b$ is at most the length of $a$.\n\nThe Cossack considers every substring of length $|b|$ in string $a$. Let's... | [{"input": "10010110100000101100\n11001\n", "output": "10\n"}, {"input": "10010110100000101100\n10011\n", "output": "10\n"}, {"input": "10010110100000101100\n00010\n", "output": "10\n"}, {"input": "10010110100000101100\n01011\n", "output": "10\n"}, {"input": "10010110100000101100\n00001\n", "output": "10\n"}, {"input":... | code_stdio |
[
{
"content": "There are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\n-----Constraints-----\n - 1 \\leq A \\leq 100\n - 1 \\leq B \\leq 100... | [{"input": "-1 -1 10", "output": "NO\n"}, {"input": "-2 -1 10", "output": "NO\n"}, {"input": "-3 -1 10", "output": "NO\n"}, {"input": "-3 -1 17", "output": "NO\n"}, {"input": "-5 -1 11", "output": "NO\n"}, {"input": "-9 -1 11", "output": "NO\n"}, {"input": "-14 -1 2", "output": "NO\n"}, {"input": "-14 -1 3", "output": ... | code_stdio |
[
{
"content": "Colonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which shows how much it's owner reached. Coolness factor can be increased by one for the cost of one coin. \n\nFor every pair of soldiers one of them should get a badge with strictly high... | [{"input": "50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\n", "output": "1225\n"}, {"input": "50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 ... | code_stdio |
[
{
"content": "Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities.\n\nRecently, it was decided to reduce the main... | [{"input": "5 6\n0 2 0\n0 1 0\n2 3 16\n1 3 2\n3 4 5\n0 0 1\n3 3\n0 2 3\n2 0 3\n0 1 12\n0 0", "output": "7\n15\n"}, {"input": "5 6\n0 0 1\n2 2 3\n2 3 12\n0 3 0\n2 4 14\n1 3 4\n3 3\n0 2 3\n1 0 3\n0 1 1\n0 0", "output": "30\n4\n"}, {"input": "5 6\n0 0 1\n2 2 3\n2 3 12\n0 3 0\n2 4 18\n1 3 4\n3 3\n0 2 3\n1 0 3\n0 1 1\n0 0",... | code_stdio |
[
{
"content": "The problem set at CODE FESTIVAL 20XX Finals consists of N problems.\n\nThe score allocated to the i-th (1≦i≦N) problem is i points.\n\nTakahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.\n\nAs problems with higher scores are harder, he w... | [{"input": "740", "output": "2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n"}, {"input": "370", "output": "1\n2\n3\n4\n5\n6\n7\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n"}, {"input": "296", "o... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nYou are given a transparent three-dimensional table, the height equals to H and the base is a two-dimensional table N∙M.\nThe layers of the 3D table are numbered from 1 to H. Each layer is a two-dimensional table, the rows are n... | [{"input": "1 2 0\n-1 5\n0 0\n-1 0", "output": "Impossible\n"}, {"input": "4 2 0\n-2 5\n0 1\n0 -1", "output": "Impossible\n"}, {"input": "3 2 0\n-2 5\n0 1\n0 -1", "output": "Impossible\n"}, {"input": "1 2 3\n0 1\n1 1\n-1 0", "output": "Impossible\n"}, {"input": "1 2 3\n0 1\n1 0\n-1 0", "output": "Impossible\n"}, {"inpu... | code_stdio |
[
{
"content": "Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink \"Beecola\", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to x_{i} coins.\n\nVasiliy plans... | [{"input": "12\n35345 58181 32223 84621 35905 73863 99537 30666 67771 39229 36847 29038\n23\n55052824\n82504840\n35160556\n78141700\n73401989\n86305919\n39430705\n31939373\n23501765\n4406029\n61436920\n14295390\n34275309\n28028753\n91433780\n70158847\n2396455\n66994588\n84024224\n30175981\n34941071\n118223886\n76605341... | code_stdio |
[
{
"content": "The JOI Railways is the only railway company in the Kingdom of JOI. There are $N$ stations numbered from $1$ to $N$ along a railway. Currently, two kinds of trains are operated; one is express and the other one is local.\n\nA local train stops at every station. For each $i$ ($1 \\leq i < N$), by a... | [{"input": "10 3 1\n10 6 -1\n10\n-1\n1\n10", "output": "3\n"}, {"input": "10 3 5\n3 2 6\n79\n-1\n13\n10", "output": "11\n"}, {"input": "16 3 10\n10 3 6\n16\n2\n11\n11", "output": "2\n"}, {"input": "10 3 1\n10 6 -1\n51\n-1\n1\n10", "output": "7\n"}, {"input": "8 3 1\n10 11 -1\n65\n0\n10\n13", "output": "7\n"}, {"input":... | code_stdio |
[
{
"content": "Snuke has decided to play with N cards and a deque (that is, a double-ended queue).\nEach card shows an integer from 1 through N, and the deque is initially empty.\nSnuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N.\nThen, he will perform the ... | [{"input": "2000 1000\n", "output": "674286644\n"}, {"input": "1862 1782\n", "output": "833498751\n"}, {"input": "1999 1223\n", "output": "472460308\n"}, {"input": "2000 1073\n", "output": "303581106\n"}, {"input": "2000 2000\n", "output": "319838403\n"}, {"input": "1058 839\n", "output": "176907232\n"}, {"input": "189... | code_stdio |
[
{
"content": "Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLucky number is super lucky if it's decimal representation contains equal amou... | [{"input": "30031570122539810394917235521810308756951528310540001786873013276929170093903592140501464021419065914012638320445831511113616470715362861617746753830753466417401868324537734863867785800605235651632883839976995020705498271231449454388975049026825387016009535745686407525035073547430120652345917209266590096502... | code_stdio |
[
{
"content": "There are $n$ students and $m$ clubs in a college. The clubs are numbered from $1$ to $m$. Each student has a potential $p_i$ and is a member of the club with index $c_i$. Initially, each student is a member of exactly one club. A technical fest starts in the college, and it will run for the next ... | [{"input": "20 20\n0 0 3 2 1 2 2 3 2 2 1 1 0 3 0 0 1 1 1 3\n15 1 20 13 6 12 16 8 3 14 10 5 18 17 4 9 2 11 7 19\n20\n2\n10\n7\n4\n6\n5\n14\n8\n9\n18\n13\n11\n19\n1\n16\n20\n17\n12\n15\n3\n", "output": "4\n4\n4\n4\n4\n4\n4\n4\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n0\n0\n"}, {"input": "20 20\n0 0 3 2 1 2 2 3 2 2 1 1 0 3 0 0 1 1 1... | code_stdio |
[
{
"content": "A professor invented Cookie Breeding Machine for his students who like cookies very much.\n\nWhen one cookie with the taste of x is put into the machine and a non-negative integer y less than or equal to 127 is input on the machine, it consumes the cookie and generates two cookies with the taste o... | [{"input": "3\n3 0\n4 108\n2 10", "output": "254\n400\n244\n"}, {"input": "3\n3 0\n2 108\n2 10", "output": "254\n146\n244\n"}, {"input": "3\n3 1\n4 108\n2 10", "output": "255\n400\n244\n"}, {"input": "3\n3 1\n4 108\n2 13", "output": "255\n400\n241\n"}, {"input": "3\n6 0\n2 108\n2 10", "output": "762\n146\n244\n"}, {"in... | code_stdio |
[
{
"content": "Ann and Borya have n piles with candies and n is even number. There are a_{i} candies in pile with number i.\n\nAnn likes numbers which are square of some integer and Borya doesn't like numbers which are square of any integer. During one move guys can select some pile with candies and add one cand... | [{"input": "100\n444272562 25 25 0 49 73291074 64 100 638092144 756033694 0 700405846 16 25 25 100 36 25 269573395 288578186 366853675 36 81 49 4 0 25 49 9 64 0 4 36 36 49 0 64 64 532899768 1 64 9 549673690 25 64 4 817183855 25 146555318 36 495564252 100 49 9 36 100 49 100 4 100 9 64 9 432227412 756728309 25 0 33207251... | code_stdio |
[
{
"content": "You are given two non-empty strings $s$ and $t$, consisting of Latin letters.\n\nIn one move, you can choose an occurrence of the string $t$ in the string $s$ and replace it with dots.\n\nYour task is to remove all occurrences of the string $t$ in the string $s$ in the minimum number of moves, and... | [{"input": "10\nakhvjuejwrazexjkmzfersbjnvdvdbrdvuexbdloltpllcnvqtdoooftuhphtdfcveomexsbn\ni\ndgkrbariruzn\njwa\nttbbvxlxjsksrziizcmhhxpntxvmkqvhtqqedhqprzdidcvgfgrbqyhlrpwpisajpwmbszyjntqgaoskvc\nmk\ntwakxsrktfktpkrmrxsruzjvivionieksdngxrhcifxcyzuqfaciojwifrusfrlvikfcqeextlfcudoahqqm\na\nb\nwr\nds\na\npwrawcwzympnqwbq... | code_stdio |
[
{
"content": "We have had record hot temperatures this summer. To avoid heat stroke, you decided to buy a quantity of drinking water at the nearby supermarket. Two types of bottled water, 1 and 0.5 liter, are on sale at respective prices there. You have a definite quantity in your mind, but are willing to buy a... | [{"input": "467 101 10577", "output": "2222\n"}, {"input": "467 100 16500", "output": "3300\n"}, {"input": "467 100 12758", "output": "2600\n"}, {"input": "467 101 12758", "output": "2626\n"}, {"input": "467 111 12758", "output": "2886\n"}, {"input": "467 111 18557", "output": "4218\n"}, {"input": "467 111 18051", "out... | code_stdio |
[
{
"content": "C*++ language is quite similar to C++. The similarity manifests itself in the fact that the programs written in C*++ sometimes behave unpredictably and lead to absolutely unexpected effects. For example, let's imagine an arithmetic expression in C*++ that looks like this (expression is the main te... | [{"input": "399\n469*++a-935*++a-838*++a-468*++a+79*++a-89*++a-863*++a+531*a++-523*a++-583*++a-411*++a+301*++a+201*a++-108*a+++581*a+++938*++a-16*a++-632*a+++146*a++-230*++a+151*++a-618*a+++593*a+++320*++a+750*++a+185*a++-68*++a+839*a++-853*a+++761*a++-442*a++-385*a++-487*a++-573*a++-820*a++-123*a+++792*++a+95*++a+228*... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.