messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a_1, a_2, \\dots, a_n$. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements $a_i = a_{i + 1}$ (if there is at least one such pair). Replac...
[{"type": "stdin_stdout", "input": "50\n1 1 1 1 1 2 1 1 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 1 1 1 2 2 2 2 2 1 2 2 2 1\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "50\n1 1 1 1 1 2 1 1 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 1 1 1 2 2 2 2 2 1 2 2 2 1\n", "output": "19\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of ...
[{"type": "stdin_stdout", "input": "50\n48 45 42\n32 45 8\n15 41 47\n32 29 38\n7 16 48\n19 9 21\n18 40 5\n39 40 7\n37 0 6\n42 15 37\n9 33 37\n40 41 33\n25 43 2\n23 21 38\n30 20 32\n28 15 5\n47 9 19\n47 22 26\n26 9 18\n24 23 24\n11 29 5\n38 44 9\n49 22 42\n1 15 32\n18 25 21\n8 48 39\n48 7 26\n3 30 26\n34 21 47\n34 14 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen little Petya grew up and entered the university, he started to take part in АСМ contests. Later he realized that he doesn't like how the АСМ contests are organised: the team could only have three members (and he coul...
[{"type": "stdin_stdout", "input": "16 25\nbBZ\nEr\nZ\nrYJmfZLgmx\nPaJNrF\naHtRqSxOO\nD\nhsagsG\nMDuBOXrmWH\nSgjMQZ\nYXgWq\nxDwpppG\nSDY\nJwZWx\ncOzrgrBaE\nFJYX\nYXgWq SgjMQZ\nSDY PaJNrF\nFJYX rYJmfZLgmx\nhsagsG Er\nxDwpppG rYJmfZLgmx\naHtRqSxOO rYJmfZLgmx\nhsagsG bBZ\nJwZWx hsagsG\nFJYX cOzrgrBaE\nSDY YXgWq\nFJYX Z\nJ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\nSince this sum can be enormous, p...
[{"type": "stdin_stdout", "input": "100000 100000\n", "output": "742202979\n"}, {"type": "stdin_stdout", "input": "101000 100000", "output": "817082185\n"}, {"type": "stdin_stdout", "input": "101010 100000", "output": "781111243\n"}, {"type": "stdin_stdout", "input": "99991 99989\n", "output": "215961669\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nFor each k=1, ..., N, solve the problem below:\n - Consider writing a number on each vertex in the tree in the follo...
[{"type": "stdin_stdout", "input": "8\n1 3\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8", "output": "240\n240\n1680\n240\n240\n1008\n144\n144\n"}, {"type": "stdin_stdout", "input": "8\n1 3\n2 3\n5 4\n3 5\n3 6\n3 7\n3 8", "output": "360\n360\n2520\n120\n840\n360\n360\n360\n"}, {"type": "stdin_stdout", "input": "8\n1 2\n2 3\n2 4\n3 5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the ...
[{"type": "stdin_stdout", "input": "92\n13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12\n", "output": "DOWN\n"}, {"type": "stdin_stdout", "input": "9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of length $n$ consisting of zeros. You perform $n$ actions with this array: during the $i$-th action, the following sequence of operations appears: Choose the maximum by length subarray (contin...
[{"type": "stdin_stdout", "input": "6\n4\n4\n2\n26\n2\n10\n", "output": "3 1 2 4\n3 1 2 4\n1 2\n11 16 7 12 17 3 13 18 4 19 8 20 1 14 21 5 22 9 23 2 15 24 6 25 10 26\n1 2\n7 3 4 8 1 5 9 2 6 10\n"}, {"type": "stdin_stdout", "input": "6\n2\n2\n2\n16\n3\n21\n", "output": "1 2\n1 2\n1 2\n9 5 10 3 11 6 12 1 13 7 14 2 15 4 8 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Cybermen and the Daleks have long been the Doctor's main enemies. Everyone knows that both these species enjoy destroying everything they encounter. However, a little-known fact about them is that they both also love ...
[{"type": "stdin_stdout", "input": "10\n11 11\n11 12\n11 15\n11 17\n11 18\n11 19\n11 28\n11 33\n11 38\n11 40\n12 11\n15 46\n17 11\n17 46\n18 46\n19 11\n19 46\n20 11\n20 46\n24 46\n25 46\n26 11\n32 11\n32 46\n33 11\n34 46\n36 11\n39 11\n40 46\n43 11\n44 0\n46 14\n46 15\n46 17\n46 22\n46 26\n46 28\n46 32\n46 43\n46 45\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCasimir has a string $s$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:\n\nhe can either erase exactly one letter 'A' and exactly one letter...
[{"type": "stdin_stdout", "input": "6\nABABAB\nABBA\nBC\nABC\nCABBCB\nBBCBCBCBCBCCCBCB\n", "output": "YES\nYES\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "6\nBBAACB\nABBA\nBC\nABA\nACBCBB\nCBCBCBCBCBCBCBCB\n", "output": "YES\nYES\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "6\nABACAB\nABBA\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke found a random number generator. It generates an integer between 0 and 2^N-1 (inclusive). An integer sequence A_0, A_1, \\cdots, A_{2^N-1} represents the probability that each of these integers is generated. The int...
[{"type": "stdin_stdout", "input": "4\n337 780 799 18 796 875 331 223 1804 67 268 483 390 565 116 355", "output": "0\n870892872\n738673049\n866136893\n809360917\n134965576\n496873404\n200938352\n392063026\n225113281\n769068776\n945265000\n612087551\n845908556\n726467732\n606029955\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMole is hungry again. He found one ant colony, consisting of n ants, ordered in a row. Each ant i (1 ≤ i ≤ n) has a strength si.\n\nIn order to make his dinner more interesting, Mole organizes a version of «Hunger Games» ...
[{"type": "stdin_stdout", "input": "5\n1 5 2 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "4\n4\n1\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "4\n4\n2\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4 4 2\n4\n1 5\n2 5\n3 5\n2 5\n", "output": "4\n4\n2\n4\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Elephant is playing a game with arrays. He is given an array A0, A1, ..., AN−1 of N integers. And then Q queries are given, each containing an integer K. He has to tell how many subarrays satisfy the condition: the...
[{"type": "stdin_stdout", "input": "5\n4 1 2 3 4\n4\n3\n4\n6\n1\n\n\n", "output": "2\n2\n0\n8\n"}, {"type": "stdin_stdout", "input": "5\n4 1 1 6 4\n4\n1\n0\n1\n-1", "output": "11\n0\n11\n0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 1 6 4\n4\n0\n5\n1\n-1", "output": "0\n0\n11\n0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya’s elder brother Petya loves playing computer games. In one of his favourite computer games Petya reached the final level where a fight with the boss take place.\n\nWhile playing the game Petya found spell scrolls an...
[{"type": "stdin_stdout", "input": "70 1000 1\n91 2\n43 1\n100 1\n79 2\n26 1\n68 2\n4 2\n64 1\n100 1\n80 2\n20 2\n70 1\n25 1\n99 1\n64 1\n35 2\n60 1\n63 2\n93 1\n40 2\n100 1\n54 1\n100 1\n15 2\n72 1\n28 1\n5 1\n93 1\n100 2\n39 2\n54 2\n100 1\n55 1\n43 1\n20 1\n28 2\n21 1\n100 2\n98 1\n35 1\n12 2\n50 2\n7 2\n7 2\n12 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence A, where its elements are either in the form + x or -, where x is an integer.\n\nFor such a sequence S where its elements are either in the form + x or -, define f(S) as follows:\n\n * iterate th...
[{"type": "stdin_stdout", "input": "15\n+ 2101039\n-\n+ 4567886\n+ 113371486\n-\n+ 578943\n-\n-\n+ 62356680\n-\n+ 711111\n-\n+ 797735011\n-\n-\n", "output": "431927902\n"}, {"type": "stdin_stdout", "input": "15\n+ 2168539\n-\n+ 4567886\n+ 113371486\n-\n+ 578943\n-\n-\n+ 62356680\n-\n+ 711111\n-\n+ 797735011\n-\n-\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoger is a robot. He has an arm that is a series of n segments connected to each other. The endpoints of the i-th segment are initially located at points (i - 1, 0) and (i, 0). The endpoint at (i - 1, 0) is colored red an...
[{"type": "stdin_stdout", "input": "50 50\n1 41 261\n2 47 324\n1 41 256\n1 31 339\n2 23 116\n2 44 184\n2 32 115\n1 40 301\n2 40 303\n1 29 309\n2 49 348\n2 47 356\n1 41 263\n2 42 276\n1 45 135\n1 33 226\n2 31 166\n1 50 171\n2 47 166\n2 50 146\n2 25 324\n2 48 307\n2 41 176\n1 50 353\n1 45 323\n2 50 343\n1 47 200\n2 48 26...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC: Skewering\n\nproblem\n\nOne day, when Homura was playing with blocks, Tempura came. Homura decided to play with blocks with Tempura.\n\nThere is a rectangular parallelepiped of A \\ times B \\ times C, which is made by...
[{"type": "stdin_stdout", "input": "28 11 20", "output": "Tem\n"}, {"type": "stdin_stdout", "input": "28 11 17", "output": "Hom\n"}, {"type": "stdin_stdout", "input": "54 11 17", "output": "Hom\n"}, {"type": "stdin_stdout", "input": "12 6 20", "output": "Tem\n"}, {"type": "stdin_stdout", "input": "24 6 20", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching to...
[{"type": "stdin_stdout", "input": "12 8\n3\n-1 1\n3 4\n18 6", "output": "31\n3 4\n"}, {"type": "stdin_stdout", "input": "1 4\n3\n1 -1\n0 6\n2 -1", "output": "10\n1 -1\n"}, {"type": "stdin_stdout", "input": "12 8\n3\n-1 1\n3 4\n18 5", "output": "30\n3 4\n"}, {"type": "stdin_stdout", "input": "12 8\n3\n-1 1\n5 4\n10 5",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs we all know, F.C. Barcelona is the best soccer team of our era! Their entangling and mesmerizing game style usually translates into very high ball possession, consecutive counter-attack plays and goals. Lots of goals, ...
[{"type": "stdin_stdout", "input": "2\n28 3\n8 2", "output": "198073708\n86\n"}, {"type": "stdin_stdout", "input": "2\n28 3\n8 1", "output": "198073708\n1\n"}, {"type": "stdin_stdout", "input": "2\n28 3\n8 0", "output": "198073708\n0\n"}, {"type": "stdin_stdout", "input": "2\n16 3\n8 2", "output": "10761681\n86\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a little polar bear. He has n balls, the i-th ball has size t_{i}.\n\nLimak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy...
[{"type": "stdin_stdout", "input": "50\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "NO\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two towers consisting of blocks of two colors: red and blue. Both towers are represented by strings of characters B and/or R denoting the order of blocks in them from the bottom to the top, where B corresponds t...
[{"type": "stdin_stdout", "input": "23\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n", "output": "YES\nYES\nYES...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call the string beautiful if it does not contain a substring of length at least $2$, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from ...
[{"type": "stdin_stdout", "input": "10 3\naaabababaa\n1 1\n2 10\n1 2\n", "output": "0\n6\n1\n"}, {"type": "stdin_stdout", "input": "10 3\naaabababaa\n1 1\n3 10\n1 2\n", "output": "0\n5\n1\n"}, {"type": "stdin_stdout", "input": "10 3\naaabababaa\n1 1\n2 10\n1 4\n", "output": "0\n6\n2\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$.\n\nThere are three...
[{"type": "stdin_stdout", "input": "100 43\n76 77 1\n24 25 1\n2 3 1\n85 86 1\n49 50 1\n15 16 1\n30 31 1\n78 79 1\n54 55 1\n58 59 1\n17 18 1\n67 68 1\n21 22 1\n80 81 1\n35 36 1\n8 9 1\n83 84 1\n44 45 1\n62 63 1\n64 65 1\n72 73 1\n27 28 1\n56 57 1\n12 13 1\n40 41 1\n32 33 1\n52 53 1\n70 71 1\n97 98 1\n37 38 1\n87 88 1\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between the easy and hard versions are the locations you can teleport to.\n\nConsider the points $0,1,\\dots,n+1$ on the number line. There is a teleporter located on each of the points $1,2,\\dots,n$....
[{"type": "stdin_stdout", "input": "1\n100 123\n398 282 403 364 468 174 143 360 217 340 354 195 84 253 114 421 494 370 104 214 149 469 446 362 108 106 115 402 253 461 483 59 365 94 281 84 248 321 228 196 96 360 321 357 151 250 496 207 425 397 114 345 252 489 30 345 182 310 440 392 111 361 49 307 328 84 201 339 351 459 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSince I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer L, how many pairs of positive integers a, b (a ≤ b) such that LCM(a, b) = L are there? Here, L...
[{"type": "stdin_stdout", "input": "12\n7\n24\n0", "output": "8\n2\n11\n"}, {"type": "stdin_stdout", "input": "12\n11\n2\n0", "output": "8\n2\n2\n"}, {"type": "stdin_stdout", "input": "12\n15\n2\n0", "output": "8\n5\n2\n"}, {"type": "stdin_stdout", "input": "12\n11\n4\n0", "output": "8\n2\n3\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMin Element\n\nGiven the sequence a_1, a_2, .., a_N.\n\nFind the minimum number in this sequence.\n\nIf the minimum value is in more than one place, answer the one with the lowest number.\n\ninput\n\n\nN\na_1 a_2 ... a_N\...
[{"type": "stdin_stdout", "input": "6\n10 17 3 2 6 -1", "output": "6\n"}, {"type": "stdin_stdout", "input": "6\n3 33 0 2 10 -1", "output": "6\n"}, {"type": "stdin_stdout", "input": "6\n3 55 0 2 10 -1", "output": "6\n"}, {"type": "stdin_stdout", "input": "6\n3 55 0 4 10 -1", "output": "6\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSoon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called \"chizhik\". One has to pay in chizhiks to buy a coco...
[{"type": "stdin_stdout", "input": "500000000000000000 500000000000000000 1000000000000000000\n", "output": "1 500000000000000000\n"}, {"type": "stdin_stdout", "input": "500000000000000000 500000000000000000 1000000000000000000\n", "output": "1 500000000000000000\n"}, {"type": "stdin_stdout", "input": "3509193081606779...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the advanced algorithm class, n2 students sit in n rows and n columns. One day, a professor who teaches this subject comes into the class, asks the shortest student in each row to lift up his left hand, and the tallest...
[{"type": "stdin_stdout", "input": "3\n1 2 5\n11 3 6\n12 5 9\n3\n1 11 3\n13 11 14\n4 8 6\n0", "output": "5\n11\n"}, {"type": "stdin_stdout", "input": "3\n2 1 3\n4 2 11\n7 0 4\n3\n1 4 12\n14 10 18\n4 8 10\n0", "output": "2\n10\n"}, {"type": "stdin_stdout", "input": "3\n1 2 10\n11 3 6\n12 9 15\n3\n1 11 3\n13 11 9\n7 8 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices ...
[{"type": "stdin_stdout", "input": "0.0,0.0\n0.0,1.0\n1.0,1.0\n2.0,0.0\n1.0,-1.0", "output": "2.500000"}, {"type": "stdin_stdout", "input": "0.0,0.0\n0.0,1.0\n0.0,.11\n2.1,0.0\n1.1,-1.0", "output": "1.1655\n"}, {"type": "stdin_stdout", "input": "0.1,0.0\n0.0,1.0\n1.01,.0\n2.0,0.0\n1.0,-0.0", "output": "0.455\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\...
[{"type": "stdin_stdout", "input": "100 3\n94 94 149 27 80 73 61 38 34 139 72 96 59 36 113 15 83 78 39 22 21 57 54 20 9 32 81 64 55 90 67 41 18 57 93 76 44 62 77 66 31 70 39 73 81 57 43 31 20 104 62 26 44 26 23 23 66 53 3 14 10 170 53 19 43 81 98 12 91 15 122 90 89 86 58 30 67 73 46 69 68 47 30 7 89 35 17 93 45 6 4 23 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a regular polygon with $n$ vertices labeled from $1$ to $n$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the in...
[{"type": "stdin_stdout", "input": "500\n", "output": "41666498\n"}, {"type": "stdin_stdout", "input": "497\n", "output": "40920990\n"}, {"type": "stdin_stdout", "input": "494\n", "output": "40184428\n"}, {"type": "stdin_stdout", "input": "491\n", "output": "39456758\n"}, {"type": "stdin_stdout", "input": "488\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA binary string is a string that consists of characters $0$ and $1$. A bi-table is a table that has exactly two rows of equal length, each being a binary string.\n\nLet $\\operatorname{MEX}$ of a bi-table be the smallest ...
[{"type": "stdin_stdout", "input": "4\n7\n0001000\n1101100\n5\n01001\n10110\n2\n01\n01\n6\n010000\n011111\n", "output": "10\n10\n2\n10\n"}, {"type": "stdin_stdout", "input": "4\n7\n0101000\n1100100\n5\n01100\n10101\n2\n01\n01\n6\n000100\n111111\n", "output": "10\n8\n2\n10\n"}, {"type": "stdin_stdout", "input": "4\n7\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tutorial for this problem is now available on our blog. Click here to read it. \n\nYou are asked to calculate factorials of some small positive integers.\n\n------ Input ------ \n\nAn integer t, 1≤t≤100, denoting the n...
[{"type": "stdin_stdout", "input": "4\n1\n2\n4\n57", "output": "1\n2\n24\n40526919504877216755680601905432322134980384796226602145184481280000000000000\n"}, {"type": "stdin_stdout", "input": "4\n5\n3\n10\n29", "output": "120\n6\n3628800\n8841761993739701954543616000000\n"}, {"type": "stdin_stdout", "input": "4\n5\n4\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.\n\nMeanwhile, crimes keeps occurring within the city. One member of...
[{"type": "stdin_stdout", "input": "146\n4 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 3 -1 3 -1 -1 1 4 -1 2 -1 -1 3 -1 -1 -1 4 1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 3 2 -1 3 2 4 5 2 4 1 5 -1 -1 2 -1 -1 1 -1 5 3 -1 1 2 2 3 5 3 -1 -1 3 -1 -1 3 5 5 -1 -1 5 -1 4 4 1 -1 -1 -1 2 1 -1 -1 -1 2 5 3 -1 -1 -1 3 -1 5 4 -1 1 -1 -1 3 -1 -1 3 1 1 2 -1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring a voyage of the starship Hakodate-maru (see Problem A), researchers found strange synchronized movements of stars. Having heard these observations, Dr. Extreme proposed a theory of \"super stars\". Do not take this...
[{"type": "stdin_stdout", "input": "4\n10.431258066320945 10.00000 10.963374203026609\n21.297630146026126 10.00000 10.00000\n20.00000 20.997700286656844 10.00000\n11.414338431837134 20.00000 10.00000\n4\n11.03531062521475 12.469639655902677 10.968703737628516\n10.00000 51.12714506944212 50.70404839090845\n51.1844286530...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.\n\...
[{"type": "stdin_stdout", "input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on...
[{"type": "stdin_stdout", "input": "1204", "output": "+--00--+\n"}, {"type": "stdin_stdout", "input": "1942", "output": "+0-000-+\n"}, {"type": "stdin_stdout", "input": "384", "output": "+---+-0\n"}, {"type": "stdin_stdout", "input": "567", "output": "+-+0000\n"}, {"type": "stdin_stdout", "input": "397", "output": "+--...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Pari and Arya are playing a game called Remainders.\n\nPari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value <image>. There are n ancient numbers c1, c2, ..., cn and Pari...
[{"type": "stdin_stdout", "input": "61 531012\n698043 698043 698043 963349 698043 698043 698043 963349 698043 698043 698043 963349 698043 698043 698043 698043 966694 698043 698043 698043 698043 698043 698043 636247 698043 963349 698043 698043 698043 698043 697838 698043 989253 698043 698043 966694 698043 698043 698043 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage and strength will be a...
[{"type": "stdin_stdout", "input": "847094637 -152905363 -1000000000 -1000000000\n", "output": "FIRST\n-152905363\n"}, {"type": "stdin_stdout", "input": "-1000000000 1000000000 1230987 17135570\n", "output": "FIRST\n-983588156\n"}, {"type": "stdin_stdout", "input": "547686188 61562151 -496372503 -115242932\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n numbers a_1, a_2, ..., a_{n}. 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 $1$ denotes the bitwise ...
[{"type": "stdin_stdout", "input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"type": "stdin_stdout", "input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"type": "stdin_stdout", "input": "5 10 8\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSpace Coconut Crab\n\nSpace coconut crab\n\nEnglish text is not available in this practice contest.\n\nKen Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space co...
[{"type": "stdin_stdout", "input": "1\n2\n4\n48\n266\n1236\n0", "output": "1\n2\n2\n12\n14\n36\n"}, {"type": "stdin_stdout", "input": "1\n2\n4\n48\n266\n1300\n0", "output": "1\n2\n2\n12\n14\n38\n"}, {"type": "stdin_stdout", "input": "1\n2\n4\n27\n557\n1250\n0", "output": "1\n2\n2\n3\n23\n44\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\n\nGiven a sequence a consisting of n integers. The player can m...
[{"type": "stdin_stdout", "input": "100\n4 8 10 1 8 8 8 1 10 3 1 8 6 8 6 1 10 3 3 3 3 7 2 1 1 6 10 1 7 9 8 10 3 8 6 2 1 6 5 6 10 8 9 7 4 3 10 5 3 9 10 5 10 8 8 5 7 8 9 5 3 18 9 2 7 8 2 10 4 9 2 8 10 10 5 8 5 1 7 3 4 5 2 2 9 3 2 5 6 2 3 10 1 5 9 6 10 4 10 8\n", "output": "392\n"}, {"type": "stdin_stdout", "input": "100\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMany computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. \n\nLet's suppose that your task is to build a square city. The w...
[{"type": "stdin_stdout", "input": "10\n-260530833 169589238\n-681955770 -35391010\n223450511 24504262\n479795061 -26191863\n-291344265 21153856\n714700263 -328447419\n-858655942 161086142\n-270884153 462537328\n-501424901 977460517\n115284904 -151626824\n", "output": "2475449747812002025\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have an array $a$ of length $n$. For every positive integer $x$ you are going to perform the following operation during the $x$-th second:\n\n Select some distinct indices $i_{1}, i_{2}, \\ldots, i_{k}$ which are bet...
[{"type": "stdin_stdout", "input": "6\n3\n1000000000 -1 -1000000000\n1\n6\n2\n-1000000000 1000000000\n2\n1000000000 -1000000000\n2\n1000000000 1000000000\n2\n-1000000000 -1000000000\n", "output": "31\n0\n0\n31\n0\n0\n"}, {"type": "stdin_stdout", "input": "6\n3\n1000000000 0 -1000000000\n1\n6\n2\n-1000000000 1000000000\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.\n\nDISCOSMOS can be described as an H \\times W grid. Let (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W) denote the square at the...
[{"type": "stdin_stdout", "input": "1486 120 1001", "output": "960152848\n"}, {"type": "stdin_stdout", "input": "328 102 1011", "output": "261361566\n"}, {"type": "stdin_stdout", "input": "328 102 1111", "output": "647647330\n"}, {"type": "stdin_stdout", "input": "328 117 1011", "output": "407646568\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. C...
[{"type": "stdin_stdout", "input": "32\n402528994560 0 0 0 0 0 0 932646223872 893192888700 0 813583026900 0 0 0 0 143521875000 0 177570054144 186624000000 0 517655600000 202145625000 341007975000 0 116252718750 0 148561875000 0 304819200000 248474688000 0 103125000000\n29 25\n20 24\n8 21\n23 3\n32 14\n29 30\n31 24\n28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.\n...
[{"type": "stdin_stdout", "input": "xwcxggxvfqbdklewbxkjzibmufnaywuxsqvwakefxbbkfandvigasbhbatsxyqxicrosatfsfybedklsaztyyiuurfbrzmwumujy\n100\n14 43 30 13 8 19 33 7 16 14 15 35 5 18 44 1 35 1 18 7 50 47 9 49 28 29 39 37 27 17 19 12 5 24 37 42 37 23 35 31 10 26 5 38 40 34 42 47 2 40 43 32 16 25 14 45 35 38 46 48 49 27 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFizzBuzz is a game in which integers of 1 or more are spoken in order according to the following rules.\n\n* \"Fizz\" when divisible by 3\n\n* \"Buzz\" when divisible by 5\n\n* \"FizzBuzz\" when divisible by both 3 and 5\...
[{"type": "stdin_stdout", "input": "10010000000", "output": "990079BuzzFizz141999\n"}, {"type": "stdin_stdout", "input": "10010000001", "output": "90079BuzzFizz1419990\n"}, {"type": "stdin_stdout", "input": "10000000001", "output": "3FizzBuzz1418650796F\n"}, {"type": "stdin_stdout", "input": "10000001001", "output": "4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSometimes some words like \"localization\" or \"internationalization\" are so long that writing them many times in one text is quite tiresome.\n\nLet's consider a word too long, if its length is strictly more than 10 char...
[{"type": "stdin_stdout", "input": "20\nlkpmx\nkovxmxorlgwaomlswjxlpnbvltfv\nhykasjxqyjrmybejnmeumzha\ntuevlumpqbbhbww\nqgqsphvrmupxxc\ntrissbaf\nqfgrlinkzvzqdryckaizutd\nzzqtoaxkvwoscyx\noswytrlnhpjvvnwookx\nlpuzqgec\ngyzqfwxggtvpjhzmzmdw\nrlxjgmvdftvrmvbdwudra\nvsntnjpepnvdaxiporggmglhagv\nxlvcqkqgcrbgtgglj\nlyxwxbis...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, m...
[{"type": "stdin_stdout", "input": "100\n-57 -64 83 76 80 27 60 76 -80 -56 52 72 -17 92 -96 87 41 -88 94 89 12 42 36 34 -100 -43 -42 62 3 87 -69 -6 -27 -59 -7 5 -90 -23 63 -87 -60 -92 -40 54 -16 -47 67 -64 10 33 -19 53 -7 -62 16 -74 -36 4 -75 -55 92 3 -22 43 -30 48 -27 88 -58 41 36 8 -40 -30 -18 16 22 -66 -91 -46 48 -6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro had his own personal computer and set a password for login. However, Taro inadvertently forgot the password. Then, remembering that there was a piece of paper with the password written down, Taro found the paper and ...
[{"type": "stdin_stdout", "input": "KUSATSU\nLSATSU", "output": "No\n"}, {"type": "stdin_stdout", "input": "RUPCUAOC\n__PC", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "KUSATSU\nLSATRU", "output": "No\n"}, {"type": "stdin_stdout", "input": "RUPCUAOC\n__OC", "output": "Yes\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is one card each with the numbers from \"1\" to \"10\", for a total of 10 cards. This card has numbers on the front and nothing on the back. Using this card, you and your opponent will play the game according to the...
[{"type": "stdin_stdout", "input": "1 2 3\n4 1 10\n5 1 10", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "1 2 3\n5 6 10\n4 9 10", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "1 2 3\n7 1 10\n5 1 10", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "1 4 3\n5 6 10\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe map of Bertown can be represented as a set of $n$ intersections, numbered from $1$ to $n$ and connected by $m$ one-way roads. It is possible to move along the roads from any intersection to any other intersection. The...
[{"type": "stdin_stdout", "input": "20 50\n20 3\n5 16\n1 3\n10 11\n10 15\n15 9\n20 9\n14 6\n16 5\n13 4\n11 5\n3 20\n13 17\n11 8\n11 6\n12 14\n16 18\n17 13\n18 7\n3 1\n8 10\n17 15\n7 2\n9 13\n5 11\n6 1\n2 16\n8 18\n10 8\n4 13\n9 15\n14 12\n1 6\n9 20\n7 18\n6 14\n7 6\n18 16\n2 7\n3 11\n15 17\n3 12\n14 10\n4 14\n19 4\n11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and $Q$ integers $x_i$ as queries, for each query, print the number of combinations of two integers $(l, r)$ which satisfies the condition: $1 \\leq l \\leq r \...
[{"type": "stdin_stdout", "input": "6 5\n1 2 3 2 7 6\n12 12 12 21 15", "output": "14\n14\n14\n21\n18\n"}, {"type": "stdin_stdout", "input": "6 5\n1 4 3 2 12 6\n10 1 22 25 23", "output": "11\n1\n18\n19\n19\n"}, {"type": "stdin_stdout", "input": "6 5\n1 4 3 2 12 1\n10 1 22 25 23", "output": "11\n2\n20\n21\n21\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCurrently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write $x$ angry comments for every occurrence of subsequence 01 and $y$ angry comments for ever...
[{"type": "stdin_stdout", "input": "?00?0?0??00100?00?001111?11???1010110100?00?0?1?1?1001??001010?011???0000???????1111?1?101100110?001\n801448 0\n", "output": "819079856\n"}, {"type": "stdin_stdout", "input": "10001?0011?0??1?1001??001?001?0100??00???0???011?00111???1?1?0?0?0??1?1?1?1?1010?1101?0000?1??11?101\n0 1\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.\n\nFor another exercise, Pasha needs exactly $\\frac{...
[{"type": "stdin_stdout", "input": "200\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", "output": "100\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the quarantine, Sicromoft has more free time to create the new functions in \"Celex-2021\". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper ...
[{"type": "stdin_stdout", "input": "1\n118730819 699217111 1229905591 978426672\n", "output": "310250620284395093\n"}, {"type": "stdin_stdout", "input": "1\n118730819 699217111 995255402 1762535216\n", "output": "932024458581475216\n"}, {"type": "stdin_stdout", "input": "1\n118730819 699217111 1571293294 978426672\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong is experimenting with an interesting machine Graph Traveler. In Graph Traveler, there is a directed graph consisting of n vertices numbered from 1 to n. The i-th vertex has m_i outgoing edges that are labeled as e...
[{"type": "stdin_stdout", "input": "4\n4 -9 -1 -1\n2\n2 3\n1\n2\n3\n2 4 1\n4\n3 1 2 1\n6\n1 -1\n3 -1\n3 -1\n4 -4\n2 1\n1 5\n", "output": "1\n1\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "4\n4 -9 -1 -1\n2\n2 3\n1\n2\n3\n2 4 1\n4\n3 1 2 1\n6\n1 -1\n3 0\n3 -1\n4 -4\n2 1\n1 5\n", "output": "1\n1\n1\n1\n1\n1\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!\n\nWhen Polycarp went to a doctor with his problem, the doctor asked him about his sleepi...
[{"type": "stdin_stdout", "input": "10 5\n1384 1129 1780 1960 1567 1928 12 1523 1165 344\n", "output": "6931.333333333333030"}, {"type": "stdin_stdout", "input": "10 4\n127 1459 718 1183 880 1044 1857 1340 725 1496\n", "output": "4574.428571428571558"}, {"type": "stdin_stdout", "input": "10 5\n1384 1129 1780 1960 1567 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contai...
[{"type": "stdin_stdout", "input": "15 10 15\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n", "output": ".X.X.X.X.XXXXXX\n"}, {"type": "stdin_stdout", "input": "15 10 15\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n1\n14\n15\n", "output": ".X.X.X.X.XXX.XX"}, {"type": "stdin_stdout", "input": "15 10 15\n1\n2\n3\n3\n5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTom gives a number N to Roy and ask him to tell the total number of even divisors of the number N. Help Roy to answer the question of Tom.\n\nINPUT:\n\nFirst line contains the number of testcases T, followed by T lines ea...
[{"type": "stdin_stdout", "input": "100\n221614680\n613118744\n825161854\n393619966\n433416647\n918290125\n875590062\n364287285\n540653024\n282896407\n834916465\n819950927\n260491958\n606161260\n616177142\n575204996\n709562762\n710833433\n425478909\n578641871\n461777994\n818969932\n542538037\n994852175\n474901231\n3567...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFolding a Ribbon\n\nThink of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You c...
[{"type": "stdin_stdout", "input": "4 3 2\n30 578 1954\n59 471605241352156968 431565444592236940\n0 0 0", "output": "LRRR\nLLLLLRLLRLLLLLLLLLLRRRRLRLLLLL\nLRRRLRRLLRRRRLLLLRLLRRRLRRLLRLLLLLLRLRLLRLRLLLRLRLLRLLRRRLL\n"}, {"type": "stdin_stdout", "input": "4 3 2\n20 578 1954\n59 471605241352156968 431565444592236940\n0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEhab has an array $a$ of length $n$. He has just enough free time to make a new array consisting of $n$ copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subseque...
[{"type": "stdin_stdout", "input": "4\n7\n6 6 12 8 6 6 6\n1\n2\n5\n4 5 9 2 7\n7\n1 2 7 1 6 20 2\n", "output": "3\n1\n5\n5\n"}, {"type": "stdin_stdout", "input": "4\n7\n6 6 12 8 6 5 6\n1\n2\n5\n4 5 9 2 7\n7\n1 2 7 1 6 20 2\n", "output": "4\n1\n5\n5\n"}, {"type": "stdin_stdout", "input": "4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNot so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.\n\nThe testing goes in n steps, at each ...
[{"type": "stdin_stdout", "input": "100 99 1 2\n2 1 1 1 2 2 1 1 1 2 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 1 2 1 2 1 2 2 2 2 1 1 1 1 1 2 1 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 1 2 1 2 1 2 1 1 1 1 2 1 1 0 1 1 2 2 2 1 1 1 1 2 2 2 2 1 1 2 2 2\n", "output": "Incorrect\n"}, {"type": "stdin_stdout", "input": "100 99 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.\n\n [Image] \n\nThe girl lives in house m of a village. There are n houses in that village, lining in a s...
[{"type": "stdin_stdout", "input": "100 1 100\n0 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 110 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$.\n\nA programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the sk...
[{"type": "stdin_stdout", "input": "10 35\n322022227 751269818 629795150 369443545 344607287 250044294 476897672 184054549 986884572 917181121\n6 3\n7 3\n1 9\n7 9\n10 7\n3 4\n8 6\n7 4\n6 10\n7 2\n3 5\n6 9\n3 10\n8 7\n6 5\n8 1\n8 5\n1 7\n8 10\n8 2\n1 5\n10 4\n6 7\n4 6\n2 6\n5 4\n9 10\n9 2\n4 8\n5 9\n4 1\n3 2\n2 1\n4 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.\n\nLimak is a police officer. He lives in a city a. His job is to catch c...
[{"type": "stdin_stdout", "input": "100 100\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\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 100\n1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYurii is sure he can do everything. Can he solve this task, though?\n\nHe has an array $a$ consisting of $n$ positive integers. Let's call a subarray $a[l...r]$ good if the following conditions are simultaneously satisfie...
[{"type": "stdin_stdout", "input": "10\n997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854\n", "output": "2"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, ins...
[{"type": "stdin_stdout", "input": "1000 812 976\n230 1000\n1006 -1\n", "output": "164000\n"}, {"type": "stdin_stdout", "input": "1000 394 798\n155 1242\n954 -1\n", "output": "271560\n"}, {"type": "stdin_stdout", "input": "1000 812 976\n230 1000\n696 -1\n", "output": "164000\n"}, {"type": "stdin_stdout", "input": "1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white i...
[{"type": "stdin_stdout", "input": "01010000100110111100010011111100001010101111001100001010101000100101100011110011111110100011000001111011010011100010010111011001011000010110011100111010111111010100010111100100110000100010010011101001001110000100110101011001100000010111101101100100010011110010110010101100100011001010...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\nFind the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K i...
[{"type": "stdin_stdout", "input": "10 3\n14 26 111 65 35 89 184 32 38 46", "output": "4\n"}, {"type": "stdin_stdout", "input": "10 11\n14 26 111 0 35 27 95 13 38 63", "output": "12\n"}, {"type": "stdin_stdout", "input": "10 13\n14 15 101 65 35 89 95 32 38 46", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 7\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.\n\nAny slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this sli...
[{"type": "stdin_stdout", "input": "10\n-20 1 3 -5 -27 18 -3 -9 -7 9\n", "output": "102\n"}, {"type": "stdin_stdout", "input": "10\n-20 0 3 -5 -18 15 -3 -9 -7 9\n", "output": "89\n"}, {"type": "stdin_stdout", "input": "10\n-20 0 3 -5 -27 15 -3 -9 -7 9\n", "output": "98\n"}, {"type": "stdin_stdout", "input": "10\n-20 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe sequence of $m$ integers is called the permutation if it contains all integers from $1$ to $m$ exactly once. The number $m$ is called the length of the permutation.\n\nDreamoon has two permutations $p_1$ and $p_2$ of ...
[{"type": "stdin_stdout", "input": "6\n5\n1 4 3 2 1\n6\n2 4 1 3 3 1\n4\n2 1 1 2\n4\n1 3 3 1\n12\n2 1 3 5 5 6 7 8 9 1 10 2\n3\n1 2 1\n", "output": "2\n1 4\n4 1\n0\n1\n2 2\n0\n0\n2\n1 2\n2 1\n"}, {"type": "stdin_stdout", "input": "6\n5\n1 4 3 2 1\n6\n2 4 1 3 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nConstraints\n\n* $0 < n \\leq 10000$\n* $-1000000 \\leq a_i \\leq 100...
[{"type": "stdin_stdout", "input": "5\n114 0 -15 -1 2", "output": "-15 114 100\n"}, {"type": "stdin_stdout", "input": "5\n114 -1 -15 -1 2", "output": "-15 114 99\n"}, {"type": "stdin_stdout", "input": "5\n112 -1 -15 -1 2", "output": "-15 112 97\n"}, {"type": "stdin_stdout", "input": "5\n112 1 -14 -1 2", "output": "-14 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMadoka wants to enter to \"Novosibirsk State University\", but in the entrance exam she came across a very difficult task:\n\nGiven an integer $n$, it is required to calculate $\\sum{\\operatorname{lcm}(c, \\gcd(a, b))}$,...
[{"type": "stdin_stdout", "input": "100000\n", "output": "454535891\n"}, {"type": "stdin_stdout", "input": "69228\n", "output": "778304278\n"}, {"type": "stdin_stdout", "input": "94874\n", "output": "584783437\n"}, {"type": "stdin_stdout", "input": "99413\n", "output": "461761995\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area...
[{"type": "stdin_stdout", "input": "1204648530", "output": "20\n"}, {"type": "stdin_stdout", "input": "3727082973", "output": "21\n"}, {"type": "stdin_stdout", "input": "1369610954", "output": "20\n"}, {"type": "stdin_stdout", "input": "2281056559", "output": "20\n"}, {"type": "stdin_stdout", "input": "104442668", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit mor...
[{"type": "stdin_stdout", "input": "420196140727489673 679891637638612258\n", "output": "1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B"}, {"type": "stdin_stdout", "input": "498454011879264 806515...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYes, that's another problem with definition of \"beautiful\" numbers.\n\nLet's call a positive integer x beautiful if its decimal representation without leading zeroes contains even number of digits, and there exists a pe...
[{"type": "stdin_stdout", "input": "60\n799032\n1880\n489633\n167604\n641858\n521214\n951107\n121088\n952294\n514428\n890184\n883033\n317778\n456130\n373364\n404297\n757369\n815335\n317046\n148887\n834163\n990592\n721319\n402371\n458279\n570263\n887791\n365893\n433095\n463049\n457336\n669570\n803506\n178817\n214599\n21...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are n solutions, the i-th of them should be tested on a_i tests, testing one solution...
[{"type": "stdin_stdout", "input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe year 2015 is almost over.\n\nLimak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 2015_10 = 1...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "500000000000000000 1000000000000000000\n", "output": "58\n"}, {"type": "stdin_stdout", "input": "500000000000000000 1000000000000000000\n", "output": "58\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting t...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "500000\n"}, {"type": "stdin_stdout", "input": "999 1000\n", "output": "499500\n"}, {"type": "stdin_stdout", "input": "1000 997\n", "output": "498500\n"}, {"type": "stdin_stdout", "input": "997 1000\n", "output": "498500\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nServal soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.\n\nIn his favorite math class, the teacher taught him the following interesting definitions.\n\nA parenthesis sequence is a str...
[{"type": "stdin_stdout", "input": "300\n??????(??????(???)??(???????)??????)((??????(???(??)())?(???????)???????????((??(??(??(?)???)(????)??(??(?(??(????????()?????(????(?(??(?(?????)??(????(????(??(??(????((??)(??(??????????????????(????????(????(?(???????(??(????(???)?(???????)?)??(?????((??(??(??????????()?????(??...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMiyako came to the flea kingdom with a ukulele. She became good friends with local flea residents and played beautiful music for them every day.\n\nIn return, the fleas made a bigger ukulele for her: it has $n$ strings, a...
[{"type": "stdin_stdout", "input": "10\n13 18 10 3 9 19 20 4 10 5\n20\n0 9\n5 11\n1 5\n1 16\n3 3\n0 7\n10 19\n14 20\n6 15\n11 12\n13 16\n11 13\n3 9\n7 10\n2 2\n10 11\n17 20\n17 18\n0 15\n0 6\n", "output": "27 24 22 33 9 25 27 24 27 13 20 17 24 20 9 13 20 13 33 24\n"}, {"type": "stdin_stdout", "input": "10\n13 18 10 3 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.\n\nFor n points on a plane, report a set of points which are within in a given range. Note...
[{"type": "stdin_stdout", "input": "6\n0 1\n4 0\n5 0\n6 4\n3 2\n11 6\n2\n-1 4 -1 2\n0 8 0 5", "output": "0\n1\n4\n\n0\n1\n2\n3\n4\n\n"}, {"type": "stdin_stdout", "input": "6\n2 1\n2 2\n4 2\n4 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5", "output": "0\n1\n2\n3\n4\n\n2\n3\n5\n\n"}, {"type": "stdin_stdout", "input": "6\n0 1\n4 2\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no ...
[{"type": "stdin_stdout", "input": "100\n6072 8210 6405 1191 2533 8552 7594 8793 2207 8855 7415 6252 3433 2339 5532 3118 3054 5750 3690 9843 3881 1390 936 8611 7099 988 7730 3835 7065 5030 6932 6936 5531 5173 1331 8975 5454 1592 8516 328 1091 4368 8275 6462 8638 4002 5534 113 6295 5960 1688 3668 6604 9632 4214 8687 795...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li, ri] (inclusive) on which the event could have tak...
[{"type": "stdin_stdout", "input": "10\n10 10\n13 15\n6 14\n10 15\n4 15\n11 12\n11 15\n8 15\n1 11\n1 9\n", "output": "10 14 6 12 4 11 13 8 2 1\n"}, {"type": "stdin_stdout", "input": "10\n10 10\n13 15\n6 14\n10 15\n4 15\n11 12\n11 15\n5 15\n1 11\n1 9\n", "output": "10 14 6 12 4 11 13 5 2 1\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Bill is shopping at the store. There are some coins in his wallet (10-yen coins, 50-yen coins, 100-yen coins, 500-yen coins), but he is now trying to consume as much of this coin as possible. In other words, by paying...
[{"type": "stdin_stdout", "input": "160\n1 1 2 0\n160\n1 1 2 10\n0", "output": "10 1\n50 1\n100 1\n\n10 1\n50 1\n100 1\n"}, {"type": "stdin_stdout", "input": "160\n1 1 2 0\n160\n1 -1 1 10\n0", "output": "10 1\n50 1\n100 1\n\n10 1\n500 1\n"}, {"type": "stdin_stdout", "input": "160\n1 1 4 0\n125\n-1 1 2 10\n0", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo get on the Shinkansen, you need two tickets, a \"ticket\" and a \"limited express ticket\". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen,...
[{"type": "stdin_stdout", "input": "0 0 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "1 0 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "0 1 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "0 0 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "0 1 0", "output": "Close...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nICPC Calculator\n\nIn mathematics, we usually specify the order of operations by using parentheses. For example, 7 × (3 + 2) always means multiplying 7 by the result of 3 + 2 and never means adding 2 to the result of 7 × ...
[{"type": "stdin_stdout", "input": "1\n4\n0\n+\n2.115262384218664\n1.6946524456220797\n1.2494077125386351\n0\n+\n2.4871472060127386\n+.\n.-*\n3...\n...)\n--.+1\n2....\n1.1146316365084887\n-1\n*\n0\n1.4326064398520582\n.3.\n)/\n0.6657411913142146\n*/.\n.7..\n...6\n1.7891160931823404\n-1", "output": "4\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n beacons located at distinct positions on a number line. The i-th beacon has position ai and power level bi. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coord...
[{"type": "stdin_stdout", "input": "11\n110 90\n100 70\n90 10\n155 15\n130 1\n60 1\n71 10\n40 1\n30 1\n10 1\n20 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "11\n110 90\n100 70\n90 10\n155 15\n70 1\n60 1\n71 10\n40 1\n30 1\n10 1\n20 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "11\n110 90\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nColossal! — exclaimed Hawk-nose. — A programmer! That's exactly what we are looking for.Arkadi and Boris Strugatsky. Monday starts on Saturday\n\nReading the book \"Equations of Mathematical Magic\" Roman Oira-Oira and Cr...
[{"type": "stdin_stdout", "input": "9\n3\n2\n2\n228\n1\n1\n0\n16\n1488\n", "output": "4\n2\n2\n16\n2\n2\n1\n2\n32\n"}, {"type": "stdin_stdout", "input": "9\n2\n1\n2\n228\n1\n6\n8\n16\n1488\n", "output": "2\n2\n2\n16\n2\n4\n2\n2\n32\n"}, {"type": "stdin_stdout", "input": "9\n3\n2\n2\n272\n1\n1\n15\n3\n1488\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has a string S consisting of three kinds of letters: `a`, `b` and `c`.\n\nHe has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a su...
[{"type": "stdin_stdout", "input": "bacaccbabab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "bacaacbcbab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "babcbcaacab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "bababccacab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "bacaccba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCodefortia is a small island country located somewhere in the West Pacific. It consists of $n$ settlements connected by $m$ bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time nee...
[{"type": "stdin_stdout", "input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 5 13\n5 6 13\n6 1 13\n", "output": "0 13 26 39 26 13\n"}, {"type": "stdin_stdout", "input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 1 13\n5 6 13\n6 1 13\n", "output": "0 13 26 13 26 13 "}, {"type": "stdin_stdout", "input": "6 7 13 22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a number sequence A of length N.\nFind the number of integers i \\left(1 \\leq i \\leq N\\right) with the following property:\n - For every integer j \\left(1 \\leq j \\leq N\\right) such that i \\neq j , A_j doe...
[{"type": "stdin_stdout", "input": "10\n33 18 45 28 8 19 89 86 2 4\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n33 4 45 28 15 19 123 86 2 4", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n33 18 45 28 8 19 89 86 2 7", "output": "6\n"}, {"type": "stdin_stdout", "input": "10\n33 4 45 28 15 19 89...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,...
[{"type": "stdin_stdout", "input": "5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n", "output": "0\n5\n0\n"}, {"type": "stdin_stdout", "input": "5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n0 10\n13 13", "output": "0\n5\n0\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland shop sells $n$ kinds of juices. Each juice has its price $c_i$. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin \"A\", vitamin \"B\" and vitamin \"C\". Each juice can con...
[{"type": "stdin_stdout", "input": "25\n8 CA\n4 AB\n8 CA\n4 CA\n7 CB\n4 CB\n4 CB\n2 AC\n2 CA\n3 BC\n4 AC\n7 AB\n3 CA\n5 BC\n7 CB\n9 CA\n7 AB\n7 CA\n9 BA\n8 AC\n6 BA\n2 AC\n1 CB\n5 AB\n3 AB\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "25\n8 CA\n4 AB\n8 CA\n4 CA\n2 CB\n4 CB\n4 CB\n2 AC\n2 CA\n3 BC\n4 AC\n7 AB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.\n\nAt first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds a_{i} ...
[{"type": "stdin_stdout", "input": "100 456\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...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo T-shirt sizes are given: $a$ and $b$. The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.\n\nFor example, strings M, XXL, S, XXXXXXXS ...
[{"type": "stdin_stdout", "input": "15\nM M\nM L\nL M\nS M\nM S\nL L\nXL L\nL XXXXXXL\nS S\nXXXXS XXXS\nXS XXXXXXS\nM XXXS\nM XXXL\nXXXXXS XL\nXL XXXXS\n", "output": "=\n<\n>\n<\n>\n=\n>\n<\n=\n<\n>\n>\n<\n<\n>\n"}, {"type": "stdin_stdout", "input": "1\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXS XXXXXXXXXXXXXXX...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven positive integers N, K and M, solve the following problem for every integer x between 1 and N (inclusive):\n - Find the number, modulo M, of non-empty multisets containing between 0 and K (inclusive) instances of ea...
[{"type": "stdin_stdout", "input": "100 100 996766481\n", "output": "100\n479013218\n301906461\n76865454\n197164919\n185261994\n562146154\n218533225\n703919664\n761757943\n421733444\n150668448\n939625796\n441056419\n399708797\n265484256\n872130614\n530113978\n956321625\n942851863\n391142590\n196625433\n784864879\n81918...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe letters shop showcase is a string s, consisting of n lowercase Latin letters. As the name tells, letters are sold in the shop.\n\nLetters are sold one by one from the leftmost to the rightmost. Any customer can only b...
[{"type": "stdin_stdout", "input": "100\nwjtwxtttttxjjwxtjtttwxjwjjwjxtwwxxwwwtwttwxjxxjxwxwjtjjwxxxxwwtwtxjxwtwtjjjxwjxjtwwwwtjtttjjtxtwtxjw\n10\nxwjxjwxtwwj\nwxjxxjxjx\nwtjxxxjxjxtwt\njwwxj\njtwjtxjxttxwtw\nwtwxjjjttjx\nwwwjtxw\ntjxjwtjwtw\ntjwtjjxtxjwt\nwxwtxtjw\n", "output": "21\n29\n29\n12\n15\n17\n21\n14\n17\n14\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHeading ##There are two integers A and B. You are required to compute the bitwise AND amongst all natural numbers lying between A and B, both inclusive.\nInput Format\n\nFirst line of the input contains T, the number of t...
[{"type": "stdin_stdout", "input": "124\n1476395008 1493172223\n1275068416 1291845631\n4009754624 4026531839\n2516582400 2533359615\n50331648 67108863\n2566914048 2583691263\n2952790016 2969567231\n3892314112 3909091327\n3489660928 3506438143\n33554432 50331647\n1694498816 1711276031\n3623878656 3640655871\n1308622848 ...
code_stdio