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 n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.\n\nEach of the employees belong...
[{"type": "stdin_stdout", "input": "100\nRDRRDRDDDDRDRRDDRDRRDDRRDDRRRDRRRDDDRDDRDDRRDRDRRRDRDRRRDRRDDDRDDRRRDRDRRRDDRDRDDDDDDDRDRRDDDDDDRRDD\n", "output": "D\n"}, {"type": "stdin_stdout", "input": "100\nRRDRRDDDDDDDRDRRRDRDRDDDRDDDRDDRDRRDRRRDRRDRRRRRRRDRRRRRRDDDRRDDRRRDRRRDDRRDRRDDDDDRRDRDDRDDRRRDRRDD\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes t...
[{"type": "stdin_stdout", "input": "20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "927799753\n"}, {"type": "stdin_stdout", "input": "20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "927799753\n"}, {"type": "stdin_stdout", "input": "10\n4 10 -1 1 6 8 9 2 -1 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasily the Programmer loves romance, so this year he decided to illuminate his room with candles.\n\nVasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smar...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "1001\n"}, {"type": "stdin_stdout", "input": "1000 1000\n", "output": "1001\n"}, {"type": "stdin_stdout", "input": "1000 2\n", "output": "1999\n"}, {"type": "stdin_stdout", "input": "1000 3\n", "output": "1499\n"}, {"type": "stdin_stdout", "input": "1000 4\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEve is a beginner stand-up comedian. Her first show gathered a grand total of two spectators: Alice and Bob.\n\nEve prepared $a_1 + a_2 + a_3 + a_4$ jokes to tell, grouped by their type:\n\ntype 1: both Alice and Bob like...
[{"type": "stdin_stdout", "input": "15\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.\n\nAt the start of the day they have x ice cream packs. Since the ice cream is free, pe...
[{"type": "stdin_stdout", "input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n", "output": "7000000000 0\n"}, {"type": "stdin_stdout", "input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n", "output": "7000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of length $n$ consisting of integers. You can apply the following operation, consisting of several steps, on the array $a$ zero or more times:\n\nyou select two different numbers in the array $a...
[{"type": "stdin_stdout", "input": "5\n6\n1 6 1 1 4 4\n2\n1 2\n2\n1 1\n5\n4 5 4 5 4\n6\n2 3 2 1 3 1\n", "output": "\n0\n0\n2\n1\n0\n"}, {"type": "stdin_stdout", "input": "5\n6\n1 6 1 1 4 4\n2\n1 2\n2\n1 1\n5\n4 5 4 5 4\n6\n2 3 2 1 3 1\n", "output": "0\n0\n2\n1\n0\n"}, {"type": "stdin_stdout", "input": "5\n6\n2 6 1 1 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors...
[{"type": "stdin_stdout", "input": "aaaaaaaaabbbbbaaaabaaaaaaaaaaaaaaaaabaaaaaabbbbbbbaaabbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "bbbbbbbbbbbbbbbbbbbbbbddddddddddddddddaaaaaaaaaaaaaccccccccbbbbbbbaaaaaaaaaabbbbbbbbaaaaaaaaaacccccc\n", "output": "11\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a positive integer N.\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n - Operation: if K divides N, replace N with N/K; otherwise, r...
[{"type": "stdin_stdout", "input": "1000000000000\n", "output": "266\n"}, {"type": "stdin_stdout", "input": "523968956449\n", "output": "385\n"}, {"type": "stdin_stdout", "input": "145329450841\n", "output": "289\n"}, {"type": "stdin_stdout", "input": "642507465600\n", "output": "12\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring a New Year special offer the \"Sudislavl Bars\" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar \"Mosquito Shelter\". Of course, all the promoco...
[{"type": "stdin_stdout", "input": "58\n145410\n686144\n766870\n859775\n922809\n470967\n034349\n318920\n019664\n667953\n295078\n908733\n691385\n774622\n325695\n443254\n817406\n984471\n512092\n635832\n303546\n189826\n128551\n720334\n569318\n377719\n281502\n956352\n758447\n207280\n583935\n246631\n160045\n452683\n594100\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given sequence $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ which is sorted by ascending order, find a specific value $k$ given as a query.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $1 \\leq q \\leq 200,000$\n* $0 ...
[{"type": "stdin_stdout", "input": "4\n-1 0 1 4\n3\n-3\n4\n14", "output": "0\n1\n0\n"}, {"type": "stdin_stdout", "input": "4\n-1 0 1 4\n3\n-2\n4\n14", "output": "0\n1\n0\n"}, {"type": "stdin_stdout", "input": "4\n-1 0 1 4\n3\n-4\n4\n14", "output": "0\n1\n0\n"}, {"type": "stdin_stdout", "input": "4\n-1 0 1 4\n3\n-4\n0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSquirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a1, a2, ..., an are good.\n\nNow she is interested in good sequences. A sequence x1, x2, ..., xk is called good if it s...
[{"type": "stdin_stdout", "input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 354 380 406 418 428 438 442 482 532 536 544 546 554 596 626 642 682 684 704 714 792 804 820 862 880 906 946 954 966 970\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "44\n1 5 37 97 107 147 185 187 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp knows that if the sum of the digits of a number is divisible by $3$, then the number itself is divisible by $3$. He assumes that the numbers, the sum of the digits of which is divisible by $4$, are also somewhat ...
[{"type": "stdin_stdout", "input": "1000\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "1000\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "997\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "997\n", "output": "1003\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \\dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a...
[{"type": "stdin_stdout", "input": "314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170\n", "output": "243\n"}, {"type": "stdin_stdout", "input": "476640020082194381531155118436783393866726953614433851622190777875571135215042541028243752681838573", "output": "259\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote a function $f(x)$ in such a way: we add $1$ to $x$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example, $f(599) = 6$: $599 + 1 = 600 \\rightarrow 60 \\...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "91\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "91\n"}, {"type": "stdin_stdout", "input": "1472811722\n", "output": "57\n"}, {"type": "stdin_stdout", "input": "1660033091\n", "output": "63\n"}, {"type": "stdin_stdout", "input": "11000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.\n\nWe kn...
[{"type": "stdin_stdout", "input": "50\n159 880 1070 1139 1358 1608 1691 1841 2073 2171 2213 2597 2692 2759 2879 2931 3173 3217 3441 4201 4878 5106 5129 5253 5395 5647 5968 6019 6130 6276 6286 6330 6409 6728 7488 7713 7765 7828 7899 8064 8264 8457 8483 8685 8900 8946 8965 9133 9187 9638\n45\n57 159 1070 1139 1391 1608 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the following process. You have a binary string (a string where each character is either 0 or 1) $w$ of length $n$ and an integer $x$. You build a new binary string $s$ consisting of $n$ characters. The $i$-th ch...
[{"type": "stdin_stdout", "input": "3\n100110\n2\n01\n1\n111\n1\n", "output": "011001\n10\n111\n"}, {"type": "stdin_stdout", "input": "3\n100110\n2\n01\n1\n101\n1\n", "output": "011001\n10\n010\n"}, {"type": "stdin_stdout", "input": "3\n100110\n2\n01\n0\n101\n1\n", "output": "011001\n01\n010\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA number is called powerful if it is a power of two or a factorial. In other words, the number $m$ is powerful if there exists a non-negative integer $d$ such that $m=2^d$ or $m=d!$, where $d!=1\\cdot 2\\cdot \\ldots \\cd...
[{"type": "stdin_stdout", "input": "100\n101\n102\n103\n104\n105\n106\n107\n108\n109\n110\n111\n112\n113\n114\n115\n116\n117\n118\n119\n120\n121\n122\n123\n124\n125\n126\n127\n128\n129\n130\n131\n132\n133\n134\n135\n136\n137\n138\n139\n140\n141\n142\n143\n144\n145\n146\n147\n148\n149\n150\n151\n152\n153\n154\n155\n156\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTheatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each fla...
[{"type": "stdin_stdout", "input": "1000000000 1000000000 1\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 987654321 1\n", "output": "987654321000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 989104164 1\n", "output": "989104164000000000\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given an array $b$ of length $n$. Let's define another array $a$, also of length $n$, for which $a_i = 2^{b_i}$ ($1 \\leq i \\leq n$). \n\nValerii says that every two non-intersecting subarrays of $a$ have differen...
[{"type": "stdin_stdout", "input": "2\n6\n4 3 0 1 2 0\n2\n2 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n6\n0 3 0 1 2 0\n2\n2 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n6\n4 3 0 1 2 0\n2\n4 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n6\n4 3 0 1 2 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the b...
[{"type": "stdin_stdout", "input": "A\n", "output": "T\n"}, {"type": "stdin_stdout", "input": "G\n", "output": "C\n"}, {"type": "stdin_stdout", "input": "C\n", "output": "G\n"}, {"type": "stdin_stdout", "input": "T\n", "output": "A\n"}, {"type": "stdin_stdout", "input": "C", "output": "G\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Mr. Kay was browsing a certain SNS as usual, the problem that \"there are people who can solve IQ150 or more\" came to the timeline. Mr. Kay has an IQ of over 150, so he solved the problem in an instant without even ...
[{"type": "stdin_stdout", "input": "2286", "output": "3\n"}, {"type": "stdin_stdout", "input": "1020", "output": "2\n"}, {"type": "stdin_stdout", "input": "1809", "output": "1\n"}, {"type": "stdin_stdout", "input": "2465", "output": "0\n"}, {"type": "stdin_stdout", "input": "4598", "output": "2\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*} fib(n)= \\left \\\\{ \\begin{array}{ll} 1 & (n...
[{"type": "stdin_stdout", "input": "44", "output": "1134903170\n"}, {"type": "stdin_stdout", "input": "44", "output": "1134903170\n"}, {"type": "stdin_stdout", "input": "41", "output": "267914296\n"}, {"type": "stdin_stdout", "input": "42", "output": "433494437\n"}, {"type": "stdin_stdout", "input": "43", "output": "70...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008. Fans have been looking forward to a new title of Everlasting Sa-Ga.\n\nLittle Jimmy is in trouble. He is a seven-year-old boy, ...
[{"type": "stdin_stdout", "input": "10 24\n30 20\n0 0", "output": "a\nb\n"}, {"type": "stdin_stdout", "input": "19 24\n30 20\n0 0", "output": "a\nb\n"}, {"type": "stdin_stdout", "input": "10 3\n11 106\n0 0", "output": "b\nb\n"}, {"type": "stdin_stdout", "input": "10 3\n11 150\n0 0", "output": "b\na\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTanechka is shopping in the toy shop. There are exactly $n$ toys in the shop for sale, the cost of the $i$-th toy is $i$ burles. She wants to choose two toys in such a way that their total cost is $k$ burles. How many way...
[{"type": "stdin_stdout", "input": "100000000000000 100000000000000\n", "output": "49999999999999\n"}, {"type": "stdin_stdout", "input": "100000000000000 100000000000000\n", "output": "49999999999999\n"}, {"type": "stdin_stdout", "input": "100000000010000 100000000000000\n", "output": "49999999999999\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaptain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story...
[{"type": "stdin_stdout", "input": "2\n11405\n58469\n", "output": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has forgotten the password to his mobile phone. The password consists of $4$ digits from $0$ to $9$ (note that it can start with the digit $0$).\n\nMonocarp remembers that his password had exactly two different d...
[{"type": "stdin_stdout", "input": "12\n8\n1 2 3 5 6 7 8 9\n6\n4 5 6 7 8 9\n7\n0 4 5 6 7 8 9\n7\n1 4 5 6 7 8 9\n8\n0 1 4 5 6 7 8 9\n7\n2 4 5 6 7 8 9\n8\n0 2 4 5 6 7 8 9\n8\n1 2 4 5 6 7 8 9\n7\n3 4 5 6 7 8 9\n8\n0 3 4 5 6 7 8 9\n8\n1 3 4 5 6 7 8 9\n8\n2 3 4 5 6 7 8 9\n", "output": "6\n36\n18\n18\n6\n18\n6\n6\n18\n6\n6\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Hedgehog recently remembered one of his favorite childhood activities, — solving puzzles, and got into it with new vigor. He would sit day in, day out with his friend buried into thousands of tiny pieces of the pictur...
[{"type": "stdin_stdout", "input": "20 20\nABBBAAABABAAAAABBABB\nBABABBAABAABBAAABABB\nBABBBAABAABBABBBBABA\nBAAABBAAABABBABBAAAA\nABBAABAABBBBAAABBBAA\nBAAAAAAAABABBAAAAABB\nAAAAAAABABBBBBAABAAB\nABBBBABAABBAAAAABAAA\nBAAAAABBABAAAAABAAAB\nABABAABABBBABBAABBAA\nBAAABBBAAAABBBBBABAA\nAAABBABABAABBABAABAB\nABBABABABABAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThere are $ N $ propositions, named $ 1, 2, \\ cdots, N $, respectively. Also, $ M $ information about the propositions is given. The $ i $ th information is \"$ a_i $$\". Given in the form \"b_i $\", which mea...
[{"type": "stdin_stdout", "input": "211 0\n4 2\n0 3", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInternational Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the mu...
[{"type": "stdin_stdout", "input": "5 5\n1 2 3 2 5\n1 2 1 4 5\n5 5\n2 3 3 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 1 4 5\n3 3\n7 7 7\n7 14 7\n3 3\n2 4 4\n4 3 4\n4 3\n4 0 2 5\n0 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 17 9 9 17 9 9\n9 16 9 9 9 9 9 9 9 3\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 17 20 20 4\n0 0", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nYamano Mifune Gakuen's 1st grade G group is a class where female students carrying misfortune gather. They face various challenges every day with the goal of being happy.\n\nIn their class, they can take practi...
[{"type": "stdin_stdout", "input": "5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 0 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 3\n4 1 1 2\n4 2 1 2", "output": "13\n"}, {"type": "stdin_stdout", "input": "5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 0 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 4\n4 1 1 2\n4 2 0 2", "output": "14\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment $0$ and turn power off at moment $M$. Moreover, the lamp allows...
[{"type": "stdin_stdout", "input": "7 1000000000\n1 10001 10011 20011 20021 40021 40031\n", "output": "999999969\n"}, {"type": "stdin_stdout", "input": "7 1000000000\n3 10001 10011 20011 20021 40021 40031\n", "output": "999999969\n"}, {"type": "stdin_stdout", "input": "7 1000000000\n1 10001 10011 20011 20021 40021 4003...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBackgorund\n\nThe super popular game \"Puzzle & Hexagons\" has finally been released. This game is so funny that many people are addicted to it. There were a number of people who were certified as addicted by doctors beca...
[{"type": "stdin_stdout", "input": "4 5\nBYYGG\nRRRRR\nRRBRR\nYYGGB\n2\n4 1\n3 1", "output": ".....\nBYYBG\n..G..\nYYGBG\n"}, {"type": "stdin_stdout", "input": "4 5\nBYYGG\nRRRRR\nRBRRR\nYYGGB\n2\n3 1\n3 1", "output": ".....\nBYY..\n.B...\nYYB..\n"}, {"type": "stdin_stdout", "input": "4 5\nBYYGG\nRRRRR\nRBRRR\nYYGGB\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as...
[{"type": "stdin_stdout", "input": "19\n11 10 2 12 1 1 9 13 8 40 16 27 18 22 33 1 14 32 12\n", "output": "34\n"}, {"type": "stdin_stdout", "input": "19\n11 10 2 12 1 1 9 13 8 40 8 27 18 22 33 1 14 32 12\n", "output": "34\n"}, {"type": "stdin_stdout", "input": "19\n11 10 6 11 2 1 6 13 8 38 8 27 9 22 18 7 14 20 12\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easier version of the problem. In this version $1 \\le n, m \\le 100$. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers $a=[a_1,a_2,\\dots,a_n]$ of le...
[{"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day you wanted to read something, so you went to your bookshelf to grab some book. But when you saw how messy the bookshelf was you decided to clean it up first.\n\nThere are $n$ books standing in a row on the shelf, ...
[{"type": "stdin_stdout", "input": "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEfim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he de...
[{"type": "stdin_stdout", "input": "320 142\n2704701300865535.432223312233434114130011113220102420131323010344144201124303144444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447444444444444444444444444444444615444444482101673308979557675074444444444444446...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'.\n\nThe period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$...
[{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "1999936805\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "1999936805\n"}, {"type": "stdin_stdout", "input": "1000000000 956817411\n", "output": "1956733985\n"}, {"type": "stdin_stdout", "input": "1000000000 839933539\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJohnny has recently found an ancient, broken computer. The machine has only one register, which allows one to put in there one variable. Then in one operation, you can shift its bits left or right by at most three positio...
[{"type": "stdin_stdout", "input": "10\n10 5\n11 73\n17 21\n1 1\n96 3\n2 128\n0001 1100611139403776\n1000000000000000000 1000000001000000000\n7 1\n10 8\n", "output": "1\n-1\n-1\n0\n2\n2\n-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "10\n10 5\n11 73\n17 18\n1 1\n96 3\n2 128\n0001 1100611139403776\n1000000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all n dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In th...
[{"type": "stdin_stdout", "input": "9983 34\n6626 5976\n4448 3568\n2794 2309\n3741 8806\n4754 129\n2780 9275\n5785 9243\n3915 6159\n2609 4331\n238 6756\n6987 3887\n3384 5711\n4349 5563\n1135 4483\n9151 1584\n1500 766\n1608 4440\n7768 5005\n7205 2360\n9088 2933\n3923 7814\n7538 9372\n7504 165\n5277 1636\n2061 4384\n7668...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a_1, a_2, \\dots, a_n$ consisting of $n$ distinct integers. Count the number of pairs of indices $(i, j)$ such that $i < j$ and $a_i \\cdot a_j = i + j$.\n\n\n-----Input-----\n\nThe first line cont...
[{"type": "stdin_stdout", "input": "3\n2\n3 1\n3\n3 1 5\n5\n3 1 4 10 2\n", "output": "1\n2\n3\n"}, {"type": "stdin_stdout", "input": "3\n2\n2 1\n3\n4 2 5\n5\n3 1 4 10 2\n", "output": "0\n0\n3\n"}, {"type": "stdin_stdout", "input": "3\n2\n3 2\n3\n3 1 5\n5\n3 1 4 10 2\n", "output": "0\n2\n3\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOur bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the fie...
[{"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000 100 -100 1000000000000000000\n", "output": "969796608 969796608\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 1000000001 100 -100 1000000000000000000\n", "output": "599261184 599261185\n"}, {"type": "stdin_stdout", "input": "1000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Dormi received a histogram with $n$ bars of height $a_1, a_2, \\ldots, a_n$ for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he wanted to modify it...
[{"type": "stdin_stdout", "input": "2\n4\n0 16 14 1\n6\n2 1 14 4 0 0\n", "output": "30\n19\n"}, {"type": "stdin_stdout", "input": "2\n4\n0 16 17 1\n6\n2 1 14 4 0 0\n", "output": "33\n19\n"}, {"type": "stdin_stdout", "input": "2\n4\n13 8 15 13\n6\n2 1 7 8 1 0\n", "output": "33\n16\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.\n\nLet's try to make a new task. Firs...
[{"type": "stdin_stdout", "input": "6\nzfnkpxaavrcvqhhkclcuiswawpghlqrlq wnvbzhvsjozlkwxowcvyclmehjkkvkxin\nzkxkvlnovnloxjdydujkjydaegzjypsgrzq dmiilhmkspokltabpvwalijhlitbfp\nldfbfggqsdqethdgkmbcwloluguxiluqjyr fewoondewvndcxticvpiqnvvdhsnzfd\nepokfmixjnawdfgkmqlcyirxuprrvudh xvijbdzqdyjwsyhjucytuxrxuiynxf\nxntrjusjwb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nI chose creature observation as the theme of my free study during the summer vacation and purchased a creature observation kit.\n\nThis creature prefers to live in a three-dimensional grid-like space. Only one ...
[{"type": "stdin_stdout", "input": "5\n00000\n01010\n00000\n00100\n00000\n\n00000\n01010\n00000\n01010\n00000\n\n00000\n00100\n00000\n01010\n00000\n\n00000\n01110\n00000\n00100\n00000\n\n00000\n00000\n00100\n00000\n00000\n\n1 2\n2 3 4\n4\n01110\n00100\n00100\n00100\n01110\n\n01110\n10001\n10000\n10001\n01110\n\n11111\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nwHAT DO WE NEED cAPS LOCK FOR?\n\nCaps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had...
[{"type": "stdin_stdout", "input": "cTKDZNWVYRTFPQLDAUUNSPKTDJTUPPFPRXRSINTVFVNNQNKXWUZUDHZBUSOKTABUEDQKUIVRTTVUREEOBJTSDKJKVEGFXVHXEYPE\n", "output": "Ctkdznwvyrtfpqldauunspktdjtuppfprxrsintvfvnnqnkxwuzudhzbusoktabuedqkuivrttvureeobjtsdkjkvegfxvhxeype\n"}, {"type": "stdin_stdout", "input": "KETAXTSWAAOBKUOKUQREHIOMVMM...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi and Aoki will have a battle using their monsters.\nThe health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.\nThe two monsters will take tur...
[{"type": "stdin_stdout", "input": "100 1 100 1\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "85 7 30 19\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "85 7 23 19\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "38 11 7 79\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "45 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA stowaway and a controller play the following game. \n\nThe train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially ...
[{"type": "stdin_stdout", "input": "50 42 13\nto head\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\n", "output": "Controller 61\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVolodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.\n\nVolodya calls a string powerful if it starts with \"heavy\" a...
[{"type": "stdin_stdout", "input": "trueheavymetalissotruewellitisalsosoheavythatyoucanalmosteeeltheweightofmetalonyou\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "trueheavymetalissotrufwellitisalsosoheavythatyoucanalmosteeeltheweightofmetalonyou\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "uoyn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn recent years John has very successfully settled at his new job at the office. But John doesn't like to idly sit around while his code is compiling, so he immediately found himself an interesting distraction. The point ...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000 1000000000000000000\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000 1000000000000000000\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNow Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. \n\nAs a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers...
[{"type": "stdin_stdout", "input": "100\n0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 1\n1 2 3 4 2 6 5 5 4 8 10 8 1 14 5 16 3 11 13 11 12 8 11 22 8 17 19 5 15 27 14 13...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is about to assemble a character figure, consisting of N parts called Part 1, Part 2, ..., Part N and N-1 connecting components. Parts are distinguishable, but connecting components are not.\nPart i has d_i hole...
[{"type": "stdin_stdout", "input": "44242\n1 2 1 1 3 2 2 1 1 2 1 1 3 3 2 1 3 3 1 1 2 4 2 1 3 3 1 2 1 4 2 1 4 1 1 3 1 1 1 2 3 1 3 1 1 3 2 2 2 1 2 2 2 2 3 1 3 2 2 2 2 2 2 1 4 3 1 2 1 2 2 1 2 5 1 1 3 5 2 2 1 3 6 2 1 2 1 1 3 1 1 1 1 4 1 2 2 1 1 1 2 1 2 3 1 4 1 1 1 2 2 3 1 1 1 2 3 1 1 4 1 1 2 2 2 4 2 3 1 1 2 3 2 2 2 2 2 2 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind \\displaystyle{\\sum_{a=1}^{K}\\sum_{b=1}^{K}\\sum_{c=1}^{K} \\gcd(a,b,c)}.\nHere \\gcd(a,b,c) denotes the greatest common divisor of a, b, and c.\n\n-----Constraints-----\n - 1 \\leq K \\leq 200\n - K is an integer....
[{"type": "stdin_stdout", "input": "200\n", "output": "10813692\n"}, {"type": "stdin_stdout", "input": "199\n", "output": "10611772\n"}, {"type": "stdin_stdout", "input": "198\n", "output": "10493367\n"}, {"type": "stdin_stdout", "input": "197\n", "output": "10290813\n"}, {"type": "stdin_stdout", "input": "196\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a small restaurant there are a tables for one person and b tables for two persons. \n\nIt it known that n groups of people come today, each consisting of one or two people. \n\nIf a group consist of one person, it is s...
[{"type": "stdin_stdout", "input": "30 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "30 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "20 4 3\n2 2 2 2 2 2 2 2 1 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives...
[{"type": "stdin_stdout", "input": "rdtevvmiqmfgvafkdypxjthzhfsbavmhgkavkfonscaokdxoscenpxrc\nijbvueenzsmgkmkrskjspvfchwkqdglkxnrdtevvmiqmfgvafkdypxjthz\nkqdglkxnrdtevvmiqmfgvafkdypxjthzhfsbavmhgkavkfonscaokdxoscenpxrcivydtkrxjy\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "iefouqzxoyuieqdzalfktehtvdbvjmeu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNauuo is a girl who loves playing cards.\n\nOne day she was playing cards but found that the cards were mixed with some empty ones.\n\nThere are $n$ cards numbered from $1$ to $n$, and they were mixed with another $n$ emp...
[{"type": "stdin_stdout", "input": "20\n0 0 0 0 5 6 7 8 0 0 11 12 13 14 15 16 17 18 0 0\n20 9 19 0 0 0 0 0 0 10 0 0 0 0 0 0 1 2 3 4\n", "output": "37\n"}, {"type": "stdin_stdout", "input": "20\n15 10 6 0 0 11 19 17 0 0 0 0 0 1 14 0 3 4 0 12\n20 7 0 0 0 0 0 0 5 8 2 16 18 0 0 13 9 0 0 0\n", "output": "30\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAncient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as Ahmes arithmet...
[{"type": "stdin_stdout", "input": "((((4?6)?9)?((5?(7?1))?(6?(4?(((((((7?3)?7)?(((((8?(6?7))?((1?2)?(5?8)))?8)?7)?4))?6)?7)?1)?((7?(2?((1?(((8?(((((2?7)?(((((3?6)?3)?(((((9?5)?7)?(1?(5?5)))?(8?((3?(1?2))?((8?5)?(7?((9?((9?8)?7))?1))))))?1))?1)?(9?2)))?((7?5)?((9?(4?(9?6)))?(8?(((5?7)?2)?(6?(3?8)))))))?(((4?(2?2))?(7?9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIto joined the Kyudo club after entering high school. At first, I had a hard time because the arrow didn't reach the target, but in the fall of my first year of high school, I managed to improve to the point where the arr...
[{"type": "stdin_stdout", "input": "20\n1\n11\n1\n-1\n0\n8\n-2\n1\n0", "output": "12\n-1\n"}, {"type": "stdin_stdout", "input": "20\n1\n10\n1\n-1\n0\n8\n-2\n1\n0", "output": "11\n-1\n"}, {"type": "stdin_stdout", "input": "20\n3\n2\n0\n1\n12\n8\n-1\n-1\n0", "output": "18\n-2\n"}, {"type": "stdin_stdout", "input": "20\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n All cells in a set have the same color. Every two cells in a set share row or column...
[{"type": "stdin_stdout", "input": "5 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day in the IT lesson Anna and Maria learned about the lexicographic order.\n\nString x is lexicographically less than string y, if either x is a prefix of y (and x ≠ y), or there exists such i (1 ≤ i ≤ min(|x|, |y|)),...
[{"type": "stdin_stdout", "input": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the length of the string.\n\nYou are given a string $s$ and a string $t$, both consisting only of lowercase Latin letters. It is guaranteed that $t$ can be obtained fr...
[{"type": "stdin_stdout", "input": "izoiweukqszkkhwapzxyotbaarpqxbybsjxilhylbbjbvoedrezyluaabsfzvtxxvncdwxrlfdtfvbfoqwlzqwneimwzpoygfdcldmxdhoxzensxlspituzocvzzrfomhggrwurdccgfoorvhyzsdkpjhwakuoxwdjhzaalanyzwuuqwlrtmvmdraleyusjqdyxuztvc\nizoiweukqszkkhwapzxyotbaarpqxbybsjxilhylbbjbvoedrezyluaabsfzvtxxvncdwxrlfdtfvbfoqw...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNathan O. Davis is challenging a kind of shooter game. In this game, enemies emit laser beams from outside of the screen. A laser beam is a straight line with a certain thickness. Nathan moves a circular-shaped machine wi...
[{"type": "stdin_stdout", "input": "100 100 1 1\n78 1 50 100 21\n640 295 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "100 100 1 0\n78 1 50 100 21\n640 295 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "100 100 1 0\n78 1 50 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nPrepare the Othello board. The upper left is $ (1,1) $ and the lower right is $ (8,8) $. The board to be prepared here is $ (5,4) as follows. ) There is no $ black stone.\n\n\n........\n........\n........\n... ...
[{"type": "stdin_stdout", "input": "3\n1 1 10 1\n2 4 6 8\n6 3 8 8", "output": "10\n19\n15\n"}, {"type": "stdin_stdout", "input": "3\n1 1 10 1\n2 4 6 8\n8 3 8 8", "output": "10\n19\n6\n"}, {"type": "stdin_stdout", "input": "3\n1 1 10 1\n2 4 6 8\n8 3 8 4", "output": "10\n19\n2\n"}, {"type": "stdin_stdout", "input": "3\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:\n\n Each digit is represented with number of '1' characte...
[{"type": "stdin_stdout", "input": "89\n11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "89\n11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111\n", "output": "999999999\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.\n\nYou can perform zero or more operations of the following type: \n\n...
[{"type": "stdin_stdout", "input": "20\n53 86 76 100 16 12 13 97 79 23 28 64 42 10 23 56 59 76 48 12\n48 49 49 49 48 49 48 49 49 49 48 48 48 49 49 49 49 49 49 48\n", "output": "YES\n19\n14 1 4\n14 16 7\n14 17 10\n14 12 15\n14 3 2\n6 3 25\n6 18 11\n20 18 16\n20 9 20\n7 9 10\n7 2 25\n5 2 12\n5 8 20\n10 8 25\n15 8 3\n15 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call the set of positive integers $S$ correct if the following two conditions are met:\n\n$S \\subseteq \\{1, 2, \\dots, n\\}$;\n\nif $a \\in S$ and $b \\in S$, then $|a-b| \\neq x$ and $|a-b| \\neq y$.\n\nFor the g...
[{"type": "stdin_stdout", "input": "1000000000 22 22\n", "output": "500000006\n"}, {"type": "stdin_stdout", "input": "1000000000 21 22\n", "output": "488372094\n"}, {"type": "stdin_stdout", "input": "1000000000 20 22\n", "output": "476190480\n"}, {"type": "stdin_stdout", "input": "455678451 22 17\n", "output": "2219971...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left ...
[{"type": "stdin_stdout", "input": "ABBAAAABBBB\nBBABAAAABAABAB\nBAABABBBABBBBBAAA\nBABABAAABBAAABBAAAAB\nABAAAABBBBBABAABABBAAAAABBBBBB\nBBBBAABBAABBBBABAAABAABBAABBAA\n", "output": "BAABABBBABBBBBAAA.............\nA...............B.............\nB...............A.............\nA...............A.............\nB..........
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout th...
[{"type": "stdin_stdout", "input": "100 100\n52 93 36 69 49 37 48 42 63 27 16 60 16 63 80 37 69 24 86 38 73 15 43 65 49 35 39 98 91 24 20 35 12 40 75 32 54 4 76 22 23 7 50 86 41 9 9 91 23 18 41 61 47 66 1 79 49 21 99 29 87 94 42 55 87 21 60 67 36 89 40 71 6 63 65 88 17 12 89 32 79 99 34 30 63 33 53 56 10 11 66 80 73 50...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th w...
[{"type": "stdin_stdout", "input": "15\n18 6 33 21 14 20 13 9 18 20 28 13 19 25 21\n", "output": "10 -1 11 8 6 6 0 -1 2 2 3 -1 -1 0 -1 "}, {"type": "stdin_stdout", "input": "15\n18 6 33 21 14 20 20 9 18 20 28 13 19 25 21\n", "output": "10 -1 11 8 6 6 5 -1 2 2 3 -1 -1 0 -1 "}, {"type": "stdin_stdout", "input": "15\n18 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTraining is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.\n\nToday's training is to perform a very large number of calculations to improve the calc...
[{"type": "stdin_stdout", "input": "3\n0\n0\n1000000010", "output": "1000000010\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n0\n0\n1000000000", "output": "1000000000\n0\n0"}, {"type": "stdin_stdout", "input": "4\n11\n5\n10\n10", "output": "5\n10\n10\n11\n"}, {"type": "stdin_stdout", "input": "4\n11\n5\n19\n10", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a non-negative integer N, define S(N) as the sum of the odd digits of N\nplus twice the sum of the even digits of N.\nFor example, S(5)=5, S(456)=2*4+5+2*6=25, and S(314159)=3+1+2*4+1+5+9=27.\nDefine D(N) as the last ...
[{"type": "stdin_stdout", "input": "3\n0 10\n34 453\n517800 1591348", "output": "46\n1890\n4830969\n"}, {"type": "stdin_stdout", "input": "3\n0 10\n16 252\n314159 1591348", "output": "46\n1065\n5747356\n"}, {"type": "stdin_stdout", "input": "3\n1 10\n28 297\n314159 559966", "output": "46\n1207\n1106130\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is a holiday season, and Koala is decorating his house with cool lights! He owns $n$ lights, all of which flash periodically.\n\nAfter taking a quick glance at them, Koala realizes that each of his lights can be descri...
[{"type": "stdin_stdout", "input": "70\n0010011111011101101111000111101011010101000011000000010100010101010001\n3 1\n1 5\n3 1\n4 1\n3 3\n2 4\n2 1\n5 1\n2 4\n5 2\n5 2\n4 1\n2 5\n2 2\n4 2\n5 1\n1 2\n2 4\n3 1\n1 1\n5 3\n5 2\n3 5\n4 4\n2 1\n3 2\n1 3\n5 1\n3 4\n2 3\n1 5\n4 1\n2 2\n5 1\n3 3\n4 2\n1 4\n5 2\n1 2\n4 1\n1 4\n5 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\nInitially, there is no ball placed.\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n - Place A blue balls a...
[{"type": "stdin_stdout", "input": "984159202374430527 552558592232591693 265756112319848958\n", "output": "718403090054581569\n"}, {"type": "stdin_stdout", "input": "994914121424164663 818665214162491101 129546857230076861\n", "output": "865367264194087802\n"}, {"type": "stdin_stdout", "input": "501719768609305159 370...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains n ski junctions, numbered from 1 to n. Init...
[{"type": "stdin_stdout", "input": "2 40\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "output": "0\n1\n3\n7\n15\n31\n63\n127\n255\n511\n1023\n2047\n4095\n8191\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reverses a given string str.\n\n\n\nInput\n\nstr (the size of str ≤ 20) is given in a line.\n\nOutput\n\nPrint the reversed str in a line.\n\nExample\n\nInput\n\nw32nimda\n\n\nOutput\n\nadmin23w\n\nT...
[{"type": "stdin_stdout", "input": "w32njmda", "output": "admjn23w\n"}, {"type": "stdin_stdout", "input": "admjn23w", "output": "w32njmda\n"}, {"type": "stdin_stdout", "input": "acmjn23w", "output": "w32njmca\n"}, {"type": "stdin_stdout", "input": "3cmjn2aw", "output": "wa2njmc3\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJoe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.\n\nJoe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty...
[{"type": "stdin_stdout", "input": "20 20\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\nAt the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishin...
[{"type": "stdin_stdout", "input": "16\n203671 381501\n58867 59732\n817520 962123\n125391 163027\n601766 617692\n381501 444610\n761937 817520\n16 10551\n21096 38291\n718073 761937\n583868 601766\n554859 731755\n678098 718073\n962123 992003\n163027 203671\n87917 96397\n", "output": "1\n12 "}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nImagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors from bottom to top with integers from 1 to n. Now you're on the floor number a. You are very...
[{"type": "stdin_stdout", "input": "5000 2081 3619 5000\n", "output": "557114846\n"}, {"type": "stdin_stdout", "input": "5000 2314 1234 5000\n", "output": "546628648\n"}, {"type": "stdin_stdout", "input": "5000 1031 4782 5000\n", "output": "981271392\n"}, {"type": "stdin_stdout", "input": "5000 4998 5000 5000\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s.\n\nLet's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in...
[{"type": "stdin_stdout", "input": "justamassivetesttocheck\nhowwellyouhandlemodulooperations\n", "output": "\n667387032\n"}, {"type": "stdin_stdout", "input": "justamassivetestsocheck\nhowwellyouhandlemodulooperations\n", "output": "732028571\n"}, {"type": "stdin_stdout", "input": "kcehcostsetevissamatsuj\nhowwellyouh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, \"Play with Tsukuro\". This time I will make a box with sticks, but I would like to see if I can ma...
[{"type": "stdin_stdout", "input": "0 1 1 4 11 16 3 2 0 0 5 13", "output": "no\n"}, {"type": "stdin_stdout", "input": "0 1 1 4 11 16 6 2 0 0 5 13", "output": "no\n"}, {"type": "stdin_stdout", "input": "0 1 1 4 11 16 6 2 1 0 5 13", "output": "no\n"}, {"type": "stdin_stdout", "input": "0 1 1 4 2 20 6 2 2 0 13 13", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA queen is the strongest chess piece. In modern chess the queen can move any number of squares in any horizontal, vertical or diagonal direction (considering that there're no other pieces on its way). The queen combines t...
[{"type": "stdin_stdout", "input": "10 20\n6 10\n3 10\n10 4\n5 3\n9 4\n10 1\n10 3\n10 7\n8 5\n7 2\n4 7\n5 1\n2 9\n5 5\n6 6\n9 8\n2 10\n9 10\n1 4\n7 4\n", "output": "0 0 4 9 4 1 2 0 0\n"}, {"type": "stdin_stdout", "input": "100 10\n97 5\n53 35\n92 86\n54 95\n98 13\n36 23\n55 56\n96 94\n25 96\n49 31\n", "output": "6 4 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teac...
[{"type": "stdin_stdout", "input": "|||||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||||||||||||||||||||||||||||||||||||||||=||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n", "output": "||||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPrint all the integers that satisfies the following in ascending order:\n - Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\n-----Constraints...
[{"type": "stdin_stdout", "input": "0 32 110", "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\n26\n27\n28\n29\n30\n31\n32\n"}, {"type": "stdin_stdout", "input": "8 35 011", "output": "8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n25\n26\n27\n28\n29\n30\n31\n32\n33\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides...
[{"type": "stdin_stdout", "input": "2 7 1\n10 3 10\n100\n3 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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation $p$ of length $n$, and Skynyrd bought an array $a$ of length $m$, consisting of integers from $1$ to $n$. \n\nLynyrd and Skynyrd became bored, s...
[{"type": "stdin_stdout", "input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 5\n2 6\n3 5\n", "output": "110\n"}, {"type": "stdin_stdout", "input": "3 6 3\n2 1 3\n1 1 3 1 2 3\n1 5\n2 6\n3 5\n", "output": "110\n"}, {"type": "stdin_stdout", "input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 5\n3 6\n3 5\n", "output": "100\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFalling Block Puzzle\n\nBlock drop\n\nYou are playing a falling block puzzle. As shown in the figure below, the field of this puzzle has a shape in which cubic cells are arranged in 2 squares x 2 squares in each row, and ...
[{"type": "stdin_stdout", "input": "1 1\n##\n#.\n..\n..\n#.\n..\n1 1\n.#\n#.\n#.\n..\n..\n.#\n2 2\n##\n#.\n##\n#.\n..\n.#\n##\n#.\n.#\n..\n#.\n..\n1 3\n#.\n..\n##\n##\n##\n##\n##\n##\n##\n##\n##\n##\n##\n##\n10 3\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\nHeidi and Doctor Who hopped out of the TARDIS and found themselves at EPFL in 2018. They were surrounded by stormtroopers and Darth Vader was approaching. Miraculously, they managed to escape to a nearby rebel base but th...
[{"type": "stdin_stdout", "input": "1 2\n1156621358\n561572949 6885\n312543334 3629\n", "output": "10514\n"}, {"type": "stdin_stdout", "input": "1 2\n458828651\n209599643 7592\n208642144 8751\n", "output": "16343\n"}, {"type": "stdin_stdout", "input": "1 2\n754725914\n561572949 6885\n312543334 3629\n", "output": "10514...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nConstraints\n\n* 1 ≤ length of the side ≤ 1,0...
[{"type": "stdin_stdout", "input": "3\n-1 -2 0\n0 1 -1\n-2 0 2", "output": "NO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "3\n-1 -2 -1\n0 1 0\n-2 0 2", "output": "NO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "3\n1 1 0\n29 1 -1\n0 1 -1", "output": "YES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "3\n2 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a positive integer extremely round if it has only one non-zero digit. For example, $5000$, $4$, $1$, $10$, $200$ are extremely round integers; $42$, $13$, $666$, $77$, $101$ are not.\n\nYou are given an integer...
[{"type": "stdin_stdout", "input": "5\n9\n42\n13\n100\n111\n", "output": "9\n13\n10\n19\n19\n"}, {"type": "stdin_stdout", "input": "1\n707951\n", "output": "52\n"}, {"type": "stdin_stdout", "input": "1\n99889\n", "output": "45\n"}, {"type": "stdin_stdout", "input": "1\n9123\n", "output": "36\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeen from above, there is a grid-like square shaped like Figure 1. The presence or absence of \"walls\" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts yo...
[{"type": "stdin_stdout", "input": "1111\n00001\n0110\n11111\n1010\n00011\n1010\n01011\n1111", "output": "RRRRDDDDLLLLRULRDRRULRULULDLUDRURRDDDRUUUULLLL\n"}, {"type": "stdin_stdout", "input": "1111\n01001\n0010\n11101\n1110\n00111\n1110\n10001\n1110", "output": "RRRRDDDDUUUULLLDDRURLDRDLLLDRRRLLLURRULLUDRUUL\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are $n$ crossroads in the line in the town, and there is either the bus or the tram station at ...
[{"type": "stdin_stdout", "input": "5\n3 1 1\nBC\n1 0 0\nAB\n4 1 11\nAABBBBAABB\n1 3 1\nBBBBB\n6 1 1\nABABAB\n", "output": "1\n2\n1\n5\n6\n"}, {"type": "stdin_stdout", "input": "5\n2 1 1\nBB\n1 1 1\nAB\n3 2 0\nAABBBBAABB\n5 3 4\nBBBBB\n2 1 1\nABABAB\n", "output": "1\n1\n10\n1\n6\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHighway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divided into $n$ sub-tracks. Yo...
[{"type": "stdin_stdout", "input": "3\n3\n1 2 3\n4\n0 1 1 0\n10\n10 3 1 11 5 2 1 7 19 4\n", "output": "0\n4\n21\n"}, {"type": "stdin_stdout", "input": "3\n3\n1 2 3\n4\n0 1 1 0\n10\n10 3 1 11 5 2 1 7 10 4\n", "output": "0\n4\n24\n"}, {"type": "stdin_stdout", "input": "3\n3\n1 1 3\n4\n1 1 1 0\n10\n16 3 6 11 0 2 1 3 10 4\...
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": "44447774444474477747774774477777474774744744477444447777477477744747477774744444744777777777747777477447744774744444747477744744\n77777474477477747774777777474474477444474777477747747777477747747744474474747774747747444777474444744744444477477777747744747477\n", "output": "37\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves numbers. \n\nHe has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) dig...
[{"type": "stdin_stdout", "input": "1010000000\n", "output": "117\n"}, {"type": "stdin_stdout", "input": "1011000000\n", "output": "171\n"}, {"type": "stdin_stdout", "input": "654885000\n", "output": "698\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "91\n"}, {"type": "stdin_stdout", "input": "101871...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, you found a bot to play \"Rock paper scissors\" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \\dots s_{n}$ of length $n$ where each letter is either R, S or P....
[{"type": "stdin_stdout", "input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"type": "stdin_stdout", "input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"type": "stdin_stdout", "input": "3\nRRRR\nSSP\nS\n", "output": "PPPP\nRRR\nR\n"}, {"type": "stdin_stdout", "input": "3\nQRRR\nRSP\nS\n", "output": "P...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has...
[{"type": "stdin_stdout", "input": "50\n3 60 52 60 60 84 63 40 50 21 39 59 40 15 59 54 5 84 63 23 11 69 27 65 64 8 39 4 89 19 10 45 51 66 69 60 82 25 82 66 86 35 24 64 43 67 35 25 39 82\n50\n57\n46\n44\n70\n74\n98\n36\n48\n76\n52\n86\n40\n28\n56\n73\n64\n78\n21\n37\n54\n33\n93\n16\n18\n66\n75\n62\n77\n81\n96\n31\n41\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the va...
[{"type": "stdin_stdout", "input": "50 15 47\n795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 473967724102502 795366679311762 766773867637913 795366679311762 795366679311762 795366679311762 79...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.\n\nDefine $a$ and $b$ as the lengths of two of the sides in the right ...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1333333336\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "1333333335\n"}, {"type": "stdin_stdout", "input": "999999998\n", "output": "1333333333\n"}, {"type": "stdin_stdout", "input": "999999997\n", "output": "1333333332\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represent...
[{"type": "stdin_stdout", "input": "-565 -444 -419 -421\n30\n363 -249 790\n704 57 999\n-316 -305 119\n-778 -543 373\n-589 466 190\n516 -174 893\n-742 -662 390\n-382 825 1000\n520 -732 909\n-220 -985 555\n-49 -697 396\n-701 -882 520\n-105 227 691\n-113 -470 231\n-503 98 1088\n236 69 759\n150 393 951\n414 381 1000\n1096 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeople in the Tomskaya region like magic formulas very much. You can see some of them below.\n\nImagine you are given a sequence of positive integer numbers p_1, p_2, ..., p_{n}. Lets write down some magic formulas:$q_{i}...
[{"type": "stdin_stdout", "input": "25\n39226529 640445129 936289624 364461191 1096077769 573427707 1919403410 950067229 1217479531 455229458 1574949468 397268319 1267289585 995220637 1920919164 501015483 1815262670 1197059269 86947741 1137410885 667368575 733666398 1536581408 611239452 947487746\n", "output": "2596546...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.\n\nWet Shark ...
[{"type": "stdin_stdout", "input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n885 306\n660 304\n369 371\n798 657\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n885 306\n660 304\n369 371\n798 657\n", "output": "0\n"}, {"type": "stdin_stdou...
code_stdio