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\nTaro is planning a long trip by train during the summer vacation. However, in order for Taro, who is a high school student, to travel as far as possible during the summer vacation, which has only one month, he cannot make...
[{"type": "stdin_stdout", "input": "6 5\n1 2 200 12\n1 4 400 15\n1 5 250 25\n2 4 100 10\n4 5 150 20\n3 5 300 21\n2\n1 5 0\n1 5 0\n0 0", "output": "250\n250\n"}, {"type": "stdin_stdout", "input": "6 14\n1 2 200 10\n2 4 103 22\n2 3 250 13\n2 3 100 10\n4 5 178 10\n3 3 300 30\n2\n2 5 0\n1 5 1\n0 0", "output": "281\n42\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve opera...
[{"type": "stdin_stdout", "input": "1 0\n4\n-153 -1\n8 13\n-1 -1", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 0\n4\n-153 -1\n8 13\n-1 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 0\n4\n-153 -1\n8 13\n-1 0", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 0\n4\n-91 -1\n8 13\n-1 -1", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Denjiro is a science teacher. Today he has just received a specially ordered water tank that will certainly be useful for his innovative experiments on water flow.\n\n<image>\n---\nFigure 1: The water tank\n\nThe size...
[{"type": "stdin_stdout", "input": "2\n5\n15 43\n35 20\n50 45\n70 30\n80 10\n3\n20 3\n34 2\n65 2\n6\n40 5237\n25 1753\n10 18000\n90 7000\n25 15000\n14 22000\n5\n15 40\n23 20\n50 45\n70 43\n80 10\n0\n60 4\n75 1\n3\n60 6000\n17 6000\n85 6000", "output": "24.93809524\n14.60833333\n45.00000000\n0.00000000\n45.00000000\n50....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet’s play a stone removing game.\n\nInitially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one following t...
[{"type": "stdin_stdout", "input": "12 2 3\n100 15522 98\n10000 10000 10000\n0 0 0", "output": "10\n89\n2019\n"}, {"type": "stdin_stdout", "input": "12 2 3\n100 15914 98\n10000 10000 10000\n0 0 0", "output": "10\n16\n2019\n"}, {"type": "stdin_stdout", "input": "12 2 3\n100 15914 98\n10001 10000 10000\n0 0 0", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nScores of Final Examination\n\nI am a junior high school teacher. The final examination has just finished, and I have all the students' scores of all the subjects. I want to know the highest total score among the students...
[{"type": "stdin_stdout", "input": "5 2\n10 14 60 40 50\n15 25 68 85 55\n6 3\n10 20 30 20 46 126\n21 34 11 28 20 0\n27 29 4 11 23 10\n4 2\n1 0 -1 -1\n0 0 0 0\n0 0", "output": "128\n136\n1\n"}, {"type": "stdin_stdout", "input": "5 2\n8 20 34 74 50\n15 25 35 127 55\n6 3\n10 20 30 15 25 15\n21 34 11 52 20 0\n27 15 42 10 3...
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 quickly solve popular puzzles and train your instantaneous powe...
[{"type": "stdin_stdout", "input": "5 10\n..A.......\n.......B..\n..........\n..B.......\n..A.CC....", "output": "4"}, {"type": "stdin_stdout", "input": "5 7\nNBTUUOR\nQT.SZSQ\nASNAGIP\nMBYGDML\nKKLIODP", "output": "14\n"}, {"type": "stdin_stdout", "input": "5 7\nNUTUBOR\nQT.SZRQ\nSANAGIP\nLMDGZBM\nLKKIODP", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember their prefixes and suffixes. For example, you may want to use a word which begins with 'appr' ...
[{"type": "stdin_stdout", "input": "6 7\nappreciate\nappropriate\nacceptance\nace\nacm\nacetylene\nappr iate\na e\na a\nac ce\nace e\nacceptance acceptance\non match", "output": "2\n5\n0\n2\n2\n1\n0\n"}, {"type": "stdin_stdout", "input": "6 7\nappreciate\nappropriate\nacceptance\nace\nacm\nacetylene\nappr eati\na e\na ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nDen, the phone number of Ukunikia Co., Ltd., enters a very long phone number into the phone every day.\nOne day, too tired, Den came up with a surprising idea.\n\"Isn't it even a little easier if you rearrange ...
[{"type": "stdin_stdout", "input": "11\n129483884450", "output": "125\n694\n738\n"}, {"type": "stdin_stdout", "input": "11\n128935478480", "output": "123\n689\n745\n"}, {"type": "stdin_stdout", "input": "11\n18396312558", "output": "124\n857\n369\n"}, {"type": "stdin_stdout", "input": "11\n24764186449", "output": "318\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given three integers $a, b, c$, print the minimum value and the maximum value.\n\nConstraints\n\n* $-1,000,000,000 \\leq a, b, c \\leq 1,000,000,000$\n\nInput\n\nThe input is given in the following format.\n\n\n$a \\;...
[{"type": "stdin_stdout", "input": "-30 -1 -1", "output": "-30 -1\n"}, {"type": "stdin_stdout", "input": "-22 -1 -1", "output": "-22 -1\n"}, {"type": "stdin_stdout", "input": "-22 -2 -2", "output": "-22 -2\n"}, {"type": "stdin_stdout", "input": "-2 10 -1", "output": "-2 10\n"}, {"type": "stdin_stdout", "input": "-2 28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem description\nAs a holiday gift, Tojo received a probability problem. The problem read as follows\nConsider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from left to ri...
[{"type": "stdin_stdout", "input": "2\n2 2\n1 6", "output": "3.000000\n6.000000\n"}, {"type": "stdin_stdout", "input": "2\n-1 21\n-1 13", "output": "19.0\n11.0\n"}, {"type": "stdin_stdout", "input": "2\n0 1\n18 101", "output": "0.0\n118.0\n"}, {"type": "stdin_stdout", "input": "2\n0 13\n-1 13", "output": "12.0\n11.0\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Vasya found a golden ticket — a sequence which consists of n digits a_1a_2... a_n. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example...
[{"type": "stdin_stdout", "input": "100\n0809740931424957283280264749151125408689778966769781910603952566405858112111930579193115510555198933\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100\n4818858843973413173925628155746968198939484726544502550668299768135121284562358161389491805498328723\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPalo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.\n\nLyft has become so popular so that it is now used by all m taxi drivers in the city, who every day...
[{"type": "stdin_stdout", "input": "1 4\n2 4 6 10 15\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"type": "stdin_stdout", "input": "1 4\n2 4 6 10 14\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"type": "stdin_stdout", "input": "1 4\n3 4 6 10 15\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"type": "stdin_stdout", "input": "1 4\n2 4 6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an angle ang. \n\nThe Jury asks You to find such regular n-gon (regular polygon with n vertices) that it has three vertices a, b and c (they can be non-consecutive) with \\angle{abc} = ang or report that the...
[{"type": "stdin_stdout", "input": "69\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "output": "180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nReziba has many magic gems. Each magic gem can be split into M normal gems. The amount of space each magic (and normal) gem takes is 1 unit. A normal gem cannot be split.\n\nReziba wants to choose a set of magic gems and ...
[{"type": "stdin_stdout", "input": "1000000000000000000 100\n", "output": "161502719\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 42\n", "output": "683499162\n"}, {"type": "stdin_stdout", "input": "288230376151711743 100\n", "output": "626842151\n"}, {"type": "stdin_stdout", "input": "1000000000000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-s...
[{"type": "stdin_stdout", "input": "5\n1 0\n1 -1\n0 -1\n-1 0\n-1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n-751115 -16747294\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n-751115 -11499666\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n-751115 -14990265\n", "output": "0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen n distinct positive integers and put all of them in a set S. Now he defines a magical permutation to be:\n\...
[{"type": "stdin_stdout", "input": "69\n1034 414 632 614 62 855 915 385 1098 8 462 1750 1227 960 450 25 1307 578 37 262 482 1143 844 696 1004 1008 70 1137 509 1217 561 557 192 513 792 794 1335 1201 1290 543 698 55 119 536 1088 162 1074 676 246 457 662 595 1054 1252 778 165 703 1222 326 158 145 272 729 381 1087 1261 717...
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\nYou are given two binary strings x and y, which are binary representations of some two integers (let's denote these integers as f(x) and f(y)). You can choose any integer k ≥ 0, calculate the expression s_k = f(x) + f(y) ...
[{"type": "stdin_stdout", "input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010101\n11110000\n", "output": "1\n3\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010100\n11110000\n", "output": "1\n3\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n1010\n11\n10001\n110\n1\n1\n10101010101...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe development of a text editor is a hard problem. You need to implement an extra module for brackets coloring in text.\n\nYour editor consists of a line with infinite length and cursor, which points to the current chara...
[{"type": "stdin_stdout", "input": "21\n(RRRRR)LLLL(RRR)LL(R)\n", "output": "-1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 2 2 2 -1 -1 3 "}, {"type": "stdin_stdout", "input": "11\n'R)R(R)Ra)c\n", "output": "0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1\n"}, {"type": "stdin_stdout", "input": "11\n'R)R(R(Ra)c\n", "output": "0 0 -1 -1 -1 -1 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, Mezo is playing a game. Zoma, a character in that game, is initially at position x = 0. Mezo starts sending n commands to Zoma. There are two possible commands:\n\n * 'L' (Left) sets the position x: =x - 1; \n * ...
[{"type": "stdin_stdout", "input": "13\nLRLLLLRRLLRLR\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "13\nLRLRLLRLLLRLR\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "13\nRLRLLRRLLLLRL\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "13\nLRLRLLRLRLRLL\n", "output": "14\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.\n\nGildong tries so hard to satisfy the customers that he even memorized all custome...
[{"type": "stdin_stdout", "input": "4\n3 0\n5 1 2\n7 2 5\n10 -1 0\n2 12\n4 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n122 -100 -1\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n3 0\n5 1 2\n7 2 5\n10 -1 0\n2 12\n4 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...\n\nThe string s he found is a binary string of length n (i. e. str...
[{"type": "stdin_stdout", "input": "5\n10\n0010111111\n4\n0000\n8\n01011111\n10\n1011010100\n1\n0\n", "output": "000111111\n0000\n0011111\n0\n0\n"}, {"type": "stdin_stdout", "input": "5\n10\n0010111111\n4\n1111\n8\n01011111\n10\n1011010100\n1\n0\n", "output": "000111111\n1111\n0011111\n0\n0\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of length n 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 permutation (2 appears twice in the array) and [1,3,4...
[{"type": "stdin_stdout", "input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n2\n13\n14\n23\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n90\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n69\n50\n51\n52\n53\n80\n55\n56\n57\n58\n59\n51\n61\n62\n103\n64\n65\n66\n67\n68\n69\n72\n71\n72\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning...
[{"type": "stdin_stdout", "input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 4\n- 5\n- 8\n+\n- 6\n+\n- 2\n", "output": "YES\n3 10 9 7 1 8 5 4 6 2\n"}, {"type": "stdin_stdout", "input": "10\n+\n- 3\n+\n+\n+\n+\n- 2\n- 8\n- 9\n- 10\n+\n+\n+\n- 4\n- 10\n- 1\n+\n+\n- 6\n- 4\n", "output": "NO\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence a consisting of n integers a_1, a_2, ..., a_n, and an integer x. Your task is to make the sequence a sorted (it is considered sorted if the condition a_1 ≤ a_2 ≤ a_3 ≤ ... ≤ a_n holds).\n\nTo make...
[{"type": "stdin_stdout", "input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "\n3\n0\n0\n-1\n1\n3\n"}, {"type": "stdin_stdout", "input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 412\n", "output": "3\n0\n0\n-...
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\n * you select two different numbers in the array a_i...
[{"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\n2 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 7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly m letters long. Let's number the names from 1 to n in the order in which they are written.\n\nA...
[{"type": "stdin_stdout", "input": "30 10\nUTNTGOKZYJ\nQHOUHNYZVW\nLTVGHJRZVW\nMZHYHOLZYJ\nERYEUEPZYE\nUZDBFTURYJ\nRVSMQTIZGW\nWDJQHMIRYY\nKCORHQPZYE\nRRPLFOZZVY\nJTXMFNNNYJ\nMVTGGOZZVV\nEHAFFNUZVF\nLBRNWJZNYE\nJVMOHTPZYJ\nWTARFJLZVV\nLVJCWOURVW\nLCLQFJYRVV\nQVBVGNJRYF\nNTZGHOLRYE\nMGQKHOUPYJ\nRRSSBXPZYJ\nRYCRGTLZYJ\nJ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya studies divisibility rules at school. Here are some of them:\n\n * Divisibility by 2. A number is divisible by 2 if and only if its last digit is divisible by 2 or in other words, is even.\n * Divisibility by 3. A...
[{"type": "stdin_stdout", "input": "30 100\n", "output": "2-type\n2\n"}, {"type": "stdin_stdout", "input": "10 100\n", "output": "2-type\n2\n"}, {"type": "stdin_stdout", "input": "10 10\n", "output": "2-type\n1\n"}, {"type": "stdin_stdout", "input": "10 25\n", "output": "2-type\n2\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of peop...
[{"type": "stdin_stdout", "input": "50 50\n6 10\n10 0\n1 9\n8 2\n4 9\n0 7\n2 0\n7 5\n4 8\n13 7\n2 4\n5 6\n6 8\n3 2\n4 6\n7 8\n6 9\n7 7\n7 3\n9 5\n3 10\n7 2\n4 3\n2 0\n6 5\n5 3\n1 7\n1 7\n9 1\n10 4\n10 5\n4 2\n10 10\n0 7\n1 2\n10 1\n1 7\n3 7\n8 7\n5 2\n6 1\n3 1\n4 7\n7 10\n1 5\n10 8\n5 5\n5 1\n3 3\n1 6\n2 1\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got two rectangular tables with sizes na × ma and nb × mb cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will define the element ...
[{"type": "stdin_stdout", "input": "14 28\n1000000010111011101010010101\n1110010011000011000110001001\n0001100110101000010110110011\n0101101011010101110100100101\n0100100101000011011111100010\n0001111000100000101000110101\n1011100111110101000110101010\n1111011011110100100000101000\n0011111101110001010010001110\n1011100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe \"BerCorp\" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of...
[{"type": "stdin_stdout", "input": "100 100\n1 33\n0\n2 35 4\n2 40 78\n1 69\n0\n1 2\n0\n0\n2 81 34\n1 45\n0\n1 87\n1 50\n1 97\n0\n2 100 59\n0\n0\n0\n1 45\n0\n0\n0\n1 6\n1 54\n0\n0\n0\n4 79 96 52 84\n1 86\n0\n0\n0\n0\n0\n0\n0\n0\n3 90 2 80\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n1 2\n0\n1 64\n0\n1 78\n1 82\n0\n0\n0\n0\n0\n1 6\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is impossible to send a le...
[{"type": "stdin_stdout", "input": "21\n280810160 291988863\n760364563 140163983\n16417017 364832782\n400253359 677358550\n597688496 794948223\n400253359 603304541\n589408417 603304541\n385039298 307729574\n293170375 805849550\n140163983 219301181\n732214548 760364563\n307729574 280810160\n131915938 219301181\n4615652 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a cube of size k × k × k, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.\n\nYour task is to paint each of k3 unit cubes one of two colours (black or white...
[{"type": "stdin_stdout", "input": "46\n", "output": "wwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbww\nwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbww\nbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbb\nbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbb\nwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbwwbbww\nwwbbwwbbwwbbwwbbwwbbwwbbww...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDE...
[{"type": "stdin_stdout", "input": "KOROXDDWEUVYWJIXSFPEJFYZJDDUXISOFJTIFJSBTWIJQHMTQWLAGGMXTFALRXYCMGZNKYQRCDVTPRQDBAALTWAXTNLDPYWNSFKE\nNHZGRZFMFQGSAYOJTFKMMUPOOQXWCPPAIVRJHINJPHXTTBWRIYNOHMJKBBGXVXYZDBVBBTQRXTOFLBBCXGNICBKAAGOKAYCCJYCW\nXCXLBESCRBNKWYGFDZFKWYNLFAKEWWGRUIAQGNCFDQXCHDBEQDSWSNGVKUFOGGSPFFZWTXGZQMMFJXDW...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order...
[{"type": "stdin_stdout", "input": "0 10000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "10995116277750000\n"}, {"type": "stdin_stdout", "input": "0 00000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "8551757104850000\n"}, {"type": "stdin_stdout", "input": "0 4499 7885\n10073 0 8400\n8724 2588 0\n40\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. \n\nIn this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the ...
[{"type": "stdin_stdout", "input": "17599 51115547\n", "output": "51106749 102213498 1 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 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor - 1 and floor 1. Every day, tho...
[{"type": "stdin_stdout", "input": "-1000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "-1325769607\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "-1737641826\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "-408490162\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "-41005838...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.\n\nThey will have dinner around some round tables. You want to distribute foxes such that:\n...
[{"type": "stdin_stdout", "input": "178\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKarafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.\n\n<image>\n\nEach Karafs has a positiv...
[{"type": "stdin_stdout", "input": "469 128038 4\n143 914502 747\n74 1244223 74477\n835 246699 1021\n7 477777 444444\n", "output": "-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "469 128038 4\n82 914502 747\n80 1244223 74477\n1360 246699 1021\n7 477777 444444\n", "output": "-1\n-1\n-1\n-1\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has sha...
[{"type": "stdin_stdout", "input": "965 1000\n606 895\n533 394\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "958 1000\n326 461\n836 674\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "993 1000\n201 307\n692 758\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "808 1000\n583 676\n527 416...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe mobile application store has a new game called \"Subway Roller\".\n\nThe protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field cons...
[{"type": "stdin_stdout", "input": "1\n100 26\ns................PPPP.CCCCC..UUUUUU.........YYYQQQQQQQ...GGGGG............MMM.....JJJJ..............\n.OOOOOO....EEE....................................................SSSSSS........LLLLLL......NNNIIII.\n......FFFFFF...VVVV..ZZZBBB...KKKKK..WWWWWWWXXX..RRRRRRR......AAAAADD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are...
[{"type": "stdin_stdout", "input": "200\nNESENEESEESWWWNWWSWSWNWNNWNNESWSWNNWNWNENESENNESSWSESWWSSSEEEESSENNNESSWWSSSSESWSWWNNEESSWWNNWSWSSWWNWNNEENNENWWNESSSENWNESWNESWNESEESSWNESSSSSESESSWNNENENESSWWNNWWSWWNESEENWWWWNWWNWWNENESESSWWSWWSES\nNWNESESSENNNESWNWWSWWWNWSESSSWWNWWNNWSENWSWNENNNWWSWWSWNNNESWWWSSESSWWWSSENWSE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\nYou can preview the image in better quality by the link: [http://assets.codeforces.com/files/656/without-text.png](//assets.codeforces.com/files/656/without-text.png)\n\nInput\n\nThe only line of the input is a...
[{"type": "stdin_stdout", "input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "-1300\n"}, {"type": "stdin_stdout", "input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzyzzzzzzzzzzzzzzzzzz\n", "output": "-1299\n"}, {"type": "stdin_stdout", "input": "zzzzzzyzzzzzzzzzzzzzzzzzzzzzzzzyzzzzzzzzzzzzzzzzzz\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provid...
[{"type": "stdin_stdout", "input": "10 10\n2 52 280 401 416 499 721 791 841 943\n246 348 447 486 507 566 568 633 953 986\n", "output": "244\n"}, {"type": "stdin_stdout", "input": "10 10\n4 52 280 401 416 499 721 791 841 943\n246 348 447 486 507 566 568 633 953 986\n", "output": "242\n"}, {"type": "stdin_stdout", "input...
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 the integer m.\n\nOne should choose some symbols from the given string so that any contiguous subsegment of length m has at least one selected symbol....
[{"type": "stdin_stdout", "input": "5\nvbidtenkzctwzegvahvxyxuspzjgwutolxuatnxyrygnxyjpfjcrguiwklbrrcujgeuveyuarplsegrescvqmynrgtvpcwaqdjjw\n", "output": "aaaabbcccccddeeeeeefggggggghiijjjjjjkklllmnnnnoppppqqrrrrrrrssstttttu\n"}, {"type": "stdin_stdout", "input": "5\nwjjdqawypvtgrncmqvcsergermprauyevcegjtcrrblkwiugrcjf...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInnokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.\n\nInnokentiy doesn't like to drink the...
[{"type": "stdin_stdout", "input": "70000 2748 31589 38411\n", "output": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has the sequence consisting of n integers. Vasya consider the pair of integers x and y k-interesting, if their binary representation differs from each other exactly in k bits. For example, if k = 2, the pair of inte...
[{"type": "stdin_stdout", "input": "100 14\n8192 8192 8192 8192 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8191 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8192 8192 8192 8192 8192 8192 8191 8191 8192 8192 8191 8191 8192 8192 8192 8191 8191 8192 8191 8191 8191 8191 8191 8191 8192 8191 8191 8192 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office.\n\nThe crossroads are connected with m oriented bi...
[{"type": "stdin_stdout", "input": "10 7\n50\n4 7 655\n7 3 220\n3 5 15\n5 10 811\n10 1 490\n1 2 800\n7 10 200\n1 5 377\n1 4 656\n6 4 432\n3 7 563\n1 8 122\n2 9 777\n3 2 157\n5 8 912\n9 8 496\n9 2 740\n3 2 201\n6 7 653\n1 7 554\n6 9 660\n3 2 622\n6 10 227\n9 1 42\n2 6 346\n2 7 944\n3 10 654\n5 2 501\n1 6 786\n3 8 306\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.\n\nTo get rid of the oddity and rec...
[{"type": "stdin_stdout", "input": "100 5\n175 30 124 0 12 111 6 0 119 108 0 38 127 3 151 114 95 54 4 128 91 11 168 120 80 107 18 21 149 169 0 141 195 20 78 157 33 118 17 69 105 130 197 57 74 110 138 84 71 172 132 93 191 44 152 156 24 101 146 26 2 36 143 122 104 42 103 97 39 116 115 0 155 87 53 85 7 43 65 196 136 154 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in ...
[{"type": "stdin_stdout", "input": "150\n0 -2 1 -2 0 0 0 0 -2 0 -2 -1 0 0 2 0 1 -2 1 -1 0 0 0 2 -2 2 -1 0 0 0 -2 0 2 0 1 0 -2 0 -2 -1 -1 -2 -2 2 0 0 1 -2 -2 -1 -2 0 2 1 1 -1 1 0 -2 2 0 0 0 1 -1 0 -2 -1 0 -2 2 1 1 0 0 2 0 0 2 -1 0 0 2 0 2 0 -2 -1 1 -2 1 0 0 -2 -1 -1 0 0 2 -1 -1 -1 -1 -2 0 0 2 -1 -1 1 0 0 1 -1 0 0 -1 2 2...
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\nVlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.\n...
[{"type": "stdin_stdout", "input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n100 1000 1000 1000 1000\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "5\n100 1000 1000 1100 1000\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "5\n100 1000 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be <image> of them.\n\nYou want to draw these segm...
[{"type": "stdin_stdout", "input": "100\n", "output": "2550\n"}, {"type": "stdin_stdout", "input": "68\n", "output": "1190\n"}, {"type": "stdin_stdout", "input": "75\n", "output": "1444\n"}, {"type": "stdin_stdout", "input": "73\n", "output": "1369\n"}, {"type": "stdin_stdout", "input": "70\n", "output": "1260\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Bob comes to you for candies as you are his favorite coder! He wants X candies. You have N bags and the i^th bag contains A[i] candies.\n\nYou can give him a set of one or more bags such that the sum of candies in ...
[{"type": "stdin_stdout", "input": "20 1000\n10 20 15 40 50 60 70 80 113 100 200 300 400 500 1031 914 110 120 130 400", "output": "10 13 14\n"}, {"type": "stdin_stdout", "input": "20 1000\n10 35 30 40 29 107 70 80 113 100 43 26 400 617 356 700 110 120 130 400", "output": "6 8 9 16\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmer cabs has released a scheme through which a user gets a free drive when he shares a reference code with another Amer app user. Given N number of app users, output total number of free drives gained by all of them. Two...
[{"type": "stdin_stdout", "input": "684\n2924\n7062\n7105\n4716\n9111\n6913\n1421\n9429\n2378\n4540\n9243\n544\n2898\n298\n6607\n4585\n1940\n8635\n5490\n8456\n4913\n5788\n9975\n9536\n1810\n5396\n103\n7349\n438\n1916\n1105\n8690\n6767\n1869\n8552\n4652\n5591\n890\n4494\n4695\n3567\n7945\n3752\n7690\n8886\n4504\n5411\n13...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeter visited Big Bazar and he was very delighted to know the Loot offer on marbles. The offer was that, If he buys a marble with price p', then he will get all other marbles whose price lies between [p′,p′+4] (both inclu...
[{"type": "stdin_stdout", "input": "10000\n9849 9230 1777 2478 1745 1296 9825 3102 8646 2739 3434 4276 1177 10690 2252 89 9216 5323 6358 9138 3506 7476 2649 8172 84 885 337 251 7113 5283 2881 3314 4514 4658 2145 2611 5954 1970 5714 952 1061 5500 5228 8591 8552 7480 8680 7769 2804 1390 6907 6310 5218 5908 835 1655 6793 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are N integers A_1,\\ldots,A_N.\n\nFind the sum of A_i \\times A_j over all pairs (i,j) such that 1\\leq i < j \\leq N, modulo (10^9+7).\n\nConstraints\n\n* 2 \\leq N \\leq 2\\times 10^5\n* 0 \\leq A_i \\leq 10^9\n*...
[{"type": "stdin_stdout", "input": "4\n141421356 17320508 22360679 176612", "output": "432841470\n"}, {"type": "stdin_stdout", "input": "4\n141421356 17320508 44188846 176612", "output": "442072669\n"}, {"type": "stdin_stdout", "input": "4\n141421356 15438004 10545868 176612", "output": "309796111\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n* 1 \\leq r \\le...
[{"type": "stdin_stdout", "input": "270", "output": "218700\n"}, {"type": "stdin_stdout", "input": "256", "output": "196608\n"}, {"type": "stdin_stdout", "input": "203", "output": "123627\n"}, {"type": "stdin_stdout", "input": "196", "output": "115248\n"}, {"type": "stdin_stdout", "input": "251", "output": "189003\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi likes the sound when he buys a drink from a vending machine.\n\nThat sound can be heard by spending A yen (the currency of Japan) each time.\n\nTakahashi has B yen. He will hear the sound as many times as he can...
[{"type": "stdin_stdout", "input": "011 -1 106", "output": "-1\n"}, {"type": "stdin_stdout", "input": "001 -1 106", "output": "-1\n"}, {"type": "stdin_stdout", "input": "101 -1 106", "output": "-1\n"}, {"type": "stdin_stdout", "input": "111 -1 33", "output": "-1\n"}, {"type": "stdin_stdout", "input": "001 11 13", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then rep...
[{"type": "stdin_stdout", "input": "abcdefghijklmnopqrstuvwxyz\nunomzpgwdtsjxlcvakerfqhybi", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "zyxwvutsrqponmlkjihgfedcba\nunomzpgwdtsjxlcvakerfqhybi", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "zxywvutsrqponmlkjihgfedcba\nunomzpgwdtsjxlcvakerfqhybi", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\n* Each person simultaneously divides his cookies in half and give...
[{"type": "stdin_stdout", "input": "1390 180 1200", "output": "1\n"}, {"type": "stdin_stdout", "input": "1390 180 2246", "output": "1\n"}, {"type": "stdin_stdout", "input": "1390 180 2625", "output": "0\n"}, {"type": "stdin_stdout", "input": "1390 213 2625", "output": "0\n"}, {"type": "stdin_stdout", "input": "1390 213...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConstruct an N-gon that satisfies the following conditions:\n\n* The polygon is simple (see notes for the definition).\n* Each edge of the polygon is parallel to one of the coordinate axes.\n* Each coordinate is an intege...
[{"type": "stdin_stdout", "input": "8\n90\n90\n270\n90\n90\n90\n270\n90", "output": "0 0\n2 0\n2 1\n3 1\n3 2\n1 2\n1 1\n0 1"}, {"type": "stdin_stdout", "input": "3\n-1\n-4\n-14", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3\n-1\n-1\n-14", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3\n-1\n-2\n-14",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.\n\nShe will concatenate all of the strings in some order, to produce a long string.\n\nAmong all strings that she can produce in this w...
[{"type": "stdin_stdout", "input": "3 3\ndxx\naxx\ndxx", "output": "axxdxxdxx\n"}, {"type": "stdin_stdout", "input": "3 3\ndxx\naxx\nxxd", "output": "axxdxxxxd\n"}, {"type": "stdin_stdout", "input": "3 3\ndxx\nxxa\nxxd", "output": "dxxxxaxxd\n"}, {"type": "stdin_stdout", "input": "3 3\ncxx\nxxa\nxxd", "output": "cxxxxa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYuta is addicted to the popular game \"Beat Panel\" at a nearby arcade. The game consists of a total of 16 panel-type buttons, 4x4, arranged in a grid as shown.\n\n<image>\n\n\nAs shown in the figure, the buttons are arra...
[{"type": "stdin_stdout", "input": "2 2\n0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1\n1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0\n0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1\n1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0\n2 2\n0 0 1 0 1 1 1 1 0 0 1 0 0 0 1 0\n0 1 0 1 0 1 1 1 0 1 0 1 0 0 1 1\n0 0 1 1 1 1 0 0 0 0 1 0 0 0 1 1\n0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0\n5 3\n0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBrave Ponta has finally arrived at the final dungeon. This is a dark wilderness in front of the fort of the evil emperor Boromos, with fairly strong monsters guarding their territories.\n\n<image>\n\n\nFigure 1: Wildernes...
[{"type": "stdin_stdout", "input": "2\n1 1\n5 5\n4\n1.0 1.0317956219670807\n1.5068159031079704 3.2675997669892194\n4.150171138530334 2.1332708795299036\n3.0 3.589169796022375\n1\n2.6727744925703703 2.0\n0", "output": "impossible\n4.57812033\nimpossible\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n5 5\n4\n1.0 1.03179...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose that there are some light sources and many spherical balloons. All light sources have sizes small enough to be modeled as point light sources, and they emit light in all directions. The surfaces of the balloons ab...
[{"type": "stdin_stdout", "input": "12 5 4\n0 10 0 1\n1 3 0 2\n1 4 0 2\n0 0 0 2\n10 0 0 1\n3 -1 0 2\n5 -1 0 2\n10 10 0 15\n-1 -10 0 1\n10 -10 0 1\n-10 -10 0 1\n10 10 0 1\n0 10 0 240\n10 0 0 200\n10 -2 0 52\n-10 0 0 100\n1 0 0 2\n-1 1 0\n12 5 4\n0 10 0 1\n1 5 0 2\n1 4 0 2\n0 0 0 2\n10 0 0 1\n3 -1 0 2\n5 -1 0 2\n10 10 0 ...
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 survived several months of exam wars and were able to enter ICPC University on a sunny day. On the day of admission, there was an enthusiastic recruitment of circles on the campus of the university, and you received a...
[{"type": "stdin_stdout", "input": "9\n315\n0", "output": "2\n11\n"}, {"type": "stdin_stdout", "input": "9\n256\n0", "output": "2\n0\n"}, {"type": "stdin_stdout", "input": "9\n160\n0", "output": "2\n1\n"}, {"type": "stdin_stdout", "input": "9\n213\n0", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "9\n200\n0",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n2 2\n1 2 0\n3 4 1\n\n\nOutput\n\n2\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite Python code to ...
[{"type": "stdin_stdout", "input": "8 0\n-2 0 1\n12 2 12", "output": "680445551\n"}, {"type": "stdin_stdout", "input": "4 0\n-2 0 -1\n12 2 5", "output": "15400\n"}, {"type": "stdin_stdout", "input": "4 0\n-2 0 1\n12 2 10", "output": "15400\n"}, {"type": "stdin_stdout", "input": "4 0\n1 0 1\n9 -1 -1", "output": "15400\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConstraints\n\n* 1 ≤ |V| ≤ 100\n* 0 ≤ |E| ≤ 9900\n* -2 × 107 ≤ di ≤ 2 × 107\n* There are no parallel edges\n* There are no self-loops\n\nInput\n\nAn edge-weighted graph G (V, E).\n\n\n|V| |E|\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-...
[{"type": "stdin_stdout", "input": "15 6\n1 2 2\n1 3 -5\n1 2 3\n1 11 4\n2 0 1\n3 2 12", "output": "0 INF INF INF INF INF INF INF INF INF INF INF INF INF INF\n4 0 3 -5 INF INF INF INF INF INF INF 4 INF INF INF\n1 INF 0 INF INF INF INF INF INF INF INF INF INF INF INF\n13 INF 12 0 INF INF INF INF INF INF INF INF INF INF I...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are standing near a very strange machine. If you put C cents in the machine, the remaining money in your purse will transform in an unusual way. If you have A dollars and B cents remaining in your purse after depositi...
[{"type": "stdin_stdout", "input": "2\n9 72 53\n98 73 69", "output": "125\n27\n"}, {"type": "stdin_stdout", "input": "2\n9 82 69\n98 116 69", "output": "33\n11\n"}, {"type": "stdin_stdout", "input": "2\n9 82 100\n98 116 69", "output": "1\n11\n"}, {"type": "stdin_stdout", "input": "2\n9 90 80\n100 73 69", "output": "125...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nColossal! — exclaimed Hawk-nose. — A programmer! That's exactly what we are looking for.\n\nArkadi and Boris Strugatsky. Monday starts on Saturday\n\nReading the book \"Equations of Mathematical Magic\" Roman Oira-Oira an...
[{"type": "stdin_stdout", "input": "9\n3\n2\n2\n228\n1\n1\n0\n16\n1488\n", "output": "4\n2\n2\n16\n2\n2\n1\n2\n32\n"}, {"type": "stdin_stdout", "input": "9\n2\n1\n2\n228\n1\n6\n8\n16\n1488\n", "output": "2\n2\n2\n16\n2\n4\n2\n2\n32\n"}, {"type": "stdin_stdout", "input": "9\n3\n2\n2\n272\n1\n1\n15\n3\n1488\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHiasat registered a new account in NeckoForces and when his friends found out about that, each one of them asked to use his name as Hiasat's handle.\n\nLuckily for Hiasat, he can change his handle in some points in time. ...
[{"type": "stdin_stdout", "input": "64 2\n1\n1\n2 csxom\n1\n2 csxom\n1\n1\n1\n1\n1\n2 yl\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "61 1\n1\n2 wrlc...
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 y). It is...
[{"type": "stdin_stdout", "input": "01:02\n03:02\n", "output": "02:02\n"}, {"type": "stdin_stdout", "input": "11:10\n11:12\n", "output": "11:11\n"}, {"type": "stdin_stdout", "input": "10:00\n11:00\n", "output": "10:30\n"}, {"type": "stdin_stdout", "input": "09:10\n09:12\n", "output": "09:11\n"}, {"type": "stdin_stdout"...
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 1 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\nAt first, there was a legend related to the name of the problem, but now it's just a formal statement.\n\nYou are given n points a_1, a_2, ..., a_n on the OX axis. Now you are asked to find such an integer point x on OX a...
[{"type": "stdin_stdout", "input": "3\n3 2\n1 2 5\n2 1\n1 1000000000\n1 0\n11\n", "output": "3\n500000000\n11\n"}, {"type": "stdin_stdout", "input": "3\n3 2\n1 2 5\n2 1\n1 1000000000\n1 0\n13\n", "output": "3\n500000000\n13\n"}, {"type": "stdin_stdout", "input": "3\n3 2\n0 2 5\n2 1\n1 1000000000\n1 0\n11\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white...
[{"type": "stdin_stdout", "input": "9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n*.**\n", "output": "0\n0\n0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe problem was inspired by Pied Piper story. After a challenge from Hooli's compression competitor Nucleus, Richard pulled an all-nighter to invent a new approach to compression: middle-out.\n\nYou are given two strings ...
[{"type": "stdin_stdout", "input": "6\n7\ncontest\nntecost\n7\ncontest\nnsttdco\n7\ncontest\ntnsteco\n7\ncontess\ncotestn\n7\ncontest\ncontest\n7\nontestc\ncontest\n", "output": "3\n-1\n4\n-1\n0\n1\n"}, {"type": "stdin_stdout", "input": "6\n7\ncontest\nntecost\n7\ncontest\nnstteco\n7\ncontest\ntnsteco\n7\ncontess\ncote...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string \"one\" or at least one string \"two\" (or both at the s...
[{"type": "stdin_stdout", "input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\nooone\nonnne\noneeeee\noneeeeeeetwooooo\n", "output": "6\n2 6 10 13 18 21 \n1\n2 \n1\n2 \n1\n2 \n1\n5 \n0\n\n1\n4 \n0\n\n1\n2 \n2\n2 11 \n"}, {"type": "stdin_stdout", "input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntw...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka wants to buy some food in the nearby shop. Initially, he has s burles on his card. \n\nMishka can perform the following operation any number of times (possibly, zero): choose some positive integer number 1 ≤ x ≤ s,...
[{"type": "stdin_stdout", "input": "6\n1\n10\n19\n9876\n12345\n1000000000\n", "output": "1\n11\n21\n10973\n13716\n1111111111\n"}, {"type": "stdin_stdout", "input": "6\n1\n10\n33\n9876\n12345\n1000000000\n", "output": "1\n11\n36\n10973\n13716\n1111111111\n"}, {"type": "stdin_stdout", "input": "6\n1\n10\n24\n9876\n12345\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a tree of n vertices. You are going to convert this tree into n rubber bands on infinitely large plane. Conversion rule follows:\n\n * For every pair of vertices a and b, rubber bands a and b should intersect if...
[{"type": "stdin_stdout", "input": "28\n2 24\n2 4\n2 3\n1 2\n1 17\n1 21\n1 22\n10 22\n22 23\n22 26\n25 26\n16 25\n7 26\n5 7\n5 8\n5 15\n5 14\n5 12\n10 20\n11 4\n9 25\n6 9\n12 19\n9 28\n13 14\n18 28\n27 28\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "28\n2 24\n2 4\n2 3\n1 2\n1 17\n1 21\n1 22\n10 22\n22 23\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe call two numbers x and y similar if they have the same parity (the same remainder when divided by 2), or if |x-y|=1. For example, in each of the pairs (2, 6), (4, 3), (11, 7), the numbers are similar to each other, and...
[{"type": "stdin_stdout", "input": "7\n4\n11 14 16 23\n2\n1 8\n4\n1 1 1 1\n4\n1 4 5 6\n2\n12 13\n6\n0 6 3 10 5 8\n6\n1 12 3 10 0 16\n", "output": "YES\nNO\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "7\n4\n11 14 16 12\n2\n1 2\n4\n1 1 1 1\n4\n1 2 5 6\n2\n12 13\n6\n1 6 3 10 9 8\n6\n1 12 3 10 5 14\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n warriors in a row. The power of the i-th warrior is a_i. All powers are pairwise distinct.\n\nYou have two types of spells which you may cast: \n\n 1. Fireball: you spend x mana and destroy exactly k consecut...
[{"type": "stdin_stdout", "input": "23 5\n10 3 4\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 23\n", "output": "64\n"}, {"type": "stdin_stdout", "input": "23 5\n10 3 3\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 23\n", "output": "56\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a_1, a_2 ... a_n. Calculate the number of tuples (i, j, k, l) such that: \n\n * 1 ≤ i < j < k < l ≤ n; \n * a_i = a_k and a_j = a_l; \n\nInput\n\nThe first line contains a single integer t (1 ≤ t ...
[{"type": "stdin_stdout", "input": "2\n5\n2 2 2 2 2\n6\n1 3 3 1 2 3\n", "output": "5\n2\n"}, {"type": "stdin_stdout", "input": "2\n5\n2 2 2 4 2\n6\n1 3 3 1 2 3\n", "output": "1\n2\n"}, {"type": "stdin_stdout", "input": "2\n5\n2 2 3 4 2\n6\n2 3 3 1 2 3\n", "output": "0\n2\n"}, {"type": "stdin_stdout", "input": "2\n5\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n// We decided to drop the legend about the power sockets but feel free to come up with your own :^)\n\nDefine a chain: \n\n * a chain of length 1 is a single vertex; \n * a chain of length x is a chain of length x-1 wit...
[{"type": "stdin_stdout", "input": "100 5000\n101 168 189 84 24 14 195 139 200 76 73 177 95 9 39 117 32 82 166 37 68 70 123 110 119 129 37 35 200 44 149 46 164 6 71 81 159 160 103 184 139 75 92 162 173 10 129 122 37 150 97 60 4 172 73 146 61 167 127 141 163 132 22 102 127 75 5 104 42 101 162 52 195 140 83 134 142 153 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper.\n\nA permutation p is written from left to right on...
[{"type": "stdin_stdout", "input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 23 18 15 4 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "40\n5 29 12 16 25 36 18 37 27 32 34 40 20 3 1 24 26 19 33 9 6 22 8 13 15 21 28 7 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed t...
[{"type": "stdin_stdout", "input": "40\n685 711\n433 403\n703 710\n491 485\n616 619\n288 282\n884 871\n367 352\n500 511\n977 982\n51 31\n576 564\n508 519\n755 762\n22 20\n368 353\n232 225\n953 955\n452 436\n311 330\n967 988\n369 364\n791 803\n150 149\n651 661\n118 93\n398 387\n748 766\n852 852\n230 228\n555 545\n515 51...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOverall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favor...
[{"type": "stdin_stdout", "input": "50 25\n8 18 41 25 16 39 2 47 49 37 40 23 3 35 15 7 11 28 22 48 10 17 38 46 44\n4\nswyzirxhx\n28\n43 32 14 5 0 17 25 39 0 0 36 0 0 34 27 22 6 13 26 0 0 41 12 16 0 0 0 23\nzyn\n3\n36 12 47\np\n33\n38 0 35 0 6 20 43 9 15 37 17 23 2 0 0 0 0 0 34 0 28 10 33 0 5 4 7 12 36 46 0 0 45\nycaqpk...
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\nLittle penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).\n\nLitt...
[{"type": "stdin_stdout", "input": "1000 8\n", "output": "339760446\n"}, {"type": "stdin_stdout", "input": "1000 6\n", "output": "834332109\n"}, {"type": "stdin_stdout", "input": "1000 1\n", "output": "760074701\n"}, {"type": "stdin_stdout", "input": "1000 5\n", "output": "583047503\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nQuite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called \"Black Square\" on his super cool touchscreen phone.\n\nIn this game, the phone's screen is divided into fo...
[{"type": "stdin_stdout", "input": "1809 1302 7164 6122\n3144121413113111223311232232114144321414421243443243422322144324121433444342231344234443332241322442\n", "output": "420780\n"}, {"type": "stdin_stdout", "input": "1809 1302 8936 6122\n3144121413113111223311232232114144321414421243443243422322144324121433444342231...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwilight Sparkle learnt that the evil Nightmare Moon would return during the upcoming Summer Sun Celebration after one thousand years of imprisonment on the moon. She tried to warn her mentor Princess Celestia, but the pr...
[{"type": "stdin_stdout", "input": "10 10\n1 2\n3 1\n4 3\n1 5\n6 5\n7 4\n8 7\n9 5\n10 4\n6 10\n1 0 0 1 1 0 1 1 0 0\n", "output": "33\n8 7 4 10 6 5 9 5 9 5 1 3 1 3 1 2 1 2 1 5 6 5 6 10 6 10 4 10 4 7 8 7 8 \n"}, {"type": "stdin_stdout", "input": "10 10\n1 2\n3 1\n4 3\n1 5\n6 1\n7 4\n8 7\n9 5\n10 4\n6 10\n1 0 0 1 1 0 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m. \n\nWhat is the minimal number of moves making him climb to the t...
[{"type": "stdin_stdout", "input": "10000 10\n", "output": "5000\n"}, {"type": "stdin_stdout", "input": "24634 6\n", "output": "12318\n"}, {"type": "stdin_stdout", "input": "48898 6\n", "output": "24450\n"}, {"type": "stdin_stdout", "input": "26032 9\n", "output": "13023\n"}, {"type": "stdin_stdout", "input": "20108 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the pos...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1000 539\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "999 1000\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1000 999\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "998 1000\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA social network for dogs called DH (DogHouse) has k special servers to recompress uploaded videos of cute cats. After each video is uploaded, it should be recompressed on one (any) of the servers, and only after that it ...
[{"type": "stdin_stdout", "input": "10 10\n999999991 1000000000\n999999992 1000000000\n999999993 1000000000\n999999994 1000000000\n999999995 1000000000\n999999996 1000000000\n999999997 1000000000\n999999998 1000000000\n999999999 1000000000\n1000000000 1000000000\n", "output": "1999999991\n1999999992\n1999999993\n199999...
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\nToday Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first sh...
[{"type": "stdin_stdout", "input": "100000000 100000000 100000000\n", "output": "300000000\n"}, {"type": "stdin_stdout", "input": "73676138 150324676 35182\n", "output": "147422640\n"}, {"type": "stdin_stdout", "input": "73676138 230952454 17921\n", "output": "147388118\n"}, {"type": "stdin_stdout", "input": "73676138 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: \"A lion is never afraid of a hundred sheep\". \n\nNevertheless Shapur has to find weaknesses in ...
[{"type": "stdin_stdout", "input": "97\n800 771 66 126 231 306 981 96 196 229 253 35 903 739 461 962 979 347 152 424 934 586 225 838 103 178 524 400 156 149 560 629 697 417 717 738 181 430 611 513 754 595 847 464 356 640 24 854 138 481 98 371 142 460 194 288 220 41 999 581 441 407 301 651 271 226 457 393 980 166 272 25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA revolution took place on the Buka Island. New government replaced the old one. The new government includes n parties and each of them is entitled to some part of the island according to their contribution to the revolut...
[{"type": "stdin_stdout", "input": "50 50 50 49 26\n205 221 199 178 191 202 180 192 185 204 183 194 215 216 185 200 182 170 190 180 176 204 166 164 194 174\n", "output": "YES\naaaaabbbbccccddddeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrsssstttuuuvvvvwwwwxxxxyyyyzzz\naaaaabbbbccccddddeeffffgggghhhhiiiijjjjkkk...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.\n\nThe area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that...
[{"type": "stdin_stdout", "input": "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 6\n", "output": "INFINITE\n"}, {"type": "stdin_stdout", "input": "10\n>>>>>>>>><\n2 1 1 1 1 1 1 1 1 5\n", "output": "INFINITE\n"}, {"type": "stdin_stdout", "input": "10\n>>>>>>>>>>\n1 1 1 1 1 1 2 1 1 100\n", "output": "FINITE\n"}, {"type": "stdin_std...
code_stdio