messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example, if x = 4, and y = 7, then numbers 47, 744, 4 are lucky.\n\nLet's call a positive integer a undoubtedly...
[{"input": "1000000000\n", "output": "40744\n"}, {"input": "1000000000\n", "output": "40744\n"}, {"input": "999999999\n", "output": "40743\n"}, {"input": "999999998\n", "output": "40742\n"}, {"input": "999999997\n", "output": "40741\n"}, {"input": "909090901\n", "output": "38532\n"}, {"input": "142498040\n", "output": ...
code_stdio
[ { "content": "After learning a lot about space exploration, a little girl named Ana wants to change the subject.\n\nAna is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tir...
[{"input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\num\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\num\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"input": "20\nhw\nix\nudb\nbg\noi\nuo\njsm\num\ns\nquy\nqo\nbxct\nng\nrmr\nnu\np...
code_stdio
[ { "content": "In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. ...
[{"input": "S..SSS.A\nS.S.SSSS\nSSSSSSSS\n...SS...\nS.SSSSSS\nSS..SS.S\nSS..S.S.\nMSS..SSS\n", "output": "LOSE\n"}, {"input": ".SSSSSSA\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\nSSSSSSS.\nMSSSSSSS\n", "output": "LOSE\n"}, {"input": ".SSSS.SA\n.SS.SSS.\n..S.SS..\nSSSS.SS.\nS.S.....\nS.S.SSSS\nS..SS..S\nMS.SS.TS...
code_stdio
[ { "content": "++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+\n++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++\n+++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<\n<<<<<>>>>>>>>>>>>>+.-<<<<<<<<<<<<<>>>>>>>>>>>>>>--.++<<<<<<<<<<<...
[{"input": "1000000\n", "output": "2\n"}, {"input": "1000000\n", "output": "2\n"}, {"input": "1000010\n", "output": "3\n"}, {"input": "1229030\n", "output": "0\n"}, {"input": "1000011\n", "output": "3\n"}, {"input": "1160745\n", "output": "1\n"}, {"input": "1100011\n", "output": "1\n"}, {"input": "1333299\n", "output":...
code_stdio
[ { "content": "Inna likes sweets and a game called the \"Candy Matrix\". Today, she came up with the new game \"Candy Matrix 2: Reload\".\n\nThe field for the new game is a rectangle table of size n Γ— m. Each line of the table contains one cell with a dwarf figurine, one cell with a candy, the other cells of the...
[{"input": "10 10\nG********S\n*G*******S\n**G******S\n***G*****S\n****G****S\nS***G*****\n******G**S\n*******G*S\n********GS\nG********S\n", "output": "-1\n"}, {"input": "10 10\nG********S\n*G*******S\n**G******S\n***G*****S\n****S****G\nS***G*****\n******G**S\n*******G*S\n********GS\nG********S\n", "output": "-1\n"},...
code_stdio
[ { "content": "You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.\n\n\n-----Input-----\n\nThe ...
[{"input": "101 298\n", "output": "10000000000000000000000000000000000000000000000000000000000000000000999999999999999999999999999999999 99999999999999999999999999999999910000000000000000000000000000000000000000000000000000000000000000000\n"}, {"input": "101 299\n", "output": "100000000000000000000000000000000000000000...
code_stdio
[ { "content": "Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.\n\nNatasha doesn't like when Vany...
[{"input": "123 222\n44 -190 -188 -185 -55 17 190 176 157 176 -24 -113 -54 -61 -53 53 -77 68 -12 -114 -217 163 -122 37 -37 20 -108 17 -140 -210 218 19 -89 54 18 197 111 -150 -36 -131 -172 36 67 16 -202 72 169 -137 -34 -122 137 -72 196 -17 -104 180 -102 96 -69 -184 21 -15 217 -61 175 -221 62 173 -93 -106 122 -135 58 7 -...
code_stdio
[ { "content": "Consider the infinite sequence $s$ of positive integers, created by repeating the following steps:\n\n Find the lexicographically smallest triple of positive integers $(a, b, c)$ such that $a \\oplus b \\oplus c = 0$, where $\\oplus$ denotes the bitwise XOR operation. $a$, $b$, $c$ are not in ...
[{"input": "9\n2\n3\n3\n12\n13\n6\n7\n11\n9\n", "output": "2\n3\n3\n13\n7\n12\n5\n11\n15\n"}, {"input": "9\n2\n3\n3\n12\n10\n6\n3\n22\n6\n", "output": "2\n3\n3\n13\n6\n12\n3\n18\n12\n"}, {"input": "9\n1\n5\n3\n4\n18\n6\n12\n8\n9\n", "output": "1\n8\n3\n4\n48\n12\n13\n10\n15\n"}, {"input": "9\n1\n3\n3\n12\n10\n6\n3\n14\...
code_stdio
[ { "content": "Given is a permutation P of \\{1, 2, \\ldots, N\\}.\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\n-----Constraints-----\n - 2 \\le N \\le 10^5 \n - 1 \\l...
[{"input": "95\n41 7 46 26 89 2 78 92 8 16 45 57 17 6 35 62 91 95 63 48 19 79 74 52 1 77 28 93 56 31 25 54 40 64 9 34 53 11 10 55 94 24 67 58 27 60 90 87 18 73 50 80 20 21 61 42 88 14 44 76 39 70 51 66 83 32 30 81 23 82 72 65 15 68 75 71 69 13 4 3 85 84 49 59 22 33 5 47 12 37 29 36 38 86 43\n", "output": "380173\n"}, {...
code_stdio
[ { "content": "Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some l...
[{"input": "100\n87 32 53 24 60 2 44 15 45 29 69 10 7 95 61 91 86 51 1 30 58 67 49 50 88 23 82 39 14 66 6 19 96 13 12 33 54 41 43 72 21 34 28 59 75 85 65 94 90 80 83 38 62 46 78 81 92 31 35 3 73 4 5 79 98 40 48 8 47 99 20 89 36 77 9 68 11 93 18 100 37 25 22 76 64 55 52 26 71 84 70 97 17 16 74 56 27 42 57 63\n", "output...
code_stdio
[ { "content": "Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factorΒ β€”Β a square tile that is diagonally split into white and black part as depicted in the figure below. [Image] \n\nThe dimension of this tile is perfec...
[{"input": "1000 1000\n", "output": "708964705\n"}, {"input": "1000 1000\n", "output": "708964705\n"}, {"input": "1000 1001\n", "output": "419685057\n"}, {"input": "1000 122\n", "output": "712990290\n"}, {"input": "1000 122\n", "output": "712990290\n"}, {"input": "1000 0001\n", "output": "46452554\n"}, {"input": "432 3...
code_stdio
[ { "content": "You are given an angle $\\text{ang}$. \n\nThe Jury asks You to find such regular $n$-gon (regular polygon with $n$ vertices) that it has three vertices $a$, $b$ and $c$ (they can be non-consecutive) with $\\angle{abc} = \\text{ang}$ or report that there is no such $n$-gon. [Image] \n\nIf there are...
[{"input": "69\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "output": "180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180...
code_stdio
[ { "content": "There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\nAmong them, some K consecutive stones are painted black, and the others are painted white.\nAdditionally, we know that the stone at coordinate X is painted b...
[{"input": "100 100\n", "output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...
code_stdio
[ { "content": "You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nNotes\n\nConstraints\n\n* Elements in S is sorted in ascending order\n* n ≀ 100000\n* q ≀ 50000\n* 0 ≀ an element in S ≀ 1...
[{"input": "5\n-1 -3 -1 4 0\n4\n1 2", "output": "0\n"}, {"input": "5\n-1 -3 -1 4 1\n4\n1 2", "output": "1\n"}, {"input": "5\n-1 -3 -1 4 0\n5\n1 2", "output": "0\n"}, {"input": "5\n-1 -3 -1 4 0\n5\n2 2", "output": "0\n"}, {"input": "5\n-2 -3 -1 4 0\n5\n2 2", "output": "0\n"}, {"input": "5\n1 2 3 4 1\n5\n2 4 1", "output"...
code_stdio
[ { "content": "You are given a string $s$ of even length $n$. String $s$ is binary, in other words, consists only of 0's and 1's.\n\nString $s$ has exactly $\\frac{n}{2}$ zeroes and $\\frac{n}{2}$ ones ($n$ is even).\n\nIn one operation you can reverse any substring of $s$. A substring of a string is a contiguou...
[{"input": "3\n2\n10\n4\n0110\n8\n11101000\n", "output": "0\n1\n2\n"}, {"input": "3\n2\n10\n4\n0110\n8\n11100001\n", "output": "0\n1\n3\n"}, {"input": "3\n2\n10\n4\n1010\n8\n11101000\n", "output": "0\n0\n2\n"}, {"input": "3\n2\n10\n4\n0011\n8\n11101000\n", "output": "0\n1\n2\n"}, {"input": "3\n2\n10\n4\n0101\n8\n111000...
code_stdio
[ { "content": "You are given two positive integers A and B. Compare the magnitudes of these numbers.\n\n-----Constraints-----\n - 1 ≀ A, B ≀ 10^{100}\n - Neither A nor B begins with a 0.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA\nB\n\n-----Output-----\nPrint GREATER if A>...
[{"input": "123456789012345678901234567890\n54295952540662239241952312402", "output": "GREATER\n"}, {"input": "123456789012345678901234567890\n67478580391614097833417622355", "output": "GREATER\n"}, {"input": "123456789012345678901234567890\n12740860331988085550751547536", "output": "GREATER\n"}, {"input": "12345678901...
code_stdio
[ { "content": "Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly \"adjust\" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i β‰  j) that haven't been chosen...
[{"input": "10\n8003.867 4368.000 2243.000 3340.287 5384.000 1036.456 3506.000 4463.000 1477.000 2420.314 9391.000 1696.000 5857.833 244.000 8220.000 5879.000 5424.482 2631.197 7111.000 9157.536\n", "output": "0.028\n"}, {"input": "10\n8003.867 4368.000 2243.298 3340.000 5384.489 1036.000 3506.115 4463.317 1477.000 242...
code_stdio
[ { "content": "We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round. \n\nThe diameter of a multiset of points on the line is the largest distance between two points from this set. For example, the diameter of the multiset ...
[{"input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "\"The zombies are lurking outside. Waiting. Moaning. And when they come...\"\n\n\"When they come?\"\n\n\"I hope the Wall is high enough.\"\n\nZombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In places, gaps have appeared, splitt...
[{"input": "10 7\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n...B...\nB.BB.B.\n", "output": "3\n"}, {"input": "10 7\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n...-...\n...B...\nB.BB.B.\n", "output": "3\n"}, {"input": "10 7\n.......\n.......\n.......\n.......\n.......\n....
code_stdio
[ { "content": "Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that there are n piles of cows, with the i-th pile containing a_{i} cows. During each player's turn, that ...
[{"input": "10 2\n3 10 10 8 11 10 9 9 5 7\n", "output": "Nicky\n"}, {"input": "10 2\n3 12 10 8 11 10 9 9 5 7\n", "output": "Nicky\n"}, {"input": "10 2\n3 10 10 8 6 10 9 9 5 7\n", "output": "Kevin\n"}, {"input": "10 2\n3 10 10 8 6 10 9 9 5 7\n", "output": "Kevin\n"}, {"input": "10 2\n3 12 10 8 11 2 9 9 5 7\n", "output":...
code_stdio
[ { "content": "Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicol...
[{"input": "5 5\nzbacg\nbaaac\naaaaa\neaaad\nweadd\n", "output": "31\n"}, {"input": "5 5\nzbacg\nbaaac\naaaaa\ndaaae\nweadd\n", "output": "31\n"}, {"input": "5 5\nzbacf\nbcaaa\naaaaa\neaaad\nveadd\n", "output": "28\n"}, {"input": "5 5\nabzcg\nbaaac\naaaaa\neaabd\nwdaed\n", "output": "27\n"}, {"input": "5 5\nzbcaf\nbcaa...
code_stdio
[ { "content": "Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number x_...
[{"input": "9\n0 85236 27579 82251 69479 24737 87917 15149 52311\n59640 0 74687 34711 3685 30121 4961 7552 83399\n33376 68733 0 81357 18042 74297 15466 29476 5865\n7493 5601 3321 0 20263 55901 58229 55361 87633\n26751 17161 76681 58775 0 39745 50717 56887 90055\n18885 76353 47089 43601 21561 0 60571 33551 53753\n103347...
code_stdio
[ { "content": "Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied.\n\nThe classroom c...
[{"input": "5 5 3\n.....\n.....\n*...*\n*....\n.*...\n", "output": "18\n"}, {"input": "5 5 3\n.....\n.....\n*...*\n*....\n.*...\n", "output": "18\n"}, {"input": "5 5 3\n.....\n.....\n*...*\n*....\n...*.\n", "output": "18\n"}, {"input": "5 5 3\n.....\n.....\n*...*\n....*\n...*.\n", "output": "18\n"}, {"input": "5 5 3\n....
code_stdio
[ { "content": "The Central Company has an office with a sophisticated security system. There are $10^6$ employees, numbered from $1$ to $10^6$.\n\nThe security system logs entrances and departures. The entrance of the $i$-th employee is denoted by the integer $i$, while the departure of the $i$-th employee is de...
[{"input": "20\n384933 946658 407136 242739 -242739 -407136 -946658 -384933 384933 -384933 319281 407136 804861 -407136 415987 946658 -946658 -415987 -804861 -319281\n", "output": "3\n8 2 10 \n"}, {"input": "20\n384933 946658 407136 242739 -242739 -407136 -946658 -384933 384933 -384933 319281 407136 804861 -407136 4159...
code_stdio
[ { "content": "Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.\n\nYou can assume that a word consists of at most 30 characters, and the page number is less than or equal to 1000. The number of pairs of a...
[{"input": "ntzsd 22\neevn 1\nnutrodnctioi -1\nse_z 1\nstyle 32\ntndmucod 2\nstyld 10\nmuee -2", "output": "eevn\n1\nmuee\n-2\nntzsd\n22\nnutrodnctioi\n-1\nse_z\n1\nstyld\n10\nstyle\n32\ntndmucod\n2\n"}, {"input": "ntzsd 10\neevn 1\nnutrodnctioi -1\nse_z 1\nstyle 32\ntndmucod 2\nstyld 10\nmuee -2", "output": "eevn\n1\n...
code_stdio
[ { "content": "A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.\n\nYour task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers....
[{"input": "6\n1001\n1277\n9999999999999999999999999999999999999999\n8\n406457296153147731569431812193957336633213953097465104312094248394524915238944551\n-2\n65979473807971894016634449726827689065678029413262970240066900026271391930713716\n5\n1010000000001000000000000000000000000000000000000000000000010000000000000000...
code_stdio
[ { "content": "Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. [Image] \n\nBarney asked the bar tender Carl about this distance value, but Carl was so busy talking to the cu...
[{"input": "2.0629094807595491132306264747042243928486303384791951220362096240931158821630792563855724946791054152e85\n", "output": "20629094807595491132306264747042243928486303384791951220362096240931158821630792563855.724946791054152\n"}, {"input": "1.739019376653594888733439697327057664160248690309535536328717793279...
code_stdio
[ { "content": "There is a square of size $10^6 \\times 10^6$ on the coordinate plane with four points $(0, 0)$, $(0, 10^6)$, $(10^6, 0)$, and $(10^6, 10^6)$ as its vertices.\n\nYou are going to draw segments on the plane. All segments are either horizontal or vertical and intersect with at least one side of the ...
[{"input": "3 3\n2 3 1000000\n4 0 4\n3 0 1000000\n4 0 1\n2 0 5\n3 2 1000000\n", "output": "7\n"}, {"input": "3 3\n2 3 1000000\n7 0 4\n3 0 1000000\n4 0 1\n2 0 5\n3 2 1000000\n", "output": "6\n"}, {"input": "3 3\n2 3 1000000\n4 0 4\n3 0 1000000\n4 0 1\n2 0 5\n3 1 1000000\n", "output": "7\n"}, {"input": "3 3\n2 3 1000000\...
code_stdio
[ { "content": "Kurohashi has never participated in AtCoder Beginner Contest (ABC).\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\nWhat is the earliest ABC where Kurohashi can make his debut?\n\n...
[{"input": "111\n", "output": "111\n"}, {"input": "112\n", "output": "222\n"}, {"input": "750\n", "output": "777\n"}, {"input": "234\n", "output": "333\n"}, {"input": "999\n", "output": "999\n"}, {"input": "626\n", "output": "666\n"}, {"input": "555\n", "output": "555\n"}, {"input": "554\n", "output": "555\n"}, {"input...
code_stdio
[ { "content": "You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.\n\nA subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous.\n\n...
[{"input": "10\n32372808 517917901 640274071 1836610331 71867556 96204862 120140751 446173607 796619138 1156360703\n", "output": "6\n"}, {"input": "10\n32372808 517917901 156515250 1836610331 71867556 96204862 120140751 446173607 796619138 1156360703\n", "output": "6\n"}, {"input": "10\n802030518 598196518 640274071 98...
code_stdio
[ { "content": "You are given an array $a$ of length $2^n$. You should process $q$ queries on it. Each query has one of the following $4$ types: $Replace(x, k)$Β β€” change $a_x$ to $k$; $Reverse(k)$Β β€” reverse each subarray $[(i-1) \\cdot 2^k+1, i \\cdot 2^k]$ for all $i$ ($i \\ge 1$); $Swap(k)$Β β€” swap subarrays...
[{"input": "3 8\n7 0 3 15 7 1 5 2\n4 3 7\n2 1\n3 2\n4 1 6\n2 3\n1 5 16\n4 8 8\n3 0\n", "output": "31\n22\n1\n"}, {"input": "3 8\n7 0 8 8 7 1 5 2\n4 3 7\n2 1\n3 2\n4 1 6\n2 3\n1 5 16\n4 8 8\n3 0\n", "output": "29\n22\n1\n"}, {"input": "3 8\n4 0 8 8 7 1 5 2\n4 3 7\n2 1\n3 2\n4 1 6\n2 3\n1 5 16\n4 8 8\n3 0\n", "output": "...
code_stdio
[ { "content": "Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.\n\nThis time mr. B...
[{"input": "98 24\n52 20 12 75 44 22 22 25 28 100 8 41 31 47 95 87 5 54 7 49 32 46 42 37 45 22 29 11 54 98 46 94 10 47 114 2 15 108 17 82 46 22 32 62 89 37 30 26 92 77 69 11 59 78 24 66 88 10 32 93 46 14 57 20 5 69 53 99 81 94 67 22 54 31 49 52 46 51 49 4 53 31 4 66 28 38 103 5 40 75 15 52 87 16 68 6 36 98\n", "output"...
code_stdio
[ { "content": "One tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some period of time, then explodes, splitting into several parts flying in different directions. Sometimes those parts also explode after some period of time, splitt...
[{"input": "30\n1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5\n", "output": "43348\n"}, {"input": "30\n5 5 1 1 4 4 3 1 5 3 5 5 1 2 2 3 4 5 2 1 4 3 1 1 4 5 4 4 2 2\n", "output": "24339\n"}, {"input": "30\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "10479\n"}, {"input": "30\n4...
code_stdio
[ { "content": "You are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.\n\nIn a more formal way, you have to find the quantity of tuples (a, b, x, y) such that 1 ≀ a ≀ b < x ≀ y ≀ |s| and substrings s[a... b], s[x... y]...
[{"input": "bababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababba...
code_stdio
[ { "content": "Coming up with a new problem isn't as easy as many people think. Sometimes it is hard enough to name it. We'll consider a title original if it doesn't occur as a substring in any titles of recent Codeforces problems. \n\nYou've got the titles of n last problems β€” the strings, consisting of lowerca...
[{"input": "30\nwaiphwcqrrinr\no\nqiqehzmgsjdoqd\nkjexeesevrlowxhghq\njudikhzkj\nz\nxo\nlsdzypkfqro\nsshgcxsky\ngecntpcmoojfwp\nsvmytmcfhc\njrsrvsvbaiumlmkptn\ns\nwpcsovfjlyspviflk\nktvyzvddgllht\nszahigtmklglrcocbo\nznligfxkgxzkcfeu\nliryvzmqwhr\nxgrxkgiehxztv\netrjxdczppafly\njrdgajschhwsci\ndoxnxbjwptnimjmsuijx\nzci...
code_stdio
[ { "content": "$n$ players are playing a game.\n\nThere are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map.\n\nYou are the g...
[{"input": "1\n10\n1109412863 911871372 379798020 844017253 852316352 439889133 601615010 999121621 343144247 662484047\n148682006 868690703 149843110 1652026160 587798634 40092006 292693207 256527822 128794711 765771574\n", "output": "1111111111\n"}, {"input": "1\n10\n617560334 1490885171 379798020 844017253 852316352...
code_stdio
[ { "content": "Snuke loves working out. He is now exercising N times.\nBefore he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.\nFind Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.\n\n-...
[{"input": "100000\n", "output": "457992974\n"}, {"input": "100001", "output": "755072381\n"}, {"input": "110001", "output": "817497558\n"}, {"input": "110011", "output": "422312314\n"}, {"input": "101001", "output": "249638241\n"}, {"input": "110000", "output": "559938709\n"}, {"input": "111011", "output": "864631379\...
code_stdio
[ { "content": "Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $x$, Egor on the floor $y$ (not on the same floor with Masha).\n\nThe house has a staircase...
[{"input": "1000 999 1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 999 1100 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 999 1000 1000 1000 1000\n", "output": "NO"}, {"input": "188 288 112 595 331 414\n", "output": "YES\n"}, {"input": "837 544 703 808 549 694\n", "output": "YES\n"}, {"input": "723...
code_stdio
[ { "content": "Lunar New Year is approaching, and Bob is struggling with his homework – a number division problem.\n\nThere are $n$ positive integers $a_1, a_2, \\ldots, a_n$ on Bob's homework paper, where $n$ is always an even number. Bob is asked to divide those numbers into groups, where each group must conta...
[{"input": "100\n28 27 23 6 23 11 25 20 28 15 29 23 20 2 8 24 8 9 30 8 8 1 11 7 6 17 17 27 26 30 12 22 17 22 9 25 4 26 9 26 10 30 13 4 16 12 23 19 10 22 12 20 3 16 10 4 29 11 15 4 5 7 29 16 3 1 7 16 26 14 28 1 15 19 30 28 5 22 14 28 13 12 11 30 3 4 7 10 22 8 4 10 22 12 17 27 23 11 18 7\n", "output": "48573\n"}, {"input...
code_stdio
[ { "content": "Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: the Euclidean distance between A and B is one unit and neither A nor B is blocked; or ther...
[{"input": "30426905\n", "output": "172120564\n"}, {"input": "38450759\n", "output": "217510336\n"}, {"input": "19863843\n", "output": "112366864\n"}, {"input": "24562258\n", "output": "138945112\n"}, {"input": "24483528\n", "output": "138499748\n"}, {"input": "25329968\n", "output": "143287936\n"}, {"input": "31975828...
code_stdio
[ { "content": "You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subseq...
[{"input": "11\nb\naaaaaaaaaaa\ncba\nabcabcabcabcabcabcabc\nbvdhsdvlbelrivbhxbhie\ny\nabacabadabacaba\nabacabadabacaba\nabacabadabacaba\nbaabaabdaa\nabbab\nbabaabaabcbabaaa\nt\nz\nu\nt\nkiihgfedcba\nabccefghijk\nabcdefghijk\nkjihgfdecba\nbba\nabaabbbb\n", "output": "-1\n15\n-1\n1\n2\n-1\n-1\n-1\n-1\n10\n5\n"}, {"input"...
code_stdio
[ { "content": "Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.\n\nThe game is played on the following field. [Image] \n\nPlayers are making moves by turns. At first move a player can put his ...
[{"input": "... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4\n", "output": "... ... ... \n... ... ... \n... ... ... \n\n... ... ... \n... ... ... \n... x.. ... \n\n!!! ... ... \n!!! ... ... \n!!! ... ... \n\n"}, {"input": "xoo x.. x..\nooo ... ...
code_stdio
[ { "content": "We have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\nDetermine w...
[{"input": "60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n", "output": "Yes\n"}, {"input": "60 106 34\n92 41 43\n39 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34", "output": "Yes\n"}, {"input": "60 88 34\n92 41 43\n39 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34", "output": "Yes\n"}...
code_stdio
[ { "content": "Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as ment...
[{"input": "1001 8\n1 0 4 5 6 7 15 11", "output": "2222\n"}, {"input": "1001 8\n1 3 2 5 6 7 15 9", "output": "4000\n"}, {"input": "1001 8\n1 3 4 5 6 7 8 9", "output": "2000\n"}, {"input": "1000 8\n2 3 4 5 6 7 8 9", "output": "1000\n"}, {"input": "1001 8\n1 3 4 5 6 7 8 2", "output": "9000\n"}, {"input": "1000 8\n1 3 4 5...
code_stdio
[ { "content": "Everyone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital was surrounded by n hills, forming a circle. On each hill there was a watchman, who watched the neighbourhood day and night.\n\nIn case of any danger the watchman could make a fire on the...
[{"input": "10\n8097 8097 8097 14160 8097 8097 8097 8097 8097 8097\n", "output": "45\n"}, {"input": "10\n8097 8097 8097 14160 8097 8097 8097 8097 8097 4894\n", "output": "38\n"}, {"input": "10\n8097 8097 8097 14160 8097 8097 8097 8097 9062 4894\n", "output": "26\n"}, {"input": "10\n8097 8097 8097 14160 8097 5098 8097 8...
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 visit it, ...
[{"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "10\n10 60 12 13 14 15 16 77 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": "9\n4 10 21 7 22 9 15 11 12\n", "output": "43\...
code_stdio
[ { "content": "Problem\n\nN idols, numbered from 1 to n in order, are lined up in a row.\nIdle i can transmit information to idle i-1 and idle i + 1 in a unit time. However, idol 1 can transmit information only to idol 2, and idol n can transmit information only to idol n-1.\n\nAt time 0, m idols with numbers a1...
[{"input": "39 5\n0 6 10 8 10", "output": "29\n"}, {"input": "27 5\n4 6 6 8 10", "output": "17\n"}, {"input": "39 5\n0 6 7 4 13", "output": "26\n"}, {"input": "10 3\n4 5 6 13 10", "output": "4\n"}, {"input": "100001 1\n1", "output": "100000\n"}, {"input": "110001 1\n1", "output": "110000\n"}, {"input": "10 3\n2 5 6 8 1...
code_stdio
[ { "content": "problem\n\nJOI Pizza sells pizza home delivery along the d-meter-long ring road that runs through the city center.\n\nJOI Pizza has n stores S1, ..., Sn on the loop line. The head office is S1. The distance from S1 to Si when moving the loop line clockwise is set to di meters. D2 , ..., dn is an i...
[{"input": "8\n3\n2\n3\n2\n4\n6\n20\n4\n4\n33\n16\n15\n15\n12\n5\n8\n0", "output": "3\n15\n"}, {"input": "8\n3\n2\n3\n0\n4\n6\n20\n4\n4\n14\n14\n23\n7\n7\n11\n8\n0", "output": "3\n23\n"}, {"input": "8\n3\n2\n3\n0\n4\n6\n20\n4\n4\n17\n17\n23\n7\n7\n11\n8\n0", "output": "3\n28\n"}, {"input": "8\n3\n2\n4\n0\n4\n6\n20\n4\n...
code_stdio
[ { "content": "This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.\n\nArray a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly $\\frac{n}{k}$ times consecutively. In other words, array a ...
[{"input": "100 20\n2 2 2 1 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 2 2 2 2 1 2 1 2 1 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1\n", "output": "13\n"}, {"input": "100 25\n2 2 1 2 2 2 2 2 1 2 2 1 2 1 1 2 1 2 1 2 2 2 1 2 2 2 1 1 2 ...
code_stdio
[ { "content": "N hotels are located on a straight line. The coordinate of the i-th hotel (1 \\leq i \\leq N) is x_i.\nTak the traveler has the following two personal principles:\n - He never travels a distance of more than L in a single day.\n - He never sleeps in the open. That is, he must stay at a hotel at th...
[{"input": "9\n1 3 6 13 15 18 19 29 31\n10\n4\n1 8\n7 3\n6 7\n8 5\n", "output": "4\n2\n1\n2\n"}, {"input": "9\n1 3 6 13 15 18 19 29 31\n10\n4\n1 8\n7 3\n6 7\n8 3", "output": "4\n2\n1\n3\n"}, {"input": "9\n1 3 6 13 23 18 19 29 31\n12\n4\n1 8\n1 5\n9 7\n8 7", "output": "3\n2\n1\n1\n"}, {"input": "9\n1 3 6 13 23 19 19 29 ...
code_stdio
[ { "content": "PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of $6$ slices, medium ones consist of $8$ slices, and large pizzas consist of $10$ slices each. Baking them takes $15$, $20$ and $25$ minutes, respectively.\n\nPetya's birthday is toda...
[{"input": "6\n40\n15\n300\n1\n9999999999999999\n2\n", "output": "100\n40\n750\n15\n25000000000000000\n15\n"}, {"input": "6\n12\n15\n300\n1\n9999999999999999\n3\n", "output": "30\n40\n750\n15\n25000000000000000\n15\n"}, {"input": "6\n20\n15\n300\n1\n9999999999999999\n3\n", "output": "50\n40\n750\n15\n25000000000000000\...
code_stdio
[ { "content": "Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve the end of the last segment. \nThere are few problem...
[{"input": "2\n5\n11 11 1 4 -1\n5\n6 4 15 0 1", "output": "12\n17\n"}, {"input": "2\n5\n6 15 1 4 -3\n5\n12 4 15 0 1", "output": "16\n17\n"}, {"input": "2\n5\n6 15 1 4 -4\n5\n12 4 28 0 1", "output": "16\n30\n"}, {"input": "2\n5\n6 11 1 4 -1\n5\n3 4 12 1 1", "output": "12\n14\n"}, {"input": "2\n5\n6 11 1 4 -1\n5\n3 4 10 ...
code_stdio
[ { "content": "Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the...
[{"input": "156161456146164104103460452045416165146141414651641564105461465156445621465146514562146145465165145145614561465145614561\n", "output": "3\n"}, {"input": "103558265279194540919999479104736998591144614354128226385356523500136575934047295164369877371826192807895143756308323575\n", "output": "3\n"}, {"input": "...
code_stdio
[ { "content": "There were n groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.\n\nThe coach decided to form teams of exactly three people for this training. Determine the...
[{"input": "247\n2 2 1 2 1 2 2 2 2 2 2 1 1 2 2 1 2 1 1 1 2 1 1 1 1 2 1 1 2 2 1 2 1 1 1 2 2 2 1 1 2 1 1 2 1 1 1 2 1 2 1 2 2 1 1 2 1 2 2 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 1 1 1 1 1 2 1 2 2 1 2 1 2 2 2 1 2 2 2 1 1 2 2 1 1 1 2 1 1 1 1 2 2 1 2 2 1 1 1 2 1 2 2 1 2 1 1 1 2 2 2...
code_stdio
[ { "content": "-----Input-----\n\nThe input contains a single integer a (10 ≀ a ≀ 999).\n\n\n-----Output-----\n\nOutput 0 or 1.\n\n\n-----Examples-----\nInput\n13\n\nOutput\n1\n\nInput\n927\n\nOutput\n1\n\nInput\n48\n\nOutput\n0\n\nWrite Python code to solve this problem. Your program should read the input from ...
[{"input": "927\n", "output": "1\n"}, {"input": "999\n", "output": "1\n"}, {"input": "142\n", "output": "0\n"}, {"input": "309\n", "output": "1\n"}, {"input": "572\n", "output": "0\n"}, {"input": "835\n", "output": "1\n"}, {"input": "990\n", "output": "0\n"}, {"input": "168\n", "output": "0\n"}, {"input": "431\n", "out...
code_stdio
[ { "content": "Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented by the following formulas:\n\n$ v = 9.8 t $\n$ y = 4.9 t^2 $\n\n\nA person is trying to drop down a glass ball and check whether it will crack. Your task is to wri...
[{"input": "30.680680649968536\n28.560601801329888", "output": "11\n10\n"}, {"input": "31.609624009789687\n28.560601801329888", "output": "12\n10\n"}, {"input": "37.215162984287666\n34.783659160997495", "output": "16\n14\n"}, {"input": "43.458654705246964\n43.015002690398575", "output": "21\n20\n"}, {"input": "50.86628...
code_stdio
[ { "content": "Natasha travels around Mars in the Mars rover. But suddenly it broke down, namelyΒ β€” the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex $1$, in which every leaf (excluding root) is an input, and all other vertices are logical elements,...
[{"input": "60\nAND 20 4\nNOT 42\nAND 48 59\nOR 17 7\nIN 0\nAND 36 37\nIN 1\nIN 0\nIN 1\nNOT 47\nAND 52 49\nOR 44 35\nIN 0\nIN 1\nAND 33 56\nIN 0\nIN 0\nIN 0\nAND 31 41\nOR 15 3\nOR 43 46\nIN 1\nXOR 22 28\nIN 1\nIN 1\nIN 1\nAND 34 21\nIN 0\nIN 1\nIN 0\nXOR 51 23\nXOR 10 54\nOR 57 40\nIN 0\nNOT 18\nNOT 25\nIN 1\nAND 5 5...
code_stdio
[ { "content": "It is known that passages in Singer house are complex and intertwined. Let's define a Singer k-house as a graph built by the following process: take complete binary tree of height k and add edges from each vertex to all its successors, if they are not yet present.\n\n<image> Singer 4-house\n\nCoun...
[{"input": "181\n", "output": "421742777\n"}, {"input": "261\n", "output": "952127278\n"}, {"input": "121\n", "output": "631667314\n"}, {"input": "351\n", "output": "625447969\n"}, {"input": "141\n", "output": "551624811\n"}, {"input": "361\n", "output": "465138299\n"}, {"input": "301\n", "output": "484957644\n"}, {"in...
code_stdio
[ { "content": "This morning, Roman woke up and opened the browser with $n$ opened tabs numbered from $1$ to $n$. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many tabs open so he wants to close some of them.\n\...
[{"input": "100 47\n-1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1\n", "output": "19\n"}, {"input": "100 47\n...
code_stdio
[ { "content": "One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out that the reason is not (as previously suspected) any kind of brain defec...
[{"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 5\n", "output": "no\n"}, {"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 5\n", "output": "no\n"}, {"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 2\n", "output": "no\n"}, {"input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 4\n7 10...
code_stdio
[ { "content": "You are standing near a very strange machine. If you put C cents in the machine, the remaining money in your purse will transform in an unusual way. If you have A dollars and B cents remaining in your purse after depositing the C cents, then after the transformation you will have B dollars and A c...
[{"input": "2\n9 72 53\n98 73 69", "output": "125\n27\n"}, {"input": "2\n9 82 69\n98 116 69", "output": "33\n11\n"}, {"input": "2\n9 82 100\n98 116 69", "output": "1\n11\n"}, {"input": "2\n9 90 80\n100 73 69", "output": "125\n0\n"}, {"input": "2\n11 72 32\n78 0 13", "output": "53\n121\n"}, {"input": "2\n2 77 69\n104 84...
code_stdio
[ { "content": "Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.\n\nAs for you, you're just a simple peasant. There's no surprise that you slept in this morning and we...
[{"input": "11 8\n3 5 5\n8 9 9\n4 6 6\n8 10 10\n5 7 7\n2 7 2\n10 11 11\n1 11 1\n", "output": "0 1 5 5 6 7 2 9 10 11 1 \n"}, {"input": "11 7\n7 8 8\n5 6 5\n1 3 3\n7 9 9\n5 10 10\n10 11 11\n1 11 4\n", "output": "3 3 4 0 10 5 8 9 10 11 4 \n"}, {"input": "11 7\n7 8 8\n5 6 5\n1 3 3\n7 9 9\n5 10 10\n10 11 11\n1 11 3\n", "out...
code_stdio
[ { "content": "Toad Rash has a binary string $s$. A binary string consists only of zeros and ones.\n\nLet $n$ be the length of $s$.\n\nRash needs to find the number of such pairs of integers $l$, $r$ that $1 \\leq l \\leq r \\leq n$ and there is at least one pair of integers $x$, $k$ such that $1 \\leq x, k \\le...
[{"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "output": "4672\n"}, {"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "output": "4672\n"}, {"input": "1101111000011110111111110101100110...
code_stdio
[ { "content": "New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 Γ— n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.\n\...
[{"input": "120 104\n41 15 95 85 34 11 25 42 65 39 77 80 74 17 66 73 21 14 36 63 63 79 45 24 65 7 63 80 51 21 2 19 78 28 71 2 15 23 17 68 62 18 54 39 43 70 3 46 34 23 41 65 32 10 13 18 10 3 16 48 54 18 57 28 3 24 44 50 15 2 20 22 45 44 3 29 2 27 11 2 12 25 25 31 1 2 32 4 11 30 13 16 26 21 1 13 21 8 15 5 18 13 5 15 3 8 ...
code_stdio
[ { "content": "Example\n\nInput\n\n5\n\n\nOutput\n\n5\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "304", "output": "10816520\n"}, {"input": "309", "output": "17426472\n"}, {"input": "352", "output": "45765225\n"}, {"input": "227", "output": "1542687\n"}, {"input": "280", "output": "6677055\n"}, {"input": "161", "output": "142120\n"}, {"input": "187", "output": "372075\n"}, {"input": "157", "output": "121...
code_stdio
[ { "content": "Tavas is a strange creature. Usually \"zzz\" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. [Image] \n\nToday Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. H...
[{"input": "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcbabacbbaccaabcabcbbbaaabbacbbbcacccb...
code_stdio
[ { "content": "You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≀ l ≀ r ≀ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\n* All input value...
[{"input": "7 26\n10\n20\n30\n43\n30\n20\n10", "output": "13\n"}, {"input": "1 26\n10\n20\n30\n43\n30\n20\n10", "output": "0\n"}, {"input": "1 26\n10\n20\n30\n12\n30\n20\n12", "output": "0\n"}, {"input": "1 26\n10\n20\n27\n12\n30\n20\n12", "output": "0\n"}, {"input": "1 26\n10\n20\n30\n12\n30\n20\n20", "output": "0\n"}...
code_stdio
[ { "content": "Polycarp loves ciphers. He has invented his own cipher called Right-Left.\n\nRight-Left cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \\dots s_{n}$ Polycarp uses the following algorithm: he writes down $s_1$, he appends the current word with $s_2$ (i.e. writes down $s_2$ to the...
[{"input": "qwertyuioasdfghjklrtyuiodfghjklqwertyuioasdfssddxb\n", "output": "dfogihujyktlrqlwkejrhtgyfudisoaaosidufystsrdedwxqb\n"}, {"input": "qwertyuioasdfghjklrtyuiodfghjklqwertyuioasdfssddxb\n", "output": "dfogihujyktlrqlwkejrhtgyfudisoaaosidufystsrdedwxqb\n"}, {"input": "qwertyuioasdfghjklrtyuipdfghjklqwertyuioas...
code_stdio
[ { "content": "Given is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows:\n\n* x_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n* x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\n\n\nFind x_{N,1}.\n\nConstraints\n\n...
[{"input": "10\n1806305381", "output": "0\n"}, {"input": "10\n2192114600", "output": "1\n"}, {"input": "10\n3104206232", "output": "1\n"}, {"input": "10\n2763272837", "output": "1\n"}, {"input": "10\n1238013900", "output": "1\n"}, {"input": "10\n1665759416", "output": "0\n"}, {"input": "10\n2224468077", "output": "0\n"...
code_stdio
[ { "content": "Given is an integer N. Snuke will choose integers s_1, s_2, n_1, n_2, u_1, u_2, k_1, k_2, e_1, and e_2 so that all of the following six conditions will be satisfied:\n\n* 0 \\leq s_1 < s_2\n* 0 \\leq n_1 < n_2\n* 0 \\leq u_1 < u_2\n* 0 \\leq k_1 < k_2\n* 0 \\leq e_1 < e_2\n* s_1 + s_2 + n_1 + n_2 ...
[{"input": "4\n33\n1\n28\n0111010001", "output": "996765147\n0\n399637805\n501963061\n"}, {"input": "4\n33\n1\n28\n0111110001", "output": "996765147\n0\n399637805\n744953502\n"}, {"input": "4\n24\n2\n30\n0110110001", "output": "192839398\n0\n434820093\n589150439\n"}, {"input": "4\n2\n18\n124\n0010000000", "output": "0\...
code_stdio
[ { "content": "Polycarp has built his own web service. Being a modern web service it includes login feature. And that always implies password security problems.\n\nPolycarp decided to store the hash of the password, generated by the following algorithm: take the password $p$, consisting of lowercase Latin lette...
[{"input": "5\nabacaba\nzyxaabcaabkjh\nonetwothree\nthreetwoone\none\nzzonneyy\none\nnone\ntwenty\nten\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"input": "5\nabacaba\nzyxaabcaabkjh\nonetwothree\nthreetwoone\none\nzzonneyy\neno\nnone\ntwenty\nten\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"input": "5\nabacaba\nzyxaabca...
code_stdio
[ { "content": "Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.\n\nRoma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and...
[{"input": "10 10 10\n51 87\n68 600\n82 1284\n33 936\n55 242\n89 1990\n58 357\n66 666\n62 512\n51 87\n92 1670\n56 280\n56 280\n91 1631\n77 1091\n89 1554\n61 473\n98 1901\n77 1091\n77 1091\n86 15 759\n43 58 386\n68 33 386\n39 62 386\n95 6 386\n74 27 386\n94 7 386\n17 36 386\n105 4 386\n45 56 386\n", "output": "598\n"}, ...
code_stdio
[ { "content": "Your task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r Γ— c elements, and prints a new table, which includes the total sum for each row and column.\n\nConstraints\n\n* 1 ≀ r, c ≀ 100\n* 0 ≀ an element of the table ≀ 100\n\...
[{"input": "4 5\n2 1 3 12 13\n0 2 2 12 5\n3 6 1 1 1\n2 6 3 1 21", "output": "2 1 3 12 13 31\n0 2 2 12 5 21\n3 6 1 1 1 12\n2 6 3 1 21 33\n7 15 9 26 40 97\n"}, {"input": "4 5\n2 1 3 12 13\n0 2 2 12 5\n3 3 1 1 1\n2 6 3 1 21", "output": "2 1 3 12 13 31\n0 2 2 12 5 21\n3 3 1 1 1 9\n2 6 3 1 21 33\n7 12 9 26 40 94\n"}, {"inpu...
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 vis...
[{"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "10\n8 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\n18 11 24 7 18 10 1 20 17\n", "outp...
code_stdio
[ { "content": "The faculty of application management and consulting services (FAMCS) of the Berland State University (BSU) has always been popular among Berland's enrollees. This year, N students attended the entrance exams, but no more than K will enter the university. In order to decide who are these students,...
[{"input": "1\n4 2 3 14\n7 5 7\n10 6 10\n7 10 9\n9 0", "output": "Impossible\n"}, {"input": "1\n4 2 3 14\n7 5 7\n10 6 10\n7 10 9\n9 1", "output": "Impossible\n"}, {"input": "1\n4 2 3 2\n14 7 7\n10 6 7\n7 14 11\n9 9", "output": "Impossible\n"}, {"input": "1\n4 2 3 2\n14 14 7\n10 6 7\n7 14 6\n9 9", "output": "Impossible\...
code_stdio
[ { "content": "Fox Ciel saw a large field while she was on a bus. The field was a n Γ— m rectangle divided into 1 Γ— 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes. \n\nAfter seeing the field carefully, Ciel found that the crop plants of each cell w...
[{"input": "31 31 31 4\n15 26\n29 15\n17 31\n29 21\n21 3\n9 27\n19 20\n8 19\n5 4\n1 16\n6 17\n5 24\n1 4\n27 30\n16 24\n14 29\n24 31\n6 20\n2 20\n12 26\n26 15\n23 8\n29 10\n11 8\n3 7\n2 26\n15 10\n15 24\n6 10\n31 22\n12 2\n10 3\n6 24\n23 12\n19 1\n", "output": "Grapes\nCarrots\nCarrots\nCarrots\n"}, {"input": "31 31 31 ...
code_stdio
[ { "content": "There are $n$ people in this world, conveniently numbered $1$ through $n$. They are using burles to buy goods and services. Occasionally, a person might not have enough currency to buy what he wants or needs, so he borrows money from someone else, with the idea that he will repay the loan later wi...
[{"input": "12 20\n1 3 1000000000\n3 2 1000000000\n1 4 1000000000\n4 2 1000000000\n1 5 1000000000\n5 2 1000000000\n1 6 1000000010\n6 2 1000000000\n1 7 1000000000\n7 2 1000000000\n1 8 1000000000\n8 4 1000000000\n1 9 1000000000\n9 2 1000000000\n1 10 1000000000\n10 2 1000000000\n1 11 1000000000\n11 2 1000000000\n1 12 1000...
code_stdio
[ { "content": "Tic-tac-toe is a game in which you win when you put β—‹ and Γ— alternately in the 3 Γ— 3 squares and line up β—‹ or Γ— in one of the vertical, horizontal, and diagonal lines (Fig.). 1 to Fig. 3)\n\n<image> | <image> | <image>\n--- | --- | ---\nFigure 1: β—‹ wins | Figure 2: Γ— wins | Figure 3: Draw\n\n\n\nI...
[{"input": "ooosxssxs\nxooswsosx\nooxxxooxo", "output": "o\nd\nd\n"}, {"input": "oopsxssxs\nxooswsosx\noxooxxxoo", "output": "d\nd\nd\n"}, {"input": "oopsxrsxs\nxsoswsoox\nooooxxxox", "output": "d\nd\no\n"}, {"input": "xprmnwrtt\ntoyqulosl\nxxxmilpm{", "output": "d\nd\nx\n"}, {"input": "ooosxssxs\nxoosxsosx\noxooxxxoo"...
code_stdio
[ { "content": "For a given polygon g and target points t, print \"2\" if g contains t, \"1\" if t is on a segment of g, \"0\" otherwise.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≀ i ≀ n-1) are sides of the polygon. The line segment connecting pn and...
[{"input": "4\n3 0\n15 -1\n0 1\n-1 0\n3\n-1 -2\n1 0\n-1 -1", "output": "0\n1\n0\n"}, {"input": "4\n3 0\n8 -1\n0 1\n-1 2\n3\n-1 -2\n0 -1\n0 -1", "output": "0\n0\n0\n"}, {"input": "4\n-1 -1\n4 -2\n3 -1\n1 4\n2\n0 1\n1 0\n-2 1", "output": "2\n2\n"}, {"input": "4\n0 -1\n6 -2\n3 -1\n1 4\n2\n0 1\n1 0\n-1 0", "output": "0\n2\...
code_stdio
[ { "content": "A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).\n\nKilljoy's account is already infected and has a rating equal to $x$. Its rating is constant. There are $n$ ...
[{"input": "7\n2 7\n7 1313\n2 14\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n136 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n2\n2\n1\n1\n1\n1\n"}, {"input": "7\n2 7\n7 1313\n2 8\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n312 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n1\n2\n1\n1\n1\n1\n"}, {"input": "7\n2 7\...
code_stdio
[ { "content": "Bizon the Champion isn't just charming, he also is very smart.\n\nWhile some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n Γ— m multiplication table, where the element on the intersection of the i-th row and j-th column e...
[{"input": "500000 500000 250000000000\n", "output": "250000000000\n"}, {"input": "499997 499989 248758432143\n", "output": "225563648440\n"}, {"input": "499997 499989 248758432143\n", "output": "225563648440"}, {"input": "500000 500000 250000000000\n", "output": "250000000000"}, {"input": "183656 409931 42943608085\n"...
code_stdio
[ { "content": "You are given a string $s$, consisting of lowercase Latin letters. While there is at least one character in the string $s$ that is repeated at least twice, you perform the following operation:\n\nyou choose the index $i$ ($1 \\le i \\le |s|$) such that the character at position $i$ occurs at least...
[{"input": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "ba\n"}, {"input": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed i...
[{"input": "990037 453792\n", "output": "654009570\n"}, {"input": "586189 189159\n", "output": "168174057\n"}, {"input": "512287 359783\n", "output": "542484357\n"}, {"input": "999983 239239\n", "output": "965993296\n"}, {"input": "498653 116674\n", "output": "625264514\n"}, {"input": "805711 702149\n", "output": "7598...
code_stdio
[ { "content": "From tomorrow, the long-awaited summer vacation will begin. So I decided to invite my friends to go out to the sea.\n\nHowever, many of my friends are shy. They would hate it if they knew that too many people would come with them.\n\nBesides, many of my friends want to stand out. They will probabl...
[{"input": "5\n8 100001\n14 100001\n12 100000\n11 100001\n3 100001", "output": "0\n"}, {"input": "5\n8 100001\n14 100001\n13 100000\n11 100001\n3 100001", "output": "0\n"}, {"input": "5\n8 000001\n14 100001\n13 100000\n11 100001\n3 100001", "output": "0\n"}, {"input": "5\n8 100001\n14 100001\n12 100000\n13 100001\n3 10...
code_stdio
[ { "content": "Given two matrices A and B. Both have N rows and M columns. In the matrix A, numbers from 1 to MN have been written in row major order. Row major order numbers cells from left to right, and top to bottom. That is,\n\n1 2 3 ... M\nA = M+1 ...
[{"input": "1\n1 102", "output": "102\n"}, {"input": "1\n1 167", "output": "167\n"}, {"input": "1\n-23 -5", "output": "-5\n"}, {"input": "1\n135 1", "output": "135\n"}, {"input": "1\n215 1", "output": "215\n"}, {"input": "1\n396 1", "output": "396\n"}, {"input": "1\n1 143", "output": "143\n"}, {"input": "1\n1 113", "ou...
code_stdio
[ { "content": "Bob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang) \n\nThe journey can be represented as a straight line, consisting of $n$ segments. Bob is located to the left of the first segment, while Alice's nest is on...
[{"input": "10\n324839129156 133475576222 1946579156099 185514358673 88712073883 243757012712 950854402304 21947060440 598567289966 674328002732\nGLLLLLLLLW\n", "output": "26365097587258\n"}, {"input": "10\n324839129156 133475576222 987711341463 185514358673 88712073883 243757012712 950854402304 21947060440 59856728996...
code_stdio
[ { "content": "Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). \n\nNote that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding \"+\"-s and \"1\"-s to it. For example, sequences \"(())()\", \"(...
[{"input": "92 51 18\n(()(((()())(()())())())(()())()()()())((()()())(())(())(()((())()())())(())())((())()())()()\nLRLRLLLLRRRLLRRLDLRLRRLRDLDLDLDDRRLRRRLLRDRLDDRLRRD\n", "output": "(()()()()())((()()())(())(())(()((())()())())(())())((())()())()()\n"}, {"input": "86 11 62\n(((())())(((()())())()()())(()())(()()())()(...
code_stdio
[ { "content": "You are given a system of pipes. It consists of two rows, each row consists of $n$ pipes. The top left pipe has the coordinates $(1, 1)$ and the bottom right β€” $(2, n)$.\n\nThere are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six ty...
[{"input": "6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n101\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\n"}, {"input": "6\n7\n2323216\n1615124\n1\n5\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n101\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\n"}, {"input": "6\n7\n2323216\n1615124\n1\n3\n4\n2...
code_stdio
[ { "content": "Takahashi is at an all-you-can-eat restaurant.\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\nThe restaurant has the following rules:\n - You can only order one dish at a time. The dish ordered will be immediately served and ready ...
[{"input": "3000 3000\n2996 2995\n2990 2993\n2994 2994\n2994 2997\n3000 2990\n2991 3000\n3000 2998\n2994 2997\n2996 2993\n2991 3000\n2992 2991\n2991 2994\n2996 3000\n2996 2997\n3000 2998\n2995 2995\n2994 2997\n2996 2999\n2990 2992\n2997 2994\n2995 3000\n2993 2998\n2994 2998\n2990 2997\n2995 2998\n3000 2997\n3000 2995\n...
code_stdio
[ { "content": "A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands \"T\" (\"turn around\") and \"F\" (\"move 1 unit forward\").\n\nYou are given a list of commands that will be given to the turtle. You have to change...
[{"input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n50\n", "output": "100\n"}, {"input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n40\n", "output": "100\n"}, {"input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFF...
code_stdio
[ { "content": "You are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\n-----Constraints-----\n - 2 \\leq N \\leq 100\n - 1 \\leq A_i \\leq 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard I...
[{"input": "100\n3142445 16266949 17493698 35569790 80507149 98771888 109205766 111818374 116565925 119183522 141425056 157086378 180302992 187469083 216070266 233105051 257048184 265553444 273526101 281450237 289171706 301768399 311455945 319497119 326729809 338683702 339701654 346802542 353453224 373203259 386147801 ...
code_stdio
[ { "content": "On the Internet, data is divided into packets, and each packet is transferred to a destination via a relay device called a router. Each router determines the next router to forward from the destination described in the packet. In addition, a value called TTL (Time To Live) is added to the packet t...
[{"input": "7\n1 4 2 5 5 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 2\n7 0\n6\n1 2 0\n1 5 0\n1 2 0\n5 1 3\n6 3 0\n1 7 4", "output": "NA\nNA\nNA\nNA\nNA\n3\n"}, {"input": "7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 1\n1 3 6\n1 2 0\n5 2 3\n6 3 0\n3 7 4", "output": "NA\n2\nNA\nNA\nNA\nNA\n"}, {"input": "7\...
code_stdio
[ { "content": "When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.\n\nLogin is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols (Β«_Β»). However, in order to decrea...
[{"input": "ELioO1lOoOIOiLoooi1iolul1O\n7\nOoEIuOIl1ui1010uiooOoi0Oio001L0EoEolO0\nOLIoOEuoE11u1u1iLOI0oO\nuEOuO0uIOOlO01OlEI0E1Oo0IO1LI0uE0LILO0\nEOo0Il11iIOOOIiuOiIiiLOLEOOII001EE\niOoO0LOulioE0OLIIIulli01OoiuOOOoOlEiI0EiiElIIu0\nlE1LOE1Oil\n1u0EOliIiIOl1u110il0l1O0u\n", "output": "Yes\n"}, {"input": "ELioO1lOoOIOiLo...
code_stdio
[ { "content": "------ Problem Statement ------ \n\nPast\n\nIn the year of 2048, the Virtual Reality Massively Multiplayer Online Role-Playing Game (VRMMORPG), Code Art Online (CAO), is released. With the Chef Gear, a virtual reality helmet that stimulates the user's five senses via their brain, players can exper...
[{"input": "2\n5 -1\n^^^^^\n^^]^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^^_\n^^###^^\n#^^^^^^\n^^#^^#^\n^^^^^^^", "output": "0\n0\n"}, {"input": "2\n5 -1\n^^^^_\n^^]^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^^_\n^^###^^\n#^^^^^^\n^^#^^#^\n^^^^^^^", "output": "0\n0\n"}, {"input": "2\n5 -1\n^^^^^\n^^]^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^...
code_stdio
[ { "content": "There is a line with 1000 cells numbered from 1 to 1000 from left to right and N coins placed on it. Coin i is placed at cell X_{i}, and no two coins are placed at the same cell.\n\nBob would like to move the coins to the N leftmost cells of the line. To do this, he is allowed to take a coin from ...
[{"input": "2\n12 2\n2 4 18\n22 3\n1 2 4 8 12", "output": "16\n7\n"}, {"input": "2\n10 2\n1 5 13\n8 6\n1 4 5 6 21", "output": "10\n16\n"}, {"input": "2\n10 2\n1 5 21\n8 6\n1 4 5 6 21", "output": "18\n16\n"}, {"input": "2\n10 2\n1 5 34\n8 6\n1 4 5 6 21", "output": "31\n16\n"}, {"input": "2\n12 2\n2 4 18\n22 3\n1 3 4 8 1...
code_stdio
[ { "content": "You are given an integer $n$. Pair the integers $1$ to $2n$ (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct.\n\nFormally, let $(a_i, b_i)$ be the pairs that you matched. $\\{a_1, b_1, a_2, b_2, \\ldots, a_n, b_n\\}$ should be a permut...
[{"input": "4\n1\n2\n3\n4\n", "output": "YES\n1 2\nNO\nYES\n1 6\n2 4\n3 5\nNO\n"}, {"input": "1\n100000\n", "output": "NO\n"}, {"input": "1\n99988\n", "output": "NO\n"}, {"input": "1\n99990\n", "output": "NO\n"}, {"input": "1\n99992\n", "output": "NO\n"}, {"input": "1\n99994\n", "output": "NO\n"}, {"input": "1\n99996\n...
code_stdio
[ { "content": "Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure i...
[{"input": "100\n1622 320 1261 282 1604 57 1427 1382 904 911 1719 1682 984 1727 1301 1799 1110 1057 248 764 1642 1325 1172 1677 182 32 665 397 1146 73 412 554 973 874 774 1948 1676 1959 518 280 1467 568 613 760 594 252 224 1359 876 253 760 1566 929 1614 940 1079 288 245 1432 1647 1534 1768 1947 733 225 495 1239 644 124...
code_stdio
[ { "content": "I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n βˆ’ 1, and you can use the k ticket to go to pβ‹…ak + qβ‹…bk station.\n\nRabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. Th...
[{"input": "6 279 2 5 26 14", "output": "117\n"}, {"input": "17 256 2 3 10 9", "output": "67\n"}, {"input": "6 323 2 12 8 9", "output": "182\n"}, {"input": "6 279 2 5 46 14", "output": "57\n"}, {"input": "22 144 2 3 3 5", "output": "15\n"}, {"input": "17 144 2 3 6 5", "output": "37\n"}, {"input": "6 200 2 3 26 8", "out...
code_stdio
[ { "content": "Noora is a student of one famous high school. It's her final year in schoolΒ β€” she is going to study in university next year. However, she has to get an Β«AΒ» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the o...
[{"input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "There are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white.\n\nC...
[{"input": "WBWBWB", "output": "3\n"}, {"input": "WBWBVB", "output": "1\n"}, {"input": "WBWBUB", "output": "1\n"}, {"input": "WBWBUC", "output": "1\n"}, {"input": "WBWBTC", "output": "1\n"}, {"input": "WBWBVC", "output": "1\n"}, {"input": "WBVBVC", "output": "0\n"}, {"input": "BWBWBW", "output": "6"}, {"input": "BBX", ...
code_stdio