messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "There are N arrays. The length of each array is M and initially each array contains integers (1,2,...,M) in this order.\n\nMr. Takahashi has decided to perform Q operations on those N arrays. For the i-th (1≤i≤Q) time, he performs the following operation.\n\n* Choose an arbitrary array from the N ... | [{"input": "11 12\n6\n-2 0 3 6 -1 3", "output": "No\n"}, {"input": "11 12\n6\n-3 0 3 6 -1 3", "output": "No\n"}, {"input": "11 12\n6\n-3 0 3 6 -2 3", "output": "No\n"}, {"input": "1 6\n6\n-1 -2 1 4 0 1", "output": "Yes\n"}, {"input": "4 6\n6\n-1 -2 1 4 -1 5", "output": "No\n"}, {"input": "1 6\n6\n-1 -2 1 2 0 1", "outpu... | code_stdio |
[
{
"content": "Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n.\n\nIn one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≤ i_1 < i_2 < … < i_k ≤ n. He should then change a_{i_j} to ((a_{i_j}+1) mod m) for each c... | [{"input": "100 1000\n980 755 745 448 424 691 210 545 942 979 555 783 425 942 495 741 487 514 752 434 187 874 372 617 414 505 659 445 81 397 243 986 441 587 31 350 831 801 194 103 723 166 108 182 252 846 328 905 639 690 738 638 986 340 559 626 572 808 442 410 179 549 880 153 449 99 434 945 163 687 173 797 999 274 975 6... | code_stdio |
[
{
"content": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation: add a character to the end of the string. \n\nBesides, at most once... | [{"input": "100\nyeywsnxcwslfyiqbbeoaawtmioksfdndptxxcwzfmrpcixjbzvicijofjrbcvzaedglifuoczgjlqylddnsvsjfmfsccxbdveqgu\n", "output": "100\n"}, {"input": "100\nyeywsnxcwslfyiqbbeoaawtmioksfdndptxxcwzfmrpcixjbzvicijofjrbcvzaedglifuoczgjlqylddnsvsjfmfsccxbdveqgu\n", "output": "100\n"}, {"input": "100\nyeywsnxcwslfyiqbbeoia... | code_stdio |
[
{
"content": "In the world of DragonBool there are fierce warriors called Soints. Also there are even fiercer warriors called Sofloats – the mortal enemies of Soints.\n\nThe power of each warrior is determined by the amount of chakra he possesses which is some positive integer. Warriors with zero level of chakr... | [{"input": "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n73 87\n100 13\n36 36\n77 46\n16 93\n49 46\n27 93\n118 87\n172 13\n63 36", "output": "8\n155\n"}, {"input": "2\n2 3\n7 1\n20 2\n5 2\n4 2\n18 1\n5 5\n73 87\n100 13\n36 36\n77 46\n16 93\n49 46\n27 93\n118 87\n172 13\n63 36", "output": "11\n155\n"}, {"input": "2\n2 3\n10... | code_stdio |
[
{
"content": "A ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains n ski junctions, numbered from 1 to n. Initially the junctions aren't connected in any way.\n\nIn the constructing proce... | [{"input": "2 40\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "output": "0\n1\n3\n7\n15\n31\n63\n127\n255\n511\n1023\n2047\n4095\n8191\n16383\n32767\n65535\n1310... | code_stdio |
[
{
"content": "Given is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\n-----Constraints-----\n - 0 \\leq x \\leq 1\n - x is an integer\n\n-----Input-----\nInput is given from Standard Input in the following format:\nx\n\n---... | [{"input": "000", "output": "1\n"}, {"input": "000", "output": "1\n"}, {"input": "1\n", "output": "0\n"}, {"input": "0\n", "output": "1\n"}, {"input": "1", "output": "0"}, {"input": "0", "output": "1"}] | code_stdio |
[
{
"content": "Phoenix has $n$ coins with weights $2^1, 2^2, \\dots, 2^n$. He knows that $n$ is even.\n\nHe wants to split the coins into two piles such that each pile has exactly $\\frac{n}{2}$ coins and the difference of weights between the two piles is minimized. Formally, let $a$ denote the sum of weights in... | [{"input": "100\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\n30\... | code_stdio |
[
{
"content": "You are given a long decimal number $a$ consisting of $n$ digits from $1$ to $9$. You also have a function $f$ that maps every digit from $1$ to $9$ to some (possibly the same) digit from $1$ to $9$.\n\nYou can perform the following operation no more than once: choose a non-empty contiguous subseg... | [{"input": "20\n58832646452639258958\n9 2 2 1 1 4 8 6 6\n", "output": "58832646452639258958\n"}, {"input": "20\n58832646452639258958\n9 2 2 1 1 4 8 6 6\n", "output": "58832646452639258958"}, {"input": "19\n4752348644348366742\n6 7 9 7 5 7 9 9 5\n", "output": "7957979777979977977\n"}, {"input": "19\n2612437771227631192\... | code_stdio |
[
{
"content": "Given is a string S. Replace every character in S with x and print the result.\n\n-----Constraints-----\n - S is a string consisting of lowercase English letters.\n - The length of S is between 1 and 100 (inclusive).\n\n-----Input-----\nInput is given from Standard Input in the following format:\n... | [{"input": "kvtvweokpottycaeeyfthzfvsgckwjmgqadfekjfitnsieylhumxjjezqvidkxjpywokrnzxxwraamuimhmrjwqeyvjvyjjzsxxf\n", "output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"}, {"input": "qvssniprlkdntynymqcjoxpttvplhodrlkpqwtnkdfkgmokodexzspghvslwqrerrsiasriutrr... | code_stdio |
[
{
"content": "You are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\n-----Constraints-----\n - 1≤N≤10^3\n\n-----Input-----\nThe input is given from Standard Input in the following format:\nN\n\n-----Output-----\nPrint the number of the positive divisors of N!, modulo 10^9... | [{"input": "1000\n", "output": "972926972\n"}, {"input": "1001", "output": "513172208\n"}, {"input": "108", "output": "875619122\n"}, {"input": "111", "output": "130571620\n"}, {"input": "101", "output": "167902493\n"}, {"input": "100", "output": "583951250\n"}, {"input": "110", "output": "277966376\n"}, {"input": "115... | code_stdio |
[
{
"content": "You are given two positive integers $x$ and $y$. You can perform the following operation with $x$: write it in its binary form without leading zeros, add $0$ or $1$ to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of $x$.\n\nFor examp... | [{"input": "1740680371580423905 1636173592742219971\n", "output": "NO\n"}, {"input": "999999999999999999 1636173592742219971\n", "output": "NO\n"}, {"input": "616543106594181990 1600944574522397396\n", "output": "NO\n"}, {"input": "470060730774588924 1202400343260876277\n", "output": "NO\n"}, {"input": "616543106594181... | code_stdio |
[
{
"content": "Snuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), r... | [{"input": "10000 10000 10000\n", "output": "20000\n"}, {"input": "10000 10100 10000", "output": "20000\n"}, {"input": "10000 00100 10000", "output": "10100\n"}, {"input": "11000 10100 10000", "output": "20100\n"}, {"input": "11000 10110 10000", "output": "20110\n"}, {"input": "11000 10111 10000", "output": "20111\n"},... | code_stdio |
[
{
"content": "Square Route\n\nSquare root\n\nEnglish text is not available in this practice contest.\n\nMillionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person who likes squares very much, so he wants to... | [{"input": "3 3\n2\n1\n2\n-1\n3\n1\n1 2\n22\n11\n10\n0 0", "output": "7\n0\n"}, {"input": "3 3\n1\n1\n2\n1\n1\n1\n1 2\n10\n10\n23\n0 0", "output": "11\n1\n"}, {"input": "3 3\n1\n1\n1\n2\n3\n1\n1 2\n10\n10\n10\n0 0", "output": "6\n2\n"}, {"input": "3 3\n1\n1\n1\n1\n3\n1\n1 2\n10\n10\n10\n0 0", "output": "7\n2\n"}, {"inp... | code_stdio |
[
{
"content": "Takahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_... | [{"input": "1000 1000\n-10000000000 -10000000000 -10000000000\n-10000000000 -10000000000 -10000000000\n-10000000000 -10000000000 -10000000000\n-10000000000 -10000000000 -10000000000\n-10000000000 -10000000000 -10000000000\n-10000000000 -10000000000 -10000000000\n-10000000000 -10000000000 -10000000000\n-10000000000 -100... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese . \n\nGiven an array of n non-negative integers: A_{1}, A_{2}, …, A_{N}. Your mission is finding a pair of integers A_{u}, A_{v} (1 ≤ u < v ≤ N) such that (A_{u} and A_{v}) is as large as possible.\nAnd is a bit-wise operation which is corresponding to... | [{"input": "4\n1\n11\n23\n11", "output": "11\n"}, {"input": "4\n4\n11\n18\n16", "output": "16\n"}, {"input": "4\n1\n15\n17\n14", "output": "14\n"}, {"input": "4\n13\n10\n3\n13", "output": "13\n"}, {"input": "4\n2\n30\n26\n11", "output": "26\n"}, {"input": "4\n37\n23\n0\n36", "output": "36\n"}, {"input": "4\n37\n49\n0\n... | code_stdio |
[
{
"content": "Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. \"Aha, blacks certainly didn't win!\", — Volodya said and was right for sure. And your task is to say whether whites had won o... | [{"input": "e8 e7 d8 g8\n", "output": "CHECKMATE\n"}, {"input": "d4 e5 b7 a5\n", "output": "CHECKMATE\n"}, {"input": "a5 b5 g2 a8\n", "output": "CHECKMATE\n"}, {"input": "d8 d7 h8 f8\n", "output": "CHECKMATE\n"}, {"input": "g8 h5 a6 h3\n", "output": "CHECKMATE\n"}, {"input": "b3 a5 g6 a8\n", "output": "CHECKMATE\n"}, {... | code_stdio |
[
{
"content": "For a given sequence of distinct non-negative integers $(b_1, b_2, \\dots, b_k)$ we determine if it is good in the following way:\n\nConsider a graph on $k$ nodes, with numbers from $b_1$ to $b_k$ written on them.\n\nFor every $i$ from $1$ to $k$: find such $j$ ($1 \\le j \\le k$, $j\\neq i$), for... | [{"input": "109\n74 18 237 179 195 112 156 11 72 68 173 202 78 250 224 251 107 55 186 144 57 62 28 210 132 64 93 6 211 0 174 163 248 226 167 246 46 102 253 180 121 56 151 35 150 254 168 201 242 118 190 158 196 30 75 116 187 96 215 244 192 73 12 175 33 222 131 256 181 230 114 165 128 234 63 90 44 70 229 182 101 69 92 26... | code_stdio |
[
{
"content": "This is an easier version of the next problem. The difference is only in constraints.\n\nYou are given a rectangular $n \\times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero... | [{"input": "40\n2 2\n5 2\n1 5\n1 1\n3\n1 2\n1 1\n1 2\n1 1\n1 2\n2 3\n2 1\n1\n1\n1 1\n1\n2 1\n1\n1\n1 2\n2 3\n2 2\n1 3\n3 3\n1 1\n1\n2 1\n3\n4\n1 1\n2\n2 2\n1 1\n1 1\n2 2\n1 1\n1 1\n1 1\n1\n2 1\n1\n1\n2 1\n5\n3\n1 1\n2\n1 2\n2 2\n2 1\n1\n1\n2 2\n3 2\n2 4\n1 1\n5\n1 2\n2 1\n1 2\n1 1\n1 2\n1 1\n1 2\n1 1\n1 1\n3\n2 2\n1 2\... | code_stdio |
[
{
"content": "Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shuffles the shells by swapping some pairs and t... | [{"input": "2000000000\n0\n", "output": "1\n"}, {"input": "1999999995\n0\n", "output": "2\n"}, {"input": "1999999995\n1\n", "output": "1\n"}, {"input": "1999999995\n2\n", "output": "0\n"}, {"input": "1999999996\n0\n", "output": "2\n"}, {"input": "1999999996\n1\n", "output": "0\n"}, {"input": "1999999996\n2\n", "output"... | code_stdio |
[
{
"content": "You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.\n\nThe coach decided to form a team of even number of players, exactly half of the players should play with thei... | [{"input": "100 100 100\n", "output": "300\n"}, {"input": "100 100 100\n", "output": "300\n"}, {"input": "100 101 100\n", "output": "300\n"}, {"input": "99 100 100\n", "output": "298\n"}, {"input": "100 99 100\n", "output": "298\n"}, {"input": "100 100 99\n", "output": "298\n"}, {"input": "99 100 100\n", "output": "298... | code_stdio |
[
{
"content": "You have an array of integers (initially empty).\n\nYou have to perform $q$ queries. Each query is of one of two types:\n\n\"$1$ $x$\" — add the element $x$ to the end of the array;\n\n\"$2$ $x$ $y$\" — replace all occurrences of $x$ in the array with $y$.\n\nFind the resulting array after perform... | [{"input": "8\n2 1 4\n1 1\n1 4\n1 2\n2 2 4\n2 4 3\n1 2\n2 2 7\n", "output": "1 3 3 7 \n"}, {"input": "8\n2 1 4\n1 1\n1 4\n1 2\n2 2 4\n2 4 3\n1 2\n2 2 7\n", "output": "1 3 3 7 "}, {"input": "8\n2 2 4\n1 1\n1 4\n1 2\n2 2 4\n2 4 3\n1 2\n2 2 7\n", "output": "1 3 3 7"}, {"input": "8\n2 2 4\n1 1\n1 4\n1 2\n2 2 6\n2 4 3\n1 2\... | code_stdio |
[
{
"content": "> I would, if I could,\n> If I couldn't how could I?\n> I couldn't, without I could, could I?\n> Could you, without you could, could ye?\n> Could ye? could ye?\n> Could you, without you could, could ye?\n\nIt is true, as this old rhyme says, that we can only DO what we can DO and we cannot DO... | [{"input": "15 2 3\n16 3 6\n110 9 112\n0 0 0", "output": "1\n11\n98\n"}, {"input": "15 2 4\n16 3 6\n110 9 112\n0 0 0", "output": "8\n11\n98\n"}, {"input": "15 2 4\n15 3 6\n110 9 112\n0 0 0", "output": "8\n10\n98\n"}, {"input": "10 2 3\n10 2 5\n100 13 40\n0 0 0", "output": "1\n2\n86\n"}, {"input": "10 2 3\n28 2 5\n100 1... | code_stdio |
[
{
"content": "Gildong is now developing a puzzle game. The puzzle consists of n platforms numbered from 1 to n. The player plays the game as a character that can stand on each platform and the goal of the game is to move the character from the 1-st platform to the n-th platform.\n\nThe i-th platform is labeled ... | [{"input": "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 1 4 2 1 0 2 1 0\n", "output": "\n0\n3\n2\n"}, {"input": "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 1 4 3 1 0 2 1 0\n", "output": "0\n3\n2\n"}, {"input": "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 1 4 2 1 0 2 0 0\n", "output": "0\n3\n1\n"}, {"input": "3\n4\n1 1 1 0\n5\n2 3 2 1 0\n9\n3 1 4 1... | code_stdio |
[
{
"content": "In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.\n\nMore precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a triangle.\n\nThree numbers a, b and c can form sides of ... | [{"input": "100\n42 486 341 527 189 740 490 388 989 489 711 174 305 844 971 492 998 757 832 442 176 619 906 154 293 395 439 735 738 915 453 748 2353 895 871 932 693 326 53 904 732 835 354 364 691 669 157 719 282 875 573 672 695 790 58 872 732 751 557 779 329 70 213 844 289 137 50 951 284 671 474 829 906 736 395 366 22 ... | code_stdio |
[
{
"content": "Snuke found a record of a tree with N vertices in ancient ruins. The findings are as follows:\n\n* The vertices of the tree were numbered 1,2,...,N, and the edges were numbered 1,2,...,N-1.\n* Edge i connected Vertex a_i and b_i.\n* The length of each edge was an integer between 1 and 10^{18} (inc... | [{"input": "15\n9 10\n9 15\n15 4\n4 13\n13 2\n13 11\n2 14\n13 6\n11 1\n2 12\n12 3\n12 7\n2 5\n14 8\n1154 890 2365 883 2930 2076 1590 1104 1726 1791 1091 1226 151 1000 1657", "output": "5\n6\n86\n104\n739\n85\n10\n148\n4\n37\n87\n28\n156\n8\n"}, {"input": "15\n9 10\n9 15\n15 4\n4 13\n13 2\n13 11\n2 14\n13 11\n11 1\n1 12... | code_stdio |
[
{
"content": "In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of n rooms located in a row, some of... | [{"input": "491 172\n01111101111111100000111010110001010001110111000010101111101000100010010111011101110110111101101010111000111000011100011010010010111111000011011010100110001000011100111000001011100010001111101111101000111001100110010100101000001110010100100100100101001100010101001000010000111110011000000100000100101... | code_stdio |
[
{
"content": "At Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the hospital energetically, the director plans to give a present to the person wh... | [{"input": "5\n263 1519 1817\n2 1240 1985\n11656 1896 4132\n10001 503 3107\n51 1421 2690\n3\n345 1628 2181\n7 3910 1590\n5982 2525 3616\n0", "output": "11656 6028\n5982 6141\n"}, {"input": "5\n263 1519 1817\n2 1240 1985\n11656 1896 4132\n10001 503 3107\n51 1421 2690\n3\n345 1628 2181\n7 3910 1590\n5982 2525 5629\n0", "... | code_stdio |
[
{
"content": "A sequence $a_1, a_2, \\dots, a_n$ is called good if, for each element $a_i$, there exists an element $a_j$ ($i \\ne j$) such that $a_i+a_j$ is a power of two (that is, $2^d$ for some non-negative integer $d$).\n\nFor example, the following sequences are good: $[5, 3, 11]$ (for example, for $a_1=... | [{"input": "10\n3 10 14 1 10 12 5 16 5 2\n", "output": "4\n"}, {"input": "10\n3 10 14 1 10 8 5 16 5 2\n", "output": "4\n"}, {"input": "10\n3 10 9 1 10 8 5 16 5 2\n", "output": "6\n"}, {"input": "10\n2 10 9 1 10 4 7 8 5 4\n", "output": "5\n"}, {"input": "10\n2 10 9 1 10 4 5 8 5 4\n", "output": "8\n"}, {"input": "10\n3 1... | code_stdio |
[
{
"content": "The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates fairly and to make those born under the lucky star the... | [{"input": "4 3 1\n3 1 2\n0 1 3\n4 3 4\n1 0 1\n0 0 0", "output": "2\n1\n"}, {"input": "4 3 1\n3 1 1\n0 1 3\n4 3 4\n1 0 1\n0 0 0", "output": "3\n1\n"}, {"input": "6 4 1\n3 -1 2\n2 2 3\n3 3 4\n0 2 4\n0 0 0", "output": "1\n"}, {"input": "6 4 1\n3 -1 2\n2 2 3\n3 3 4\n1 2 4\n0 0 0", "output": "1\n"}, {"input": "4 4 1\n3 2 0... | code_stdio |
[
{
"content": "Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each ... | [{"input": "14 5\n4 2\n5 4\n3 3\n2 3\n1 2\n", "output": "17\n"}, {"input": "14 5\n4 2\n3 8\n3 3\n2 3\n1 2\n", "output": "18\n"}, {"input": "14 5\n4 2\n5 4\n3 3\n2 3\n1 1\n", "output": "17\n"}, {"input": "14 5\n4 2\n9 4\n3 3\n2 3\n1 1\n", "output": "17\n"}, {"input": "14 5\n4 2\n9 4\n3 3\n2 3\n1 2\n", "output": "17\n"},... | code_stdio |
[
{
"content": "Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful.\n\nFirst, he renovated his house. Once his house had 9 rooms that were arranged in a square, but now his house has... | [{"input": "34 1\n1 6\n2 6\n0 0", "output": "..................................\n.EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.\n.E..............................E.\n.E.EEEEEEEEEEEEEEEEEEEEEEEEEEEE.E.\n.E.E..........................E.E.\n.E.E.EEEEEEEEEEEEEEEEEEEEEEEE.E.E.\n.E.E.E......................E.E.E.\n.E.E.E.EEEEEEEEEEEEEEEE... | code_stdio |
[
{
"content": "Vanya is doing his maths homework. He has an expression of form $x_{1} \\diamond x_{2} \\diamond x_{3} \\diamond \\ldots \\diamond x_{n}$, where x_1, x_2, ..., x_{n} are digits from 1 to 9, and sign [Image] represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of... | [{"input": "3+9+3+1+6+4+7+9+5+8+2+6+1+4+4+5+1+7+5+4+6+4+3+1*9+7+7+4+5+2+3+2+6+5+5+8+7+8+2+3*3+8+3+4+9+8*5+9+2+8+2+8+6+6+9+6+4+2+5+3+1+2+6+6+2+4+6+4+2+7+2+7+6+9+9+3+6+7+8+3+3+2+3+7+9+7+8+5+5+5*1+3+2+5+8+5*6+5+4*6+2+5+5+4+9+8+3+5+1+3+1+6+2+2+1+3+2+3+3+3+2+8+3+2+8+8+5+2+6+6+3+1+1+5+5*1+5+7+5+8+4+1*7+5+9+5+8+1*8+5+9+3+1+8+... | code_stdio |
[
{
"content": "Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). For example, if n = 6 then Funt has to pay 3 burles, ... | [{"input": "1999999927\n", "output": "1\n"}, {"input": "1000000009\n", "output": "1\n"}, {"input": "1847133842\n", "output": "2\n"}, {"input": "1076153021\n", "output": "3\n"}, {"input": "1908903481\n", "output": "3\n"}, {"input": "2000000000\n", "output": "2\n"}, {"input": "1000000007\n", "output": "1\n"}, {"input": "... | code_stdio |
[
{
"content": "Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory).\n\nDirectories in Vasya's operating system form a traditional hie... | [{"input": "11\npwd\ncd /home/vasya\npwd\ncd ..\npwd\ncd vasya/../../petya\npwd\ncd /a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a\npwd\ncd ..\npwd\n", "output": "/\n/h... | code_stdio |
[
{
"content": "Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones.\n\nAlice and Bob will play a game alternating turns with Alice going first.\n\nOn a player's turn, they must choose exactly $\\frac{n}{2}$ nonempty piles and in... | [{"input": "50\n42 31 49 11 28 38 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45 19 21 35 46 10 24 45 33 20 40\n", "output": "Alice\n"}, {"input": "50\n42 31 49 11 28 38 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45... | code_stdio |
[
{
"content": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two ... | [{"input": "100 1000\n1 2 1\n1 3 1\n1 4 1\n1 5 1\n1 6 1\n1 7 1\n1 8 1\n1 9 1\n1 10 1\n1 11 1\n1 12 1\n1 13 1\n1 14 1\n1 15 1\n1 16 1\n1 17 1\n1 18 1\n1 19 1\n1 20 1\n1 21 1\n1 22 1\n1 23 1\n1 24 1\n1 25 1\n1 26 1\n1 27 1\n1 28 1\n1 29 1\n1 30 1\n1 31 1\n1 32 1\n1 33 1\n1 34 1\n1 35 1\n1 36 1\n1 37 1\n1 38 1\n1 39 1\n1 ... | code_stdio |
[
{
"content": "Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as many coins as others. All coins given to Ivan must be d... | [{"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "-1\n"}, {"input": "1000000000000000000 1000000000000000000 1000010000000000000 1000000000000000000\n", "output": "-1\n"}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\... | code_stdio |
[
{
"content": "A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.\n\nOn the i-th day the festival will show a movie of genre a_{i}. We know that a movie of each of k genres oc... | [{"input": "129 37\n15 22 28 15 30 16 11 20 4 26 14 37 29 17 15 15 14 18 1 9 16 22 13 32 5 18 25 11 6 33 33 22 17 9 1 5 27 27 37 4 6 1 3 18 17 33 6 17 2 24 23 1 1 37 35 21 21 17 18 6 31 17 29 18 10 10 30 31 8 3 25 20 34 11 12 12 24 13 5 27 20 31 28 1 36 2 4 13 14 9 33 25 4 26 36 6 2 7 15 9 20 33 24 33 28 12 23 1 28 12 ... | code_stdio |
[
{
"content": "The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use it as a formal document.\n\nIn the Pindows ope... | [{"input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"input": "\"RUn.exe N\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn... | code_stdio |
[
{
"content": "You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At ... | [{"input": "17\n.EEEEE...EEEE..EE\nEEE..E...EEEEE..E\n.E..E..EEE.EE...E\n.EEE.EE..EE...E..\nE..EEEEEE.EE.....\nE.EE...EEEEEEE.E.\nEEEE....EE..E.EEE\n...EEEEE.E..EE...\nEEE.E..EEEE.EEE..\n..E.E....EEE.....\nEE..E..E.E..EEEEE\nEEE..E.EEEEE.E...\n..EEEEE.E..EE.EE.\nEE.E...E..E..E.EE\n..E.EEE.EE..EE.E.\nE..EE........E.E.\n... | code_stdio |
[
{
"content": "You are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\n* B is a (not necessarily continuous) subsequence of A.\n* For each pair of adjacents elements of B, the absolute difference of the element... | [{"input": "10 3\n1\n5\n2\n1\n1\n6\n11\n11\n4\n2", "output": "6\n"}, {"input": "10 3\n0\n5\n4\n3\n14\n11\n9\n5\n3\n4", "output": "6\n"}, {"input": "10 3\n0\n5\n4\n3\n11\n11\n9\n7\n6\n1", "output": "5\n"}, {"input": "10 1\n2\n8\n0\n3\n8\n11\n14\n7\n6\n1", "output": "4\n"}, {"input": "10 3\n1\n5\n2\n1\n1\n6\n12\n11\n4\n2... | code_stdio |
[
{
"content": "You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$.\n\nYou may perform some operations with matrix $B$. During each operation, you choose any submatrix of $B$ having size $2 \... | [{"input": "5 50\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0\... | code_stdio |
[
{
"content": "Chef Shifu and Chef Po are participating in the Greatest Dumpling Fight of 2012.\nOf course, Masterchef Oogway has formed the rules of the fight.\n\nThere is a long horizontal rope of infinite length with a center point P.\nInitially both Chef Shifu and Chef Po will stand on the center P of the ro... | [{"input": "3\n2 4 3 8 12\n1 4 0 2 -1\n11 22 10 18 16", "output": "13\n-1\n1\n"}, {"input": "3\n2 4 3 8 12\n1 4 4 2 -1\n10 22 12 9 16", "output": "13\n-1\n5\n"}, {"input": "3\n2 4 3 8 12\n1 4 0 2 -1\n11 22 10 7 16", "output": "13\n-1\n3\n"}, {"input": "3\n3 4 3 11 12\n1 6 0 1 0\n19 14 16 1 16", "output": "25\n1\n33\n"}... | code_stdio |
[
{
"content": "Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating principal and interest, there are \"single interest\" that c... | [{"input": "2\n7\n1 5 2\n-1 9 2\n2\n14\n1 5 2\n-1 13 1\n0", "output": "-1\n-1\n"}, {"input": "2\n7\n1 5 2\n-1 12 2\n2\n14\n0 5 2\n0 10 1\n0", "output": "-1\n0\n"}, {"input": "2\n14\n1 3 0\n17 6 2\n2\n12\n1 5 2\n1 12 1\n0", "output": "17\n1\n"}, {"input": "2\n25\n1 10 1\n3 7 2\n2\n7\n-1 16 1\n1 1 0\n0", "output": "3\n-1... | code_stdio |
[
{
"content": "Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. \n\nOstap's tree now has n vertices. He wants to paint some vertices of the tree black such that from any vertex u there is at least one black v... | [{"input": "64 3\n13 10\n60 54\n23 35\n4 41\n59 18\n41 36\n48 13\n64 8\n30 19\n53 3\n34 11\n24 27\n21 25\n5 55\n51 11\n3 45\n24 57\n47 38\n55 26\n8 20\n29 42\n44 3\n7 15\n9 1\n17 4\n41 9\n15 29\n60 13\n31 36\n53 52\n59 14\n12 52\n24 31\n47 28\n29 23\n2 49\n30 44\n28 31\n25 22\n9 58\n64 11\n45 35\n59 44\n62 8\n49 53\n32... | code_stdio |
[
{
"content": "We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.\n\nSnuke and Ringo will play the following game:\n\n* First, Snuke connects the N beams in any... | [{"input": "10\n1375710043 178537096\n1332309236 80797230\n164044598 544580992\n117241210 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n1789737664 267238505\n844917655 218662351\n662961957 100386692", "output": "1121712759 3406064155"}, {"input": "10\n646213683 228215172\n705445072 318106937\... | code_stdio |
[
{
"content": "You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. \nThe first line of each description consist... | [{"input": "1\n4\n15 1 11 10", "output": "11\n"}, {"input": "1\n4\n16 2 20 10", "output": "12\n"}, {"input": "1\n4\n-4 -1 0 -2", "output": "-6\n"}, {"input": "1\n4\n2 -1 0 -2", "output": "-3\n"}, {"input": "1\n4\n-1 1 0 -3", "output": "-4\n"}, {"input": "1\n4\n-2 1 0 -3", "output": "-5\n"}, {"input": "1\n4\n16 2 11 8",... | code_stdio |
[
{
"content": "Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini =... | [{"input": "6\n-1 -1 -1 1 -1 -1", "output": "-1 -1 -1 -1 -1 1\n2\n"}, {"input": "6\n-1 -1 -1 1 -2 -1", "output": "-2 -1 -1 -1 -1 1\n3\n"}, {"input": "6\n-1 -1 -1 1 -3 -1", "output": "-3 -1 -1 -1 -1 1\n3\n"}, {"input": "6\n-1 -1 -1 1 -4 -1", "output": "-4 -1 -1 -1 -1 1\n3\n"}, {"input": "6\n-1 -1 0 1 -3 -1", "output": "... | code_stdio |
[
{
"content": "Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper and the full-backs (plays defence), the othe... | [{"input": "1 100\n100 1\n99 99\n99 99\n", "output": "Team 1\n"}, {"input": "80 79\n79 30\n80 81\n40 80\n", "output": "Team 2\n"}, {"input": "48 41\n15 47\n11 38\n19 31\n", "output": "Team 1\n"}, {"input": "51 54\n95 28\n42 28\n17 48\n", "output": "Team 1\n"}, {"input": "19 56\n59 46\n40 70\n67 34\n", "output": "Team 2... | code_stdio |
[
{
"content": "Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. \n\nIn total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m students are willing to help GukiZ by removing al... | [{"input": "5 3\n999999999 999999999 999999999 999999999 19992232\n", "output": " 1339997413"}, {"input": "19 100000\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\n", "output": " 20"}, {"input": "20 20\n0 0 0 0 0 ... | code_stdio |
[
{
"content": "Did you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are coders above all, so what better way than to verify it by a small code. The ea... | [{"input": "3\n-1 0 R\n2\n1 -1 U\n1 1 D\n1 1 U\n1\n1 0 U\n0 0 R\n1\n4 -1 L", "output": "SAFE\nSAFE\nSAFE\n"}, {"input": "3\n0 0 R\n2\n1 -4 U\n2 3 D\n1 2 U\n1\n2 -1 U\n0 0 R\n1\n7 1 L", "output": "SAFE\nSAFE\nSAFE\n"}, {"input": "3\n0 0 R\n2\n1 -4 U\n2 3 D\n0 2 U\n1\n2 -1 U\n0 0 R\n1\n7 1 L", "output": "SAFE\nSAFE\nSAFE... | code_stdio |
[
{
"content": "Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: \"Little bears, wait a little, I want to make your pieces ... | [{"input": "1488496828 607500000\n", "output": "-1\n"}, {"input": "1183431925 540244525\n", "output": "-1\n"}, {"input": "1270836736 387420489\n", "output": "-1\n"}, {"input": "100000007 800000011\n", "output": "-1\n"}, {"input": "900000011 800000011\n", "output": "-1\n"}, {"input": "900000011 999900017\n", "output": "... | code_stdio |
[
{
"content": "We call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\n-----Constraints-----\n - 1000 ≤ N ≤ 9999\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following fo... | [{"input": "1118\n", "output": "Yes\n"}, {"input": "7777\n", "output": "Yes\n"}, {"input": "1234\n", "output": "No\n"}, {"input": "4000", "output": "Yes\n"}, {"input": "15093", "output": "No\n"}, {"input": "12733", "output": "No\n"}, {"input": "24549", "output": "No\n"}, {"input": "16730", "output": "No\n"}, {"input": ... | code_stdio |
[
{
"content": "During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. \n\nLet's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a_1, the second place participan... | [{"input": "10 -6\n5 2 1 9 5 2 4 4 9 2\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 -6\n5 2 1 8 5 2 4 4 9 2\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 14 1 1 5 1 1 4 9 2\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 -4\n5 4 1 7 5 1 2 4 15 2\n", "output": "2\n3\n4\n5\n7\n8\n9\n"... | code_stdio |
[
{
"content": "Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?\n\nNote, that you can't keep b... | [{"input": "100 100 100 100\n", "output": "YES\n"}, {"input": "100 101 100 100\n", "output": "NO\n"}, {"input": "100 101 99 100\n", "output": "YES\n"}, {"input": "100 100 99 100\n", "output": "NO\n"}, {"input": "100 98 99 97\n", "output": "YES\n"}, {"input": "70 100 10 86\n", "output": "NO\n"}, {"input": "76 97 99 74\n... | code_stdio |
[
{
"content": "Given are integers S and P.\nIs there a pair of positive integers (N,M) such that N + M = S and N \\times M = P?\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq S,P \\leq 10^{12}\n\n-----Input-----\nInput is given from Standard Input in the following format:\nS P\n\n----... | [{"input": "1000000000000 999999999999\n", "output": "Yes\n"}, {"input": "50000000002 100000000000\n", "output": "Yes\n"}, {"input": "978530427494 321593407609\n", "output": "No\n"}, {"input": "203939391324 871114841657\n", "output": "No\n"}, {"input": "119381456309 353176041209\n", "output": "No\n"}, {"input": "340495... | code_stdio |
[
{
"content": "Input\n\nThe input contains two integers a1, a2 (0 ≤ ai ≤ 109), separated by a single space.\n\nOutput\n\nOutput a single integer.\n\nExamples\n\nInput\n\n3 14\n\n\nOutput\n\n44\n\n\nInput\n\n27 12\n\n\nOutput\n\n48\n\n\nInput\n\n100 200\n\n\nOutput\n\n102\n\nWrite Python code to solve this proble... | [{"input": "1000000000 1000000000\n", "output": "1000000001\n"}, {"input": "1000000000 0000000000\n", "output": "1000000000\n"}, {"input": "1000000000 999999999\n", "output": "1999999999\n"}, {"input": "937477084 827336327\n", "output": "1661110812\n"}, {"input": "957747793 424238335\n", "output": "1491580217\n"}, {"in... | code_stdio |
[
{
"content": "For given a sequence $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$, print the previous permutation and the next permutation in lexicographic order.\n\nConstraints\n\n* $1 \\leq n \\leq 9$\n* $a_i$ consist of $1, 2, ..., n$\n\nInput\n\nA sequence is given in the following format.\n\n\n$n$\n$a_0 \\; a_1 \\... | [{"input": "3\n-1 12 -1", "output": "-1 -1 12\n-1 12 -1\n12 -1 -1\n"}, {"input": "3\n-1 16 -1", "output": "-1 -1 16\n-1 16 -1\n16 -1 -1\n"}, {"input": "3\n-1 13 -1", "output": "-1 -1 13\n-1 13 -1\n13 -1 -1\n"}, {"input": "3\n-1 18 -1", "output": "-1 -1 18\n-1 18 -1\n18 -1 -1\n"}, {"input": "3\n-1 20 -1", "output": "-1 ... | code_stdio |
[
{
"content": "problem\n\nOnce upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to the location of the building.\n\nThere is a descript... | [{"input": "10\n2 0\n1 1\n1 0\n1 -1\n2 5\n0 1\n2 1\n1 4\n1 14\n18 1\n10\n4 14\n4 0\n2 1\n0 2\n1 4\n0 5\n4 1\n1 1\n2 6\n5 -1\n0", "output": "1\n0\n"}, {"input": "10\n16 0\n0 1\n1 1\n1 0\n2 7\n0 3\n3 1\n1 3\n1 14\n18 2\n10\n2 7\n5 5\n2 1\n0 2\n1 4\n1 4\n4 1\n1 1\n1 6\n5 4\n0", "output": "0\n17\n"}, {"input": "10\n16 4\n4... | code_stdio |
[
{
"content": "There are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\nWe say a set of choices to put a ball or not in the boxes is go... | [{"input": "16416\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 1 1... | code_stdio |
[
{
"content": "Consider the infinite sequence s of positive integers, created by repeating the following steps:\n\n 1. Find the lexicographically smallest triple of positive integers (a, b, c) such that \n * a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_oper... | [{"input": "9\n2\n2\n6\n4\n14\n11\n13\n8\n17\n", "output": "2\n2\n12\n4\n9\n11\n7\n10\n32\n"}, {"input": "9\n2\n2\n3\n4\n10\n12\n12\n8\n11\n", "output": "2\n2\n3\n4\n6\n13\n13\n10\n11\n"}, {"input": "9\n2\n2\n6\n4\n14\n17\n13\n8\n17\n", "output": "2\n2\n12\n4\n9\n32\n7\n10\n32\n"}, {"input": "9\n2\n2\n3\n4\n8\n10\n20\n... | code_stdio |
[
{
"content": "Recently, the Fair Nut has written k strings of length n, consisting of letters \"a\" and \"b\". He calculated c — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.\n\nThen, he lost his sheet with strings. He remembers that all ... | [{"input": "100 1000000000\nbbabbaabbbaaaaabbabbbaaabbbbabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaabbbbabaabbbabbaaaaabbbbaab\nbbabbaabbbaaaaabbabbbaaabbbbabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababbbabbbbaaaaabbaaaaaaaab\n", "output": "41073741883\n"}, {"input": "100 1000000000\naaaaaaaaaaabbaaaaabbbababaaaab... | code_stdio |
[
{
"content": "Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}.\n\nMr. Kitayuta wants you to process the following q queries.\n\nIn the i-th qu... | [{"input": "5 7\n1 5 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "1\n1\n1\n1\n2\n"}, {"input": "5 7\n1 1 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "0\n0\n1\n0\n1\n"}, {"input": "5 7\n1 1 1\n2 5 1\n3 5 1\n4 5 2\n1 2 2\n2 3 2\n3 4 2\n5\... | code_stdio |
[
{
"content": "You are given a bracket sequence consisting of $n$ characters '(' and/or )'. You perform several operations with it.\n\nDuring one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.\n\nThe prefix is c... | [{"input": "8\n3\n)()\n8\n)()()(((\n4\n(()(\n5\n(())(\n6\n))((()\n5\n))())\n1\n)\n2\n)(\n", "output": "1 0\n3 1\n1 2\n2 1\n3 0\n2 1\n0 1\n0 2\n"}, {"input": "5\n3\n)()\n8\n)()()(((\n4\n(()(\n5\n(())(\n6\n))((()\n", "output": "1 0\n3 1\n1 2\n2 1\n3 0\n"}, {"input": "5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()(\n", "ou... | code_stdio |
[
{
"content": "Welcome! Everything is fine.\n\nYou have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eternity.\n\nYou have a list of k pairs of people who have arrived in a new inhabited neighborh... | [{"input": "2\n3\n1 2 3\n3 2 4\n2 4 0\n4 5 10\n5 6 5\n1\n1 2 2\n1 5 2\n1 4 6\n", "output": "12 32\n2 2\n"}, {"input": "2\n3\n1 2 3\n3 2 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 1\n1 3 0\n1 4 3\n", "output": "15 33\n4 4\n"}, {"input": "2\n3\n1 2 3\n3 2 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 0\n1 3 2\n1 4 3\n", "output": "15 33\n5 5\n"}, ... | code_stdio |
[
{
"content": "Dreamoon likes coloring cells very much.\n\nThere is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.\n\nYou are given an integer $m$ and $m$ integers $l_1, l_2, \\ldots, l_m$ ($1 \\le l_i \\le n$)\n\nDreamoon will perform $m$ operat... | [{"input": "2000 100\n5 128 1368 1679 1265 313 1854 1512 1924 338 38 1971 238 1262 1834 1878 1749 784 770 1617 191 395 303 214 1910 1300 741 1966 1367 24 268 403 1828 1033 1424 218 1146 925 1501 1760 1164 1881 1628 1596 1358 1360 29 1343 922 618 1537 1839 1114 1381 704 464 692 1450 1590 1121 670 300 1053 1730 1024 1292... | code_stdio |
[
{
"content": "You are the head of a large enterprise. $n$ people work at you, and $n$ is odd (i. e. $n$ is not divisible by $2$).\n\nYou have to distribute salaries to your employees. Initially, you have $s$ dollars for it, and the $i$-th employee should get a salary from $l_i$ to $r_i$ dollars. You have to dis... | [{"input": "3\n3 26\n10 12\n1 4\n13 26\n1 1337\n-1 1000000001\n5 26\n4 3\n1 4\n3 7\n2 12\n2 14\n", "output": "12\n1337\n7\n"}, {"input": "3\n3 25\n10 12\n1 4\n10 13\n1 1337\n1 1000000001\n5 26\n4 3\n0 4\n3 11\n2 12\n2 14\n", "output": "12\n1337\n7\n"}, {"input": "3\n3 26\n10 12\n1 4\n13 26\n1 1337\n-1 1000000001\n5 26\... | code_stdio |
[
{
"content": "Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magi... | [{"input": "150\n0 -2 1 -2 0 0 0 0 -2 0 -2 -1 0 0 2 0 1 -2 1 -1 0 0 0 2 -2 2 -1 0 0 0 -2 0 2 0 1 0 -2 0 -2 -1 -1 -2 -2 2 0 0 1 -2 -2 -1 -2 0 2 1 1 -1 1 0 -2 2 0 0 0 1 -1 0 -2 -1 0 -2 2 1 1 0 0 2 0 0 2 -1 0 0 2 0 2 0 -2 -1 1 -2 1 0 0 -2 -1 -1 0 0 2 -1 -1 -1 -1 -2 0 0 2 -1 -1 1 0 0 1 -1 0 0 -1 2 2 0 0 0 -1 -2 0 1 0 -1 0 ... | code_stdio |
[
{
"content": "We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s_1, s_2, ..., s_{k}. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices ... | [{"input": "100 3\nzsk\nzsk\nzsk\nzsk\nskz\nskz\nkzs\nskz\nkzs\nkzs\nzsk\nkzs\nkzs\nkzs\nskz\nkzs\nskz\nskz\nkzs\nzsk\nkzs\nkzs\nkzs\nskz\nskz\nskz\nzsk\nskz\nzsk\nskz\nkzs\nskz\nskz\nskz\nkzs\nzsk\nzsk\nkzs\nskz\nskz\nkzs\nkzs\nskz\nkzs\nkzs\nskz\nkzs\nskz\nkzs\nkzs\nskz\nkzs\nkzs\nkzs\nkzs\nskz\nkzs\nskz\nskz\nskz\ns... | code_stdio |
[
{
"content": "One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but ... | [{"input": "50\n363510947 363510954 363510943 363510964 363510969 363510950 363510951 363510960 363510967 363510952 363510956 363510948 363510944 363510946 363510965 363510946 363510963 363510962 363510947 363510955 363510954 363510948 363510961 363510964 363510963 363510945 363510965 363510953 363510952 363510968 3635... | code_stdio |
[
{
"content": "Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set.\n\nNow Wilbur wants to number the points in ... | [{"input": "40\n0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n1 0\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n8 0\n9 0\n10 0\n11 0\n12 0\n13 0\n14 0\n15 0\n16 0\n17 0\n18 0\n19 0\n20 0\n0 1 2 -1 -2 3 4 -3 5 6 7 8 0 -4 -5 1 -6 -7 -8 -9 -10 -11 9 2 -12 -13 -14 3 10 -15 11 4 -16... | code_stdio |
[
{
"content": "One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the righ... | [{"input": "1000000000000 999999999999\n", "output": "1000000000000\n"}, {"input": "1000000000000 999999999999\n", "output": "1000000000000\n"}, {"input": "1000000000000 999999999998\n", "output": "500000000000\n"}, {"input": "1000000000000 999999999998\n", "output": "500000000000\n"}, {"input": "1370863279309 12652739... | code_stdio |
[
{
"content": "Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements, such that the xor of all numbers from this segment was maximal possible. Hel... | [{"input": "99\n3511 2076 9314 3598 7737 271 4110 4454 5830 8661 8584 8227 2236 2626 1025 3806 3162 2837 6071 9627 1836 7729 6629 4054 9377 3261 1325 8859 3610 7616 5052 9736 1249 6224 7031 6074 4196 8075 4005 5419 5664 8214 4391 731 8714 8622 6122 6976 4057 1770 8025 3778 2792 994 5204 1826 6083 5438 8409 8029 1962 31... | code_stdio |
[
{
"content": "A wise man told Kerem \"Different is good\" once, so Kerem wants all things in his life to be different. \n\nKerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants all substrings of his string s to be distinct. Substring is a... | [{"input": "45\naaabbbcccdddeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"input": "45\naaabbbcccdddeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"input": "45\naaabbbcccdedeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"input": "45\naaabbbcccdedeeefffgghhijjjkkkkkkkkkkkkkkkkkkk\n", "o... | code_stdio |
[
{
"content": "Alice is the leader of the State Refactoring Party, and she is about to become the prime minister. \n\nThe elections have just taken place. There are $n$ parties, numbered from $1$ to $n$. The $i$-th party has received $a_i$ seats in the parliament.\n\nAlice's party has number $1$. In order to bec... | [{"input": "100\n100 48 48 22 21 27 51 43 53 34 54 37 45 37 27 53 39 53 37 44 55 44 31 36 55 47 45 23 40 32 55 54 40 38 30 25 28 20 39 20 53 50 41 26 29 37 42 55 23 27 51 30 39 50 24 30 22 50 56 32 60 45 50 43 27 25 52 59 47 58 28 56 49 39 33 52 26 46 23 42 45 58 42 50 49 25 28 30 46 43 26 32 40 53 60 21 54 16 57 50\n"... | code_stdio |
[
{
"content": "You are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:$f(p) = \\sum_{i = 1}^{n} \\sum_{j = i}^{n} \\operatorname{min}(p_{i}, p_{i + 1}, \\ldots p_{j})$\n\nFind the lexicographically m-th permutation of length n in the set of permutations having the maximum p... | [{"input": "50 562949953421311\n", "output": "49 50 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n"}, {"input": "50 562949953421310\n", "output": "48 50 49 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23... | code_stdio |
[
{
"content": "Playing with Stones\n\nKoshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows:\n\n1. Before starting the game, they define some small areas and place \"one or more black stones and one or more white stones\" in each of the areas.\n2. Koshiro and Ukik... | [{"input": "4\n24 99\n15 68\n12 155\n95 79", "output": "0\n"}, {"input": "4\n24 99\n15 97\n12 149\n95 79", "output": "0\n"}, {"input": "4\n39 99\n15 97\n12 149\n95 79", "output": "0\n"}, {"input": "4\n24 99\n15 68\n12 90\n95 66", "output": "0\n"}, {"input": "4\n24 99\n15 44\n12 90\n95 66", "output": "0\n"}, {"input": "... | code_stdio |
[
{
"content": "A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the t... | [{"input": "3\nA sample input\n9\nforward word\ndelete char\nforward word\ndelete char\nforward word\ndelete char\nbackward word\nbackward word\nforward word\nHallow, Word.\n7\nforward char\ndelete word\ninsert \"ello, \"\nforward word\nbackward char\nbackward char\ninsert \"l\"\n\n3\nforward vord\nbackward word\ndelet... | code_stdio |
[
{
"content": "Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha ha... | [{"input": "26 26\nabcdefghijklmnopqrstuvwxyz\nffffffffffffffffffffffffff\n", "output": "25\n1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 \n"}, {"input": "26 26\nabcdefghijklmnopqrstuvwxyz\nffffffffffffffffffffffffff\n", "output": "25\n1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2... | code_stdio |
[
{
"content": "Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: $1$, $4$, $8$, $9$, ....\n\nFor a given number $n$, count the number of integers from $1$ to $n$ that Polycarp likes. In other words, find the number of such $x$ that $x$ is a square o... | [{"input": "20\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "output": "32591\n32591\n32591\n32591\n32591\n32591\n32591\n3... | code_stdio |
[
{
"content": "Mr. Chanek has an integer represented by a string $s$. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, meaning they're the same digit.\n\nMr. Chanek wants to count the number of possible integer $s$, where $s$ i... | [{"input": "________\n", "output": "3600000\n"}, {"input": "X_______\n", "output": "3600000\n"}, {"input": "_____X__\n", "output": "3600000\n"}, {"input": "_______X\n", "output": "3600000\n"}, {"input": "________\n", "output": "3600000\n"}, {"input": "_____X__\n", "output": "3600000\n"}, {"input": "X_______\n", "output... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nPrincess Rupsa saw one of her friends playing a special game. The game goes as follows:\n\nN+1 numbers occur sequentially (one at a time) from A_{0} to A_{N}.\nYou must write the numbers on a sheet of paper, such tha... | [{"input": "2\n1\n1 0\n2\n10 -1 -1", "output": "0\n999999949\n"}, {"input": "2\n1\n2 4\n2\n1 -1 1", "output": "16\n1000000003\n"}, {"input": "2\n1\n1 2\n2\n1 -1 0", "output": "4\n1000000003\n"}, {"input": "2\n1\n1 2\n2\n1 0 -1", "output": "4\n1000000005\n"}, {"input": "2\n1\n0 2\n2\n1 0 -1", "output": "0\n1000000005\n"... | code_stdio |
[
{
"content": "Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these da... | [{"input": "1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 346\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102", "output": "1a 375 99300\n1c 507 119700\n1f 292 78300\n2b 535 123300\n2c 575 149600\n2e 597 140000\n3a 286 74000\n3b 556 140500\n3d 383 86800\n"}, {"input": "1a 132 243\n1c 324 183\n1f 93 199\n3b 372 1... | code_stdio |
[
{
"content": "Problem statement\n\nWhen you heard that this year's KUPC can be joined as a team, you decided to talk to your friends and join as a team.\n\nEventually, $ 4 $ people, including you, got together.\n\nIndividual strength is expressed in ratings, and $ 4 $ person ratings are $ a $, $ b $, $ c $, and... | [{"input": "-127 10 -1 -1", "output": "115\n"}, {"input": "-127 10 -1 -3", "output": "113\n"}, {"input": "-1 -12 2 137", "output": "124\n"}, {"input": "2 -2 -158 -1", "output": "153\n"}, {"input": "1 -2 -158 -1", "output": "154\n"}, {"input": "1 -2 -256 -1", "output": "252\n"}, {"input": "-127 26 -1 -1", "output": "99\... | code_stdio |
[
{
"content": "Petya is preparing for his birthday. He decided that there would be $n$ different dishes on the dinner table, numbered from $1$ to $n$. Since Petya doesn't like to cook, he wants to order these dishes in restaurants.\n\nUnfortunately, all dishes are prepared in different restaurants and therefore ... | [{"input": "4\n4\n3 7 4 5\n2 1 2 4\n4\n1 2 3 4\n3 3 3 3\n2\n1 2\n10 10\n2\n10 10\n1 2\n", "output": "5\n3\n2\n3\n"}, {"input": "4\n4\n3 11 4 2\n2 1 2 4\n4\n1 2 3 4\n3 3 3 3\n2\n1 2\n10 10\n2\n10 10\n1 2\n", "output": "3\n3\n2\n3"}, {"input": "4\n4\n3 7 4 5\n3 1 2 4\n4\n1 2 3 4\n3 3 3 10\n2\n0 2\n10 10\n2\n10 10\n1 0\n"... | code_stdio |
[
{
"content": "Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.\n\nPolycarp needed to write a code that could, given tw... | [{"input": "250\niiffiehchidfgigdbcciahdehjjfacbbaaadagaibjjcehjcbjdhaadebaejiicgidbhajfbfejcdicgfbcchgbahfccbefdcddbjjhejigiafhdjbiiehadfficicbebeeegcebideijidbgdecffeaegjfjbbcfiabfbaiddbjgidebdiccfcgfbcbbfhaejaibeicghecchjbiaceaibfgibhgcfgifiedcbhhfadhccfdhejeggcah\njbadcfjffcfabbecfabgcafgfcgfeffjjhhdaajjgcbgbechhia... | code_stdio |
[
{
"content": "For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $n$ days of summer. On the $i$-th day, $a_i$ millimeters of rain will fall. All values $a... | [{"input": "100 7 7\n1656 322 975 921 115 647 61 232 127 277 839 797 261 968 788 381 191 117 663 959 475 166 471 984 17 473 57 809 65 881 1109 725 587 933 466 537 1017 706 927 173 636 372 644 82 835 893 792 494 808 977 479 109 1858 21 625 104 626 569 524 504 16 257 274 285 404 629 247 609 521 602 483 271 45 442 503 438... | code_stdio |
[
{
"content": "You are given n switches and m lamps. The i-th switch turns on some subset of the lamps. This information is given as the matrix a consisting of n rows and m columns where a_{i}, j = 1 if the i-th switch turns on the j-th lamp and a_{i}, j = 0 if the i-th switch is not connected to the j-th lamp.\... | [{"input": "4 15\n111110100011010\n111111011010110\n101000001011001\n100110000111011\n", "output": "YES\n"}, {"input": "4 15\n111110100011010\n111111011010110\n101000001011001\n100110000111011\n", "output": "YES\n"}, {"input": "4 15\n111110100011010\n111111011010110\n101000001011001\n100110000111001\n", "output": "YES\... | code_stdio |
[
{
"content": "You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2000) — the number of points.\n\nEach o... | [{"input": "20\n0 17\n1 8\n1 9\n2 5\n2 11\n3 0\n5 10\n5 13\n6 7\n7 3\n12 13\n13 7\n14 16\n15 10\n15 18\n17 2\n17 12\n18 14\n19 18\n20 17\n", "output": "18\n"}, {"input": "20\n0 17\n1 8\n1 9\n2 5\n2 11\n3 0\n5 10\n5 13\n6 7\n7 3\n12 13\n13 7\n14 16\n15 10\n15 18\n17 2\n17 12\n18 14\n19 18\n20 17\n", "output": "18\n"}, {... | code_stdio |
[
{
"content": "A well-known art union called \"Kalevich is Alive!\" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows.\n\nEach painter uses only the color that was assigned to him. The colors are distinct for all painters. Let's assume that the ... | [{"input": "10 3\n6 10 3\n2 7 12\n7 4 7\n10 3 2\n6 5 12\n8 4 4\n5 9 11\n6 7 7\n2 6 10\n2 6 2\n", "output": "19 35 42 44 56 60 71 78 88 90\n"}, {"input": "10 3\n6 10 3\n2 7 12\n7 4 7\n6 3 0\n6 5 12\n8 4 4\n5 15 11\n6 7 3\n2 6 10\n2 6 2\n", "output": "19 35 42 42 54 58 69 72 82 84\n"}, {"input": "10 3\n6 10 3\n3 7 12\n7 ... | code_stdio |
[
{
"content": "You are given a simple weighted connected undirected graph, consisting of $n$ vertices and $m$ edges.\n\nA path in the graph of length $k$ is a sequence of $k+1$ vertices $v_1, v_2, \\dots, v_{k+1}$ such that for each $i$ $(1 \\le i \\le k)$ the edge $(v_i, v_{i+1})$ is present in the graph. A pat... | [{"input": "15 15 23\n13 10 12\n11 14 12\n2 15 5\n4 10 8\n10 2 4\n10 7 5\n3 10 1\n5 6 11\n1 13 8\n9 15 4\n4 2 9\n11 15 1\n11 12 14\n10 8 12\n3 6 11\n", "output": "3250\n"}, {"input": "15 15 23\n13 11 12\n11 14 12\n2 15 5\n4 10 8\n10 2 4\n10 7 5\n3 10 1\n5 6 11\n1 13 8\n9 15 4\n4 2 9\n11 15 1\n11 12 14\n10 8 12\n3 6 11\... | code_stdio |
[
{
"content": "The following problem is well-known: given integers n and m, calculate $2^{n} \\operatorname{mod} m$, \n\nwhere 2^{n} = 2·2·...·2 (n factors), and $x \\operatorname{mod} y$ denotes the remainder of division of x by y.\n\nYou are asked to solve the \"reverse\" problem. Given integers n and m, calcu... | [{"input": "100000000\n100000000\n", "output": "100000000\n"}, {"input": "100000000\n100000000\n", "output": "100000000\n"}, {"input": "100000000\n100001000\n", "output": "100001000\n"}, {"input": "100000000\n110001000\n", "output": "110001000\n"}, {"input": "99999999\n100000000\n", "output": "100000000\n"}, {"input": ... | code_stdio |
[
{
"content": "The R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.\n\nR2 has m Spyke chats just to discuss all sorts of issues. In each chat, some group of... | [{"input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 1 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0 0 0\n4 1\n2 6\n7 3\n7 1\n5 3\n", "output": "1 2 4 4 3 4 2 \n"}, {"input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 1 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0 0 0\n4 1\n2 6\n7 3\n7 1\n5 3\n", "output": "1 2... | code_stdio |
[
{
"content": "The Little Elephant loves to play with color cards.\n\nHe has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Elephant can turn any card to the other side. Th... | [{"input": "100\n1 2\n2 1\n2 1\n1 2\n1 1\n1 2\n2 1\n1 1\n2 2\n2 1\n2 1\n1 1\n1 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 1\n2 1\n1 1\n1 1\n2 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n2 2\n1 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n1 1\n1 2\n1 1\n1 1\n2 2\n2 2\n2 1\n2 1\n1 2\n2 2\n1 1\n2 1\n2 2\n1 1\n1 1\n1 2\n2 2... | code_stdio |
[
{
"content": "There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each b... | [{"input": "2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 4 5\n0 1 -1 1 2\n-1 1 1 2 2\n1 0 3 1 1\n0 0", "output": "Yes\nYes\n"}, {"input": "2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 7 5\n0 1 -1 1 2\n-1 1 1 2 2\n1 0 3 1 1\n0 0", "output": "Yes\nYes\n"}, {"input": "2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 7 5\n0 1 -1 1 2\n-1 1 1 0 2\n1 0 ... | code_stdio |
[
{
"content": "You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. \n\nFind the maximum possible value of <image> after performing at most k ... | [{"input": "5 1 3\n1 5 13 8 16\n", "output": " 63\n"}, {"input": "5 10 8\n0 0 0 0 0\n", "output": " 0\n"}, {"input": "5 10 8\n1000000000 1000001000 1000000000 1000000000 1000000000\n", "output": "1... | code_stdio |
[
{
"content": "Long time ago there was a symmetric array $a_1,a_2,\\ldots,a_{2n}$ consisting of $2n$ distinct integers. Array $a_1,a_2,\\ldots,a_{2n}$ is called symmetric if for each integer $1 \\le i \\le 2n$, there exists an integer $1 \\le j \\le 2n$ such that $a_i = -a_j$.\n\nFor each integer $1 \\le i \\le ... | [{"input": "6\n2\n8 12 8 12\n2\n7 7 9 11\n2\n7 11 7 11\n1\n1 1\n4\n40 56 48 40 160 56 117 48\n6\n240 154 210 162 174 154 186 240 174 186 162 210\n", "output": "YES\nNO\nNO\nNO\nNO\nYES\n"}, {"input": "6\n2\n8 12 8 12\n2\n7 7 9 11\n2\n0 11 7 11\n1\n1 1\n4\n40 56 48 40 160 56 117 48\n6\n240 154 210 162 174 154 186 240 17... | code_stdio |
[
{
"content": "You are given an array consisting of $n$ integers $a_1, a_2, \\dots , a_n$ and an integer $x$. It is guaranteed that for every $i$, $1 \\le a_i \\le x$.\n\nLet's denote a function $f(l, r)$ which erases all values such that $l \\le a_i \\le r$ from the array $a$ and returns the resulting array. Fo... | [{"input": "100 100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "ou... | code_stdio |
[
{
"content": "The princess is going to escape the dragon's cave, and she needs to plan it carefully.\n\nThe princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to su... | [{"input": "2\n100\n10\n10\n739\n", "output": "22\n"}, {"input": "1\n100\n1\n1\n1000\n", "output": "152\n"}, {"input": "2\n100\n13\n10\n739\n", "output": "22\n"}, {"input": "1\n100\n2\n1\n1000\n", "output": "151\n"}, {"input": "2\n100\n24\n10\n739\n", "output": "21\n"}, {"input": "100\n99\n1\n1\n1000\n", "output": "0\n... | code_stdio |
[
{
"content": "Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G'... | [{"input": "8\n-1\nBB\n0\nBG\n1\nGBGB\n2\nBGG\n2\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB", "output": "-1\n0\n0\n1\n1\n3\n1\n0\n"}, {"input": "8\n1\nBB\n0\nBG\n0\nBBGG\n1\nAGG\n0\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB", "output": "-1\n0\n1\n-1\n1\n3\n1\n0\n"}, {"input": "8\n1\nBB\n0\nBG\n0\nBBGG\n1\nAGG\n0\nBGGB\n1\nBBBGG\n2\nBBGG\n... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.