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\nVasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any posit...
[{"type": "stdin_stdout", "input": "48\n4 7 12 16 23 43 61 112 134 141 243 267 484 890 1427 1558 1653 2263 2889 3313 3730 5991 10176 18243 18685 36555 40006 62099 70557 106602 122641 125854 213236 309698 379653 713328 999577 1021356 2007207 2886237 4994645 5812125 11576387 14215887 26060277 35989707 36964781 57933366\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nВ самолёте есть n рядов мест. Если смотреть на ряды сверху, то в каждом ряду есть 3 места слева, затем проход между рядами, затем 4 центральных места, затем ещё один проход между рядами, а затем ещё 3 места справа.\n\nИзв...
[{"type": "stdin_stdout", "input": "30 1\nPPP-PPP.-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word \"tma\" (which now means \"too much to be counted\") used to stand f...
[{"type": "stdin_stdout", "input": "2147483647\n2147483647\n", "output": "YES\n0\n"}, {"type": "stdin_stdout", "input": "2147483646\n2147483647\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1094841453\n1656354409\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2147483647\n2147483646\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is studying in the last class of school and soon he will take exams. He decided to study polynomials. Polynomial is a function P(x) = a_0 + a_1x^1 + ... + a_{n}x^{n}. Numbers a_{i} are called coefficients of a polyn...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1001000000000000000 1000000000000000000 1000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to n from top to bottom. On each wire there are some oskols sitting next to each other. ...
[{"type": "stdin_stdout", "input": "100\n54 15 25 18 64 62 23 59 70 137 50 26 87 35 75 86 0 22 6 60 70 41 21 9 75 50 25 3 69 14 39 68 64 46 59 99 2 0 21 76 90 12 61 42 12 91 36 39 47 41 93 81 66 57 70 36 68 89 52 1 19 93 67 22 76 20 8 81 123 18 100 73 61 93 75 80 53 72 40 20 2 86 33 70 27 16 11 26 55 44 47 55 94 58 2 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme. \n\nThr...
[{"type": "stdin_stdout", "input": "50 64\n257 258 350 375 1014 1017 1051 1097 1169 1177 1223 1836 1942 1983 2111 2131 2341 2418 2593 2902 2948 3157 3243 3523 3566 4079 4499 4754 5060 5624 6279 6976 7011 7071 7278 7366 7408 7466 7526 7837 7934 8532 8577 8680 9221 9271 9327 9411 9590 9794\n", "output": "0.91891891891891...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\nOperation: Choose one character of S and replace it with a different characte...
[{"type": "stdin_stdout", "input": "sjpvbzildfxlaukqtfznjjyryrdawsycubdpieejlzsexyhuajiqqigetwdyjeignkuuedzguvqhyrubpdfsenayqahbaqnyhavlaptlqtrotfzvbqbtpkuddnopjzoteuubxgkthzdyepesqgozkdvkcakraxeulhhqtnpolbtcsgxgskjjzdimcyhclnnwfbxwmznpvjaqjqqogwgwmzzpcvhywpcocmsxxmgsodckxvipzobspvwjezxugjlivdhefgdfkzzidktxjcnayjubmsqm...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate...
[{"type": "stdin_stdout", "input": "988480 1151420 106\n", "output": "981327901099.81217265129089355"}, {"type": "stdin_stdout", "input": "1503946 527535 69\n", "output": "298092342476.75622430443763733"}, {"type": "stdin_stdout", "input": "988480 819219 106\n", "output": "684860009476.82913672924041748"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's assume that \n\n * v(n) is the largest prime number, that does not exceed n;\n * u(n) is the smallest prime number strictly greater than n. \n\n\n\nFind <image>.\n\nInput\n\nThe first line contains integer t (1 ≤ ...
[{"type": "stdin_stdout", "input": "6\n999\n1095\n821\n635\n63\n480\n", "output": "1003961/2011946\n1196833/2398042\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"type": "stdin_stdout", "input": "6\n999\n588\n821\n635\n63\n480\n", "output": "1003961/2011946\n346909/696182\n674039/1351366\n403199/808942...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaracal is fighting with a monster.\nThe health of the monster is H.\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n - If the monster's...
[{"type": "stdin_stdout", "input": "1000000000000\n", "output": "1099511627775\n"}, {"type": "stdin_stdout", "input": "999999999999\n", "output": "1099511627775\n"}, {"type": "stdin_stdout", "input": "549755813888\n", "output": "1099511627775\n"}, {"type": "stdin_stdout", "input": "707813884927\n", "output": "109951162...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nEugene loves sequences, especially arithmetic progressions. One day he was asked to solve a difficult problem.\n\nIf a sequence of numbers ...
[{"type": "stdin_stdout", "input": "2\n-3 3 -2 -2\n2 2 126 3", "output": "6\n-609\n"}, {"type": "stdin_stdout", "input": "2\n-3 3 -2 -2\n2 2 126 0", "output": "6\n-621\n"}, {"type": "stdin_stdout", "input": "2\n-1 6 -2 -2\n2 2 92 -1", "output": "8\n-461\n"}, {"type": "stdin_stdout", "input": "2\n-2 6 -2 -2\n2 2 92 -1",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Borys are playing tennis.\n\nA tennis match consists of games. In each game, one of the players is serving and the other one is receiving.\n\nPlayers serve in turns: after a game where Alice is serving follows a...
[{"type": "stdin_stdout", "input": "2\n134843 8\n2 6957\n", "output": "18\n67417 67418 67419 67420 67421 67422 67423 67424 67425 67426 67427 67428 67429 67430 67431 67432 67433 67434\n6\n3477 3478 3479 3480 3481 3482\n"}, {"type": "stdin_stdout", "input": "2\n35737 8\n0 960\n", "output": "18\n17864 17865 17866 17867 17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: \n\n * After the cutting each ribbon piece should have length a, b or c. \n * After the cutting th...
[{"type": "stdin_stdout", "input": "3043 317 1141 2438\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3399 2035 2 3334\n", "output": "683\n"}, {"type": "stdin_stdout", "input": "4000 500 1000 2000\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "4000 500 1000 1671\n", "output": "8\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ bags with candies, initially the $i$-th bag contains $i$ candies. You want all the bags to contain an equal amount of candies in the end.\n\nTo achieve this, you will:\n\nChoose $m$ such that $1 \\le m \\le ...
[{"type": "stdin_stdout", "input": "100\n100\n2\n3\n4\n5\n6\n7\n8\n9\n15\n14\n12\n13\n14\n15\n16\n17\n6\n19\n17\n21\n32\n23\n24\n6\n26\n27\n28\n29\n0\n31\n32\n52\n34\n35\n72\n37\n38\n11\n5\n20\n35\n43\n44\n15\n46\n47\n26\n49\n50\n51\n54\n53\n54\n55\n72\n73\n69\n103\n60\n61\n62\n49\n58\n6\n40\n67\n121\n69\n48\n71\n127\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enume...
[{"type": "stdin_stdout", "input": "10 10 1 8 4\n10\n2 3 4 5 6 7 8 9\n10\n1 1 3 1\n2 1 7 1\n1 1 9 1\n7 1 4 1\n10 1 7 1\n2 1 7 1\n3 1 2 1\n5 1 2 1\n10 1 5 1\n6 1 9 1\n", "output": "3\n4\n4\n3\n3\n4\n3\n3\n4\n3\n"}, {"type": "stdin_stdout", "input": "10 18 1 8 4\n10\n2 3 4 5 6 7 8 9\n10\n1 1 3 1\n2 1 7 1\n1 1 9 1\n7 1 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nChairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories pe...
[{"type": "stdin_stdout", "input": "3\n16 2\n358\n87\n1601\n010", "output": "108\n"}, {"type": "stdin_stdout", "input": "3\n16 2\n696\n77\n1150\n010", "output": "102\n"}, {"type": "stdin_stdout", "input": "3\n12 2\n200\n87\n1514\n010", "output": "122\n"}, {"type": "stdin_stdout", "input": "3\n12 2\n491\n77\n1150\n010",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have an array $a_1, a_2, \\dots, a_n$ consisting of $n$ distinct integers. You are allowed to perform the following operation on it:\n\nChoose two elements from the array $a_i$ and $a_j$ ($i \\ne j$) such that $\\gcd(...
[{"type": "stdin_stdout", "input": "57\n241 444 553 126 612 550 441 420 742 879 520 664 590 198 910 731 308 740 791 680 904 629 324 606 621 75 350 253 57 164 440 970 876 648 581 258 989 851 186 117 700 537 837 284 654 130 728 955 859 988 820 345 901 294 244 125 512\n", "output": "48"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA: Isono, let's do that! --Sendame -\n\nstory\n\nNakajima \"Isono ~, let's do that!\"\n\nIsono \"What is that, Nakajima\"\n\nNakajima \"Look, that's that. It's hard to explain because I have to express it in letters for s...
[{"type": "stdin_stdout", "input": "3\ntameru\ntameru\nuremat\ntameru\nkougekida\ntameru", "output": "Nakajima-kun\n"}, {"type": "stdin_stdout", "input": "3\ntameru\ntameru\nuremat\ntameru\nadikeguok\ntameru", "output": "Hikiwake-kun\n"}, {"type": "stdin_stdout", "input": "3\ntameru\ntameru\nuremat\ntameru\nadikeguok\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is going to participate in the contest. It starts at $h_1:m_1$ and ends at $h_2:m_2$. It is guaranteed that the contest lasts an even number of minutes (i.e. $m_1 \\% 2 = m_2 \\% 2$, where $x \\% y$ is $x$ modulo...
[{"type": "stdin_stdout", "input": "10:00\n11:00\n", "output": "10:30\n"}, {"type": "stdin_stdout", "input": "11:10\n11:12\n", "output": "11:11\n"}, {"type": "stdin_stdout", "input": "01:02\n03:02\n", "output": "02:02\n"}, {"type": "stdin_stdout", "input": "00:00\n23:58\n", "output": "11:59\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m pairs of similar problems. Authors...
[{"type": "stdin_stdout", "input": "100000 10\n99562 484\n1099 99684\n593 99867\n99529 175\n99738 616\n99523 766\n99503 121\n99784 158\n199 99199\n15 99849\n", "output": "98100\n"}, {"type": "stdin_stdout", "input": "100000 10\n99562 484\n1099 99684\n593 99867\n99529 175\n99738 616\n99523 766\n42925 121\n99784 158\n199...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n ...
[{"type": "stdin_stdout", "input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10\n7 6\n", "output": "34\n"}, {"type": "stdin_stdout", "input": "10 2\n10 2\n9 3\n9 4\n7 2\n4 6\n10 1\n9 2\n3 10\n7 1\n5 1\n", "output": "43\n"}, {"type": "stdin_stdout", "input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has N days of summer vacation.\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\nHe cannot do multiple assignments on the same day, or hang out on a day he doe...
[{"type": "stdin_stdout", "input": "1000000 10000\n10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n— This is not playing but duty as allies of justice, Nii-chan!\n\n— Not allies but justice itself, Onii-chan!\n\nWith hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen an...
[{"type": "stdin_stdout", "input": "5000 5000 5000\n", "output": "986778560\n"}, {"type": "stdin_stdout", "input": "1171 2989 2853\n", "output": "234725427\n"}, {"type": "stdin_stdout", "input": "3238 2923 4661\n", "output": "636587126\n"}, {"type": "stdin_stdout", "input": "4539 2805 2702\n", "output": "356944655\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the wo...
[{"type": "stdin_stdout", "input": "200\nmmffggzvuuzzlkafduueqocuybiiaaeeoiioouaaurccuqoouuooooooyjjtyyxxiipnoeufyuuoyxxhhkaaeoooxapauuoppzabuuoiiuuggcciissuugejjiirruummsiifaauyypauwoofiemzaeeeeeeiioozzttyyidaaaiggizzerkooooeeepueeauupathhb\n", "output": "mmffggzvuzzlkafdueqocuybiaeeoioouaurccuqoouoyjjtyxxipnoeufyuoyx...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n500-yen Saving\n\n\"500-yen Saving\" is one of Japanese famous methods to save money. The method is quite simple; whenever you receive a 500-yen coin in your change of shopping, put the coin to your 500-yen saving box. Ty...
[{"type": "stdin_stdout", "input": "4\n800\n700\n1600\n600\n4\n300\n1205\n1600\n30\n4\n300\n700\n1600\n650\n3\n1001\n2000\n638\n3\n250\n250\n1000\n4\n1251\n1466\n698\n299\n0", "output": "2 2900\n4 3135\n3 3250\n2 1639\n3 1500\n4 3714\n"}, {"type": "stdin_stdout", "input": "4\n800\n700\n1600\n600\n4\n300\n1205\n1600\n30...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHolidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory f...
[{"type": "stdin_stdout", "input": "12 1000000000\n", "output": "479001600\n"}, {"type": "stdin_stdout", "input": "1000000000 12\n", "output": "479001600\n"}, {"type": "stdin_stdout", "input": "1000000000 12\n", "output": "479001600\n"}, {"type": "stdin_stdout", "input": "12 1000000000\n", "output": "479001600\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is an infinite board of square tiles. Initially all tiles are white.\n\nVova has a red marker and a blue marker. Red marker can color $a$ tiles. Blue marker can color $b$ tiles. If some tile isn't white then you can...
[{"type": "stdin_stdout", "input": "99999999999973 99999999999971\n", "output": "199999999999948\n"}, {"type": "stdin_stdout", "input": "99999999999962 99999999999973\n", "output": "133333333333296\n"}, {"type": "stdin_stdout", "input": "99999999999973 99999999999930\n", "output": "399999999999808\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCQXYM is counting permutations length of $2n$.\n\nA permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permu...
[{"type": "stdin_stdout", "input": "20\n597\n2791\n71\n1\n6\n14\n196\n1\n4335\n14\n5133\n6\n17\n3620\n5111\n1\n119\n992\n76848\n127\n", "output": "924058387\n309126958\n25034588\n1\n239500800\n517878947\n323758520\n1\n41675960\n517878947\n479930293\n239500800\n971636156\n715097853\n974503605\n1\n796779807\n613317322\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a mayor of Berlyatov. There are $n$ districts and $m$ two-way roads between them. The $i$-th road connects districts $x_i$ and $y_i$. The cost of travelling along this road is $w_i$. There is some path between eac...
[{"type": "stdin_stdout", "input": "5 5 4\n1 2 5\n4 3 4\n1 4 3\n4 3 10\n3 5 2\n1 5\n1 3\n3 3\n1 5\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "5 5 4\n1 2 5\n4 3 4\n1 4 3\n4 3 10\n3 5 2\n1 2\n1 3\n3 3\n1 5\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "5 5 4\n1 2 5\n2 3 4\n1 4 3\n4 3 7\n3 5 2\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose $a_1, a_2, \\dots, a_n$ is a sorted integer sequence of length $n$ such that $a_1 \\leq a_2 \\leq \\dots \\leq a_n$.\n\nFor every $1 \\leq i \\leq n$, the prefix sum $s_i$ of the first $i$ terms $a_1, a_2, \\dots,...
[{"type": "stdin_stdout", "input": "10\n2 1\n1000000000\n3 2\n-100000000 -150000003\n3 2\n-100000000 -150000004\n3 2\n-100000000 -150000001\n3 2\n-100000000 -150000002\n3 2\n-100000000 -150000000\n3 2\n-100000000 -149999999\n3 2\n-100000000 -149999999\n3 2\n-100000000 -149999998\n3 2\n-100000000 -149999997\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and n,...
[{"type": "stdin_stdout", "input": "2998\n", "output": "1375\n"}, {"type": "stdin_stdout", "input": "2999\n", "output": "1375\n"}, {"type": "stdin_stdout", "input": "2997\n", "output": "1374\n"}, {"type": "stdin_stdout", "input": "3000\n", "output": "1375\n"}, {"type": "stdin_stdout", "input": "2990\n", "output": "1370...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya had a strictly increasing sequence of positive integers a_1, ..., a_{n}. Vasya used it to build a new sequence b_1, ..., b_{n}, where b_{i} is the sum of digits of a_{i}'s decimal representation. Then sequence a_{i}...
[{"type": "stdin_stdout", "input": "100\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n6\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a eq...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1998535156\n"}, {"type": "stdin_stdout", "input": "1000001000\n", "output": "1906011808\n"}, {"type": "stdin_stdout", "input": "1549355491\n", "output": "1559780582\n"}, {"type": "stdin_stdout", "input": "1292236879\n", "output": "1292236880\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties:\n\n the upper half of matri...
[{"type": "stdin_stdout", "input": "8 20\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given undirected weighted graph. Find the length of the shortest cycle which starts from the vertex 1 and passes throught all the edges at least once. Graph may contain multiply edges between a pair of vertices an...
[{"type": "stdin_stdout", "input": "15 32\n15 9 8860\n12 4 9045\n12 12 8221\n9 6 8306\n11 14 9052\n13 14 8176\n14 5 8857\n6 8 8835\n3 9 8382\n10 14 8212\n13 13 9061\n2 14 8765\n4 13 9143\n13 13 8276\n13 11 8723\n7 10 8775\n8 15 8965\n15 5 8800\n4 5 9317\n5 13 9178\n1 7 9031\n4 10 9114\n10 4 8628\n9 1 8584\n5 7 8701\n6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's ...
[{"type": "stdin_stdout", "input": "2000\nJAPAN FEBRUARY MONEY SUPPLY RISES 8.8 PCT\nTOKYO, March 17 - Japan's broadly defined money supply\naverage of M-2 plus certificate of deposits (CDs) rose a\npreliminary 8.8 pct in February from a year earlier, compared\nwith an 8.6 pct rise ni January, the Bank of Japan said.\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan plays an old action game called Heretic. He's stuck on one of the final levels of this game, so he needs some help with killing the monsters.\n\nThe main part of the level is a large corridor (so large and narrow tha...
[{"type": "stdin_stdout", "input": "2\n3 2\n1 3 5\n4 1\n5 2 3 5\n", "output": "2\n2\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n1 3 5\n4 1\n5 4 3 5\n", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n1 1 5\n4 1\n5 4 3 5\n", "output": "1\n3\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n0 1 5\n4 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is an integer sequence A of length N whose values are unknown.\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n B_i \\geq \\max(A_i, A_{i+1}) \nFind the maximum possible sum o...
[{"type": "stdin_stdout", "input": "100\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the big break Nastya came to the school dining room. There are $n$ pupils in the school, numbered from $1$ to $n$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya ...
[{"type": "stdin_stdout", "input": "20 47\n4 6 11 15 9 17 3 1 19 14 12 8 2 5 7 20 16 18 13 10\n18 10\n6 3\n15 17\n18 7\n4 5\n19 10\n6 7\n11 3\n1 10\n17 3\n6 14\n7 10\n19 5\n12 10\n1 8\n6 11\n18 5\n6 8\n12 12\n1 5\n20 11\n16 8\n3 10\n20 19\n17 8\n19 10\n2 5\n19 8\n6 9\n16 3\n16 10\n19 7\n17 16\n10 13\n8 9\n12 5\n17 10\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi participated in a contest on AtCoder.\nThe contest had N problems.\nTakahashi made M submissions during the contest.\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\...
[{"type": "stdin_stdout", "input": "100000 3\n7777 AC\n7777 AC\n7777 AC\n", "output": "1 0\n"}, {"type": "stdin_stdout", "input": "100000 3\n12676 AC\n7777 AC\n7777 CA", "output": "2 0\n"}, {"type": "stdin_stdout", "input": "100000 3\n7777 AC\n7777 AC\n7777 CA", "output": "1 0\n"}, {"type": "stdin_stdout", "input": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\nGiven an integer N, determine if S(N) divides N.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^9\n\n-----Input--...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "873041724\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "689670774\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5064791...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGrandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.\n\nShe precisely remembers she had n b...
[{"type": "stdin_stdout", "input": "40 562\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalf\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalf...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$.\n\nYou can move only in two directions:\n\nto the right, i. e. horizontally and in the direction that increase your $x$ ...
[{"type": "stdin_stdout", "input": "3\n2\n13 100\n3\n4 3 1\n5\n13 4 1 1 5\n", "output": "226\n15\n25\n"}, {"type": "stdin_stdout", "input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 2 1 5\n", "output": "226\n11\n19\n"}, {"type": "stdin_stdout", "input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 1 1 5\n", "output": "226\n11\n15\n"}, {"type...
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 81 60 92 63 9 16 6 31 90 6 5 70 48 27 86 65 66 45 8 67 17 24 44 34 93 26 32 82 54 72 83 94 81 79 79 9 9 4 59 42 83 80 67 28 62 56 58 87 67 34 3 61 14 62 19 94 31 74 97 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.\n\nInput\...
[{"type": "stdin_stdout", "input": "10000 10000 10000\n", "output": "1200"}, {"type": "stdin_stdout", "input": "10000 1 10000\n", "output": "40008"}, {"type": "stdin_stdout", "input": "9801 9801 9801\n", "output": "1188"}, {"type": "stdin_stdout", "input": "1 10000 10000\n", "output": "40008"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.\n\nAlice initially has a token on some cell on the line, and Bob...
[{"type": "stdin_stdout", "input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "50 75\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShe loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout ...
[{"type": "stdin_stdout", "input": "666660666\n134424306396481246895756\n12784174432754272468162", "output": "No\n'dhagdmdwmgt'agmtwjpjm\n'aptg'phdapjgapagmt'ma\n"}, {"type": "stdin_stdout", "input": "666660666\n113124756735251440964347\n33891614279093528467517", "output": "No\n,d'agpjmpdjaj'hwmgdgp\netw'm'gapwwdjatgmp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below. \n\nAlice goes first and then they take alternating turns. In the i...
[{"type": "stdin_stdout", "input": "1000000\n", "output": "998677\n"}, {"type": "stdin_stdout", "input": "959806\n", "output": "239958\n"}, {"type": "stdin_stdout", "input": "166320\n", "output": "110879\n"}, {"type": "stdin_stdout", "input": "221760\n", "output": "110880\n"}, {"type": "stdin_stdout", "input": "277200\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya 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.\...
[{"type": "stdin_stdout", "input": "86451 754 85 84\n", "output": "4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhat joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... \n\nToday Petya op...
[{"type": "stdin_stdout", "input": "100\n100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100\n100 100 100 100 110 100 100 100 100 100 100 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100\n100 100 100 100 110 100 100 100 100 100 101 100\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!\n\nHe decided to vis...
[{"type": "stdin_stdout", "input": "15\n12 1 52\n6 2 10\n4 1 55\n11 7 20\n10 3 54\n13 9 44\n15 2 6\n14 5 55\n9 3 32\n2 1 32\n8 4 14\n6 5 24\n5 3 74\n7 6 157\n", "output": "1039\n"}, {"type": "stdin_stdout", "input": "15\n12 1 52\n3 2 10\n4 1 45\n11 7 20\n10 3 54\n13 9 44\n15 2 6\n14 5 55\n9 3 32\n2 1 32\n8 4 14\n6 5 24...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA cricket team consists of 11 players and some are good at batting, others are good at bowling and some of them are good at both batting and bowling. The batting coach wants to select exactly K players having maximum poss...
[{"type": "stdin_stdout", "input": "2\n1 2 3 4 5 11 14 11 11 6 11\n3\n0 5 1 2 4 1 4 5 1 2 1\n11", "output": "6\n1\n"}, {"type": "stdin_stdout", "input": "2\n2 1 3 4 5 11 14 11 12 6 12\n3\n0 5 1 2 4 1 4 5 1 2 1\n11", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "2\n2 1 3 4 5 11 14 11 9 6 11\n3\n-1 5 1 2 4 1 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are playing a game on a line with $n$ cells. There are $n$ cells labeled from $1$ through $n$. For each $i$ from $1$ to $n-1$, cells $i$ and $i+1$ are adjacent.\n\nAlice initially has a token on some cell on...
[{"type": "stdin_stdout", "input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "50 75\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nВася купил стол, у которого n ножек. Каждая ножка состоит из двух частей, которые соединяются друг с другом. Каждая часть может быть произвольной положительной длины, но гарантируется, что из всех 2n частей возможно соста...
[{"type": "stdin_stdout", "input": "100\n8 7 7 5 2 7 7 5 1 8 6 3 6 7 2 4 4 2 6 8 5 6 5 2 6 1 3 9 5 8 7 6 5 4 8 6 5 5 3 2 6 5 4 9 7 1 5 7 9 5 7 4 1 6 5 8 2 6 6 1 4 2 3 2 3 9 3 8 7 1 2 4 5 7 3 5 5 6 3 8 3 6 1 5 5 3 3 3 8 8 1 4 3 6 7 1 1 2 4 4 7 3 7 7 8 9 5 8 6 6 4 7 4 9 3 4 7 5 2 8 4 1 9 7 9 7 9 6 7 7 9 6 1 1 1 9 9 4 4 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSoroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.\n\nSoroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to p...
[{"type": "stdin_stdout", "input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "\n1\n4\n1\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "1\n4\n1\n3\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeople do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.\n...
[{"type": "stdin_stdout", "input": "133 51\n", "output": "1613157\n1 2 3 4 5 6 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 66...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"...
[{"type": "stdin_stdout", "input": "50\n0\n2\n3\n0\n5\n6\n7\n8\n14\n10\n11\n1\n13\n31\n15\n22\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n54\n13\n29\n30\n31\n32\n39\n60\n9\n37\n37\n38\n39\n40\n1\n42\n43\n44\n45\n46\n22\n48\n60\n50\n", "output": "()()\n(())\n()()()\n(())()\n((()))\n()()()()()\n(())()()()\n((()))()()\n(((()...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $1$ to $n$. For every edge $e$ of this tree, Monocarp has written two number...
[{"type": "stdin_stdout", "input": "15\n10 15\n12 15\n6 15\n8 15\n2 15\n3 15\n10 15\n13 15\n5 15\n7 15\n11 15\n4 14\n1 15\n14 15\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "15\n10 15\n12 15\n6 15\n8 15\n2 15\n3 15\n10 15\n13 15\n5 15\n7 15\n11 15\n4 14\n1 15\n14 15\n", "output": "NO\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCrazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation a_{i}x + b_{i}y + c_{i} = 0, where a_{i} and b_{i} are not both equal to the zero. The roads divide the plane into conne...
[{"type": "stdin_stdout", "input": "841746 527518\n595261 331297\n10\n-946901 129987 670374\n-140388 -684770 309555\n-302589 415564 -387435\n-565799 -72069 -395358\n-523453 -511446 854898\n-846967 -749453 -341866\n-622388 434663 264157\n-638453 625357 344195\n-255265 -676356 -772398\n-824723 -319141 33585\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe city of Kyoto is well-known for its Chinese plan: streets are either North-South or East-West. Some streets are numbered, but most of them have real names.\nCrossings are named after the two streets crossing there, e....
[{"type": "stdin_stdout", "input": "7\nShijo-Kawaramachi\nKarasuma-Imadegawa\nKawaramachi-Imadegawa\nNishioji-Shijo\nKarasuma-Gojo\nTorimaru-Rokujo\nRokujo-Karasuma\n6\nShijo-Karasuma\nImadegawa-Nishioji\nNishioji-Gojo\nShijo-Torimaru\nTorimaru-Gojo\nShijo-Kawabata\n4\n1jo-Midosuji\nMidosuji-2jo\n2jo-Omotesando\nOmotes...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got down to business. In total, there are n tasks for the day and each animal should do each of these task...
[{"type": "stdin_stdout", "input": "19\n895 1302 724 952 340 952 939 1302 724 952 939 340 340 1844 770 976 435 1302 1302\n", "output": "YES\n5 12 13 17 3 9 15 1 7 11 4 6 10 16 2 8 18 19 14\n12 5 13 17 3 9 15 1 7 11 4 6 10 16 2 8 18 19 14\n12 13 5 17 3 9 15 1 7 11 4 6 10 16 2 8 18 19 14\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards ...
[{"type": "stdin_stdout", "input": "4\n20 18 2 18\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "4\n20 18 2 12", "output": "12\n"}, {"type": "stdin_stdout", "input": "4\n139 4 2 5", "output": "136\n"}, {"type": "stdin_stdout", "input": "4\n139 1 2 5", "output": "135\n"}, {"type": "stdin_stdout", "input": "4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEach employee of the \"Blake Techologies\" company uses a special messaging app \"Blake Messenger\". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many user...
[{"type": "stdin_stdout", "input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-e 1-f 1-g 1-a 1-b 1-c 1-d 1-e 1-f 2-g\n1-a 1-b 1-c 1-d 1-e 1-f 1-g\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consi...
[{"type": "stdin_stdout", "input": "ttspivgoupgupvgpusvppogsseueusuglpiugssviuutlvgvugtpovuvspvpipggooplgvgugpogvesppulovugsvuougveiivgvslllviogpvtolepglguuellotpvgevspvoiiggiiplppgosuguvtstttpielteuglspgeoeeuivtptggltoltpgliviotsospvitupiopisoetupvvspooilsopslpoloptigstspoiuutiuvvuvlpplvioitsuvlpvtleveslslovolloogsgpv...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\n\nAs shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line.\n\ng is represented by a sequence of points p1, p2,..., pn...
[{"type": "stdin_stdout", "input": "4\n-2 1\n9 2\n3 5\n0 1\n2\n1 1 1 9\n-1 15 -1 0", "output": "0.257575758\n15.545454545\n"}, {"type": "stdin_stdout", "input": "4\n-1 1\n9 1\n2 5\n0 3\n2\n1 1 1 9\n0 15 -1 0", "output": "3.500000000\n20.994871795\n"}, {"type": "stdin_stdout", "input": "4\n-1 1\n9 1\n2 5\n0 3\n2\n1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a string s of length 3 or greater. No two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi ...
[{"type": "stdin_stdout", "input": "bceab", "output": "Second\n"}, {"type": "stdin_stdout", "input": "bacba", "output": "First\n"}, {"type": "stdin_stdout", "input": "badba", "output": "First\n"}, {"type": "stdin_stdout", "input": "cadba", "output": "First\n"}, {"type": "stdin_stdout", "input": "dadba", "output": "Firs...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke received a positive integer N from Takahashi. A positive integer m is called a favorite number when the following condition is satisfied:\n\n* The quotient and remainder of N divided by m are equal, that is, \\lfloo...
[{"type": "stdin_stdout", "input": "1000010000000", "output": "2716922731275\n"}, {"type": "stdin_stdout", "input": "1000011000000", "output": "3307289212967\n"}, {"type": "stdin_stdout", "input": "1100011000000", "output": "2999416055122\n"}, {"type": "stdin_stdout", "input": "1110011000000", "output": "3146654438234\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find...
[{"type": "stdin_stdout", "input": "1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEach year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. This year's event brough...
[{"type": "stdin_stdout", "input": "10 6 1 48\n239 632\n976 315\n797 112\n1 835\n938 862\n531 884\n422 607\n152 331\n413 677\n622 978\n", "output": "5 3788.56\n10 3673.36\n2 3360.12\n6 3289.08\n4 2606.20\n3 2598.64\n9 2525.24\n7 2315.84\n1 2210.84\n8 1184.72\n"}, {"type": "stdin_stdout", "input": "10 6 1 41\n239 632\n9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nImagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then yo...
[{"type": "stdin_stdout", "input": "100\n1 2 3 4 5 6 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he di...
[{"type": "stdin_stdout", "input": "1000000000 2000000000 2\n", "output": "500000001\n"}, {"type": "stdin_stdout", "input": "200000000 2000000000 1800000011\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1500000000 2000000000 11\n", "output": "10389612\n"}, {"type": "stdin_stdout", "input": "1100000000 200000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nServal is fighting with a monster.\nThe health of the monster is H.\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\nServal wins when the monster's h...
[{"type": "stdin_stdout", "input": "10000 1\n", "output": "10000\n"}, {"type": "stdin_stdout", "input": "10000 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "11000 1", "output": "11000\n"}, {"type": "stdin_stdout", "input": "10010 1", "output": "10010\n"}, {"type": "stdin_stdout", "input": "10001 1", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of n integer numbers a_0, a_1, ..., a_{n} - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.\n\n\n-----Input...
[{"type": "stdin_stdout", "input": "85\n1 2 3 4 5 6 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 72 67 68 69 70 71 72 73 74 119 76 77 78 79 80 81 82 83 84 1\n", "output": "84\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob play ping-pong with simplified rules.\n\nDuring the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the ...
[{"type": "stdin_stdout", "input": "12\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n", "output": "0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n"}, {"type": "stdin_stdout", "input": "12\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n", "output": "0 1\n1 1\n0 7\n0 1\n1 1\n0 7\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProgrammer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are ...
[{"type": "stdin_stdout", "input": "10\ntypedef &void**** youdyfpinzk\ntypeof &youdyfpinzk***\ntypedef &&&&youdyfpinzk****** nfbsgpjzhxzskmxc\ntypeof nfbsgpjzhxzskmxc***\ntypedef &&&void*** puerqioirikxej\ntypeof &puerqioirikxej********\ntypedef &puerqioirikxej******** xzgzsamjdufuyxz\ntypeof &xzgzsamjdufuyxz******\nty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cats. We number them from 1 through N.\n\nEach of the cats wears a hat. Cat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists...
[{"type": "stdin_stdout", "input": "5\n3 4 3 4 3", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5\n3 4 3 3 3", "output": "No\n"}, {"type": "stdin_stdout", "input": "4\n1 0 -1 2", "output": "No\n"}, {"type": "stdin_stdout", "input": "4\n1 0 -1 3", "output": "No\n"}, {"type": "stdin_stdout", "input": "4\n1 1 -1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStepan had a favorite string s which consisted of the lowercase letters of the Latin alphabet. \n\nAfter graduation, he decided to remember it, but it was a long time ago, so he can't now remember it. But Stepan remembers...
[{"type": "stdin_stdout", "input": "200\n200 180 160 140 122 106 92 79 69 60 52 45 38 32 26 20 14 8 4 2 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 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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved.\n\nYou are given an array [a_1, ...
[{"type": "stdin_stdout", "input": "100\n92 42 58 62 24 59 62 100 92 62 54 100 62 82 91 62 100 100 62 100 100 62 92 92 92 62 92 92 62 92 62 92 88 100 100 36 62 92 16 92 62 100 62 92 35 62 100 92 92 62 93 100 100 62 76 100 62 62 92 62 92 50 100 8 7 62 100 18 92 62 92 92 100 62 32 92 92 62 37 76 100 39 62 92 62 41 62 62 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter in that string is divisibl...
[{"type": "stdin_stdout", "input": "12\n12 3\nzazasqzqsasq\n1 2\ny\n1 1\na\n15 5\nabccbaabccbazaa\n16 8\ncadjfdsljfdkljds\n6 2\nbaazaa\n6 3\nbosszb\n6 1\nqwerty\n7 7\ndaaaaaa\n14 2\nacabcbdeffewzc\n18 6\nzzzzzzzzzzzzyyyyyz\n9 4\naabaabbbc\n", "output": "zazasqzqsasq\n-1\na\nabccbaabccbbaac\ncbbbbbbbbccccccc\nbaazbz\nbp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.\n\nThere is a process that takes place on arrays a and b of l...
[{"type": "stdin_stdout", "input": "100\n45 21 34 56 15 0 46 59 40 39 78 83 29 77 19 30 60 39 90 64 11 47 10 47 35 79 30 13 21 31 26 68 0 67 52 43 29 94 100 76 16 61 74 34 62 63 4 41 78 31 77 21 90 2 43 70 53 15 53 29 47 87 33 20 23 30 55 57 13 25 19 89 10 17 92 24 47 6 4 91 52 9 11 25 81 14 82 75 46 49 66 62 28 84 88 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp must pay exactly $n$ burles at the checkout. He has coins of two nominal values: $1$ burle and $2$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than wi...
[{"type": "stdin_stdout", "input": "6\n1001\n42\n0\n131\n1000101010\n12\n", "output": "333 334\n14 14\n0 0\n43 44\n333367004 333367003\n4 4\n"}, {"type": "stdin_stdout", "input": "6\n1001\n42\n0\n131\n1000101010\n0\n", "output": "333 334\n14 14\n0 0\n43 44\n333367004 333367003\n0 0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a rectangular grid of n rows of m initially-white cells each.\n\nArkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and a non-empty subset ...
[{"type": "stdin_stdout", "input": "50 8\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\nVova decided to clean his room. The room can be represented as the coordinate axis $OX$. There are $n$ piles of trash in the room, coordinate of the $i$-th pile is the integer $p_i$. All piles have different coordinates.\...
[{"type": "stdin_stdout", "input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"}, {"type": "stdin_stdout", "input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an easier version of the next problem. In this version, $q = 0$.\n\nA sequence of integers is called nice if its elements are arranged in blocks like in $[3, 3, 3, 4, 1, 1]$. Formally, if two elements are equal, e...
[{"type": "stdin_stdout", "input": "100 0\n6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62 77 91 86 14 25 48 77 83 65 39 61 78 77 45 46 90 74 100 91 86 98 55 5 84 42 91 69 100 4 74 98 60 37 75 44 41 12 15 34 36 1 99 16 7 87 36 26 79 42 41 84 17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one so...
[{"type": "stdin_stdout", "input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe game of Berland poker is played with a deck of $n$ cards, $m$ of which are jokers. $k$ players play this game ($n$ is divisible by $k$).\n\nAt the beginning of the game, each player takes $\\frac{n}{k}$ cards from the...
[{"type": "stdin_stdout", "input": "4\n8 3 2\n4 2 4\n12 6 3\n42 0 7\n", "output": "3\n0\n3\n0\n"}, {"type": "stdin_stdout", "input": "4\n12 3 2\n4 2 4\n9 6 3\n42 0 7\n", "output": "3\n0\n1\n0\n"}, {"type": "stdin_stdout", "input": "4\n8 1 2\n4 2 4\n12 6 3\n66 0 7\n", "output": "1\n0\n3\n0\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an array of integer $a_1, a_2, \\ldots, a_n$. In one operation you can make $a_i := a_i + 1$ if $i < n$ and $a_i \\leq a_{i + 1}$, or $i = n$ and $a_i \\leq a_1$.\n\nYou need to check whether the array $a_1, a_2, \\...
[{"type": "stdin_stdout", "input": "5\n3\n1 2 5\n1 2 5\n2\n2 2\n1 3\n4\n3 4 1 2\n6 4 2 5\n3\n2 4 1\n4 5 3\n5\n1 2 3 4 5\n6 5 6 7 6\n", "output": "YES\nNO\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "1\n4\n1 1 1 1\n40000000 40000000 40000000 40000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not.\n\nA dish Si is called special if it's name (i.e. the...
[{"type": "stdin_stdout", "input": "3\naba\nabac\nabcd\n", "output": "YES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "3\ncdd\n_a_a\n_ed[", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "3\naba\nabac\naacd", "output": "YES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "3\nfda\n`a`a\nb`Ze", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sequence of square brackets is regular if by inserting symbols \"+\" and \"1\" into it, you can get a regular mathematical expression from it. For example, sequences \"[[]][]\", \"[]\" and \"[[][[]]]\" — are regular, at...
[{"type": "stdin_stdout", "input": "100\n[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n", "output": "+- -+\n|+- ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$, consisting of $n$ integers.\n\nEach position $i$ ($1 \\le i \\le n$) of the array is either locked or unlocked. You can take the values on the unlocked positions, rearrange them in any order an...
[{"type": "stdin_stdout", "input": "5\n3\n1 3 2\n0 0 0\n4\n2 -3 4 -1\n1 1 1 1\n7\n-8 4 -2 -6 4 7 1\n1 0 0 0 1 1 0\n5\n0 1 -4 6 3\n0 0 0 1 1\n6\n-1 7 10 4 -8 -1\n1 0 0 0 0 1\n", "output": "3 2 1 \n2 -3 4 -1 \n-8 4 1 -2 4 7 -6 \n1 0 -4 6 3 \n-1 10 7 4 -8 -1 \n"}, {"type": "stdin_stdout", "input": "5\n3\n1 3 2\n0 0 0\n4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S consisting of L and R.\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\nThe character ...
[{"type": "stdin_stdout", "input": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to ...
[{"type": "stdin_stdout", "input": "50 70\n3 3\n80 80\n23 23\n11 11\n87 87\n7 7\n63 63\n61 61\n67 67\n53 53\n9 9\n43 43\n55 55\n27 27\n5 5\n1 1\n99 99\n65 65\n37 37\n60 60\n32 32\n38 38\n81 81\n2 2\n34 34\n17 17\n82 82\n26 26\n71 71\n4 4\n16 16\n19 19\n39 39\n51 51\n6 6\n49 49\n64 64\n83 83\n10 10\n56 56\n30 30\n76 76\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other wor...
[{"type": "stdin_stdout", "input": "100277221476489181970323375139380435110027722147648918197032337513938043511002772214764891819703233751393804351100277221476489181970323375139380435120055444295297836394064675027876087022005544429529783639406467502787608702\n", "output": "1002772214764891819703233751393804351100277221...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Olympic Games in Bercouver are in full swing now. Here everyone has their own objectives: sportsmen compete for medals, and sport commentators compete for more convenient positions to give a running commentary. Today ...
[{"type": "stdin_stdout", "input": "614 163 13\n613 -1796 18\n-749 679 12\n", "output": "-481.72161 -447.61301\n"}, {"type": "stdin_stdout", "input": "614 163 21\n613 -468 18\n-749 679 25\n", "output": "-214.30328 -350.95260\n"}, {"type": "stdin_stdout", "input": "614 163 13\n613 -1029 18\n-749 679 25\n", "output": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second.\n\nNow it's raining, ...
[{"type": "stdin_stdout", "input": "100 50 1\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n21 22\n23 24\n25 26\n27 28\n29 30\n31 32\n33 34\n35 36\n37 38\n39 40\n41 42\n43 44\n45 46\n47 48\n49 50\n51 52\n53 54\n55 56\n57 58\n59 60\n61 62\n63 64\n65 66\n67 68\n69 70\n71 72\n73 74\n75 76\n77 78\n79 80\n81 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMethodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keybo...
[{"type": "stdin_stdout", "input": "10\naaaa\naaaab\naaaa\nbaaaa\na\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\na\nb\naaaaa\naaaa\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaba\naaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that $a$ yuan for $b$ kilos (...
[{"type": "stdin_stdout", "input": "50 37\n78 49\n96 4\n86 118\n28 4\n19 2\n79 43\n79 92\n95 35\n33 60\n54 84\n90 25\n2 19\n53 21\n86 52\n72 25\n6 8\n41 46\n3 68\n42 89\n33 48\n57 43\n99 45\n1 126\n38 62\n11 50\n55 84\n1 97\n12 67\n51 96\n51 7\n1 100\n79 61\n66 54\n97 93\n52 75\n80 41\n98 73\n29 28\n73 108\n24 73\n3 25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSunuke received a d-dimensional hypercube with a side length of l1 × ... × ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and...
[{"type": "stdin_stdout", "input": "5\n12\n27\n15\n17\n149\n123", "output": "867510000\n"}, {"type": "stdin_stdout", "input": "5\n12\n34\n15\n17\n149\n119", "output": "998784000\n"}, {"type": "stdin_stdout", "input": "5\n12\n34\n15\n23\n149\n119", "output": "300622393\n"}, {"type": "stdin_stdout", "input": "5\n12\n27\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crush_{i}. [Image] \n\nSomeday A...
[{"type": "stdin_stdout", "input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it.\n\nThe player chooses a squa...
[{"type": "stdin_stdout", "input": "8\n2 -1 3 -1 1 4 -1 0", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n3 -1 3 -1 1 4 -1 0", "output": "6\n"}, {"type": "stdin_stdout", "input": "8\n3 -1 3 -1 2 4 -1 0", "output": "6\n"}, {"type": "stdin_stdout", "input": "8\n3 -1 3 -1 0 4 -1 0", "output": "7\n"}, {"type": "s...
code_stdio