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\nThere are some beautiful girls in Arpa’s land as mentioned before.\n\nOnce Arpa came up with an obvious problem:\n\nGiven an array and a number x, count the number of pairs of indices i, j (1 ≀ i < j ≀ n) such that <image...
[{"type": "stdin_stdout", "input": "64 118\n361 547 410 294 448 377 482 490 13 116 346 50 251 330 443 128 543 580 370 489 337 509 414 291 228 71 245 308 319 314 154 39 317 288 145 248 547 152 262 278 89 108 522 238 128 575 112 469 86 230 310 492 127 270 475 25 179 72 345 444 17 332 544 338\n", "output": "3\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSomething happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found tha...
[{"type": "stdin_stdout", "input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 -22 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 59 96 79 -25 49 -59 -89 -75 12 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 66...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"Eat a beaver, save a tree!\" β€” That will be the motto of ecologists' urgent meeting in Beaverley Hills.\n\nAnd the whole point is that the population of beavers on the Earth has reached incredible sizes! Each day their ...
[{"type": "stdin_stdout", "input": "10\n91739 91402 94944 92279 91149 91709 96966 91401 97398 98822\n3 6\n9 6\n5 6\n1 6\n8 6\n7 6\n10 6\n4 6\n2 6\n2\n", "output": "183418\n"}, {"type": "stdin_stdout", "input": "10\n91739 91402 94944 92279 91149 91709 96966 91401 97398 98822\n3 6\n9 6\n5 6\n1 6\n8 6\n7 6\n10 6\n4 6\n2 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≀ si ≀ c).\n\nOver time the sta...
[{"type": "stdin_stdout", "input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 50 50 51 51\n", "output": "3\n3\n5\n0\n"}, {"type": "stdin_stdout", "input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 60 50 51 51\n", "output": "3\n3\n5\n0\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA positive integer is called a 2-3-integer, if it is equal to 2xΒ·3y for some non-negative integers x and y. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, ...
[{"type": "stdin_stdout", "input": "1088391167 1934917632\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "1088391168 1934917632\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "1088391168 1934917633\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "1088391169 1934917632\n", "output": "16\n"},...
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": "wobervhvvkihcmyjtmqhaaigvvgiaahqutjyuchikvvhvrebow\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes.\nBut he loves uniformity so he asks you to divide it such a way that all the cubes are of same size and volume of individual cube...
[{"type": "stdin_stdout", "input": "2\n3 10 17\n2 10 3\n\nSMAPLC", "output": "1 510\n1 60\n"}, {"type": "stdin_stdout", "input": "2\n3 16 17\n2 12 3\n\nSMAPLC", "output": "1 816\n1 72\n"}, {"type": "stdin_stdout", "input": "2\n3 8 17\n4 12 3\n\nSLAPLC", "output": "1 408\n1 144\n"}, {"type": "stdin_stdout", "input": "2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBitoholic is an inhabitant of the planet Neo in a galaxy far far away. Their civilization is studies an advanced form of mathematics. However, rules of calculus are a bit different there. On his planet, integration and di...
[{"type": "stdin_stdout", "input": "2 \n0 -2 4 2 -1 \n13 -1 35 -1 0\n\nGKPNCR", "output": "Case #1: -2\nCase #2: -14\n"}, {"type": "stdin_stdout", "input": "2 \n-1 -3 3 2 -1 \n3 -2 16 -1 0\n\nHKPOCR", "output": "Case #1: -3\nCase #2: -5\n"}, {"type": "stdin_stdout", "input": "2 \n-1 -1 19 0 6 \n0 -1 35 0 0\n\nSBNQKF", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe time is 1st January 20000014 Gazu is depressed with his life as he thinks there is nothing unique about him. One day he meets a travelling coder, Gazu tells him why he is depressed, to which coder replies β€œEveryone i...
[{"type": "stdin_stdout", "input": "3\n1410\n252\n60\n\nMAPJES", "output": "281474976710656\n512\n8\n"}, {"type": "stdin_stdout", "input": "3\n1327\n252\n60\n\nMAPJES", "output": "35184372088832\n512\n8\n"}, {"type": "stdin_stdout", "input": "3\n1169\n143\n30\n\nSAMPLE", "output": "549755813888\n32\n4\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMy flatmate, Sayan, went to the game show called Takeshi's castle.It is a game show in which you need to pass different game challenges to enter the final.\n\nNow the most famous round of all of them is the \"skipping sto...
[{"type": "stdin_stdout", "input": "710 8098 8685\n0.677856313989 0.300527362186 0.585422317594 0.579903380393 0.627528717602 0.767731549439 0.610653415599 0.885294351688 0.979034022518 0.13779743862 0.0340536649268 0.608253498417 0.742388417086 0.060505705684 0.558364356238 0.679584717746 0.0887531985081 0.12151157925...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet us denote by f(x, m) the remainder of the Euclidean division of x by m.\n\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M). Find \\displaystyle{\\sum_...
[{"type": "stdin_stdout", "input": "10000000000 15 114525", "output": "676285714116240\n"}, {"type": "stdin_stdout", "input": "10000000000 16 114525", "output": "607349285587900\n"}, {"type": "stdin_stdout", "input": "10000000000 15 99959", "output": "500550769812856\n"}, {"type": "stdin_stdout", "input": "10000000000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending ...
[{"type": "stdin_stdout", "input": "chokudai\nchokudaiz", "output": "Yes"}, {"type": "stdin_stdout", "input": "choktdai\nchokudaiz", "output": "No\n"}, {"type": "stdin_stdout", "input": "choktdai\nbhokudaiz", "output": "No\n"}, {"type": "stdin_stdout", "input": "iadtkohc\nbhokudaiz", "output": "No\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are pa...
[{"type": "stdin_stdout", "input": "16 27", "output": "12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42\n"}, {"type": "stdin_stdout", "input": "15 21", "output": "7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\n* The length ...
[{"type": "stdin_stdout", "input": "acc", "output": "cca\n"}, {"type": "stdin_stdout", "input": "acb", "output": "bca\n"}, {"type": "stdin_stdout", "input": "adb", "output": "bda\n"}, {"type": "stdin_stdout", "input": "`cb", "output": "bc`\n"}, {"type": "stdin_stdout", "input": "bc`", "output": "`cb\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRingo has a string S.\n\nHe can perform the following N kinds of operations any number of times in any order.\n\n* Operation i: For each of the characters from the L_i-th through the R_i-th characters in S, replace it wit...
[{"type": "stdin_stdout", "input": "cassert\n4\n1 2\n3 4\n1 1\n2 0", "output": "YES\n"}, {"type": "stdin_stdout", "input": "cassert\n3\n1 2\n3 4\n1 1\n2 0", "output": "YES\n"}, {"type": "stdin_stdout", "input": "cassert\n4\n2 2\n3 4\n1 1\n2 2", "output": "YES\n"}, {"type": "stdin_stdout", "input": "cassert\n4\n2 4\n3 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a correct bracket sequence.\nHere, a correct bracket sequence is defined as follows:\n\n* ...
[{"type": "stdin_stdout", "input": "8\n)))(((((", "output": "((()))((((()))))\n"}, {"type": "stdin_stdout", "input": "8\n)))))(((", "output": "((((()))))((()))\n"}, {"type": "stdin_stdout", "input": "8\n))))))))", "output": "(((((((())))))))\n"}, {"type": "stdin_stdout", "input": "8\n))))((((", "output": "(((())))(((()...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet x be a string of length at least 1. We will call x a good string, if for any string y and any integer k (k \\geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and ...
[{"type": "stdin_stdout", "input": "adad", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "bbcc", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "ccbb", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "ccbc", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "cbbc", "output": "1\n1\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour task is to develop a tiny little part of spreadsheet software.\n\nWrite a program which adds up columns and rows of given table as shown in the following figure:\n\n<image>\n\n\n\nInput\n\nThe input consists of sever...
[{"type": "stdin_stdout", "input": "4\n52 26 16 20\n143 22 35 45\n45 78 54 36\n10 86 74 55\n4\n52 151 15 28\n86 22 24 45\n45 78 54 36\n16 86 74 55\n0", "output": " 52 26 16 20 114\n 143 22 35 45 245\n 45 78 54 36 213\n 10 86 74 55 225\n 250 212 179 156 797\n 52 151 15 28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUnder the command \"Save Sergeant Ryan,\" Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they cou...
[{"type": "stdin_stdout", "input": "7\n1 2 5\n2 3 2\n3 4 3\n1 5 13\n5 6 3\n5 7 11\n0", "output": "27\n"}, {"type": "stdin_stdout", "input": "7\n1 2 4\n2 4 2\n3 4 3\n1 5 13\n5 6 3\n5 7 11\n0", "output": "25\n"}, {"type": "stdin_stdout", "input": "7\n1 3 2\n2 3 1\n7 4 3\n1 5 10\n5 6 4\n5 7 15\n0", "output": "29\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDr. Hedro is astonished. According to his theory, we can make sludge that can dissolve almost everything on the earth. Now he's trying to produce the sludge to verify his theory.\n\nThe sludge is produced in a rectangular...
[{"type": "stdin_stdout", "input": "2\n14\n0", "output": "24\n328\n"}, {"type": "stdin_stdout", "input": "2\n12\n0", "output": "24\n264\n"}, {"type": "stdin_stdout", "input": "2\n10\n0", "output": "24\n216\n"}, {"type": "stdin_stdout", "input": "2\n18\n0", "output": "24\n440\n"}, {"type": "stdin_stdout", "input": "2\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLong long ago, there lived a wizard who invented a lot of \"magical patterns.\" In a room where one of his magical patterns is drawn on the floor, anyone can use magic by casting magic spells! The set of spells usable in ...
[{"type": "stdin_stdout", "input": "7 7 0 2\n0 1 absa\n1 1 ohl\n2 -1 ket\n1 3 cada\n3 3 ea\n3 2 bra\n2 1 ket\n2 2 0 1\n0 0 a\n0 1 b\n7 6 2 0\n3 1 op\n3 2 op\n3 4 qpo\n1 0 st\n2 0 qr\n4 1 r\n2 1 0 1\n0 1 loooop\n0 0 0 0", "output": "absacadabra\nNO\nqr\nloooop\n"}, {"type": "stdin_stdout", "input": "7 7 0 2\n0 1 abra\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo experienced climbers are planning a first-ever attempt: they start at two points of the equal altitudes on a mountain range, move back and forth on a single route keeping their altitudes equal, and finally meet with e...
[{"type": "stdin_stdout", "input": "6\n0 -1\n3 4\n9 12\n17 10\n21 12\n33 -1\n5\n0 0\n12 0\n20 0\n30 0\n74 0\n10\n0 0\n1 2\n3 0\n6 3\n9 0\n11 2\n13 0\n15 2\n16 2\n35 0\n7\n0 0\n150 997\n300 1\n450 999\n600 2\n750 998\n900 0\n0", "output": "46.241105114034\n74.000000000000\n46.612166980266\n10078.072814085803\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHint\n\n* One grid may be filled more than once\n* Even if it can be represented by one line segment such as '1', it may be represented by two or more line segments.\n\n\n\nSample Input 1\nFormula for Sample Input 1.\n\nS...
[{"type": "stdin_stdout", "input": "23\n1 1 3 1\n3 1 3 3\n3 3 1 3\n1 3 1 5\n1 5 3 5\n5 2 7 2\n7 2 7 4\n7 4 5 4\n5 4 5 6\n5 6 7 6\n11 4 13 4\n13 0 15 0\n15 0 15 4\n18 2 18 2\n21 5 23 5\n21 5 21 7\n21 7 23 7\n23 7 23 8\n23 9 21 9\n24 0 26 0\n24 0 24 4\n24 4 26 4\n26 0 26 4", "output": "-328\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWind Corridor is a covered passageway where strong wind is always blowing. It is a long corridor of width W, and there are several pillars in it. Each pillar is a right prism and its face is a polygon (not necessarily con...
[{"type": "stdin_stdout", "input": "5 2\n0\n1 1\n1 4\n2 2\n2 2\n4\n3 2\n3 6\n2 4\n4 0\n0 0", "output": "5.00000000000000000000\n2.00000000000000000000\n4.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "14 2\n4\n0 0\n1 2\n2 2\n2 0\n4\n3 2\n3 4\n2 6\n4 3\n0 0", "output": "11.00000000000000000000\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a student looking for a job. Today you had an employment examination for an IT company. They asked you to write an efficient program to perform several operations. First, they showed you an N \\times N square matr...
[{"type": "stdin_stdout", "input": "39989 6 999983 999979 999961 1 1000 2 1000\nSR 1 39989\nSC 1 39989\nRL\nRH\nRR\nRV", "output": "302732557\n"}, {"type": "stdin_stdout", "input": "39989 6 999983 999979 999961 1 1010 2 1000\nSR 1 39989\nSC 1 39989\nRL\nRH\nRR\nRV", "output": "239384648\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA: A-Z Cat / A-Z Cat\n\nstory\n\nAizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend...
[{"type": "stdin_stdout", "input": "AOZUNYANPERIPERO", "output": "AZ\n"}, {"type": "stdin_stdout", "input": "OREQIRMQEAYNUYOA", "output": "-1\n"}, {"type": "stdin_stdout", "input": "OREPIREPNAYNUZOA", "output": "AZ\n"}, {"type": "stdin_stdout", "input": "OREPIRNPEAYNUZOA", "output": "AZ\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThere are many $ N $ colored balls of different weights in the queue. The queue is in ascending order from the beginning: $ 1,2,3, \\ dots, N-1, N, 1,2,3, \\ dots, N-1, N, 1,2,3, \\ dots $ The balls are lined u...
[{"type": "stdin_stdout", "input": "8 4\n46 70 57 10 174 41 130 43", "output": "193\n"}, {"type": "stdin_stdout", "input": "8 4\n46 70 57 10 174 33 130 43", "output": "201\n"}, {"type": "stdin_stdout", "input": "8 7\n46 70 57 3 174 25 130 43", "output": "1302\n"}, {"type": "stdin_stdout", "input": "8 4\n46 70 57 10 174...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDutch treat\n\nYou have organized a party to pray for the good performance of the ICPC 2019 Yokohama Regional Domestic Qualifiers. There are N participants in this party.\n\nSince it costs M yen in total to hold this part...
[{"type": "stdin_stdout", "input": "3 300\n120 100 80\n3 30\n10 20 5\n4 1000\n100 200 300 400\n5 5\n2523 8430 3 4199 987\n0 0", "output": "280\n25\n800\n5\n"}, {"type": "stdin_stdout", "input": "3 276\n120 101 80\n3 5\n10 34 10\n4 1000\n100 200 159 400\n5 10\n183 8430 3 4199 632\n0 0", "output": "264\n3\n709\n10\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMultiplication of Big Integers\n\nGiven two integers $A$ and $B$, compute the product, $A \\times B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the product...
[{"type": "stdin_stdout", "input": "2 -134", "output": "-268\n"}, {"type": "stdin_stdout", "input": "3 -134", "output": "-402\n"}, {"type": "stdin_stdout", "input": "6 -134", "output": "-804\n"}, {"type": "stdin_stdout", "input": "-124 4", "output": "-496\n"}, {"type": "stdin_stdout", "input": "-103 -1", "output": "103...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.\...
[{"type": "stdin_stdout", "input": "54160187 106765305\n", "output": "3328\n17939 17938 17937 17936 17935 17934 17933 17932 17931 17930 17929 17928 17927 17926 17925 17924 17923 17922 17921 17920 17919 17918 17917 17916 17915 17914 17913 17912 17911 17910 17909 17908 17907 17906 17905 17904 17903 17902 17901 17900 1789...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.\n\nA bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called...
[{"type": "stdin_stdout", "input": "30\n)(((())()())()(\n))(()()()(\n))()((\n)())(()\n())())((\n((((())\n(((()))(\n(())\n)()(((()(()\n((())))(\n)()()())((\n))))(()\n()(((()\n)()()(\n(())())\n(()()(())(\n)()((\n)(()(())))\n))))(())((\n)()(()(((((\n(()))((\n()())\n((()()()))\n()((((((((()\n)(()(\n)(((())(()\n)((((()(\n((...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the constraints.\n\nPolycarp has to write a coursework. The coursework consists of m pages.\n\nPolycarp also has n cups of coffee. The coffee in the i-th cup has a_i c...
[{"type": "stdin_stdout", "input": "100 10000\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo integer sequences existed initially, one of them was strictly increasing, and another one β€” strictly decreasing.\n\nStrictly increasing sequence is a sequence of integers [x_1 < x_2 < ... < x_k]. And strictly decreasi...
[{"type": "stdin_stdout", "input": "12\n12 8 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1 \n"}, {"type": "stdin_stdout", "input": "12\n12 10 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1\n"}, {"type": "stdin_stdout", "input": "12\n12 10 1 3 7 5 9 6 4 10 22 2\n", "output": "YES\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nIvan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wa...
[{"type": "stdin_stdout", "input": "78 36\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n1 52\n2 6\n9 43\n10 52\n4 63\n9 35\n10 67\n9 17\n3 43\n4 38\n1 27\n9 44\n6 74\n7 3\n8 18\n1 52\n1 68\n5 51\n5 2\n7 50\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given 4n sticks, the length of the i-th stick is a_i.\n\nYou have to create n rectangles, each rectangle will consist of exactly 4 sticks from the given set. The rectangle consists of four sides, opposite sides sh...
[{"type": "stdin_stdout", "input": "5\n1\n1 1 10 10\n2\n10 5 2 10 1 1 2 5\n2\n10 5 1 10 5 1 1 1\n2\n1 1 1 1 1 1 1 1\n1\n10000 10000 10000 10000\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n1\n1 1 2 10\n2\n10 5 2 10 1 1 2 5\n2\n10 5 1 10 5 1 1 1\n2\n1 1 1 1 1 1 1 1\n1\n10000 10000 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the set of all nonnegative integers: {0, 1, 2, ...}. Given two integers a and b (1 ≀ a, b ≀ 10^4). We paint all the numbers in increasing number first we paint 0, then we paint 1, then 2 and so on.\n\nEach number...
[{"type": "stdin_stdout", "input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"type": "stdin_stdout", "input": "4\n10 10\n1 10\n3 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"type": "stdin_stdout", "input": "4\n10 8\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinit...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer a_i written on it. For each vertex i, Evlampiy calculated c_i β€” the number of vertices j in th...
[{"type": "stdin_stdout", "input": "5\n0 1\n1 3\n2 1\n3 0\n2 0\n", "output": "YES\n2 5 3 1 4 \n"}, {"type": "stdin_stdout", "input": "5\n0 1\n1 3\n2 1\n3 0\n2 0\n", "output": "YES\n2 5 3 1 4 \n"}, {"type": "stdin_stdout", "input": "5\n0 2\n1 3\n2 1\n3 0\n2 0\n", "output": "YES\n3 5 2 1 4\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo become the king of Codeforces, Kuroni has to solve the following problem.\n\nHe is given n numbers a_1, a_2, ..., a_n. Help Kuroni to calculate ∏_{1≀ i<j≀ n} |a_i - a_j|. As result can be very big, output it modulo m.\...
[{"type": "stdin_stdout", "input": "140 149\n124 109 136 123 83 121 53 37 111 105 75 224 99 87 51 45 131 83 18 76 99 29 115 96 16 89 88 69 81 100 120 90 141 48 83 97 26 27 51 94 53 25 32 27 4 139 81 140 137 95 94 89 116 32 85 155 68 12 107 10 124 96 110 32 135 126 2 146 79 14 132 136 110 16 130 98 109 191 2 18 52 27 13...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOmkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.\n\nOmkar currently has n supports arranged in a line, the i-th of which has height a_i. Omkar ...
[{"type": "stdin_stdout", "input": "3\n4\n5 3 2 1\n5\n1 2 3 10 3\n3\n1 1 1\n", "output": "4\n7\n0\n"}, {"type": "stdin_stdout", "input": "3\n4\n5 3 2 0\n5\n1 2 3 10 3\n3\n1 1 1\n", "output": "5\n7\n0\n"}, {"type": "stdin_stdout", "input": "3\n4\n5 3 2 0\n5\n1 2 3 10 3\n3\n2 1 1\n", "output": "5\n7\n1\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a square matrix of size n. Every row and every column of this matrix is a permutation of 1, 2, …, n. Let a_{i, j} be the element at the intersection of i-th row and j-th column for every 1 ≀ i, j ≀ n. Rows a...
[{"type": "stdin_stdout", "input": "5\n3 2\n1 2 3\n2 3 1\n3 1 2\nDR\n3 2\n1 2 3\n2 3 1\n3 1 2\nLU\n3 1\n1 2 3\n2 3 1\n3 1 2\nI\n3 1\n1 2 3\n2 3 1\n3 1 2\nC\n3 16\n1 2 3\n2 3 1\n3 1 2\nLDICRUCILDICRUCI\n", "output": "\n2 3 1 \n3 1 2 \n1 2 3 \n\n3 1 2 \n1 2 3 \n2 3 1 \n\n1 2 3 \n3 1 2 \n2 3 1 \n\n1 3 2 \n2 1 3 \n3 2 1 \n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBased on a peculiar incident at basketball practice, Akari came up with the following competitive programming problem!\n\nYou are given n points on the plane, no three of which are collinear. The i-th point initially has ...
[{"type": "stdin_stdout", "input": "20\n-201268 40733 12\n279503 656971 20\n-193510 -603402 5\n414438 858084 13\n-331542 661690 3\n-249371 867695 16\n312886 681855 17\n-478053 280737 9\n279517 483377 8\n165271 255951 15\n937060 -423651 18\n-683788 -621091 1\n870049 502230 4\n681566 -890785 19\n215558 -577085 10\n788742...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nNote: the XOR-sum of an array a_1, a_2, …, a_n (1 ≀ a_i ≀ 10^9) is defined as a_1 βŠ• a_2 βŠ• … βŠ• a_n, where βŠ• denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_opera...
[{"type": "stdin_stdout", "input": "16 15\n308016736 956290215 528410265 714807573 549801784 640036314 72785399 243731193 64286020 242735735 652383284 747302261 133040055 523901569 310398221 592433960\n", "output": "? 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 \n? 1 16 15 14 13 12 11 10 9 8 7 6 5 4 3 \n? 2 1 16 15 14 13 12 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought it...
[{"type": "stdin_stdout", "input": "5 10 15\nDdunkjly\n13 12 4\n83 26 1\n63 42 3\n83 22 2\n57 33 0\n59 10 1\n89 31 1\n57 17 2\n98 79 5\n46 41 3\nFbpbc\n28 21 0\n93 66 5\n66 21 0\n68 58 0\n59 17 3\n57 23 1\n72 71 1\n55 51 2\n58 40 5\n70 67 2\nKeiotmh\n73 44 4\n98 14 0\n19 7 0\n55 10 5\n30 25 4\n66 48 2\n66 51 4\n82 79 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe \"BerCorp\" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of...
[{"type": "stdin_stdout", "input": "100 100\n1 33\n0\n2 35 4\n2 40 78\n1 69\n0\n1 2\n0\n0\n2 81 34\n1 45\n0\n1 87\n1 50\n1 97\n0\n2 100 59\n0\n0\n0\n1 45\n0\n0\n0\n1 6\n1 54\n0\n0\n0\n4 79 96 52 84\n1 86\n0\n0\n0\n0\n0\n0\n0\n0\n3 90 2 80\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n1 2\n0\n1 64\n0\n1 78\n1 82\n0\n0\n0\n0\n0\n1 6\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe new \"Die Hard\" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A \"Die Hard\" ticket costs 25 rubles. Can the bo...
[{"type": "stdin_stdout", "input": "14\n25 25 25 25 25 25 25 50 50 50 100 100 100 100\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n100 100 100 100 100 100 100 100 100 100\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n25 25 25 25 25 25 25 25 25 25\n", "output": "YES\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers wri...
[{"type": "stdin_stdout", "input": "101 298\n", "output": "10000000000000000000000000000000000000000000000000000000000000000000999999999999999999999999999999999 99999999999999999999999999999999910000000000000000000000000000000000000000000000000000000000000000000\n"}, {"type": "stdin_stdout", "input": "101 299\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department ...
[{"type": "stdin_stdout", "input": "700\n", "output": "16017044425409540\n"}, {"type": "stdin_stdout", "input": "776\n", "output": "33019955679376860\n"}, {"type": "stdin_stdout", "input": "666\n", "output": "11292070960994226\n"}, {"type": "stdin_stdout", "input": "777\n", "output": "33319741730082870\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.\n\nLimak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stol...
[{"type": "stdin_stdout", "input": "11005 209 166\n", "output": "1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 33\n33 34\n34 35\n35 36\n36 37\n37 38\n38 39\n39 40\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one...
[{"type": "stdin_stdout", "input": "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 10778591928\n15000000000 39000000000\n46000000000 51000000000\n0 0000000000\n0 0\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe winter in Berland lasts n days. For each day we know the forecast for the average air temperature that day. \n\nVasya has a new set of winter tires which allows him to drive safely no more than k days at any average a...
[{"type": "stdin_stdout", "input": "100 50\n-7 -3 9 2 16 -19 0 -10 3 -11 17 7 -7 -10 -14 -14 -7 -15 -15 -8 8 -18 -17 -5 -19 -15 -14 0 8 -3 -19 -13 -3 11 -3 -16 16 -16 -12 -2 -17 7 -16 -14 -10 0 -10 -18 -16 -11 -2 -12 -15 -8 -1 -11 -3 -17 -14 -6 -9 -15 -14 -11 -20 -20 -4 -20 -14 -2 0 -2 -20 17 -17 2 0 1 2 6 -5 -13 -16 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.\n\nIt's too hard to learn to solve Rubik's cube instantly, s...
[{"type": "stdin_stdout", "input": "2 6 3 3 5 5 2 6 1 1 12 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5 2 6 1 5 3 5 3 1 1 3 6 6 2 4 2 5 4 4 2 1 3 4 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2 6 3 3 5 5 2 6 2 1 12 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with an...
[{"type": "stdin_stdout", "input": "95 97575868 5\n4612 1644 3613 5413 5649 2419 5416 3926 4610 4419 2796 5062 2112 1071 3790 4220 3955 2142 4638 2832 2702 2115 2045 4085 3599 2452 5495 4767 1368 2344 4625 4132 5755 5815 2581 6259 1330 4938 815 5430 1628 3108 4342 3692 2928 1941 3714 4498 4471 4842 1822 867 3395 2587 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer a and subtract it from n such ...
[{"type": "stdin_stdout", "input": "1001000000\n", "output": "Mahmoud\n"}, {"type": "stdin_stdout", "input": "1011000000\n", "output": "Mahmoud\n"}, {"type": "stdin_stdout", "input": "1165278070\n", "output": "Mahmoud\n"}, {"type": "stdin_stdout", "input": "1425124860\n", "output": "Mahmoud\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s of length n consisting of lowercase English letters.\n\nFor two given strings s and t, say S is the set of distinct characters of s and T is the set of distinct characters of t. The strings s and ...
[{"type": "stdin_stdout", "input": "10 30\naccbaaccac\n6 8 3\n2 9 1\n6 8 3\n10 5 1\n6 2 2\n1 4 7\n3 10 1\n6 9 1\n7 7 3\n7 3 2\n8 4 1\n4 9 1\n7 6 4\n6 8 2\n10 2 1\n1 3 5\n5 10 1\n7 10 1\n4 1 2\n8 5 3\n9 8 1\n8 6 2\n6 9 2\n10 3 1\n3 9 1\n5 5 5\n1 5 6\n4 2 6\n10 7 1\n9 8 2\n", "output": "NO\nYES\nNO\nYES\nNO\nNO\nYES\nYES...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSee Russian Translation\n\nW.T.H.S.E.C\n\nConfused? Well it stands for Welcome To HackerEarth September Easy Challenge :). It's quite amazing when long words like this get reduced to such a short string. They sound pretty...
[{"type": "stdin_stdout", "input": "6\ncagfuq\nto\nc\no\nzmip\naqsldxek\n15\nutdk fuqgbc es akrhnsxv kexdlsqa eeht ukiphhmlp kexdlsqa ftntpjvtt cbgquf ojpkwjuk zqq rcyuuqjy p zf", "output": "U.F.E.A.K.E.U.K.F.C.O.Z.R.P.Z\n"}, {"type": "stdin_stdout", "input": "6\ncagfuq\nto\nc\no\nzmip\naqsldxek\n15\nkdtu fuqgbc es akr...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRani has challenged Nandu to generate Splendid Matrices. Splendid matrices are square matrices with dimensions 2^n X 2^n filled in a particular manner. To explain this manner, Rani gives Nandu the matrices for n=1, n=2 an...
[{"type": "stdin_stdout", "input": "3\n\nSAMPLE", "output": "1 2 5 6 17 18 21 22 \n3 4 7 8 19 20 23 24 \n9 10 13 14 25 26 29 30 \n11 12 15 16 27 28 31 32 \n33 34 37 38 49 50 53 54 \n35 36 39 40 51 52 55 56 \n41 42 45 46 57 58 61 62 \n43 44 47 48 59 60 63 64 \n"}, {"type": "stdin_stdout", "input": "3\n\nSAMPKE", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on i...
[{"type": "stdin_stdout", "input": "1 3\n3 10 127\n10 14 1\n2 4 3\n4 3 12", "output": "115\n"}, {"type": "stdin_stdout", "input": "1 3\n-1 10 120\n64 14 2\n1 4 0\n3 0 6", "output": "49\n"}, {"type": "stdin_stdout", "input": "1 3\n0 9 133\n132 19 1\n1 2 3\n4 2 12", "output": "10\n"}, {"type": "stdin_stdout", "input": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a simple connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge connects Vertex A_i and Vertex B_i. Takahashi will assign one of the two possible directio...
[{"type": "stdin_stdout", "input": "4 4\n1 2\n2 3\n3 4\n4 1", "output": "1 2\n1 4\n3 2\n3 4"}, {"type": "stdin_stdout", "input": "10 2\n1 2\n1 3\n0 4\n3 5\n4 5", "output": "1 2\n1 3\n"}, {"type": "stdin_stdout", "input": "10 2\n1 2\n1 3\n0 2\n3 5\n4 5", "output": "1 2\n1 3\n"}, {"type": "stdin_stdout", "input": "7 2\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlong a road running in an east-west direction, there are A shrines and B temples. The i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is l...
[{"type": "stdin_stdout", "input": "1 1 3\n1\n10000100000\n2\n9999999999\n5000000000", "output": "10000100000\n10000200000\n15000099998\n"}, {"type": "stdin_stdout", "input": "1 1 3\n1\n10000000000\n2\n9999999999\n1416092751", "output": "10000000000\n10000000000\n11416092749\n"}, {"type": "stdin_stdout", "input": "1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a 3Γ—3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be...
[{"type": "stdin_stdout", "input": "ant\nobe\nrfc", "output": "abc\n"}, {"type": "stdin_stdout", "input": "ddu\ncat\nion", "output": "dan\n"}, {"type": "stdin_stdout", "input": "ant\nobe\nrcf", "output": "abf\n"}, {"type": "stdin_stdout", "input": "ddu\ncat\nioo", "output": "dao\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGive you N cards. Only one natural number is written on each card. However, the same number is never written.\n\nFrom now on, as a question, I will say an appropriate natural number. Please answer the largest remainder yo...
[{"type": "stdin_stdout", "input": "3 3\n9 3 10\n12\n6\n1", "output": "10\n4\n0\n"}, {"type": "stdin_stdout", "input": "3 3\n6 2 16\n20\n7\n2", "output": "16\n6\n0\n"}, {"type": "stdin_stdout", "input": "3 3\n2 1 21\n20\n12\n2", "output": "2\n9\n1\n"}, {"type": "stdin_stdout", "input": "3 3\n9 3 8\n12\n12\n2", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe north country is conquered by the great shogun-sama (which means king). Recently many beautiful dice which were made by order of the great shogun-sama were given to all citizens of the country. All citizens received t...
[{"type": "stdin_stdout", "input": "1 2\n10 8\n0 0\n0 1\n3 3\n1 3 5\n2 13 1\n1 0 2\n0 0\n0 2\n3 3\n1 2 4\n4 8 10\n1 1 2\n0 0\n1 2\n2 2\n1 2\n5 4\n1 0\n0 1\n2 3\n1 2 3\n5 5 6\n0 0\n1 2\n0 0", "output": "24\n14\n30\n11\n21\n"}, {"type": "stdin_stdout", "input": "1 2\n10 8\n0 0\n0 1\n3 3\n1 3 5\n2 13 1\n1 0 2\n0 0\n0 2\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew th...
[{"type": "stdin_stdout", "input": "3\n49 128 67 78 41\n29 59 100 45 84\n50 36 40 95 66\n2\n100 000 100 100 110\n0 0 -1 0 0\n1\n89 90 85 120 82\n0", "output": "363 287\n410 -1\n466 466\n"}, {"type": "stdin_stdout", "input": "3\n49 128 67 78 19\n29 59 100 45 84\n50 36 40 95 66\n2\n100 000 100 100 110\n0 0 -1 0 0\n1\n89 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n5\n\n\nOutput\n\n5\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite Python code to solve this probl...
[{"type": "stdin_stdout", "input": "304", "output": "10816520\n"}, {"type": "stdin_stdout", "input": "309", "output": "17426472\n"}, {"type": "stdin_stdout", "input": "352", "output": "45765225\n"}, {"type": "stdin_stdout", "input": "227", "output": "1542687\n"}, {"type": "stdin_stdout", "input": "280", "output": "6677...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKoto Municipal Subway\n\nKoto Municipal Subway\n\nKoto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to we...
[{"type": "stdin_stdout", "input": "2 1\n11 5\n7 6\n5 0\n76 1\n1 41\n0 0", "output": "0.414213562373\n2.81024967591\n0.0827625302982\n3.60555127546\n52.7401153702\n40.0\n"}, {"type": "stdin_stdout", "input": "2 1\n14 6\n5 4\n7 7\n76 3\n9 000\n0 0", "output": "0.414213562373\n3.89949493661\n0.123105625618\n0.0\n50.74011...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nThere is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices.\n\nEach vertex has a button, and the button at the $ i $ th vertex is calle...
[{"type": "stdin_stdout", "input": "4\n1 2\n2 3\n1 4\n1 3 2 -1\n-5 2 9 -1", "output": "33\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n2 3\n1 4\n0 3 0 -1\n-4 2 5 -1", "output": "23\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n1 4\n3 4\n-1 3 2 0\n-8 4 8 -1", "output": "27\n"}, {"type": "stdin_stdout", "input": "4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\n\nA directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example,...
[{"type": "stdin_stdout", "input": "26 0\n1 0\n0 6\n-1 1\n18 9\n12 1\n0 2", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n"}, {"type": "stdin_stdout", "input": "21 -1\n1 2\n0 6\n-1 1\n11 4\n7 1\n0 1", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 1 to the number of steps in this stairway. She speaks every number aloud. For example,...
[{"type": "stdin_stdout", "input": "48\n1 2 3 4 1 2 3 1 1 2 3 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 1 1 2 1 2 1 1 2 1 2 1 2 3 1 1 1 2 1\n", "output": "22\n4 3 1 3 4 1 4 4 4 1 1 1 2 2 1 2 2 3 1 1 2 1 "}, {"type": "stdin_stdout", "input": "48\n1 2 3 4 1 2 3 1 1 2 1 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 2 1 2 1 2 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem is interactive.\n\nYou should guess hidden number x which is between 1 and M = 10004205361450474, inclusive.\n\nYou could use up to 5 queries.\n\nIn each query, you can output an increasing sequence of k ≀ x ...
[{"type": "stdin_stdout", "input": "123\n", "output": "1 204761410474\n1 2046\n1 6\n1 2\n1 1\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "1 204761410474\n1 2046\n1 6\n1 2\n1 1\n"}, {"type": "stdin_stdout", "input": "6\n", "output": "1 204761410474\n1 2046\n1 6\n1 2\n1 1\n"}, {"type": "stdin_s...
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\nSasha is a very happy guy, that's why he is always on the move. There are n cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from 1 to n in increas...
[{"type": "stdin_stdout", "input": "84 15\n", "output": "2429 \n"}, {"type": "stdin_stdout", "input": "100 100\n", "output": "99 \n"}, {"type": "stdin_stdout", "input": "100 98\n", "output": "100 \n"}, {"type": "stdin_stdout", "input": "100 97\n", "output": "102 \n"}, {"type": "stdin_stdout", "input": "100 3\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing a computer game, where you lead a party of m soldiers. Each soldier is characterised by his agility a_i.\n\nThe level you are trying to get through can be represented as a straight line segment from point ...
[{"type": "stdin_stdout", "input": "53 1 27 3\n44 28 48 60 29 42 59 32 9 58 3 11 7 53 4 19 37 41 36 52 29 9 24 8 31 39 52 41 37 44 26 37 37 48 6 21 20 42 25 3 33 2 35 39 33 23 10 60 48 4 1 28 21\n1 1 11\n1 1 21\n1 1 3\n1 1 42\n1 1 16\n1 1 32\n1 1 52\n1 1 17\n1 1 39\n1 1 22\n1 1 31\n1 1 50\n1 1 23\n1 1 14\n1 1 41\n1 1 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.\n\nYou are given a s...
[{"type": "stdin_stdout", "input": "10\nu\nxqpczgnzazxyrvx\ncfjgfhxmzqmjgzzjthziuomldylspyfuxvjlgdc\nooydbldio\nyvaamavy\nrzjjebcgotjffuzr\nhtfkwvihzuwxczopzqujdnaorgxibjfcmlzntskawxhyoymwynitukttewfpajuph\nfactnjajntcaf\nywowyovhrgradhtrqkgurkjpudnrrqhmmwiaqicfxnoyejdsmmurusdzqgjjntocryhqsgr\nqq\n", "output": "u\nxqx\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.\n\nThere is an nΓ— m gr...
[{"type": "stdin_stdout", "input": "18 22\n....................#.\n...................#..\n..........#...........\n..................#...\n..................#...\n..................#...\n......................\n......................\n...........#..........\n..............#.......\n..............#.......\n................
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to...
[{"type": "stdin_stdout", "input": "7\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "6\n6 1\n100010\n6 2\n000000\n5 1\n10101\n3 1\n001\n2 2\n00\n1 1\n0\n", "output": "1\n2\n0\n1\n1\n1\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUncle Bogdan is in captain Flint's crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index.\n\nThere are n cities and nβˆ’1 undirected roads connect...
[{"type": "stdin_stdout", "input": "2\n7 4\n1 0 1 1 0 1 0\n4 0 0 -1 0 -1 0\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n5 11\n1 2 5 2 1\n-11 -2 -6 -2 -1\n1 2\n1 3\n1 4\n3 5\n", "output": "YES\nYES\n"}, {"type": "stdin_stdout", "input": "2\n7 4\n1 0 1 1 0 1 0\n4 0 -1 -1 0 -1 0\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n5 11\n1 2 5 2 1\n-11 -2 -6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers a and b.\n\nIn one move, you can choose some integer k from 1 to 10 and add it to a or subtract it from a. In other words, you choose an integer k ∈ [1; 10] and perform a := a + k or a := a - k....
[{"type": "stdin_stdout", "input": "11\n5 5\n13 42\n18 4\n1337 420\n123456789 1000000000\n100500 9000\n5 5\n13 42\n18 4\n2524 420\n123456789 1000000000\n", "output": "0\n3\n2\n92\n87654322\n9150\n0\n3\n2\n211\n87654322\n"}, {"type": "stdin_stdout", "input": "11\n10 5\n4 42\n17 4\n1337 420\n123456789 1000000000\n100500 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaving learned (not without some help from the Codeforces participants) to play the card game from the previous round optimally, Shrek and Donkey (as you may remember, they too live now in the Kingdom of Far Far Away) hav...
[{"type": "stdin_stdout", "input": "15 31 1\n--------R---------G------------\n-G----------------------------R\n--------------G--------------R-\n---G--------------------------R\n-----R---------G---------------\n--R--G-------------------------\n-----G-----------------R-------\n--R-------------------G--------\n-R---------...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong's town has a train system that has 100 trains that travel from the bottom end to the top end and 100 trains that travel from the left end to the right end. The trains starting from each side are numbered from 1 to...
[{"type": "stdin_stdout", "input": "3\n1 2\n1\n3 4\n3 2\n2 3 11\n2 1\n9 14\n2 12 16 28 42 57 59 86 99\n3 9 14 19 25 26 20 35 41 59 85 87 99 100\n", "output": "0\n1\n2\n"}, {"type": "stdin_stdout", "input": "3\n1 2\n1\n3 4\n3 2\n1 3 4\n2 4\n9 14\n2 7 16 28 33 57 59 86 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n lanterns in a row. The lantern i is placed in position i and has power equal to p_i.\n\nEach lantern can be directed to illuminate either some lanterns to the left or some lanterns to the right. If the i-th la...
[{"type": "stdin_stdout", "input": "16\n4\n1 0 3 3\n4\n3 0 3 0\n4\n1 4 4 0\n4\n2 2 2 0\n4\n3 0 2 2\n6\n2 6 2 0 3 0\n5\n0 1 1 1 0\n14\n12 0 5 4 0 5 0 0 0 0 0 14 0 5\n7\n0 0 0 -1 0 0 0\n14\n0 0 9 0 -1 12 0 0 0 4 0 0 1 5\n18\n0 0 0 0 0 13 0 0 0 0 0 -1 0 0 0 0 0 18\n6\n0 0 0 5 0 0\n2\n1 1\n7\n3 2 0 6 1 6 2\n10\n0 0 0 0 0 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities numbered from 1 to n, and city i has beauty a_i.\n\nA salesman wants to start at city 1, visit every city exactly once, and return to city 1.\n\nFor all i≠ j, a flight from city i to city j costs max(c_...
[{"type": "stdin_stdout", "input": "30\n13 1\n111 5\n50 5\n61 0\n76 98\n110 1\n17 1\n4 17\n72 28\n75 90\n16 0\n13 12\n57 0\n47 12\n34 13\n61 120\n3 1\n134 100\n89 94\n88 10\n42 3\n93 33\n6 5\n81 48\n31 17\n32 0\n11 5\n69 1\n58 1\n3 21\n", "output": "750\n"}, {"type": "stdin_stdout", "input": "30\n13 1\n59 5\n50 5\n61 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an integer n, find the maximum value of integer k such that the following condition holds: \n\nn & (n-1) & (n-2) & (n-3) & ... (k) = 0 where & denotes the [bitwise AND operation.](https://en.wikipedia.org/wiki/Bitw...
[{"type": "stdin_stdout", "input": "1\n168457447\n", "output": "134217727\n"}, {"type": "stdin_stdout", "input": "1\n276490162\n", "output": "268435455\n"}, {"type": "stdin_stdout", "input": "1\n109011159\n", "output": "67108863\n"}, {"type": "stdin_stdout", "input": "1\n99888383\n", "output": "67108863\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAny resemblance to any real championship and sport is accidental.\n\nThe Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local champi...
[{"type": "stdin_stdout", "input": "MYCXFLPTHVGWDSRXCOI BERLAND 5:9\nSPSHVVQLXQNRUB BERLAND 0:5\nSPSHVVQLXQNRUB MYCXFLPTHVGWDSRXCOI 4:6\nZPIIZCGCLCHNLIXCPBRM MYCXFLPTHVGWDSRXCOI 7:5\nZPIIZCGCLCHNLIXCPBRM SPSHVVQLXQNRUB 3:9\n", "output": "1:0"}, {"type": "stdin_stdout", "input": "VJWNNQCMHKJVXAPRVAD BERLAND 9:3\nVJWNNQC...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNumbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows:\n\n * F(k, n) = 0, for integer n, 1 ≀ n < k; \n * F(k, k) = 1; \n * F(k, n) = F(k, n - 1) + F(k, n - 2) +...
[{"type": "stdin_stdout", "input": "615693473 3\n", "output": "22\n334745777 181997601 53798080 29249425 8646064 4700770 1389537 755476 223317 121415 35890 19513 5768 3136 927 504 149 81 24 13 4 2 "}, {"type": "stdin_stdout", "input": "999999999 30\n", "output": "21\n536870912 268435456 134217728 33554432 16777216 8388...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.\n\nYou'r...
[{"type": "stdin_stdout", "input": "141441441\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "141414141\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "111111111\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "11411414...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q1q2... qk. The algorithm consists of two s...
[{"type": "stdin_stdout", "input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\n10\n17 67\n6 42\n12 45\n56 56\n14 13\n44 49\n1 1\n50 54\n3 33\n19 40\n", "output": "NO\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxz...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInna loves sweets very much. That's why she decided to play a game called \"Sweet Matrix\".\n\nInna sees an n Γ— m matrix and k candies. We'll index the matrix rows from 1 to n and the matrix columns from 1 to m. We'll rep...
[{"type": "stdin_stdout", "input": "50 37 500\n", "output": "10544\n(1,1) (2,1) (3,1) (4,1) (4,2) (4,3) (4,4) (4,5) (4,6) (4,7) (4,8) (4,9) (4,10) (4,11) (4,12) (4,13) (4,14) (4,15) (4,16) (4,17) (4,18) (4,19) (4,20) (4,21) (4,22) (4,23) (4,24) (4,25) (4,26) (4,27) (4,28) (4,29) \n(1,1) (2,1) (3,1) (3,2) (3,3) (3,4) (3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDevelopers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check...
[{"type": "stdin_stdout", "input": "100\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?b\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?\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is g...
[{"type": "stdin_stdout", "input": "40\n37 15\n48 10\n16 5\n30 23\n32 20\n24 4\n46 19\n16 13\n1 1\n37 22\n44 29\n24 6\n27 10\n39 16\n28 13\n5 4\n31 22\n9 2\n30 26\n23 16\n16 12\n43 5\n29 1\n20 5\n40 12\n18 14\n22 15\n29 2\n3 2\n6 3\n45 28\n42 34\n43 32\n10 10\n12 8\n10 8\n4 1\n17 17\n16 7\n8 7\n", "output": "796297179\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the...
[{"type": "stdin_stdout", "input": "100000 100000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "100000 101000\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "32768 65536\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "65535 65536\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn n Γ— n table a is defined as follows:\n\n * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. \n * Each of the remaining numbers in the table is equal to the sum of ...
[{"type": "stdin_stdout", "input": "010\n", "output": "48620\n"}, {"type": "stdin_stdout", "input": "10\n", "output": "48620\n"}, {"type": "stdin_stdout", "input": "9\n", "output": "12870\n"}, {"type": "stdin_stdout", "input": "8\n", "output": "3432\n"}, {"type": "stdin_stdout", "input": "7\n", "output": "924\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn fr...
[{"type": "stdin_stdout", "input": "100000 100000 100000 123228\n", "output": "Polycarp\n"}, {"type": "stdin_stdout", "input": "100000 99999 100000 100000\n", "output": "Polycarp\n"}, {"type": "stdin_stdout", "input": "100000 99999 100010 100000\n", "output": "Polycarp\n"}, {"type": "stdin_stdout", "input": "100000 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h1 cm from the ground. On the height h2 cm (h2 > h1) on the same tree hun...
[{"type": "stdin_stdout", "input": "43951 66098\n1604 35654\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "28473 80380\n2568 95212\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "35413 75637\n4087 30166\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "25401 103980\n957 30449\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes ch...
[{"type": "stdin_stdout", "input": "12\n17:30\n", "output": "07:30\n"}, {"type": "stdin_stdout", "input": "24\n99:99\n", "output": "09:09\n"}, {"type": "stdin_stdout", "input": "24\n17:30\n", "output": "17:30\n"}, {"type": "stdin_stdout", "input": "12\n90:32\n", "output": "10:32\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGenerous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with thei...
[{"type": "stdin_stdout", "input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\n7 8\n5 10\n8 6\n1 5\n7 9\n3 9\n2 10\n2 6\n4 3\n", "output": "Impossible"}, {"type": "stdin_stdout", "input": "10\n1000000000 1000000000 1000000000 1000000000 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAccording to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents s...
[{"type": "stdin_stdout", "input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p1, p2, ..., pn...
[{"type": "stdin_stdout", "input": "20 20\n18 17 2 3 16 15 1 9 12 8 20 11 13 14 4 5 19 7 10 6\n13 15 15\n1 1 1\n2 2 2\n11 14 11\n10 11 10\n2 8 6\n12 18 16\n4 8 8\n2 2 2\n5 11 11\n4 18 9\n5 6 6\n3 20 12\n8 8 8\n6 16 11\n9 18 18\n8 18 17\n1 1 1\n2 6 5\n1 4 3\n", "output": "No\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nNo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are some ambiguities when one writes Berland names with the letters of the Latin alphabet.\n\nFor example, the Berland sound u can be written in the Latin alphabet as \"u\", and can be written as \"oo\". For this re...
[{"type": "stdin_stdout", "input": "101\nukuu\nh\nouuo\no\nkkuo\nko\nu\nh\nhku\nh\nh\nhuo\nuhoh\nkuu\nhu\nhkko\nuhuk\nkoho\nh\nhukk\noohu\nkk\nkko\nou\noou\nh\nuuu\nuh\nkhuk\nokoo\nouou\nuo\nkk\noo\nhuok\no\nu\nhok\nhu\nhhuu\nkuu\nooho\noku\nhuoh\nhhkh\nuuuh\nouo\nhou\nhhu\nh\no\nokou\nuo\nh\nukk\nu\nhook\nh\noouk\noku...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bea...
[{"type": "stdin_stdout", "input": "100 57 30 51\n", "output": "104\n103\n51\n"}, {"type": "stdin_stdout", "input": "100 99 98 97\n", "output": "196\n195\n98"}, {"type": "stdin_stdout", "input": "99 98 80 97\n", "output": "196\n195\n97\n"}, {"type": "stdin_stdout", "input": "100 50 19 13\n", "output": "100\n50\n19\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady decided to buy roses for his girlfriend.\n\nA flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a b...
[{"type": "stdin_stdout", "input": "30 15\n7926 577 5009 7237 4395 3239 8994 4429 8126 2925 139 320 4442 3397 1292 2800 9505 6043 5946 8058 4031 6871 4689 1977 73 440 5320 5290 4707 387\nOOWOWWORRWOWORWRRRRWORROOWWROW\n", "output": "91633\n"}, {"type": "stdin_stdout", "input": "30 15\n7926 577 5009 7237 4395 3239 8994 ...
code_stdio