messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Given are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\n-----Constraints-----\n - -10^9 \\leq a \\leq b \\leq 10^9\n - -10^9 \\leq c \\leq d \\leq 10^9\n - All values in input are integers.\n\n-... | [{"input": "-1000000000 1000000000 -1000000000 1000000000\n", "output": "1000000000000000000\n"}, {"input": "418379342 802780784 -790013317 -445130206\n", "output": "-186233282690604452\n"}, {"input": "-477104372 -381646699 -939378260 508013173\n", "output": "448181474807752720\n"}, {"input": "-683353808 -213997410 -57... | code_stdio |
[
{
"content": "Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.\n\nLet's denote as f(k)(x) the function f applied k times to the value x. More formally, f(1)(x) = f(x), ... | [{"input": "142\n34 88 88 88 88 88 131 53 88 130 131 88 88 130 88 131 53 130 130 34 88 88 131 130 53 88 88 34 131 130 88 131 130 34 130 53 53 34 53 34 130 34 88 88 130 88 131 130 34 53 88 34 53 88 130 53 34 53 88 131 130 34 88 88 130 88 130 130 131 131 130 53 131 130 131 130 53 34 131 34 88 53 88 53 34 130 88 88 130 53... | code_stdio |
[
{
"content": "You have N cups and 1 ball.\n\nThe cups are arranged in a row, from left to right.\n\nYou turned down all the cups, then inserted the ball into the leftmost cup.\n\nThen, you will perform the following Q operations:\n\n* The i-th operation: swap the positions of the A_i-th and B_i-th cups from the... | [{"input": "20 3\n1 4\n10 17\n1 19", "output": "4\n"}, {"input": "20 3\n1 4\n10 17\n1 14", "output": "4\n"}, {"input": "20 3\n1 4\n10 17\n1 13", "output": "4\n"}, {"input": "20 3\n1 1\n10 17\n1 13", "output": "4\n"}, {"input": "24 1\n2 1\n11 18\n1 35", "output": "3\n"}, {"input": "20 3\n1 4\n10 17\n2 14", "output": "4\... | code_stdio |
[
{
"content": "Chef loves arrays. But he really loves a specific kind of them - Rainbow Arrays. \nThe array is a Rainbow Array if it has such a structure:\n- The first a1 elements equal to 1. \n- The next a2 elements equal to 2. \n- The next a3 elements equal to 3. \n- The next a4 elements equal to 4. \n- The... | [{"input": "1018", "output": "857373624\n"}, {"input": "200", "output": "120529249\n"}, {"input": "140", "output": "119877472\n"}, {"input": "320", "output": "398506989\n"}, {"input": "147", "output": "170230452\n"}, {"input": "269", "output": "177979760\n"}, {"input": "229", "output": "666926094\n"}, {"input": "303", ... | code_stdio |
[
{
"content": "You are given a string $s$, consisting only of characters '0' and '1'.\n\nYou have to choose a contiguous substring of $s$ and remove all occurrences of the character, which is a strict minority in it, from the substring.\n\nThat is, if the amount of '0's in the substring is strictly smaller than ... | [{"input": "1\n101010101010101010101010101010010101010101010101010101010101010101010100000\n", "output": "35\n"}, {"input": "1\n10101010101010101010101010101001010101010101010101010101010101010101010000\n", "output": "35\n"}, {"input": "1\n1101010101111010110101010101001010111010\n", "output": "17\n"}, {"input": "1\n00... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese here \nRead problems statements in Russian here \n\n------ Problem Statement ------ \n\nOne day Chef is waiting his girlfriend on the bus station. The girlfriend said that she will be at time_{1}. Chef went to the bus station at time_{2}. When Chef has ... | [{"input": "3\n10:00\n09:00\n14\n10:00\n08:00\n151\n10:00\n09:00\n167", "output": "74.0 60.0\n271.0 211.0\n227.0 197.0\n"}, {"input": "3\n10:00\n09:00\n20\n10:00\n08:00\n151\n10:00\n09:00\n167", "output": "80.0 60.0\n271.0 211.0\n227.0 197.0\n"}, {"input": "3\n10:00\n09:00\n15\n10:00\n08:00\n151\n10:00\n09:00\n167", "o... | code_stdio |
[
{
"content": "Fibonacci number f(i) appear in a variety of puzzles in nature and math, including packing problems, family trees or Pythagorean triangles. They obey the rule f(i) = f(i - 1) + f(i - 2), where we set f(0) = 1 = f(-1).\n\nLet V and d be two certain positive integers and be N ≡ 1001 a constant. Cons... | [{"input": "10 1\n118 1\n22 23", "output": "10\n109\n12\n"}, {"input": "10 7\n118 1\n22 23", "output": "6\n109\n12\n"}, {"input": "10 3\n118 1\n22 23", "output": "8\n109\n12\n"}, {"input": "21 2\n104 7\n52 12", "output": "20\n59\n30\n"}, {"input": "16 2\n50 2\n22 20", "output": "15\n47\n13\n"}, {"input": "16 2\n75 2\n2... | code_stdio |
[
{
"content": "Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2.\n\nThis conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair... | [{"input": "6\n10\n14\n0", "output": "1\n2\n2\n"}, {"input": "6\n1\n12\n0", "output": "1\n0\n1\n"}, {"input": "6\n10\n8\n0", "output": "1\n2\n1\n"}, {"input": "6\n4\n12\n0", "output": "1\n1\n1\n"}, {"input": "6\n2\n14\n0", "output": "1\n0\n2\n"}, {"input": "6\n16\n1\n0", "output": "1\n2\n0\n"}, {"input": "6\n6\n14\n0",... | code_stdio |
[
{
"content": "At Akabe High School, which is a programmer training school, the roles of competition programmers in team battles are divided into the following three types.\nC: | Coder | I am familiar with the language and code.\n--- | --- | ---\nA: | Algorithm | I am good at logical thinking and think about alg... | [{"input": "4\n2 1 2\n2 1 2\n13 15 2\n0 1 3", "output": "1\n1\n7\n0\n"}, {"input": "4\n2 1 2\n2 2 2\n13 15 2\n0 1 3", "output": "1\n2\n7\n0\n"}, {"input": "4\n11 0 1\n0 3 3\n2 10 4\n1 2 3", "output": "3\n0\n2\n1\n"}, {"input": "4\n0 1 2\n3 0 2\n13 19 2\n0 1 3", "output": "0\n1\n7\n0\n"}, {"input": "4\n2 1 2\n2 4 2\n13 ... | code_stdio |
[
{
"content": "Given are N positive integers A_1,...,A_N.\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\nSince the answer ... | [{"input": "10000\n996426 991040 991394 993249 993789 994392 991787 998270 994534 999447 995337 997096 996535 997215 994454 999779 998240 991404 991682 999870 990794 994313 993602 993869 997730 991987 994764 993847 993506 990653 996555 994126 992060 995401 997275 995702 995833 993070 990511 991728 996911 991730 991236 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks.\nToday's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The machine is pretty universal - it can make l... | [{"input": "6\n1 1\n2 4\n3 16\n4 16\n4 1\n1 4", "output": "0\n1\n5\n2\n2\n2\n"}, {"input": "6\n2 1\n2 1\n3 8\n14 16\n1 1\n2 4", "output": "1\n1\n4\n7\n0\n1\n"}, {"input": "6\n1 2\n2 4\n5 4\n16 32\n3 2\n1 8", "output": "1\n1\n2\n1\n2\n3\n"}, {"input": "6\n1 2\n4 4\n5 4\n16 32\n3 2\n1 8", "output": "1\n0\n2\n1\n2\n3\n"},... | code_stdio |
[
{
"content": "You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to step 3; If b ≥ 2·a, then set the value of b to... | [{"input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000 1000000000000000000\n"}, {"input": "1100000000000000000 1000000000000000000\n", "output": "1100000000000000000 1000000000000000000\n"}, {"input": "1100000000000000000 1000000000000010000\n", "output": "1100000000000000000 10000000000... | code_stdio |
[
{
"content": "<image>\n\nTo monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:\n\nInitially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, ... | [{"input": "10\n100000 99990\n100000 99997\n100000 99995\n100000 99993\n100000 99990\n100000 99992\n100000 99999\n100000 99992\n100000 99994\n100000 99992\n", "output": "969821134\n814889585\n537223949\n802818035\n969821134\n889337472\n635814936\n889337472\n352113525\n889337472\n"}, {"input": "10\n100000 99991\n100000 ... | code_stdio |
[
{
"content": "The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively.\n\nPolycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, represented as a group of four 8-bit numbers (without ... | [{"input": "15 8\n244.1.125.160\n39.50.68.162\n142.253.101.137\n52.239.241.147\n194.4.189.143\n200.238.160.30\n245.78.177.243\n89.249.140.19\n169.51.142.22\n123.246.20.99\n133.44.192.119\n226.240.179.30\n76.209.211.184\n98.15.6.117\n227.219.117.153\n", "output": "-1\n"}, {"input": "15 8\n244.1.125.160\n39.50.68.162\n14... | code_stdio |
[
{
"content": "Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.\n\nLooking at her coins, a question came to her mind: after giving the coins to A... | [{"input": "15 388\n33 232 106 369 266 135 22 169 367 37 14 181 232 25 257\n", "output": "89\n0 14 22 25 33 36 37 39 47 51 55 58 59 61 62 69 70 72 73 76 80 84 92 94 95 98 106 109 117 131 135 149 157 160 168 169 172 174 181 182 183 186 191 193 194 195 197 202 205 206 207 214 216 219 220 228 231 239 253 257 271 279 282 2... | code_stdio |
[
{
"content": "Given are N integers A_1,\\ldots,A_N.\nFind the sum of A_i \\times A_j over all pairs (i,j) such that 1\\leq i < j \\leq N, modulo (10^9+7).\n\n-----Constraints-----\n - 2 \\leq N \\leq 2\\times 10^5\n - 0 \\leq A_i \\leq 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is give... | [{"input": "4\n141421356 17320508 22360679 244949\n", "output": "437235829\n"}, {"input": "4\n141421356 17320508 22360679 176612", "output": "432841470\n"}, {"input": "4\n141421356 17320508 44188846 176612", "output": "442072669\n"}, {"input": "4\n141421356 15438004 10545868 176612", "output": "309796111\n"}, {"input":... | code_stdio |
[
{
"content": "Joisino is planning to open a shop in a shopping street.\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during ... | [{"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 1 0 1 0\n1 0 1 1 0 0 0 1 0 1\n-8 6 -2 -11 -12 4 14 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 9 -9 12 -5 8 0 -9 -7 -7", "output": "33\n"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -15 0 11 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -7 5 5\... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at mos... | [{"input": "42 0\n286046708 405034560 -729242288 -594215986 -417878652 197367358 -252467864 -633931002 396498018 -511564535 -989028451 133570042 -189524845 -823874429 -29495943 609283144 349227466 -228464789 -326269641 -837429605 310547279 27725681 -167613209 -86658444 900798243 607258117 280296177 -521198948 862072118... | code_stdio |
[
{
"content": "A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \\cdot (q + 1)$ rectangles were left after the cutting. After the cutting, rectangles were of $n$ different types. Two rectangles are ... | [{"input": "2\n2 2 20\n2 10 40\n", "output": "6\n"}, {"input": "2\n2 2 20\n1 10 11\n", "output": "0\n"}, {"input": "2\n2 2 35\n1 10 11\n", "output": "0\n"}, {"input": "2\n2 3 20\n2 4 40\n", "output": "6\n"}, {"input": "2\n2 2 20\n2 4 40\n", "output": "6\n"}, {"input": "2\n2 2 20\n2 7 16\n", "output": "3\n"}, {"input": ... | code_stdio |
[
{
"content": "Consider a tunnel on a one-way road. During a particular day, $n$ cars numbered from $1$ to $n$ entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds.\n\nA traffic enforcement camera is mounted at the tunnel entrance. Another traffic enforcement came... | [{"input": "7\n5 2 3 6 7 1 4\n2 3 6 7 1 4 5\n", "output": "6\n"}, {"input": "7\n5 2 3 6 7 1 4\n2 3 6 7 1 4 5\n", "output": "6\n"}, {"input": "5\n3 5 2 1 4\n4 3 2 5 1\n", "output": "2\n"}, {"input": "5\n3 5 2 1 4\n4 3 2 5 1\n", "output": "2\n"}, {"input": "2\n1 2\n1 2\n", "output": "0\n"}, {"input": "2\n1 2\n2 1\n", "ou... | code_stdio |
[
{
"content": "There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank is a neighbour of itself.\n\nVasya has an account in each bank. Its balance ma... | [{"input": "50\n108431864 128274949 -554057370 -384620666 -202862975 -803855410 -482167063 -55139054 -215901009 0 0 0 0 0 94325701 730397219 358214459 -673647271 -131397668 -377892440 0 0 0 0 0 -487994257 -360271553 639988328 489338210 -281060728 250208758 0 993242346 -213071841 -59752620 -864351041 -114363541 50627995... | code_stdio |
[
{
"content": "There are n servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to n.\n\nIt is known that during the day q tasks will come, the i-th of them is characterized with three integers: t_{i} — the moment in seconds in which the task will come, k_{i} — th... | [{"input": "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "4 10\n1 1 1\n3 1 2\n4 ... | code_stdio |
[
{
"content": "Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: $f(0) = a$; $f(1) = b$; $f(n) = f(n-1) \\oplus f(n-2)$ ... | [{"input": "10\n669924290 408119795 804030560\n663737793 250734602 29671646\n431160679 146708815 289491233\n189259304 606497663 379372476\n707829111 49504411 81710658\n54555019 65618101 626948607\n578351356 288589794 974275296\n400531973 205638174 323247740\n219131617 178762989 799964854\n825160173 502080627 608216046\... | code_stdio |
[
{
"content": "Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x_1, x_2, ..., x_{k} (k > 1) is such maximum element x_{j}, that the following inequality holds: $x_{j} \\neq \\operatorname{max}_{i = 1}^{k} x_{i}$.\n\nThe lucky numbe... | [{"input": "10\n29272229 8752316 10025994 52398694 16706314 49609605 28150935 102254532 44865054 87041483\n", "output": "129354579\n"}, {"input": "10\n4547989 39261040 185956581 38131456 26174500 1101740 71295827 77784626 155701452 61318416\n", "output": "263691991\n"}, {"input": "10\n4547989 39261040 185956581 3813145... | code_stdio |
[
{
"content": "Holidays are coming up really soon. Rick realized that it's time to think about buying a traditional spruce tree. But Rick doesn't want real trees to get hurt so he decided to find some in an $n \\times m$ matrix consisting of \"*\" and \".\".\n\nTo find every spruce first let's define what a spru... | [{"input": "6\n4 7\n...*...\n..***..\n.****..\n*******\n6 10\n....*.*...\n...*****..\n..*******.\n.********.\n********.*\n**********\n5 5\n*...*\n**.**\n*****\n**.**\n*...*\n5 6\n.*....\n.**...\n.***..\n.****.\n.*****\n3 3\n*.*\n...\n*.*\n2 4\n.**.\n****\n", "output": "24\n89\n19\n22\n4\n8\n"}, {"input": "6\n4 7\n...*.... | code_stdio |
[
{
"content": "I, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me.\n\nIt is no surprise Fischl speaks with a strange choice of words. However, this time, not even Oz, her raven... | [{"input": "3\n28\nqaabzwsxedcrfvtgbyhnujmiklop\n13\ncleanairactbd\n10\naannttoonn\n", "output": "\nac\nf\nb\n"}, {"input": "4\n5\noisha\n10\niloveoisha\n16\nshahromloveoisha\n16\noishaloveshahrom\n", "output": "b\nb\nb\nb\n"}, {"input": "4\n5\naisho\n10\niloveoisha\n16\nshahromloveoisha\n16\noishaloveshahrom\n", "outp... | code_stdio |
[
{
"content": "Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: \n\n 1. The house consists of some non-zero numbe... | [{"input": "1000000000000\n", "output": "272165"}, {"input": "225849940487\n", "output": "129343\n"}, {"input": "542905489591\n", "output": "200537\n"}, {"input": "376593918338\n", "output": "167021\n"}, {"input": "249436457427\n", "output": "135929\n"}, {"input": "468135010961\n", "output": "186217\n"}, {"input": "235... | code_stdio |
[
{
"content": "You have an initially empty cauldron, and you want to brew a potion in it. The potion consists of two ingredients: magic essence and water. The potion you want to brew should contain exactly $k\\ \\%$ magic essence and $(100 - k)\\ \\%$ water.\n\nIn one step, you can pour either one liter of magic... | [{"input": "100\n2\n36\n43\n19\n99\n100\n98\n9\n79\n57\n1\n78\n56\n14\n66\n93\n62\n50\n76\n33\n25\n41\n15\n61\n97\n33\n51\n97\n95\n96\n83\n53\n12\n77\n87\n85\n37\n72\n82\n70\n44\n69\n58\n52\n48\n73\n21\n24\n20\n8\n31\n32\n45\n55\n29\n13\n28\n49\n60\n54\n90\n86\n94\n10\n71\n47\n40\n74\n80\n23\n26\n84\n38\n89\n4\n39\n6\n... | code_stdio |
[
{
"content": "Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by thei... | [{"input": "5\nH4 B9 S4 D2 C3", "output": "D2 C3 H4 S4 B9\nStable\nD2 C3 S4 H4 B9\nNot stable\n"}, {"input": "5\nH4 C9 S4 D2 C2", "output": "D2 C2 H4 S4 C9\nStable\nD2 C2 S4 H4 C9\nNot stable\n"}, {"input": "5\nH4 B9 S4 E2 C3", "output": "E2 C3 H4 S4 B9\nStable\nE2 C3 S4 H4 B9\nNot stable\n"}, {"input": "5\nI4 C9 S4 D2... | code_stdio |
[
{
"content": "Aiz, which is located in cyberspace, trades information with Wakamatsu. The two countries are developing their economies by exchanging useful data with each other. The two countries, whose national policy is philanthropy and equality, and above all, the old word of the Aizu region, \"what must be ... | [{"input": "5\n18\n102\n-181\n53\n9", "output": "0\n"}, {"input": "5\n18\n102\n-155\n53\n9", "output": "3\n"}, {"input": "5\n18\n146\n-181\n53\n9", "output": "0\n"}, {"input": "5\n33\n146\n-181\n53\n9", "output": "0\n"}, {"input": "5\n55\n146\n-181\n53\n9", "output": "0\n"}, {"input": "5\n18\n102\n-155\n53\n32", "outpu... | code_stdio |
[
{
"content": "Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they ... | [{"input": "15\nypnxn 279\njgjfwx 926\nqpuhuwq 327\nrxing 1136\npmuduhznoaqu 912\ndagktgdarveusju 764\nwocppgafnui 200\ndhavrncwfw 725\njpcmigg 658\nwrczqxycivdqn 1232\nmcmkkbnifeod 1503\nhtqvkgkbhtytsz 130\ntwflegsjz 1089\npkhfxzuxrxzwsd 989\nszfwtzfpnscgue 958\npmuduhznoaqu", "output": "8248\n"}, {"input": "15\nypnxn... | code_stdio |
[
{
"content": "The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.\n\nLet's consider a rectangular... | [{"input": "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\n"... | code_stdio |
[
{
"content": "Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).\n\nThe key in football is to divide into ... | [{"input": "100\n2382 7572 9578 1364 2325 2929 7670 5574 2836 2440 6553 1751 929 8785 6894 9373 9308 7338 6380 9541 9951 6785 13181 9942 5087 7544 6582 7139 8458 7424 9759 8199 9464 8817 7625 6200 4955 9373 9500 3062 849 4210 9337 5466 2190 8150 4971 3145 869 5675 1975 161 1998 378 5229 9000 8958 761 358 434 7636 8295 ... | code_stdio |
[
{
"content": "You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\n* The graph is simple and connected.\n* There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is... | [{"input": "4", "output": "4\n1 2\n1 3\n2 4\n3 4\n"}, {"input": "4", "output": "4\n1 2\n1 3\n2 4\n3 4\n"}, {"input": "3", "output": "2\n1 3\n2 3"}, {"input": "000", "output": "0\n"}, {"input": "001", "output": "0\n"}, {"input": "001", "output": "0\n"}, {"input": "000", "output": "0\n"}, {"input": "0", "output": "0\n"},... | code_stdio |
[
{
"content": "There are $n$ students numerated from $1$ to $n$. The level of the $i$-th student is $a_i$. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ by more than $x$.\n\nFor example, if $x = 4... | [{"input": "96 15 21\n76 26 108 220 384 4 170 198 568 571 2 193 244 359 78 133 107 340 110 135 565 341 109 572 243 138 357 52 293 344 595 105 569 362 639 134 82 356 27 137 194 291 499 104 28 290 197 477 339 50 288 289 160 54 358 640 343 542 566 79 136 385 3 641 195 355 361 169 196 429 242 162 338 80 77 161 81 337 132 5... | code_stdio |
[
{
"content": "You have a tree of $n$ vertices. You are going to convert this tree into $n$ rubber bands on infinitely large plane. Conversion rule follows:\n\nFor every pair of vertices $a$ and $b$, rubber bands $a$ and $b$ should intersect if and only if there is an edge exists between $a$ and $b$ in the tree.... | [{"input": "28\n2 24\n2 4\n2 3\n1 2\n1 17\n1 21\n1 22\n10 22\n22 23\n22 26\n25 26\n16 25\n7 26\n5 7\n5 8\n5 15\n5 14\n5 12\n10 20\n11 4\n9 25\n6 9\n12 19\n9 28\n13 14\n18 28\n27 28\n", "output": "13\n"}, {"input": "28\n2 24\n2 4\n2 3\n1 2\n1 17\n1 21\n1 22\n10 22\n22 23\n22 26\n25 26\n16 25\n7 26\n5 7\n5 8\n5 15\n5 14\... | code_stdio |
[
{
"content": "A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try?\n\n\n-----Input-----\n\nThe input contains two integers a and b (0 ≤ a, b ≤ 10^3), separa... | [{"input": "1094 350\n", "output": "1444\n"}, {"input": "1132 485\n", "output": "1617\n"}, {"input": "1062 519\n", "output": "1581\n"}, {"input": "260 1041\n", "output": "1301\n"}, {"input": "1132 306\n", "output": "1438\n"}, {"input": "1267 243\n", "output": "1510\n"}, {"input": "1062 931\n", "output": "1993\n"}, {"in... | code_stdio |
[
{
"content": "You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.\n\nThe level of the cave where you are is a rectangular square grid of n rows and m colum... | [{"input": "21 21\n.....X...X.........X.\n...X...XX......X.....\n..X........X.X...XX..\n.........X....X...X..\nX...X...........XX...\n...X...X....XX...XXX.\n.X............X......\n......X.X............\n.X...X.........X.X...\n......XX......X.X....\n....X.......X.XXX....\n.X.......X..XXX.X..X.\n..X........X....X...X\n..... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nN one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line.\nA kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L \n≤ x ≤ R.\n\nYour tas... | [{"input": "1\n3\n1 4\n-1 14\n12 12", "output": "2\n"}, {"input": "1\n3\n0 4\n-1 14\n12 12", "output": "2\n"}, {"input": "1\n3\n0 3\n-2 12\n12 19", "output": "2\n"}, {"input": "1\n3\n0 4\n-1 14\n12 22", "output": "2\n"}, {"input": "1\n3\n1 3\n-1 10\n23 13", "output": "2\n"}, {"input": "1\n3\n0 4\n-1 14\n12 16", "output... | code_stdio |
[
{
"content": "You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string.\n\nHere, a mirror string is a string S such that the following sequence of operations on S results in the same string S:\n\n1. Reverse the order of the characters in S.\n\n2. Replace each ... | [{"input": "qbdp", "output": "Yes\n"}, {"input": "dqpb", "output": "Yes\n"}, {"input": "dpqb", "output": "Yes\n"}, {"input": "bpqd", "output": "Yes\n"}, {"input": "bqpd", "output": "Yes\n"}, {"input": "pbdq", "output": "Yes\n"}, {"input": "qdbp", "output": "Yes\n"}, {"input": "dbqp", "output": "No\n"}, {"input": "bdqp"... | code_stdio |
[
{
"content": "The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of $n$ haybale piles on the farm. The $i$-th pile contains $a_i$ haybales. \n\nHowever, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move o... | [{"input": "3\n4 4\n0 0 2 2\n2 1\n100 2\n1 14\n0\n", "output": "2\n101\n0\n"}, {"input": "3\n4 5\n0 0 0 2\n2 2\n110 2\n1 14\n0\n", "output": "1\n112\n0\n"}, {"input": "3\n4 4\n0 0 2 2\n2 1\n100 4\n1 23\n1\n", "output": "2\n101\n1\n"}, {"input": "3\n4 5\n1 0 0 4\n2 1\n110 2\n1 14\n1\n", "output": "2\n111\n1\n"}, {"input... | code_stdio |
[
{
"content": "Amr bought a new video game \"Guess Your Way Out! II\". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.\n\nLet's index all the ... | [{"input": "4 3\n4 10 14 1\n3 7 6 0\n2 3 3 1\n", "output": "Data not sufficient!\n"}, {"input": "4 3\n4 10 26 1\n3 7 6 0\n2 3 3 1\n", "output": "Data not sufficient!\n"}, {"input": "4 3\n4 10 23 1\n3 7 6 0\n2 3 3 1\n", "output": "Data not sufficient!\n"}, {"input": "8 3\n4 10 14 1\n3 7 6 0\n2 3 3 1\n", "output": "Data ... | code_stdio |
[
{
"content": "There are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the following operation on these integers any number of times:\n\n* Choose 1 \\leq i \\leq N and multiply the value of A_i by -2.\n\n\n\nNotice that he multiplies it by minus two.\n\nHe would like to make A_1 \\leq A_2 \\leq .... | [{"input": "8\n657312726 129662684 181537270 131300599 468214806 916875077 825989291 319670097", "output": "11\n"}, {"input": "8\n67210447 129662684 189766490 160785725 468214806 1492516422 483353884 319670097", "output": "15\n"}, {"input": "8\n347554626 129662684 181537270 324043958 468214806 916875077 825989291 31967... | code_stdio |
[
{
"content": "Snuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively. Snuke is happier when the abs... | [{"input": "10\n10 102 113 60 6 47 23 25 52 118", "output": "58\n"}, {"input": "10\n10 102 113 60 6 90 16 25 52 118", "output": "61\n"}, {"input": "10\n10 102 113 72 6 90 16 25 52 118", "output": "73\n"}, {"input": "10\n10 102 113 72 6 90 16 25 89 118", "output": "95\n"}, {"input": "10\n19 183 113 60 6 194 16 6 52 118"... | code_stdio |
[
{
"content": "Vasya has an array a_1, a_2, ..., a_n.\n\nYou don't know this array, but he told you m facts about this array. The i-th fact is a triple of numbers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n) and it means:\n\n * if t_i=1 then subbarray a_{l_i}, a_{l_i + 1}, ..., a_{r_i} is sorted in non-dec... | [{"input": "1001 2\n1 999 1000\n0 230 581\n", "output": "YES\n1001 1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 ... | code_stdio |
[
{
"content": "In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the production volume is small and the price is high... | [{"input": "17 5128 240 126 32\n20 4907 303 151 7\n60 73980 2086 337 15\n3 3216 562 010 6\n40 8478 221 53 307\n23 27966 5 92 13\n50 107893 4497 65 20\n199 88677 2825 226 8\n0", "output": "21 0\n7 18\n15 126\n5 40\n37 5\n13 303\n20 276\n8 292\n"}, {"input": "49 5128 240 252 32\n20 4907 303 151 7\n60 73980 2086 337 15\n3... | code_stdio |
[
{
"content": "This problem is same as the previous one, but has larger constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days sin... | [{"input": "10\n30518 30518 30518 30518 30518 30518 30518 30518 30518 30518\n", "output": "10\n"}, {"input": "10\n30518 30518 30518 30518 30518 30518 30518 30518 30518 30518\n", "output": "10"}, {"input": "10\n30518 96518 74071 59971 50121 4862 43967 73607 19138 90754\n", "output": "10\n"}, {"input": "10\n30518 96518 7... | code_stdio |
[
{
"content": "Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$.\n\nDuring each turn Vova can choose what to do: If the current charge of his laptop... | [{"input": "20\n1000000001 510000100 2 1\n1000000000 500000000 2 1\n1000000000 500000000 2 1\n1000000000 500000000 2 1\n1000000000 500000000 2 1\n1000000000 684100035 2 1\n1000000100 500000000 2 1\n1000000000 690764083 2 1\n1000000000 500000000 2 1\n1000000000 167868648 2 1\n1000000001 999999995 2 1\n1000000000 2618165... | code_stdio |
[
{
"content": "AtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the repo... | [{"input": "5\n3 10\n48 17\n31 199\n231 23\n3 2\n", "output": "6930\n"}, {"input": "5\n3 10\n48 28\n31 199\n300 23\n3 4", "output": "12600\n"}, {"input": "5\n3 11\n87 28\n31 199\n300 23\n3 2", "output": "13000\n"}, {"input": "5\n3 11\n33 28\n31 269\n300 23\n3 2", "output": "12000\n"}, {"input": "5\n1 10\n48 28\n31 199\... | code_stdio |
[
{
"content": "Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!\n\nIn the morning, there are $n$ opportunities to buy shares. The $i$-th of them allows to buy as many shares as y... | [{"input": "29 30 989\n450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 434\n451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451\n", "output": "1023\n"}, {"input": "29 30 989\n450 450 450 4... | code_stdio |
[
{
"content": "Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at... | [{"input": "1 100\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"... | code_stdio |
[
{
"content": "You are given a sequence of positive integers a_1, a_2, ..., a_{n}. \n\nWhile possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of elements). If the two integers are equal to ... | [{"input": "4\n1101111010 1000000000 1000010000 1001001010\n", "output": "4\n1101111010 1000000000 1000010000 1001001010\n"}, {"input": "4\n1101111010 1000000000 1100010000 1001001010\n", "output": "4\n1101111010 1000000000 1100010000 1001001010\n"}, {"input": "4\n1101111010 1000000000 1100000000 1001001010\n", "output... | code_stdio |
[
{
"content": "Let us define the FizzBuzz sequence a_1,a_2,... as follows:\n - If both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n - If the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n - If none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n - If none of the above holds, a_i=i.\nFind the sum ... | [{"input": "1000000\n", "output": "266666333332\n"}, {"input": "999997\n", "output": "266665333334\n"}, {"input": "870108\n", "output": "201890463153\n"}, {"input": "1100000", "output": "322667033332\n"}, {"input": "1110000", "output": "328560000000\n"}, {"input": "1110010", "output": "328565550022\n"}, {"input": "1111... | code_stdio |
[
{
"content": "Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exactly one element from the array and replace it with an... | [{"input": "25\n1 1 1 2 2 2 1 2 1 2 2 2 2 2 1 2 2 2 1 2 2 2 2 1 2\n", "output": "1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"input": "25\n1 1 1 2 2 2 1 2 1 2 4 2 2 2 1 2 2 2 1 2 2 2 2 1 2\n", "output": "1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"input": "25\n2 1 1 2 2 2 1 2 1 2 2 2 2 2 1 2 2 ... | code_stdio |
[
{
"content": "A positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n - In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\nFor example, 1234, 1, and 334 are l... | [{"input": "100000\n", "output": "3234566667\n"}, {"input": "94598\n", "output": "2345654334\n"}, {"input": "91278\n", "output": "2332345676\n"}, {"input": "97979\n", "output": "3223456555\n"}, {"input": "94981\n", "output": "3210111111\n"}, {"input": "96910\n", "output": "3222212323\n"}, {"input": "32454\n", "output":... | code_stdio |
[
{
"content": "Write a program which reads a $n \\times m$ matrix $A$ and a $m \\times l$ matrix $B$, and prints their product, a $n \\times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:\n\n\\\\[ c_{ij} = \\sum_{k=1}^m a_{ik}b_{kj} \\\\]\n\nwhere $a_{ij}$, $b_{ij}$ and $c_{ij}$ ar... | [{"input": "4 0 13\n1 1\n2 4\n4 15\n-1 0 2\n1 5 2", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "4 0 12\n1 1\n-1 2\n4 1\n1 0 -1\n1 12 5", "output": "0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0... | code_stdio |
[
{
"content": "There is a set of cards with positive integers written on them. Stack the cards to make several piles and arrange them side by side. Select two adjacent piles of cards from them, and stack the left pile on top of the right pile. Repeat this operation until there is only one pile of cards.\n\nWhen ... | [{"input": "3\n2 21\n0 48\n-1 12", "output": "-1152\n"}, {"input": "3\n4 21\n0 48\n-1 12", "output": "-2304\n"}, {"input": "3\n4 21\n0 28\n-1 12", "output": "-1344\n"}, {"input": "3\n6 93\n1 -14\n1 -1", "output": "-7728\n"}, {"input": "3\n2 4\n-1 -12\n27 2", "output": "-1200\n"}, {"input": "3\n2 4\n-1 -12\n27 4", "outp... | code_stdio |
[
{
"content": "There are N islands lining up from west to east, connected by N-1 bridges.\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\nRequest i: A... | [{"input": "21189 4345\n10171 15645\n10849 16732\n6014 18169\n3995 20232\n1557 8296\n2238 15717\n10071 12875\n2148 13213\n14696 19948\n2063 14524\n7571 10285\n2102 14395\n12673 13427\n15751 16347\n317 13928\n9825 17447\n7990 9393\n8479 14766\n6185 6858\n2781 11064\n14909 16382\n8468 9916\n7189 12428\n16941 18034\n8365 ... | code_stdio |
[
{
"content": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6\n\nWrite Python code to solve this problem. Your prog... | [{"input": "64\n", "output": "267\n"}, {"input": "16\n", "output": "14\n"}, {"input": "24\n", "output": "15\n"}, {"input": "32\n", "output": "51\n"}, {"input": "36\n", "output": "14\n"}, {"input": "40\n", "output": "14\n"}, {"input": "48\n", "output": "52\n"}, {"input": "54\n", "output": "15\n"}, {"input": "56\n", "out... | code_stdio |
[
{
"content": "Grandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string $s$ of length $n$.\n\nGrandma Capa wants to knit a beautiful scarf, and in her opinion, a beautiful scarf can only be... | [{"input": "5\n8\nabbaacab\n6\nxyzwyz\n4\nabba\n8\nspaqrlap\n10\nykhyhhyyhl\n", "output": "-1\n-1\n0\n-1\n-1\n"}, {"input": "5\n8\nabcaacbb\n6\nxyzxyz\n4\nabca\n8\nrpqarlap\n10\nykhxhhyyhk\n", "output": "-1\n-1\n1\n-1\n-1\n"}, {"input": "5\n8\nabbaacab\n6\nxyzwyz\n4\nbcaa\n8\nrpqarlap\n10\nykhyhhyyhk\n", "output": "-1\... | code_stdio |
[
{
"content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya dreamt of a lexicographically k-th permutation of integers fro... | [{"input": "1000000000 1000000000\n", "output": "1022\n"}, {"input": "1000010000 1000000000\n", "output": "1022\n"}, {"input": "77777779 1000000000\n", "output": "508\n"}, {"input": "444747744 1000000000\n", "output": "554"}, {"input": "77777779 1000000001\n", "output": "508\n"}, {"input": "854459 95554455\n", "output"... | code_stdio |
[
{
"content": "A burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are m containers, in the i-th container there are ai matchboxes, and each matchbox contains bi matches. All the matchboxes are of the same size. The burglar's rucksack can hold n matchboxe... | [{"input": "200000000 20\n983125 2\n7453215 9\n9193588 2\n11558049 7\n28666199 1\n34362244 1\n5241493 5\n15451270 4\n19945845 8\n6208681 3\n38300385 7\n6441209 8\n21046742 7\n577198 10\n3826434 8\n9764276 8\n6264675 7\n8567063 3\n3610303 4\n2908232 3\n", "output": "1131379312\n"}, {"input": "200000000 20\n983125 2\n745... | code_stdio |
[
{
"content": "Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.\n\nLet's assume that strings s and t have the same length n, then the function h(s, t) is defined as the num... | [{"input": "318\nTATCAATCGGTACGTGCGCATCATTGTCAATCGGGCTTCATGGCTTGCGGGCGCTACCCGAGGGGAAGCTGCGGACAGGTAGGTAAGATACACACGAACCAAACGGAGTTATGTTGGATAAATTGGCTGGAAGGGCGTAGGTATATCGAGTCGCGGACCTGGCATAGACTATCAGGGGCAGCGGTACAAGGCAACCGTGAGCGGGGTCTGCCCACCATTAGACCGATGCGCCGGCTCGTATATGTGATTCTGGTGAAAAGTATCATGCCGGGACGCGTAATGACCCGGCTGGCTAATCCACCG... | code_stdio |
[
{
"content": "There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\n-----Constraints-----\n - 1≦N≦100\n\n-----In... | [{"input": "-465", "output": "107880\n"}, {"input": "-792", "output": "313236\n"}, {"input": "-937", "output": "438516\n"}, {"input": "-845", "output": "356590\n"}, {"input": "-647", "output": "208981\n"}, {"input": "-164", "output": "13366\n"}, {"input": "-152", "output": "11476\n"}, {"input": "-299", "output": "44551... | code_stdio |
[
{
"content": "A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. \n\nThe game goes as follows. Kids stand in circle. Let's agree to think of the children as numbered with numbers from 1 to n clockwise and... | [{"input": "102\n", "output": "2 4 7 11 16 22 29 37 46 56 67 79 92 4 19 35 52 70 89 7 28 50 73 97 20 46 73 101 28 58 89 19 52 86 19 55 92 28 67 5 46 88 29 73 16 62 7 55 2 52 1 53 4 58 11 67 22 80 37 97 56 16 79 41 4 70 35 1 70 38 7 79 50 22 97 71 46 22 101 79 58 38 19 1 86 70 55 41 28 16 5 97 88 80 73 67 62 58 55 53 52... | code_stdio |
[
{
"content": "Let's call a string a phone number if it has length 11 and fits the pattern \"8xxxxxxxxxx\", where each \"x\" is replaced by a digit.\n\nFor example, \"80123456789\" and \"80000000000\" are phone numbers, while \"8012345678\" and \"79000000000\" are not.\n\nYou have $n$ cards with digits, and you ... | [{"input": "100\n10073026040057460848727605087211482331696312132261702754626166388448133087167204984955299978572844873\n", "output": "9\n"}, {"input": "100\n12214470388509637187316171407185732399094381485438987303313809772379863936872280956215437122989955784\n", "output": "9\n"}, {"input": "100\n88202862851852449384524... | code_stdio |
[
{
"content": "There are n heroes fighting in the arena. Initially, the i-th hero has a_i health points.\n\nThe fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals 1 damage to all other heroes. Hits of all heroes occur simultaneously. Heroes whose health is les... | [{"input": "371 306\n", "output": "512015273\n"}, {"input": "222 500\n", "output": "382157018\n"}, {"input": "124 212\n", "output": "806210307\n"}, {"input": "300 500\n", "output": "567125736\n"}, {"input": "224 375\n", "output": "555865043\n"}, {"input": "365 500\n", "output": "552203508\n"}, {"input": "444 500\n", "o... | code_stdio |
[
{
"content": "One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: \"Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representation contains exactly k digits one\".\n\nThe gi... | [{"input": "101628400788615604 30\n", "output": "999999999999995905\n"}, {"input": "101628400798615604 31\n", "output": "981546175132942729\n"}, {"input": "101628400798615604 31\n", "output": "981546175132942729\n"}, {"input": "101628400788615604 30\n", "output": "999999999999995905\n"}, {"input": "10000000000000000 35... | code_stdio |
[
{
"content": "You have full control over a robot that walks around in a rectangular field paved with square tiles like a chessboard. There are m columns of tiles from west to east, and n rows of tiles from south to north (1 <= m, n <= 100). Each tile is given a pair of coordinates, such as (i, j), where 1 <= i ... | [{"input": "11 5\nFORWARD 3\nRIGHT\nFORWARD 10\nLEFT\nBACKWARD 3\nSTOP\n3 1\nFORWARD 2\nSTOP\n0 0", "output": "11 1\n1 1\n"}, {"input": "14 5\nFORWARD 3\nRIGHT\nFORWARD 8\nLEFT\nBACKWARD 2\nSTOP\n3 1\nFORVARD 5\nSTOP\n0 0", "output": "9 2\n1 1\n"}, {"input": "1 10\nFORDARW 1\nRIGHT\nFORWARD 5\nLEFT\nBACKWARD 1\nSTOP\n3... | code_stdio |
[
{
"content": "We have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecti... | [{"input": "ant\nobe\nrec\n", "output": "abc\n"}, {"input": "edu\ncat\nion\n", "output": "ean\n"}, {"input": "ant\nobe\nrfc", "output": "abc\n"}, {"input": "ddu\ncat\nion", "output": "dan\n"}, {"input": "ant\nobe\nrcf", "output": "abf\n"}, {"input": "ddu\ncat\nioo", "output": "dao\n"}, {"input": "ddu\ncat\nooi", "outpu... | code_stdio |
[
{
"content": "The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.\n\nThe Galaxy contains N planets, connected by bidirectio... | [{"input": "24\n19 14\n8 15\n13 4\n18 16\n1 17\n10 3\n22 21\n10 14\n6 11\n9 12\n15 22\n11 3\n21 7\n2 12\n7 4\n4 19\n16 9\n24 17\n5 15\n8 2\n23 10\n20 12\n18 24\n", "output": "1 20 21 22 23 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24\n"}, {"input": "24\n19 14\n8 15\n13 4\n18 16\n1 17\n10 3\n22 21\n10 14\n6 ... | code_stdio |
[
{
"content": "Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like \"1,2 ,3,..., 1... | [{"input": ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n", "output": ", , , , , , , , , , , , , , , , , , ,... | code_stdio |
[
{
"content": "You survived several months of exam wars and were able to enter ICPC University on a sunny day. On the day of admission, there was an enthusiastic recruitment of circles on the campus of the university, and you received a large number of pamphlets and returned. When you return to your room, you fi... | [{"input": "9\n315\n0", "output": "2\n11\n"}, {"input": "9\n256\n0", "output": "2\n0\n"}, {"input": "9\n160\n0", "output": "2\n1\n"}, {"input": "9\n213\n0", "output": "2\n3\n"}, {"input": "9\n200\n0", "output": "2\n2\n"}, {"input": "9\n135\n0", "output": "2\n7\n"}, {"input": "9\n350\n0", "output": "2\n5\n"}, {"input": ... | code_stdio |
[
{
"content": "You are given an integer array $a_1, a_2, \\ldots, a_n$.\n\nThe array $b$ is called to be a subsequence of $a$ if it is possible to remove some elements from $a$ to get $b$.\n\nArray $b_1, b_2, \\ldots, b_k$ is called to be good if it is not empty and for every $i$ ($1 \\le i \\le k$) $b_i$ is div... | [{"input": "50\n170081 797965 40736 224325 102476 20832 954026 923972 391400 247099 95141 927386 79799 749285 104039 200818 623552 872203 355273 838168 352783 850365 389351 930945 847154 608047 727586 549184 520573 608953 338849 536466 345479 589848 882827 771475 874283 787115 992590 128903 97800 74550 674140 282514 51... | code_stdio |
[
{
"content": "Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \\rightarrow acxyx \\rightarrow cxyx \\rightarrow cyx.\n\nYou are given N different strings S_1, S_2, \\ldots, S_N. Among N \\cdot (N-1) / 2 pairs (S_i, S_j), in how many pairs could Limak obtain one string... | [{"input": "3\nabcxyx\ncyx\nabb", "output": "1\n"}, {"input": "3\nabxxyc\ncyx\nabb", "output": "0\n"}, {"input": "6\nb\na\nabb\nc\nd\nab", "output": "5\n"}, {"input": "6\nb\na\nabb\nc\nd\nba", "output": "4\n"}, {"input": "3\naxxbyc\ncyx\nabb", "output": "0\n"}, {"input": "3\naxxbyc\ncyx\naab", "output": "0\n"}, {"input... | code_stdio |
[
{
"content": "Polycarp is very fond of playing the game Minesweeper. Recently he found a similar game and there are such rules.\n\nThere are mines on the field, for each the coordinates of its location are known ($x_i, y_i$). Each mine has a lifetime in seconds, after which it will explode. After the explosion,... | [{"input": "3\n\n5 0\n0 0 1\n-1 1 4\n1 1 2\n1 0 3\n2 2 9\n\n5 2\n0 -1 1\n0 1 4\n2 0 2\n1 1 3\n2 2 9\n\n6 1\n1 -1 3\n0 -1 9\n0 1 7\n-1 0 1\n0 1 14\n-1 -1 11\n", "output": "2\n1\n1"}, {"input": "3\n\n5 0\n0 0 1\n-1 1 4\n1 0 2\n1 0 3\n2 2 11\n\n5 2\n0 0 0\n0 1 4\n3 0 2\n1 1 3\n2 2 15\n\n6 1\n1 -1 3\n0 -1 9\n0 1 9\n-1 0 1\... | code_stdio |
[
{
"content": "Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \\le i \\le n-1$ then $a_i = c^i$.\n\nGiven a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permuta... | [{"input": "100\n881 479 355 759 257 497 690 598 275 446 439 787 257 326 436 713 322 5 253 781 434 307 164 154 241 381 38 942 680 906 240 11 431 478 628 1203 346 74 493 964 455 746 950 41 585 549 892 687 264 41 487 676 63 453 861 980 477 901 80 907 285 506 619 748 773 743 56 925 651 685 845 313 419 504 770 324 2 559 40... | code_stdio |
[
{
"content": "Everybody knows that the m-coder Tournament will happen soon. m schools participate in the tournament, and only one student from each school participates.\n\nThere are a total of n students in those schools. Before the tournament, all students put their names and the names of their schools into th... | [{"input": "100 10 1\n62 68 24 82 66 47 73 43 85 23 78 13 94 14 84 17 27 5 72 48 59 46 97 81 88 9 76 69 11 15 12 61 130 7 91 34 99 52 54 57 56 64 55 67 40 38 74 25 30 4 22 92 33 3 86 45 37 26 150 53 75 71 58 96 98 20 36 1 95 63 10 49 19 41 89 21 39 100 93 42 32 90 28 83 6 29 60 65 44 35 18 16 8 50 80 31 51 2 146 79\n6 ... | code_stdio |
[
{
"content": "Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.\n\nIn a single second, he can modify the length of a single side of the ... | [{"input": "100000 25000\n", "output": "5\n"}, {"input": "100000 25000\n", "output": "5\n"}, {"input": "167552 16353\n", "output": "7\n"}, {"input": "113151 20996\n", "output": "6\n"}, {"input": "141391 23890\n", "output": "6\n"}, {"input": "100100 25000\n", "output": "5\n"}, {"input": "119562 71629\n", "output": "3\n"... | code_stdio |
[
{
"content": "We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n - For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n - There is an edge between Vertex X and Vertex Y.\nFor each k=1,2,...,N-1, solve the problem below:\n - Find the number of pairs of ... | [{"input": "2000 999 1001\n", "output": "2000\n1999\n1998\n1997\n1996\n1995\n1994\n1993\n1992\n1991\n1990\n1989\n1988\n1987\n1986\n1985\n1984\n1983\n1982\n1981\n1980\n1979\n1978\n1977\n1976\n1975\n1974\n1973\n1972\n1971\n1970\n1969\n1968\n1967\n1966\n1965\n1964\n1963\n1962\n1961\n1960\n1959\n1958\n1957\n1956\n1955\n195... | code_stdio |
[
{
"content": "Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji... | [{"input": "3559 9 5\n2425 12 2\n2980 9 14", "output": "heisei 1571 9 5\nheisei 437 12 2\nheisei 992 9 14\n"}, {"input": "3559 9 5\n2425 12 2\n2980 9 7", "output": "heisei 1571 9 5\nheisei 437 12 2\nheisei 992 9 7\n"}, {"input": "3080 6 3\n2027 12 3\n3210 9 1", "output": "heisei 1092 6 3\nheisei 39 12 3\nheisei 1222 9 ... | code_stdio |
[
{
"content": "Dwarfs have planted a very interesting plant, which is a triangle directed \"upwards\". This plant has an amusing feature. After one year a triangle plant directed \"upwards\" divides into four triangle plants: three of them will point \"upwards\" and one will point \"downwards\". After another ye... | [{"input": "1000000000000000000\n", "output": "899770636\n"}, {"input": "148049062285906746\n", "output": "913927498\n"}, {"input": "615812227854199662\n", "output": "357939938\n"}, {"input": "585335721566249104\n", "output": "301383716\n"}, {"input": "791809296233191092\n", "output": "369199735\n"}, {"input": "5228421... | code_stdio |
[
{
"content": "You are given an array $a_1, a_2, \\dots, a_n$, consisting of $n$ positive integers. \n\nInitially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move ca... | [{"input": "4\n5 4 0\n1 5 4 3 2\n5 4 1\n1 5 7 3 2\n5 4 4\n10 20 30 40 78\n10 7 3\n4 6 12 2 9 12 14 4 10 9\n", "output": "15\n25\n178\n71\n"}, {"input": "4\n5 4 0\n1 5 4 3 2\n5 4 1\n1 5 7 3 2\n5 4 4\n10 20 30 40 50\n10 7 3\n4 6 8 2 9 12 14 4 10 9\n", "output": "15\n25\n150\n67\n"}, {"input": "4\n5 4 0\n1 5 4 3 2\n5 4 1\... | code_stdio |
[
{
"content": "Tashizan Hikizan (Calculation Training)\n\nsquare1001 You gave E869120 two numbers, $ A $ and $ B $, as birthday presents.\n\nE869120 You decided to use these two numbers for calculation training.\n\nSpecifically, E869120 does the following for these numbers exactly $ N $ times:\n\n* Replace $ A $... | [{"input": "3\n-2 -10", "output": "10 -2\n"}, {"input": "3\n-2 -15", "output": "15 -2\n"}, {"input": "3\n-2 -21", "output": "21 -2\n"}, {"input": "3\n-2 -27", "output": "27 -2\n"}, {"input": "3\n-1 -27", "output": "27 -1\n"}, {"input": "3\n-1 -21", "output": "21 -1\n"}, {"input": "3\n-1 -24", "output": "24 -1\n"}, {"in... | code_stdio |
[
{
"content": "Find the least common multiple (LCM) of given n integers.\n\nConstraints\n\n* 2 ≤ n ≤ 10\n* 1 ≤ ai ≤ 1000\n* Product of given integers ai(i = 1, 2, ... n) does not exceed 231-1\n\nInput\n\n\nn\na1 a2 ... an\n\n\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput... | [{"input": "3\n12 39 11", "output": "1716\n"}, {"input": "4\n1 2 5 24", "output": "120\n"}, {"input": "3\n3 37 10", "output": "1110\n"}, {"input": "4\n1 2 5 44", "output": "220\n"}, {"input": "3\n9 37 10", "output": "3330\n"}, {"input": "4\n1 3 5 44", "output": "660\n"}, {"input": "3\n9 39 10", "output": "1170\n"}, {"i... | code_stdio |
[
{
"content": "Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty str... | [{"input": "abcdefghijklmnopqrytuvwzsx", "output": "abcdefghijklmnopqrytuvwzx\n"}, {"input": "abcpefghijklmnodqrytuvwzsx", "output": "abcpefghijklmnodqrytuvwzx\n"}, {"input": "azcdefghijklmnopqrstuvwbyx", "output": "azcdefghijklmnopqrstuvwx\n"}, {"input": "abcdefghijklmnopqrstuvwzyx", "output": "abcdefghijklmnopqrstuvx... | code_stdio |
[
{
"content": "In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organizer of the auction price he is willing to pay... | [{"input": "100\n2515 3324 7975 6171 4240 1217 4829 5203 8603 6900 3031 4699 4732 6070 4221 3228 6497 7359 9130 4346 4619 1109 3945 5442 3271 16 9711 2045 6410 2301 3406 8125 6003 1892 1260 9661 3940 6692 4708 7027 4930 6925 1979 5361 4263 3144 867 8639 6230 5562 9714 3676 4231 3347 4733 4920 4881 3431 1059 7313 8912 3... | code_stdio |
[
{
"content": "Cat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\n-----Constraints-----\n... | [{"input": "119\n", "output": "991\n"}, {"input": "999\n", "output": "111\n"}, {"input": "191\n", "output": "919\n"}, {"input": "111\n", "output": "999\n"}, {"input": "191\n", "output": "919\n"}, {"input": "199\n", "output": "911\n"}, {"input": "911\n", "output": "199\n"}, {"input": "919\n", "output": "191\n"}, {"input... | code_stdio |
[
{
"content": "Lee tried so hard to make a good div.2 D problem to balance his recent contest, but it still doesn't feel good at all. Lee invented it so tediously slow that he managed to develop a phobia about div.2 D problem setting instead. And now he is hiding behind the bushes...\n\nLet's define a Rooted Dea... | [{"input": "7\n2\n2\n6\n8\n5\n110\n1478999\n", "output": "0\n0\n24\n96\n12\n782548134\n793574295\n"}, {"input": "7\n3\n2\n5\n8\n5\n101\n2000000\n", "output": "4\n0\n12\n96\n12\n981997171\n804665184\n"}, {"input": "3\n1234567\n1268501\n1268499\n", "output": "788765312\n999997375\n999999350\n"}, {"input": "3\n1234567\n12... | code_stdio |
[
{
"content": "The robot is located on a checkered rectangular board of size $n \\times m$ ($n$ rows, $m$ columns). The rows in the board are numbered from $1$ to $n$ from top to bottom, and the columns — from $1$ to $m$ from left to right.\n\nThe robot is able to move from the current cell to one of the four ce... | [{"input": "4\n1 1\nL\n12 2\nL\n3 3\nUULDRR\n10 3\nUULLLDRRDUUL\n", "output": "1 1\n1 2\n3 2\n3 3\n"}, {"input": "4\n1 1\nL\n12 2\nL\n3 3\nUULDRR\n11 3\nUULLLDRRDUUL\n", "output": "1 1\n1 2\n3 2\n3 3\n"}, {"input": "4\n1 1\nL\n12 2\nL\n5 3\nUULDRR\n10 3\nUULLLDRRDUUL\n", "output": "1 1\n1 2\n3 2\n3 3\n"}, {"input": "4\... | code_stdio |
[
{
"content": "A famous gang of pirates, Sea Dogs, has come back to their hideout from one of their extravagant plunders. They want to split their treasure fairly amongst themselves, that is why You, their trusted financial advisor, devised a game to help them:\n\nAll of them take a sit at their round table, som... | [{"input": "1000000000 3\n30490 19232\n45250 999980767\n264372930 1\n", "output": "-1"}, {"input": "1000000000 3\n30490 19232\n45250 999980767\n264372930 1\n", "output": "-1"}, {"input": "221407444 1\n999999999 999999999\n", "output": "-1\n"}, {"input": "300 4\n1 200\n2 200\n50 100\n70 100\n", "output": "-1"}, {"input"... | code_stdio |
[
{
"content": "In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.\n\nOne example of a grid path is (0, 0) →... | [{"input": "200\nNESENEESEESWWWNWWSWSWNWNNWNNESWSWNNWNWNENESENNESSWSESWWSSSEEEESSENNNESSWWSSSSESWSWWNNEESSWWNNWSWSSWWNWNNEENNENWWNESSSENWNESWNESWNESEESSWNESSSSSESESSWNNENENESSWWNNWWSWWNESEENWWWWNWWNWWNENESESSWWSWWSES\nNWNESESSENNNESWNWWSWWWNWSESSSWWNWWNNWSENWSWNENNNWWSWWSWNNNESWWWSSESSWWWSSENWSENWWNENESESWNENNESWNWNNEN... | code_stdio |
[
{
"content": "Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.\n\nThe text includes only alphabetical characters and spaces. A word is a sequence of l... | [{"input": "Thank you for your mail amd your lectures", "output": "your lectures\n"}, {"input": "ahTnk you for your mail and your serutcel", "output": "your serutcel\n"}, {"input": "Uhank you for your mail mad your lrctuees", "output": "your lrctuees\n"}, {"input": "ahTnk you for your mail and your leeturcs", "output":... | code_stdio |
[
{
"content": "Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then t... | [{"input": "96 70\n30 37\n47 56\n19 79\n15 28\n2 43\n43 54\n59 75\n42 22\n38 18\n18 14\n47 41\n60 29\n35 11\n90 4\n14 41\n11 71\n41 24\n68 28\n45 92\n14 15\n34 63\n77 32\n67 38\n36 8\n37 4\n58 95\n68 84\n69 81\n35 23\n56 63\n78 91\n35 44\n66 63\n80 19\n87 88\n28 14\n62 35\n24 23\n83 37\n54 89\n14 40\n9 35\n94 9\n56 46\... | code_stdio |
[
{
"content": "Polycarpus takes part in the \"Field of Wonders\" TV show. The participants of the show have to guess a hidden word as fast as possible. Initially all the letters of the word are hidden.\n\nThe game consists of several turns. At each turn the participant tells a letter and the TV show host respond... | [{"input": "42\n*****o*******t********************oo******\n10\nvcrccobltkeidtxhsxhccaslkjhfyeqsetoowaemso\nuimjsoxifamvctkgqmrwhyjrgmlydczzqjoobnnwch\nuvmjsoqizfavctkxemrpaycngmlyemzzqjoobszwbh\nusmjsoviskzvctkljmrlmylugmlydfzzqvoobzawgh\nfeqweodinkhiatqmfokaxwcmlmbmvskssyookgcrax\ntackfosjhxeqftkgjynbbedrczegtimuvooo... | code_stdio |
[
{
"content": "Write a program to simulate rolling a dice, which can be constructed by the following net.\n\n\n<image>\n<image>\n\n\n\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a s... | [{"input": "-1 4 13 -2 100 13\nES", "output": "100\n"}, {"input": "0 2 0 16 25 35\nEESWN", "output": "35\n"}, {"input": "0 2 0 16 25 38\nEESWN", "output": "38\n"}, {"input": "0 2 4 12 16 14\nEESWN", "output": "14\n"}, {"input": "1 2 4 14 24 30\nEESWN", "output": "30\n"}, {"input": "1 2 1 14 24 30\nEESWN", "output": "30... | code_stdio |
[
{
"content": "In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is... | [{"input": "250\n5 3 5 1 3 5 3 4 4 3 1 5 2 2 1 1 5 2 3 3 2 5 4 3 2 4 2 3 5 4 1 2 3 5 2 2 5 4 1 3 3 5 4 4 4 4 4 2 4 2 3 5 1 4 3 3 2 3 5 3 3 4 4 2 3 1 3 4 1 4 5 4 1 2 3 4 1 5 3 3 2 3 5 4 2 5 2 2 3 5 4 3 5 4 2 1 4 1 4 1 1 3 5 1 1 2 1 3 4 5 4 3 2 5 1 3 5 1 1 3 3 5 1 4 5 1 2 1 1 5 5 3 5 1 4 1 4 4 4 4 4 1 4 3 4 5 4 1 2 2 5 2... | code_stdio |
[
{
"content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya loves tickets very much. As we know, each ticket has a number that i... | [{"input": "50\n44747747774474747747747447777447774747447477444474\n", "output": "YES"}, {"input": "50\n44444444444444444444444444444444444444444444444444\n", "output": "YES"}, {"input": "50\n77777777777777777777777777777777777777777777777777\n", "output": "YES"}, {"input": "50\n4099666333439734310852914372075143390351... | code_stdio |
[
{
"content": "We have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shi... | [{"input": "26\nYIHVXVZROUSFCUXIOGFIOUSIYDBTQLMECEEHARRBWUDXRITQZSTXNECYMODBOSODWDSWEFEXTVVPENGERSVLYSBDSJOKYSGTJQPEDQWMLFZANYYWWHRHPCOYXLEEBUPOBJMZVUTWCPXQEEHRPSUKCMIDRSBGHBRBAYXUGTZGFRSZTHEVFCFOOTPWYQMXJICOFMXDLCBINVZCPVWRKWDVGBDTDCWRNKPOXANOHOOCKXCSZBSHXXTGCKTSKBRZZTFAAQYFKZGNIZJJZSYTBOKKMTSHMXUPAMANKSBOPRGAAVHRNWCH... | code_stdio |
[
{
"content": "Joisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 throu... | [{"input": "5\n7 5 1 10 5\n3\n4 3\n1 11\n3 12", "output": "21\n32\n39\n"}, {"input": "5\n7 5 1 10 5\n3\n4 3\n2 11\n3 12", "output": "21\n34\n39\n"}, {"input": "5\n7 8 1 10 11\n3\n4 3\n0 11\n3 7", "output": "30\n37\n43\n"}, {"input": "5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n", "output": "19\n25\n30\n"}, {"input": "5\n7 2 3 10 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.