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\nRead problems statements in Russian here \nPolo, the Penguin, has a lot of tests tomorrow at the university.\nHe knows that there are N different questions that will be on the tests. For each question i (i = 1..N), he kno...
[{"type": "stdin_stdout", "input": "1\n3 20\n1 -2 0\n6 4 8\n4 -1 3", "output": "24\n"}, {"type": "stdin_stdout", "input": "1\n3 12\n1 0 1\n1 3 14\n13 4 3", "output": "52\n"}, {"type": "stdin_stdout", "input": "1\n3 7\n0 -1 1\n4 0 5\n12 5 3", "output": "60\n"}, {"type": "stdin_stdout", "input": "1\n3 7\n1 1 0\n2 3 20\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct.\n...
[{"type": "stdin_stdout", "input": "3\n3\n4\n18\n11\n0\n10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3\n4\n18\n20\n0\n10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3\n10\n8\n7\n0\n10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3\n10\n9\n7\n0\n10", "output": "1\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a positive integer n\n\n* If n is even, divide by 2.\n* If n is odd, multiply by 3 and add 1.\n\n\n\nIf you repeat the above operation, the result will be 1. A problem called \"Colatz conjecture\" is that repeating th...
[{"type": "stdin_stdout", "input": "3\n1043\n0", "output": "7\n124\n"}, {"type": "stdin_stdout", "input": "3\n3340\n0", "output": "7\n136\n"}, {"type": "stdin_stdout", "input": "3\n109\n0", "output": "7\n113\n"}, {"type": "stdin_stdout", "input": "3\n440\n0", "output": "7\n115\n"}, {"type": "stdin_stdout", "input": "3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour master went to the town for a day. You could have a relaxed day without hearing his scolding. But he ordered you to make donuts dough by the evening. Loving donuts so much, he can't live without eating tens of donuts...
[{"type": "stdin_stdout", "input": "5 7\nRRCABXT\nAABMFAB\nRROMJAC\nAPTADAB\nYABADAO\n3 13\nABCDEFGHIJKLM\nYMADAMIMADAMY\nACEGIKMOQSUWY\n3 4\nDEFG\nACAB\nHIJK\n3 6\nFEDCB@\nHHIAKL\nMNOPQR\n10 19\nJFZODYDXMZZPEYTRNCW\nXVGHPOKEYNZTQFZJKOD\nEYEHHQKHFZOVNRGOOLP\nQFZOIHRQMGHPNISHXOC\nDRGILJHSQEHHQLYTILL\nNCSHQMKHTZZIHRPAUJA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's define $p_i(n)$ as the following permutation: $[i, 1, 2, \\dots, i - 1, i + 1, \\dots, n]$. This means that the $i$-th permutation is almost identity (i.e. which maps every element to itself) permutation but the ele...
[{"type": "stdin_stdout", "input": "30 5\n4 2 8 3 4\n", "output": "14 16 16 14 12 12 12 8 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14\n"}, {"type": "stdin_stdout", "input": "30 5\n4 4 8 3 4\n", "output": "10 10 14 14 8 8 8 8 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAizuwakamatsu City is known as the \"City of History\". About 400 years ago, the skeleton of the castle town was created by Gamo Ujisato, but after that, it became the central city of the Aizu clan 230,000 stones, whose a...
[{"type": "stdin_stdout", "input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,500\n0", "output": "23\n"}, {"type": "stdin_stdout", "input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,400\n0", "output": "22\n"}, {"type": "stdin_stdout", "input": "4\n4\n0,1,0500\n0,2,2000\n0,2,600\n2,3,400\n0", "output": "12\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is practicing shiritori alone again today.\nShiritori is a game as follows:\n - In the first turn, a player announces any one word.\n - In the subsequent turns, a player announces a word that satisfies the follo...
[{"type": "stdin_stdout", "input": "100\nlkykrymhey\nyujwmjhnzx\nxgmkqgsajk\nkkvqjyapln\nnkcubvbxdx\nxheccrzfne\neqeizvicxx\nxesnssfeuz\nzsjdhxndds\nsuvxanfkpe\neodirlsywl\nlmiwshvenl\nluomflsyiq\nqcjuajhxme\nelfadfvxvm\nmknedshbyv\nvnboqueaai\niwexnqgqvj\njzfofokvkg\nggzhwrtktd\nderapdnumy\nyfobbqcozo\noivhkngvyy\nytj...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant very much loves sums on intervals.\n\nThis time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x e...
[{"type": "stdin_stdout", "input": "100000000000000000 1000000000000000000\n", "output": "90000000000000000\n"}, {"type": "stdin_stdout", "input": "645762257531682046 885295120956158518\n", "output": "23953286342447648\n"}, {"type": "stdin_stdout", "input": "819875140559301752 946247219812473271\n", "output": "12637207...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGeorge woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t. \n\nHelp George! Write a program that will, given time s and t, determine the time p when George went to ...
[{"type": "stdin_stdout", "input": "05:50\n05:44\n", "output": "00:06\n"}, {"type": "stdin_stdout", "input": "00:00\n01:00\n", "output": "23:00\n"}, {"type": "stdin_stdout", "input": "00:01\n00:00\n", "output": "00:01\n"}, {"type": "stdin_stdout", "input": "23:59\n23:59\n", "output": "00:00\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation P_1 ... P_N of the set {1, 2, ..., N}.\n\nYou can apply the following operation to this permutation, any number of times (possibly zero):\n\n* Choose two indices i,j (1 ≦ i < j ≦ N), such that ...
[{"type": "stdin_stdout", "input": "8 2\n4 5 7 8 3 1 2 6", "output": "1\n2\n3\n6\n5\n4\n7\n8\n"}, {"type": "stdin_stdout", "input": "8 6\n4 5 7 8 3 1 2 6", "output": "4\n5\n7\n8\n3\n1\n2\n6\n"}, {"type": "stdin_stdout", "input": "8 5\n4 5 7 8 3 1 2 6", "output": "4\n5\n6\n8\n3\n1\n2\n7\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub has drawn a set of n points in the cartesian plane which he calls \"special points\". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called...
[{"type": "stdin_stdout", "input": "50\n-768 -243\n-741 -984\n-370 213\n-808 571\n-726 442\n234 452\n-105 -990\n-876 -278\n987 473\n-968 -531\n-274 -842\n259 -655\n-59 -555\n976 -396\n878 -85\n551 213\n675 599\n-990 -507\n1 48\n-147 919\n-218 798\n-191 928\n916 263\n-975 169\n567 -967\n394 16\n-224 915\n280 -613\n804 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked $n$ of them how much effort they needed to reach red.\n\n\"O...
[{"type": "stdin_stdout", "input": "15\n5318008\n379009\n06\n79153975193751375917591379919397337913333535330\n791539751937513759175913799193973379133301353533\n123456789023487138475693874561834576138495713485673485364857638475673465873457346581495713641\n7915397519375137511917591379919397337913333535330\n31553555535353...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be w_{i}, th...
[{"type": "stdin_stdout", "input": "100 50 10\n7 8 7 1 6 7 9 2 4 6 7 7 3 9 4 5 1 7 8 10 4 1 3 6 8 10 4 6 6 1 6 12 7 4 10 3 10 1 3 2 10 6 9 9 5 2 9 2 9 8 10 2 10 3 3 2 3 8 6 2 7 10 7 2 7 2 8 9 6 2 5 4 4 5 3 3 9 10 9 4 9 3 9 5 3 6 6 1 3 6 10 3 10 2 6 10 10 10 4 8\n3 3 2 9 4 4 10 2 7 3 3 2 6 3 3 4 7 4 1 2 3 8 1 6 7 7 2 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is a number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. The value of the $i$-th element of the array is $a_i$.\n\nYou are also giv...
[{"type": "stdin_stdout", "input": "50 50\n1 -9 8 -9 5 -4 -4 3 -2 -1 3 -8 -6 -6 2 -5 -1 -2 -5 10 2 0 10 10 5 -3 12 -1 -9 9 -10 4 7 0 -6 0 -1 4 8 0 -3 -8 10 10 6 6 -3 -5 -3 -8\n28 41\n28 49\n49 49\n6 38\n22 30\n50 50\n41 45\n30 32\n17 44\n24 25\n27 39\n17 39\n50 50\n10 14\n11 12\n18 28\n11 20\n36 42\n45 49\n29 36\n32 44...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands \"ping a\" and \"ping b\". Each ping command s...
[{"type": "stdin_stdout", "input": "14\n1 7 3\n1 0 10\n1 7 3\n1 1 9\n2 2 8\n2 0 10\n1 1 9\n2 8 2\n2 6 4\n1 3 7\n1 3 7\n2 6 4\n2 1 9\n2 7 3\n", "output": "DEAD\nDEAD\n"}, {"type": "stdin_stdout", "input": "14\n1 7 3\n1 0 10\n1 7 3\n1 1 9\n2 2 8\n2 0 10\n1 1 9\n2 8 2\n2 6 4\n1 3 7\n1 3 7\n2 6 4\n2 1 9\n2 7 3\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nA graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.\n\n...
[{"type": "stdin_stdout", "input": "6\n1 2\n2 3\n3 4\n3 5\n5 6", "output": "6\n7\n8\n7\n7\n6\n"}, {"type": "stdin_stdout", "input": "6\n1 2\n2 3\n6 4\n3 5\n5 6", "output": "5\n6\n7\n5\n7\n6\n"}, {"type": "stdin_stdout", "input": "6\n1 2\n2 3\n6 4\n3 4\n5 6", "output": "5\n6\n7\n7\n5\n6\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. \n\nLet's denote s as the total number of cells of table a, that...
[{"type": "stdin_stdout", "input": "4\n40 40 24 5\n56 14 59 76 92 34 43 96 33 44 72 37 81 27 42 5 7 95 22 4 60 18 61 103 74 84 93 55 3 62 70 82 77 51 86 102 29 67 91 9\n71 53 21 64 17 45 46 101 97 30 109 100 57 16 80 87 28 12 94 23 39 98 32 52 54 10 19 41 90 11 66 65 99 89 40 36 58 20 78 108\n35 88 73 75 104 63 79 31 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPermutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n ...
[{"type": "stdin_stdout", "input": "1000 500\n", "output": "979041279\n"}, {"type": "stdin_stdout", "input": "1000 700\n", "output": "642759746\n"}, {"type": "stdin_stdout", "input": "1000 900\n", "output": "301804159\n"}, {"type": "stdin_stdout", "input": "1000 998\n", "output": "583666213\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIkta loves fast programs. Recently, I'm trying to speed up the division program. However, it doesn't get much faster, so I thought it would be better to make it faster only for \"common sense and typical\" inputs. The pro...
[{"type": "stdin_stdout", "input": "001", "output": "2\n"}, {"type": "stdin_stdout", "input": "000", "output": "1\n"}, {"type": "stdin_stdout", "input": "178", "output": "0\n"}, {"type": "stdin_stdout", "input": "209", "output": "0\n"}, {"type": "stdin_stdout", "input": "375", "output": "0\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTokitsukaze and CSL are playing a little game of stones.\n\nIn the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each t...
[{"type": "stdin_stdout", "input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "output": "sjfnb\n"}, {"type": "stdin_stdout", "input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125477\n", "output": "cslnb\n"}, {"type": "stdin_stdout", "input": "14\n9 9 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe marmots need to prepare k problems for HC^2 over n days. Each problem, once prepared, also has to be printed.\n\nThe preparation of a problem on day i (at most one per day) costs a_{i} CHF, and the printing of a probl...
[{"type": "stdin_stdout", "input": "13 13\n93 19 58 34 96 7 35 46 60 5 36 40 41\n57 3 42 68 26 85 25 45 50 21 60 23 79\n", "output": "1154\n"}, {"type": "stdin_stdout", "input": "13 13\n93 19 58 34 96 7 35 46 60 5 66 40 41\n57 3 42 68 26 85 25 45 50 21 60 23 79\n", "output": "1184\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $36...
[{"type": "stdin_stdout", "input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15\n180\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nXenia the beginner programmer has a sequence a, consisting of 2^{n} non-negative integers: a_1, a_2, ..., a_2^{n}. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate...
[{"type": "stdin_stdout", "input": "2 10\n47 17 22 0\n2 15\n2 42\n1 9\n3 13\n3 28\n1 20\n1 13\n1 50\n2 20\n2 12\n", "output": "57\n57\n61\n38\n55\n34\n51\n38\n42\n34\n"}, {"type": "stdin_stdout", "input": "2 10\n47 17 22 0\n4 15\n2 42\n1 9\n3 13\n3 28\n1 20\n1 13\n1 50\n2 20\n2 12\n", "output": "32\n48\n52\n36\n52\n33\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's define a function $f(x)$ ($x$ is a positive integer) as follows: write all digits of the decimal representation of $x$ backwards, then get rid of the leading zeroes. For example, $f(321) = 123$, $f(120) = 21$, $f(10...
[{"type": "stdin_stdout", "input": "100\n1\n2\n3\n4\n5\n4\n7\n8\n9\n10\n11\n12\n13\n17\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n17\n28\n29\n30\n31\n32\n31\n34\n35\n36\n27\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n29\n54\n100\n56\n57\n58\n59\n109\n61\n62\n63\n120\n65\n66\n67\n68\n69\n70\n71\n7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a graph with $3 \\cdot n$ vertices and $m$ edges. You are to find a matching of $n$ edges, or an independent set of $n$ vertices.\n\nA set of edges is called a matching if no two edges share an endpoint.\n\n...
[{"type": "stdin_stdout", "input": "1\n5 39\n1 2\n3 4\n5 6\n7 8\n1 9\n3 10\n3 11\n5 12\n5 13\n7 14\n7 15\n9 2\n10 2\n11 2\n12 2\n13 2\n14 2\n15 2\n9 4\n10 4\n11 4\n12 4\n13 4\n14 4\n15 4\n9 6\n10 6\n11 6\n12 6\n13 6\n14 6\n15 6\n9 8\n10 8\n11 8\n12 8\n13 8\n14 8\n15 8\n", "output": "IndSet\n9 10 11 12 13 \n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health.\n\nYou may shoot t...
[{"type": "stdin_stdout", "input": "10\n8\n7 4\n9 10\n4 8\n3 1\n1 7\n9 5\n1 4\n2 5\n8\n9 8\n4 7\n7 7\n3 6\n14 9\n2 5\n4 9\n2 8\n7\n2 2\n2 7\n2 10\n8 6\n1 4\n2 6\n3 10\n4\n4 10\n7 5\n6 10\n9 5\n7\n8 9\n8 1\n3 4\n5 1\n3 10\n9 3\n5 5\n5\n6 1\n7 3\n6 5\n6 1\n1 8\n2\n7 8\n7 10\n4\n6 8\n9 3\n8 1\n9 7\n4\n13 7\n5 7\n10 10\n8 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits are numbered from 1 to n. An integer is stored in the cell in the following way: the l...
[{"type": "stdin_stdout", "input": "100\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is becau...
[{"type": "stdin_stdout", "input": "RRYOGB\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "YROVBG\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "RYGOBG\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "VOBYGO\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "GRBYVO\n", "output": "30...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA nearby pie shop is having a special sale. For each pie you pay full price for, you may select one pie of a strictly lesser value to get for free. Given the prices of all the pies you wish to acquire, determine the minim...
[{"type": "stdin_stdout", "input": "50\n4 2 6 7 2 6 3 8 8 2 4 8 4 4 1 4 5 2 2 5 6 4 3 3 3 6 8 2 1 3 1 8 2 3 7 4 7 5 4 8 3 5 7 8 6 7 5 8 7 1\n", "output": "130\n"}, {"type": "stdin_stdout", "input": "50\n4 2 6 7 2 6 3 8 8 2 4 8 4 4 1 3 5 2 2 5 6 4 3 3 3 6 8 2 1 3 1 8 2 3 7 4 7 5 4 8 3 5 7 8 6 7 5 8 7 1\n", "output": "12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings $s$ and $t$ both of length $2$ and both consisting only of characters 'a', 'b' and 'c'.\n\nPossible examples of strings $s$ and $t$: \"ab\", \"ca\", \"bb\".\n\nYou have to find a string $res$ con...
[{"type": "stdin_stdout", "input": "24288\naa\nbc\n", "output": "YES\nacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to ...
[{"type": "stdin_stdout", "input": "155\n", "output": "12013\nC.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has $a$ vanilla cookies and $b$ chocolate cookies for the party.\n\nSh...
[{"type": "stdin_stdout", "input": "6\n2 2 1 2\n0 100 0 1\n12 13 25 1\n27 83 14 25\n0 0 1 0\n1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "Yes\nNo\nNo\nYes\nNo\nYes\n"}, {"type": "stdin_stdout", "input": "6\n2 2 1 2\n0 100 0 1\n11 13 25 1\n27 83 14 25\n0 0 1 0\n100000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFirst-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge ...
[{"type": "stdin_stdout", "input": "prntaxhysjfcfmrjngdsitlguahtpnwgbaxptubgpwcfxqehrulbxfcjssgocqncscduvyvarvwxzvmjoatnqfsvsilubexmwugedtzavyamqjqtkxzuslielibjnvkpvyrbndehsqcaqzcrmomqqwskwcypgqoawxdutnxmeivnfpzwvxiyscbfnloqjhjacsfnkfmbhgzpujrqdbaemjsqphokkiplblbflvadcyykcqrdohfasstobwrobslaofbasylwiizrpozvhtwyxtzl\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Chanek The Ninja is one day tasked with a mission to handle mad snakes that are attacking a site. Now, Mr. Chanek already arrived at the hills where the destination is right below these hills. The mission area can be ...
[{"type": "stdin_stdout", "input": "20 17 998\n1000 1000 295133\n1 1000 322998\n31 1 412809\n1 457 347941\n1000 579 600207\n1 708 315587\n1 159 302269\n1000 447 1582128\n247 1 591835\n933 1 16036\n140 1 305582\n1 1 147502\n1000 1 631288\n216 1000 145614\n402 1000 875933\n594 1000 874200\n1000 963 839096\n1 865 156116\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N. Find the minimum possible positive integer k such that (1+2+\\cdots+k) is a multiple of N. It can be proved that such a positive integer k always exists.\n\nConstraints\n\n* 1 \\leq N \\leq 10^{15}\...
[{"type": "stdin_stdout", "input": "150916391", "output": "67547447\n"}, {"type": "stdin_stdout", "input": "116446379", "output": "20549361\n"}, {"type": "stdin_stdout", "input": "39730771", "output": "39730770\n"}, {"type": "stdin_stdout", "input": "71266519", "output": "17269679\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBishwock is a chess figure that consists of three squares resembling an \"L-bar\". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:\n\n \n\nXX XX .X X.\n\nX. .X XX XX\...
[{"type": "stdin_stdout", "input": "0000000000000000000000000000000000000000000000000000000000X0000000000000000000000000000000000000X000\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "66\n"}, {"type": "stdin_stdout", "input": "0000X00X000000X0000X00X...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi and Aoki love calculating things, so they will play with numbers now.\n\nFirst, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y. Then, they will enjoy themselves by...
[{"type": "stdin_stdout", "input": "10 10 14\n1100110011\n1011001101", "output": "100001000000000010001000\n100001000000000000100010\n"}, {"type": "stdin_stdout", "input": "10 10 14\n1110110011\n1011001101", "output": "100001000000000100001000\n100001000000000000100010\n"}, {"type": "stdin_stdout", "input": "10 10 14\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves wit...
[{"type": "stdin_stdout", "input": "3\n1 0\n0 1\n-2 0\n1 0\n0 8\n-1 0\n0 -1\n5 0\n0 1\n0 -4\n1 0\n0 -5\n-3 0\n0 3\n2 0\n-1 -1\n-2 1\n0 1\n0 -1\n1 0\n0 2\n-2 -1\n0 -3\n3 1\n-1 0\n-4 0\n0 0\n-2 0\n1 0\n0 0\n-3 0\n0 0\n2 0\n0 1\n-1 0\n-1 1\n-1 0\n0 -2\n0 0", "output": "4 9\n-2 0\n-3 0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph.\n\nThere are n vertices in the tree, each of them is painted black or white. Anton doesn't like multicolored tre...
[{"type": "stdin_stdout", "input": "42\n1 0 0 1 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0\n35 6\n35 39\n4 31\n31 5\n14 35\n1 2\n40 32\n35 31\n37 35\n32 38\n1 36\n3 25\n35 11\n26 35\n24 35\n3 2\n35 23\n21 1\n20 27\n16 26\n2 18\n34 39\n39 28\n3 32\n26 30\n41 7\n13 35\n1 8\n31 22\n33 21\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.\n\nYou are ...
[{"type": "stdin_stdout", "input": "5\n2 2\n10\n11\n3 3\n011\n101\n010\n4 4\n1111\n0110\n0110\n1111\n5 5\n01011\n11001\n00010\n11011\n10000\n2 3\n011\n101\n", "output": "1\n1 1 2 1 2 2 \n5\n1 2 1 3 2 2 \n2 1 2 2 3 2 \n2 2 3 2 2 3 \n2 2 2 3 3 3 \n3 2 2 3 3 3 \n8\n1 1 1 2 2 1 \n1 3 1 4 2 3 \n2 1 2 2 3 1 \n3 1 4 1 3 2 \n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people...
[{"type": "stdin_stdout", "input": "6\n23426\n5600\n33800\n0\n26495\n52000", "output": "23553\n"}, {"type": "stdin_stdout", "input": "6\n23426\n5600\n33800\n0\n17519\n52000", "output": "22057\n"}, {"type": "stdin_stdout", "input": "6\n23426\n5600\n33800\n0\n14222\n52000", "output": "21508\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\nLet the current time be time 0. Kizahashi has N jobs numbered 1 ...
[{"type": "stdin_stdout", "input": "30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of size $n$ is an array of size $n$ such that each integer from $1$ to $n$ occurs exactly once in this array. An inversion in a permutation $p$ is a pair of indices $(i, j)$ such that $i > j$ and $a_i < a_j$...
[{"type": "stdin_stdout", "input": "69\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": " ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSummer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be bui...
[{"type": "stdin_stdout", "input": "5 5 5\n3\n2\n11\n16\n18", "output": "5\n"}, {"type": "stdin_stdout", "input": "5 5 5\n3\n2\n11\n29\n18", "output": "5\n"}, {"type": "stdin_stdout", "input": "5 4 5\n3\n2\n11\n29\n18", "output": "5\n"}, {"type": "stdin_stdout", "input": "5 4 5\n3\n2\n11\n29\n30", "output": "5\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\nTakahashi will now announce a string, an...
[{"type": "stdin_stdout", "input": "1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nuoldemort\nvoldemort\nvoldemort\nvolde...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTheofanis started playing the new online game called \"Among them\". However, he always plays with Cypriot players, and they all have the same name: \"Andreas\" (the most common name in Cyprus).\n\nIn each game, Theofanis...
[{"type": "stdin_stdout", "input": "5\n3 2\n1 2 imposter\n2 3 crewmate\n5 4\n1 5 crewmate\n2 5 crewmate\n2 4 imposter\n3 4 imposter\n2 2\n1 2 imposter\n2 1 crewmate\n3 5\n1 2 imposter\n1 2 imposter\n3 2 crewmate\n2 2 crewmate\n1 3 imposter\n13 0\n", "output": "2\n4\n-1\n2\n13\n"}, {"type": "stdin_stdout", "input": "5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe neutral city of Eyes City, in the heart of the four countries, is home to the transcontinental train Bandai. The platform has a row of chairs for passengers waiting for the Bandai, and people who enter the platform ca...
[{"type": "stdin_stdout", "input": "10 4\nA\nB\nB\nC\n8 4\nD\nD\nB\nB\n0 0", "output": "AC######BB\nD####BBD\n"}, {"type": "stdin_stdout", "input": "12 4\nA\nB\nB\nD\n5 4\nC\nD\nB\nB\n0 0", "output": "A####D####BB\nD#CBB\n"}, {"type": "stdin_stdout", "input": "10 4\nA\nC\nD\nB\n7 4\nC\nA\nB\nB\n0 0", "output": "AC#####...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells conta...
[{"type": "stdin_stdout", "input": "11 6\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 3\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 4\n", "output": "5\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZibi is a competitive programming coach. There are $n$ competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactl...
[{"type": "stdin_stdout", "input": "40 39\n0 -2\n-2 3\n3 3\n3 -2\n-1 1\n2 0\n-3 2\n-2 1\n0 -3\n-1 -3\n1 -1\n-3 -1\n2 2\n0 2\n1 -3\n-2 -1\n1 2\n-1 -2\n-1 0\n3 2\n1 3\n-3 1\n-2 -3\n-3 -1\n3 0\n-1 3\n3 1\n-2 2\n0 3\n3 -1\n2 -3\n1 1\n-1 -1\n0 1\n-3 0\n1 0\n-3 3\n-3 -3\n2 2\n-1 2\n1 29\n29 2\n29 3\n29 4\n5 29\n29 6\n7 29\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program that extracts n different numbers from the numbers 0 to 9 and outputs the number of combinations that add up to s. Each n number is from 0 to 9, and the same number cannot be used in one combination. For e...
[{"type": "stdin_stdout", "input": "4 14\n3 1\n0 0", "output": "13\n0\n"}, {"type": "stdin_stdout", "input": "3 10\n5 -2\n0 0", "output": "8\n0\n"}, {"type": "stdin_stdout", "input": "2 -1\n13 1\n0 0", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "3 -1\n13 1\n0 0", "output": "0\n0\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.\n\n-----Input-----\nThe first line of input contain an integer T denoting ...
[{"type": "stdin_stdout", "input": "1\n127", "output": "63\n"}, {"type": "stdin_stdout", "input": "1\n101", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1\n100", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1\n110", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1\n111", "output": "-1\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.\n\nHe looks at the first two students and ...
[{"type": "stdin_stdout", "input": "484\nLLRRRL==RRLRRLR=LRR=RL=LLLRL===RLRRRLRR=RRRL=LLLLRL==RL==R==LLLRL=RLLRLRLLLLLLLRRLL=LLR=LLR==RLL==LLLR=RL==LL=LRRL=LLRRRLR====R=R=LRRRLLL==RLRRLR=LL==LLRLR===RR=LR==RL==L==R====LRL=LR=R=R=R=LL=L=RLR=RL==R==LRLRL==L==LL=LR=L=RRRR=R==RRLRRRLR==R=LL===R===RLRRR===LRRLLRRRRR=L==LLRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese , Russian and Vietnamese \n\nChuru is taking the course called “Introduction to Data Structures”. Yesterday, he learned how to use a stack to check is a given parentheses expr...
[{"type": "stdin_stdout", "input": "2\n4 1\n0 3\n4 2\n0 3\n-1 -2", "output": "()()\n()()\n"}, {"type": "stdin_stdout", "input": "2\n4 1\n0 3\n4 2\n0 3\n-2 -2", "output": "()()\n()()\n"}, {"type": "stdin_stdout", "input": "2\n4 1\n0 3\n4 1\n0 3\n-1 -2", "output": "()()\n()()\n"}, {"type": "stdin_stdout", "input": "2\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\ncrc\n1\n\n\nOutput\n\ncrc\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Your progra...
[{"type": "stdin_stdout", "input": "epi\n-2", "output": "eipie\n"}, {"type": "stdin_stdout", "input": "eoi\n-2", "output": "eioie\n"}, {"type": "stdin_stdout", "input": "eoj\n-2", "output": "ejoje\n"}, {"type": "stdin_stdout", "input": "enj\n-2", "output": "ejnje\n"}, {"type": "stdin_stdout", "input": "fnj\n-2", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor he knew every Who down in Whoville beneath, Was busy now, hanging a mistletoe wreath. \"And they're hanging their stockings!\" he snarled with a sneer, \"Tomorrow is Christmas! It's practically here!\"\n\nDr. Suess, H...
[{"type": "stdin_stdout", "input": "336 336\nHHHHHHHHHS..S..HH..H.S.H..HHH.H.H.H.S.H.S.S.H.S..SS..H.SS.H.HH.HH..HH.H...H.H.H.HSS..H...HH..HH.H..H.S.S....S.H.HH..HS..S.S.S.H.H.S..S.H.HH.HH..HH.HH.HS.HH.HSSHHHHHHHHH.H.HH..HHH.H.H.S..H.HH.S.H..HH.HS.HH.S.H.H.H..H.HH.HS.HHHHH.HH.S.SSS.S.S.HH.HS.H.S.HH.H.HH.H.S.HH.HS.HH..HH...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are $\\frac{n \\cdot(n - 1)}{2}$ roads in total. It takes exactly y seconds to traverse any single...
[{"type": "stdin_stdout", "input": "50 23129 410924\n18 28\n17 23\n21 15\n18 50\n50 11\n32 3\n44 41\n50 31\n50 34\n5 14\n36 13\n22 40\n20 9\n9 43\n19 47\n48 40\n20 22\n33 45\n35 22\n33 24\n9 6\n13 1\n13 24\n49 20\n1 20\n29 38\n10 35\n25 23\n49 30\n42 8\n20 18\n32 15\n32 1\n27 10\n20 47\n41 7\n20 14\n18 26\n4 20\n20 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima overslept the alarm clock, which was supposed to raise him to school.\n\nDima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home ...
[{"type": "stdin_stdout", "input": "10 8 2\n0 -1 0 -1 -1 0 0 -1 -1\n-1 0 -1 0 0 -1 -1 0 -1\n-1 -1 -1 0 -1 -1 0 0 0\n0 0 0 0 -1 0 0 0 -1\n0 -1 -1 0 -1 -1 -1 0 0\n-1 -1 -1 0 -1 -2 0 -1 0\n0 0 0 0 -1 0 0 0 -1\n0 0 -1 0 -1 0 0 -1 0\n-1 0 0 0 -1 -1 -1 0 0\n-1 -1 -1 0 0 0 -1 -1 0\n", "output": "-1\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consi...
[{"type": "stdin_stdout", "input": "ttspivgoupgupvgpusvppogsseueusuglpiugssviuutlvgvugtpovuvspvpipggooplgvgugpogvesppulovugsvuougveiivgvslllviogpvtolepglguuellotpvgevspvoiiggiiplppgosuguvtstttpielteuglopgeoeeuivtptggltoltpgliviotsospvitupiopisoetupvvspooilsopslpoloptigstspoiuutiuvvuvlpplvioitsuvlpvtleveslslovolloogsgpv...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements...
[{"type": "stdin_stdout", "input": "56\n-157 136 457 598 -138 -586 -338 752 -566 -718 -333 -965 309 -125 -938 -188 -390 17 -75 -902 -320 163 820 -970 -525 -329 81 488 -412 978 138 344 305 -358 -273 -967 253 -665 -245 187 602 252 -825 -511 828 764 -402 278 995 541 542 549 612 -536 527 -884 225 800 160 -409 -926 -795 -32...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. F has n positive integers, a_1, a_2, …, a_n.\n\nHe thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.\n\nBut this problem is too simple for h...
[{"type": "stdin_stdout", "input": "100\n95 94 31 65 35 95 70 78 81 36 69 97 39 28 89 62 36 23 35 21 36 11 65 39 13 34 79 87 91 70 43 82 24 97 6 87 49 140 60 92 63 9 16 6 31 90 6 5 55 48 27 86 65 66 45 8 67 17 24 44 34 93 26 32 82 54 72 83 94 81 79 79 15 9 4 59 42 83 80 67 28 62 56 58 87 67 34 3 61 10 62 19 94 31 74 97...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point $T$, which coordinates to be found out.\n\nBob travelled around the world and collected clues of the treasure...
[{"type": "stdin_stdout", "input": "25\n2 2\n1 -2\n1 1\n0 1\n2 1\n-2 2\n-1 -2\n-1 2\n0 -2\n-1 1\n-2 -1\n-1 -1\n1 -1\n2 -1\n1 2\n-2 -2\n2 0\n-2 0\n-2 1\n2 -2\n-1 0\n1 0\n0 -1\n0 2\n0 0\n1 3\n-3 -1\n-2 0\n-3 1\n1 1\n0 0\n-2 2\n-1 -1\n1 -1\n-3 3\n0 3\n-2 1\n0 1\n-3 2\n-1 3\n-2 3\n-2 -1\n1 2\n1 0\n-3 0\n0 -1\n-1 2\n-1 1\n-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce Bob decided to lay a parquet floor in his living room. The living room is of size n × m metres. Bob had planks of three types: a planks 1 × 2 meters, b planks 2 × 1 meters, and c planks 2 × 2 meters. Help Bob find ou...
[{"type": "stdin_stdout", "input": "100 100 10000 10000 10000\n", "output": "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\naabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\nbbaabbaabbaabbaabbaabbaabbaabbaabbaabba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA dial lock is a kind of lock which has some dials with printed numbers. It has a special sequence of numbers, namely an unlocking sequence, to be opened.\n\nYou are working at a manufacturer of dial locks. Your job is to...
[{"type": "stdin_stdout", "input": "4\n1433 4680\n6\n777777 003330\n0", "output": "4\n2\n"}, {"type": "stdin_stdout", "input": "4\n1357 4680\n6\n509138 003330\n0", "output": "1\n4\n"}, {"type": "stdin_stdout", "input": "4\n1357 4680\n6\n297443 003330\n0", "output": "1\n5\n"}, {"type": "stdin_stdout", "input": "4\n1357 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results. \n\nA player is given a non-negative integer number of p...
[{"type": "stdin_stdout", "input": "10\nj 10\ni 9\nh 8\ng 7\nf 6\ne 5\nd 4\nc 3\nb 2\na 1\n", "output": "10\na noob\nb noob\nc noob\nd noob\ne random\nf random\ng random\nh average\ni hardcore\nj pro\n"}, {"type": "stdin_stdout", "input": "10\na 1\nb 2\nc 3\nd 4\ne 5\nf 6\ng 7\nh 8\ni 9\nj 10\n", "output": "10\na noob\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a rectangular grid of size $n \\times m$. Each cell of the grid is colored black ('0') or white ('1'). The color of the cell $(i, j)$ is $c_{i, j}$. You are also given a map of directions: for each cell, there is...
[{"type": "stdin_stdout", "input": "3\n1 2\n01\nRL\n3 3\n001\n101\n110\nRLL\nDLD\nULL\n3 3\n000\n000\n000\nRRD\nRLD\nULL\n", "output": "2 1\n4 3\n2 2\n"}, {"type": "stdin_stdout", "input": "3\n1 2\n01\nRL\n3 3\n000\n101\n110\nRLL\nDLD\nULL\n3 3\n000\n000\n000\nRRD\nRLD\nULL\n", "output": "2 1\n4 3\n2 2\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeveral drivers had lined up for the Drag Racing Competition at the Tokyo Drift Street. Dom had organized the competition, but he was not available during all the races and hence he did not know their results. In the drag...
[{"type": "stdin_stdout", "input": "12\nylwdycynzm qikgzjftsy\nuyjjakdllg oupsqupono\nrzydxwplrl rarepbgeqk\nhzunfitubv tmnfmyxhmb\njqomnyflox znowiqbzyq\nuxpwihqnjy hxsmfvssru\nglsafbvhvu xfszigeomu\niahkxbubof rzvfmulbxj\nsreepibkei wrhzprsrme\nuroagvltiy ahxrusrokr\nrpyfumbrxy wklfolgpzi\ndyejhfnwml rztiqhzhmx\nidzq...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe just discovered a new data structure in our research group: a suffix three!\n\nIt's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a s...
[{"type": "stdin_stdout", "input": "30\nmnidamnida\nopmnida\nadinm_masu\nus`m_masu\nuseddesu\nadinmmasu\nmnida_po\ndnmnida\nmasumnida\nusam_po\nmnidadesu\nuted_masu\nmnida_mnida\nadinm_mnida\nusammasu\nmasu_desu\nvsammnida\ngenki_desu\nmm_mnida\nadinmmnida\nop_mnida\nadinm_desu\nused_desu\nusam_desu\nadinmdesu\nsarangh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPaladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each o...
[{"type": "stdin_stdout", "input": "50 2 5\n9 14\n46 34\n40 35\n44 30\n32 16\n1 38\n48 2\n17 14\n50 25\n6 1\n45 19\n21 15\n22 11\n15 33\n8 28\n2 32\n10 22\n37 3\n43 39\n25 16\n9 19\n16 3\n28 32\n20 45\n24 32\n4 18\n49 39\n13 45\n26 4\n11 33\n14 37\n42 19\n31 45\n38 3\n34 8\n18 29\n35 34\n29 16\n7 46\n19 28\n27 33\n30 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on the...
[{"type": "stdin_stdout", "input": "ABCDEFGHIJKLMNOPQRSGTUVWXYZ\n", "output": "YXWVUTGHIJKLM\nZABCDEFSRQPON\n"}, {"type": "stdin_stdout", "input": "UTEDBZRVWLOFUASHCYIPXGJMKNQ\n", "output": "PIYCHSAUTEDBZ\nXGJMKNQFOLWVR\n"}, {"type": "stdin_stdout", "input": "ZWMFLTCQIAJEVUPODMSGXKHRNYB\n", "output": "HKXGSMFLTCQIA\nRN...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nAndy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. \nIt's known that the amount of tips may be different when...
[{"type": "stdin_stdout", "input": "5 3 3\n2 1 1 16 4\n11 4 1 -1 1", "output": "36\n"}, {"type": "stdin_stdout", "input": "5 3 3\n1 1 1 8 15\n18 1 0 -1 1", "output": "43\n"}, {"type": "stdin_stdout", "input": "5 3 4\n0 2 3 2 34\n-1 2 6 0 3", "output": "44\n"}, {"type": "stdin_stdout", "input": "5 2 11\n3 0 -1 1 0\n3 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct?\n\nInput:\n\nThere are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10^100), each on a separate...
[{"type": "stdin_stdout", "input": "200000000000000000000000000000000000000000000000000000000000000000000000000000\n100000000000000000000000000000000000000000000000000000000000000000000000000000\n300000000000000000000000000000000000000000000000000000000000000000000000000000", "output": "YES"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC: Mod! Mod!\n\nstory\n\nThat's right! I'm looking for eyewitness testimony! A phantom thief has appeared in Aizu! Everyone's horse stick was stolen! Who is the culprit! ?? Unravel! Mod! Mod!\n\nProblem statement\n\n\"Eye...
[{"type": "stdin_stdout", "input": "6\n1 25 1 10 1 3", "output": "4\n"}, {"type": "stdin_stdout", "input": "6\n0 15 1 10 2 3", "output": "6\n"}, {"type": "stdin_stdout", "input": "6\n0 15 0 10 2 3", "output": "6\n"}, {"type": "stdin_stdout", "input": "6\n0 15 0 10 2 4", "output": "6\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTeacher thinks that we make a lot of progress. Now we are even allowed to use decimal notation instead of counting sticks. After the test the teacher promised to show us a \"very beautiful number\". But the problem is, he...
[{"type": "stdin_stdout", "input": "40020 4\n", "output": "102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102564102...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCreate a program that inputs the vertex information of two polygons inscribed in one circle and outputs the magnitude relationship of their areas.\n\nAssume that each vertex of the X-side is numbered counterclockwise from...
[{"type": "stdin_stdout", "input": "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n149\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n52\n50\n50\n25\n75\n0", "output": "0\n2\n2\n"}, {"type": "stdin_stdout", "input": "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n149\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n52\n79\n50\n25\n75\n0", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.\n\nInitially, Bob chooses integer m, bit depth of the game, which means that all num...
[{"type": "stdin_stdout", "input": "17 15\na := 010000111111110\nb := 101100110000100\nc := 100101100100111\nd := 010110101110110\ne := 111111000010110\nf := 011001110111110\ng := 110011010100101\nh := 000001010010001\ni := 110000111001011\nj := 000010000010111\nk := 110110111110110\nl := 010000110000100\nm := 00011110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's say Pak Chanek has an array $A$ consisting of $N$ positive integers. Pak Chanek will do a number of operations. In each operation, Pak Chanek will do the following:\n\nChoose an index $p$ ($1 \\leq p \\leq N$).\n\nL...
[{"type": "stdin_stdout", "input": "8 8\n1\n2\n3\n4\n5\n6\n7\n8\n", "output": "27\n1\n2\n3\n3\n4\n4\n5\n5\n"}, {"type": "stdin_stdout", "input": "7 7\n1\n2\n3\n4\n5\n6\n7\n", "output": "22\n1\n2\n3\n3\n4\n4\n5\n"}, {"type": "stdin_stdout", "input": "6 6\n1\n2\n3\n4\n5\n6\n", "output": "17\n1\n2\n3\n3\n4\n4\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below. [Image] \n\nSo, for example, to show the...
[{"type": "stdin_stdout", "input": "196542\n", "output": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer found two positive integers, a and b.\nDetermine whether the product of a and b is even or odd.\n\n-----Constraints-----\n - 1 ≤ a,b ≤ 10000\n - a and b are integers.\n\n-----Input-----\nInput is given f...
[{"type": "stdin_stdout", "input": "-1 -2", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-2 -2", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-2 -1", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-4 -1", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-6 -1", "output": "Even\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe \"Western calendar\" is a concept imported from the West, but in Japan there is a concept called the Japanese calendar, which identifies the \"era name\" by adding a year as a method of expressing the year on the cale...
[{"type": "stdin_stdout", "input": "1 1914", "output": "3781\n"}, {"type": "stdin_stdout", "input": "2 1914", "output": "3825\n"}, {"type": "stdin_stdout", "input": "1 125", "output": "1992\n"}, {"type": "stdin_stdout", "input": "2 125", "output": "2036\n"}, {"type": "stdin_stdout", "input": "2 141", "output": "2052\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to ...
[{"type": "stdin_stdout", "input": "5\n void 8os6s2b ( T )\n void 8os6s2b ( int, int, int,int, int ) \n void 8os6s2b ( int, int, T) \n void fow8dmm ( T,T, int, int ) \n void fow8dmm ( int) \n2\n int 2 \n double 9c9t0 \n7\n 8os6s2b ( 9c9t0 ) \n 8os6s2b (9c9t0,9c9t0,9c9t0 ) \n8os6s2b ( 9c9t0,...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells ...
[{"type": "stdin_stdout", "input": "100 10 30\n40 4\n15 3\n75 3\n88 10\n32 1\n16 5\n81 8\n45 2\n72 8\n11 6\n86 4\n50 2\n9 4\n11 1\n20 3\n47 3\n2 4\n68 3\n90 5\n85 2\n88 1\n88 5\n86 3\n70 9\n49 3\n34 4\n5 7\n77 5\n50 1\n87 5\n", "output": "402737011\n"}, {"type": "stdin_stdout", "input": "100000 100000 4\n50001 50001\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.\n\nYou are given l and r. For all integers from l to r, inclusive, we wrote down all of the...
[{"type": "stdin_stdout", "input": "519002744 519002744\n", "output": "519002744\n"}, {"type": "stdin_stdout", "input": "331900277 331900277\n", "output": "331900277\n"}, {"type": "stdin_stdout", "input": "349533413 349533413\n", "output": "349533413\n"}, {"type": "stdin_stdout", "input": "568814539 568814539\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nChef had a hard day and want to play little bit. The game is called \"Chain\". Chef has the sequence of symbols. Each symbol is either '-' or '+'. The sequenc...
[{"type": "stdin_stdout", "input": "2\n+++-+-+---\n-------", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n-+--+++--+\n-------", "output": "4\n3\n"}, {"type": "stdin_stdout", "input": "2\n-+-+-+-+-+\n-------", "output": "0\n3\n"}, {"type": "stdin_stdout", "input": "2\n--++---+++\n-----+-", "output": "4\n2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe chef has a recipe he wishes to use for his guests,\nbut the recipe will make far more food than he can serve to the guests.\nThe chef therefore would like to make a reduced version of the recipe which has the same rat...
[{"type": "stdin_stdout", "input": "3\n2 4 11\n3 2 2 7\n4 3 36 13 11", "output": "4 11\n2 2 7\n3 36 13 11\n"}, {"type": "stdin_stdout", "input": "3\n2 4 10\n3 2 2 7\n4 3 36 13 11", "output": "2 5\n2 2 7\n3 36 13 11\n"}, {"type": "stdin_stdout", "input": "3\n2 2 10\n3 2 2 7\n4 3 36 13 11", "output": "1 5\n2 2 7\n3 36 13...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. \nThe AND operation is the Bitwise AND operation, defined as in here. \n\n------ Input ------ \n\...
[{"type": "stdin_stdout", "input": "5\n2 14 11 2 0", "output": "20\n"}, {"type": "stdin_stdout", "input": "5\n13 2 12 4 2", "output": "22\n"}, {"type": "stdin_stdout", "input": "5\n11 1 29 8 2", "output": "29\n"}, {"type": "stdin_stdout", "input": "5\n4 2 5 15 12", "output": "35\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.\n\nPolycarp is a very famous freelancer. His current rating is $r$...
[{"type": "stdin_stdout", "input": "50 15000\n142 -300\n20 -298\n560 -300\n1815 -292\n282 -297\n92 -293\n34 -284\n555 -299\n408 -293\n504 -284\n278 -284\n139 -291\n64 -298\n311 -293\n130 -293\n89 -298\n129 -294\n385 -295\n136 -288\n41 -293\n112 -290\n416 -295\n178 -294\n154 -300\n110 -300\n346 -299\n209 -294\n1394 -295...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image>...
[{"type": "stdin_stdout", "input": "6 2\n1 2 536870912\n2 3 864795845\n", "output": "YES\n536870912 864795845 864795845 0 0 0\n"}, {"type": "stdin_stdout", "input": "6 2\n1 1 536870912\n2 3 864795845\n", "output": "YES\n536870912 864795845 864795845 0 0 0\n"}, {"type": "stdin_stdout", "input": "3 2\n1 2 536870912\n2 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings \"kek\", \"abacaba\", \"r\" and \"papicipap\" are palindromes, while the strings \"abb\" an...
[{"type": "stdin_stdout", "input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "wobervhvvkihcuyjtmqhaaigvahheoqleromusrartldojsjvy\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nЕсть n-подъездный дом, в каждом подъезде по m этажей, и на каждом этаже каждого подъезда ровно k квартир. Таким образом, в доме всего n·m·k квартир. Они пронумерованы естественным образом от 1 до n·m·k, то есть первая ква...
[{"type": "stdin_stdout", "input": "1000 1000 1000\n1000000000 990000001\n", "output": "1144\n"}, {"type": "stdin_stdout", "input": "491 980 907\n253658701 421137262\n", "output": "3985\n"}, {"type": "stdin_stdout", "input": "200 970 827\n113595903 145423943\n", "output": "1484\n"}, {"type": "stdin_stdout", "input": "8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThey say \"years are like dominoes, tumbling one after the other\". But would a year fit into a grid? I don't think so.\n\nLimak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows...
[{"type": "stdin_stdout", "input": "7 39\n.......................................\n.###..###..#..###.....###..###..#..###.\n...#..#.#..#..#.........#..#.#..#..#...\n.###..#.#..#..###.....###..#.#..#..###.\n.#....#.#..#....#.....#....#.#..#..#.#.\n.###..###..#..###.....###..###..#..###.\n...................................
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given weighted directed graph G(V, E), find the distance of the shortest route that meets the following criteria:\n\n* It is a closed cycle where it ends at the same point it starts.\n* It visits each vertex exactly...
[{"type": "stdin_stdout", "input": "2 -1\n-1 2 8\n-1 15 4\n-1 0 12\n1 -2 3\n-1 0 4\n3 -1 1", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 -1\n-1 2 8\n-1 10 4\n-1 0 12\n1 -2 3\n-1 0 4\n3 -1 1", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 -1\n-1 2 8\n-1 10 4\n-1 0 12\n1 -2 3\n-1 0 4\n3 -1 2", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSquirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. ...
[{"type": "stdin_stdout", "input": "rrlllrrrlrrlrrrlllrlrlrrrlllrllrrllrllrrlrlrrllllrlrrrrlrlllrlrrrlrlrllrlrlrrlrrllrrrlrlrlllrrllllrl\n", "output": "1\n2\n6\n7\n8\n10\n11\n13\n14\n15\n19\n21\n23\n24\n25\n29\n32\n33\n36\n39\n40\n42\n44\n45\n50\n52\n53\n54\n55\n57\n61\n63\n64\n65\n67\n69\n72\n74\n76\n77\n79\n80\n83\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left o...
[{"type": "stdin_stdout", "input": "501\noilesjbgowlnayckhpoaitijewsyhgavnthycaecwnvzpxgjqfjyxnjcjknvvsmjbjwtcoyfbegmnnheeamvtfjkigqoanhvgdfrjchdqgowrstlmrjmcsuuwvvoeucfyhnxivosrxblfoqwikfxjnnyejdiihpenfcahtjwcnzwvxxseicvdfgqhtvefswznuyohmmljlnxubhevywpmnitnkhecsgccpstxkmdzabsnwxkokdfsogzbpnfvgudvqlstxojzfzugxbfrozveai...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria:\n\n* Visit the points according to the following steps:\n1. It starts from the leftmost point (star...
[{"type": "stdin_stdout", "input": "5\n-1 0\n1 2\n2 1\n3 2\n4 0", "output": "12.462840740\n"}, {"type": "stdin_stdout", "input": "3\n-13 -1\n0 -1\n10 -2", "output": "46.071604488\n"}, {"type": "stdin_stdout", "input": "3\n-10 -1\n0 -1\n10 -2", "output": "40.074860016\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n1 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (x_{i}, y_{i}). All sensors are located at distinct points strictly inside the rectangle. \n\nOpposite corners ...
[{"type": "stdin_stdout", "input": "11 17 10\n1 8\n1 7\n2 3\n3 2\n4 8\n5 3\n2 15\n8 6\n6 3\n3 1\n", "output": "-1\n109\n-1\n-1\n26\n71\n-1\n74\n-1\n69\n"}, {"type": "stdin_stdout", "input": "10 17 10\n1 8\n1 7\n2 3\n7 2\n4 8\n10 3\n2 8\n8 6\n6 3\n3 1\n", "output": "-1\n41\n-1\n-1\n76\n-1\n42\n28\n-1\n103\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider an array $a$ of length $n$ with elements numbered from $1$ to $n$. It is possible to remove the $i$-th element of $a$ if $gcd(a_i, i) = 1$, where $gcd$ denotes the greatest common divisor. After an element is rem...
[{"type": "stdin_stdout", "input": "1337 424242424242\n", "output": "119112628\n"}, {"type": "stdin_stdout", "input": "300000 1000000000\n", "output": "590856313\n"}, {"type": "stdin_stdout", "input": "2 1000000000000\n", "output": "138131255\n"}, {"type": "stdin_stdout", "input": "17957 2\n", "output": "653647969\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer h_{i}. The tourist pick smooth enough ro...
[{"type": "stdin_stdout", "input": "190877881 20\n3 100000000\n14 100000000\n22 100000000\n24 100000000\n31 100000000\n41 100100000\n46 100000000\n84 100000000\n94 100000000\n98 100000000\n99999912 100000000\n99999915 100000000\n99999916 100000000\n99999923 100000000\n99999935 100000000\n99999937 100000000\n99999954 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence A of N non-negative integers.\nCompute the sum of \\prod _{i = 1} ^N \\dbinom{B_i}{A_i} over all sequences B of N non-negative integers whose sum is at most M, and print it modulo (10^9 + 7).\nHere, \\d...
[{"type": "stdin_stdout", "input": "2000 4000001\n2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThey say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, b...
[{"type": "stdin_stdout", "input": "5\n3 4\n4 5\n1 2\n2 4\n3\n2 3\n1 3\n3 5\n", "output": "3 1 1 2\n"}, {"type": "stdin_stdout", "input": "5\n3 1\n4 5\n1 4\n2 4\n3\n2 3\n1 3\n3 5\n", "output": "3 1 2 1\n"}, {"type": "stdin_stdout", "input": "5\n3 1\n4 5\n1 4\n2 1\n3\n2 3\n1 3\n3 5\n", "output": "3 1 1 1\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings s and t consisting of lowercase English letters and an integer L.\n\nWe will consider generating a string of length L by concatenating one or more copies of s and t. Here, it is allowed to use th...
[{"type": "stdin_stdout", "input": "8\ncoding\nfestiual", "output": "festiual\n"}, {"type": "stdin_stdout", "input": "8\ngnicoc\nfisteual", "output": "fisteual\n"}, {"type": "stdin_stdout", "input": "8\ngoicdm\neisteual", "output": "eisteual\n"}, {"type": "stdin_stdout", "input": "8\nmdciog\nlauetsie", "output": "lauet...
code_stdio