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\nOn a chessboard with a width of 10^9 and a height of 10^9, the rows are numbered from bottom to top from 1 to 10^9, and the columns are numbered from left to right from 1 to 10^9. Therefore, for each cell of the chessboar... | [{"type": "stdin_stdout", "input": "0 5\n-1 96762320 34608098\n243235878 312125306 50510976\n326016273 498514053 50510976\n614560077 445224816 25950222\n1077021507 901150398 37242747\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "0 5\n-1 96762320 34608098\n243235878 312125306 50510976\n326016273 498514053 907... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp, Arkady's friend, prepares to the programming competition and decides to write a contest. The contest consists of $n$ problems and lasts for $T$ minutes. Each of the problems is defined by two positive integers $... | [{"type": "stdin_stdout", "input": "2\n4\n1.9585346052548882 31.000\n12 0\n11 6\n30 1\n5 1\n3\n1.360280845492949 30.337801087585063\n0 10\n10 8\n20 8\n", "output": "7\n18\n"}, {"type": "stdin_stdout", "input": "2\n4\n1.557488533293537 31.000\n12 0\n11 6\n30 1\n5 1\n3\n1.360280845492949 30.337801087585063\n0 10\n10 8\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProfessor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.\n\nTheir algorithm will be tested on an array of integers, where the $i$-th i... | [{"type": "stdin_stdout", "input": "100 10\n39 242 238 155 95 30 129 132 72 59 22 91 203 113 99 81 253 204 160 109 92 187 11 227 145 211 100 42 78 14 113 91 140 197 123 182 4 185 208 27 182 207 63 146 102 39 159 195 26 100 72 127 157 159 152 53 0 117 101 125 19 188 179 145 240 50 205 207 113 246 42 56 161 13 188 244 15... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the city of Ultima Thule job applicants are often offered an IQ test. \n\nThe test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black... | [{"type": "stdin_stdout", "input": "####\n.#..\n####\n....\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "....\n....\n....\n....\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "#..#\n.##.\n####\n####\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "#.#.\n.###\n#.#.\n.###\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe hobbits Frodo and Sam are carrying the One Ring to Mordor. In order not to be spotted by orcs, they decided to go through the mountains.\n\nThe mountain relief can be represented as a polyline with n points (x_i, y_i)... | [{"type": "stdin_stdout", "input": "5 9990\n300000 909\n366685 9999\n370849 9998\n379178 9996\n400000 1\n", "output": "25178.6601865589\n"}, {"type": "stdin_stdout", "input": "4 90\n362174 10000\n365957 13123\n373522 9997\n400000 3804\n", "output": "35378.024406478464\n"}, {"type": "stdin_stdout", "input": "4 90\n36217... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNobody knows, but $N$ frogs live in Chef's garden.\nNow they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to $K$.\nChef... | [{"type": "stdin_stdout", "input": "5 3 3\n0 3 8 5 12\n1 2\n1 3\n2 5\n", "output": "Yes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "5 6 3\n0 3 8 8 12\n1 2\n1 3\n2 5", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "5 3 3\n0 3 15 8 12\n1 2\n1 3\n3 5", "output": "Yes\nNo\nYes\n"}, {"type": "stdin_st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n[0, 0]\n[0, 1] [1, 1]\n[0, 2] [1, 2] [2, 2]\n[0, 3] [1, 3] [2, 3] [3, 3]\n[0, 4] [1, 4] [2, 4] [3, 4] [4, 4]\n[0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5]\n[0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6... | [{"type": "stdin_stdout", "input": "6\n16 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n13 23 14 16 15 25\n10\n00 01 11 02 12 30 03 13 36 33", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n11 23 16 16 15 25\n10\n00 01 11 02 12 22 03 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\n1. Get out of the nest with N acorns in his hands.\n2. Go t... | [{"type": "stdin_stdout", "input": "23\n1 2 1\n20 1 10", "output": "920\n"}, {"type": "stdin_stdout", "input": "23\n1 2 4\n10 1 4", "output": "460\n"}, {"type": "stdin_stdout", "input": "23\n1 12 1\n1 1 1", "output": "276\n"}, {"type": "stdin_stdout", "input": "23\n2 11 1\n2 1 2", "output": "506\n"}, {"type": "stdin_st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nTuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things that coins are. He knows that for every coin he can g... | [{"type": "stdin_stdout", "input": "2\n10 16\n14 18", "output": "10\n14\n"}, {"type": "stdin_stdout", "input": "2\n130 45\n4 17", "output": "42\n4\n"}, {"type": "stdin_stdout", "input": "2\n10 4\n21 19", "output": "2\n10\n"}, {"type": "stdin_stdout", "input": "2\n44 45\n2 17", "output": "44\n2\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPaul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.\n\nP... | [{"type": "stdin_stdout", "input": "333 9\nedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedce... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn some other world, today is Christmas.\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n - A level-0 burger is a... | [{"type": "stdin_stdout", "input": "50 4321098765432109\n", "output": "2160549382716056\n"}, {"type": "stdin_stdout", "input": "50 2251799813685246\n", "output": "1125899906842623\n"}, {"type": "stdin_stdout", "input": "50 2251799813685247\n", "output": "1125899906842624\n"}, {"type": "stdin_stdout", "input": "50 22517... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or o... | [{"type": "stdin_stdout", "input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000110000\n0000001001\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n101101001... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLearn, learn and learn again — Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this ... | [{"type": "stdin_stdout", "input": "100\n-88 -5 -96 -45 -11 -81 -68 -58 -73 -91 -27 -23 -89 -34 -51 -46 -70 -95 -9 -77 -99 -61 -74 -98 -88 -44 -61 -88 -35 -71 -43 -23 -25 -98 -23 0 -1 -80 -52 -47 -26 -92 -82 -73 -45 -37 -15 -49 -9 -7 -47 0 -6 -76 -91 -20 -58 -46 -74 -57 -54 -39 -61 -18 -65 -61 -19 -64 -93 -29 -82 -25 -... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. \n\nTotally in Berland there are n citizens, the ... | [{"type": "stdin_stdout", "input": "70\n644488 5444 150441 714420 602059 335330 510670 196555 546346 740011 509449 850947 692874 524857 750434 952985 223744 533151 896124 609694 367352 679050 560202 172728 569291 778616 332116 286927 843598 372698 244906 498046 900681 709791 420904 724593 864493 813094 791377 39998 296... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHongcow likes solving puzzles.\n\nOne day, Hongcow finds two identical puzzle pieces, with the instructions \"make a rectangle\" next to them. The pieces can be described by an n by m grid of characters, where the charact... | [{"type": "stdin_stdout", "input": "1 500\n.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMonocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded ... | [{"type": "stdin_stdout", "input": "6 1000000000\n999999995 999999996 999999997 999999998 999999999 1000000000\n", "output": "5999999991\n"}, {"type": "stdin_stdout", "input": "5 1000000000\n500000000 500000000 500000000 500000000 500000000\n", "output": "2500000001\n"}, {"type": "stdin_stdout", "input": "5 999999999\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is \"Squares\". Today we are visiting his studio to see how his masterpieces are given birth.\n\nAt the center of his studio, there is a h... | [{"type": "stdin_stdout", "input": "1\n5\n0 0\n0 -1\n0 2\n0 3\n12\n0 0\n0 0\n2 0\n3 0\n4 1\n5 1\n6 2\n3 2\n8 2\n9 3\n10 3\n10\n0 2\n1 3\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n3 0\n0", "output": "1 1\n3 2\n4 5\n4 5\n"}, {"type": "stdin_stdout", "input": "1\n5\n0 -1\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 1\n8 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficie... | [{"type": "stdin_stdout", "input": "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n5 25 10000\n2 30 8781\n22 300 5500\n10 117 9000\n7 7 2175\n8\n32 251 2396\n132 281 1659\n222 235 5641\n162 217 1883\n22 158 7195\n194 198 9190\n119 274 1469\n122 334 13708\n0", "output": "30\n21175\n35734\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\nAlso, there is a bus going from Station B to Station C that costs Y yen.\nJoisino got a special ticket. With this ticket, she c... | [{"type": "stdin_stdout", "input": "100 100\n", "output": "150\n"}, {"type": "stdin_stdout", "input": "81 58\n", "output": "110\n"}, {"type": "stdin_stdout", "input": "100 2\n", "output": "101\n"}, {"type": "stdin_stdout", "input": "76 48\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "-1 -17", "output": "-1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\nTo begin with, he is using a plain text editor with this keyboard. This e... | [{"type": "stdin_stdout", "input": "5000\n01000001011101000100001101101111011001000110010101110010000\n", "output": "500886057\n"}, {"type": "stdin_stdout", "input": "5000\n01000001011101010100001101101111011001000110010101110010000", "output": "500886057\n"}, {"type": "stdin_stdout", "input": "5000\n010000010110010101... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDrazil is playing a math game with Varda.\n\nLet's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.\n\nFirst, they choose a decimal number a consisting of n digits that... | [{"type": "stdin_stdout", "input": "15\n989898989898989\n", "output": "777777777777777333333333333333322222222222222222222222222222\n"}, {"type": "stdin_stdout", "input": "15\n999999999999990\n", "output": "77777777777777333333333333333333333333333322222222222222\n"}, {"type": "stdin_stdout", "input": "15\n997953296764... | 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\nTheofanis decided to visit his uncle's farm. There are $s$ animals and $n$ animal pens on the farm. For utility purpose, animal pens are constructed in one row.\n\nUncle told Theofanis that a farm is lucky if you can dist... | [{"type": "stdin_stdout", "input": "4\n1 1 1\n1 1 1\n100 50 200\n56220 47258 14497\n", "output": "YES\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "4\n1 1 1\n1 -1 2\n110 50 200\n56220 47258 14497\n", "output": "YES\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "4\n1 1 1\n1 -1 2\n110 53 200\n56220 47258 14... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem. Refer to the Interaction section below for better understanding.\n\nIthea and Chtholly want to play a game in order to determine who can use the kitchen tonight.\n\n<image>\n\nInitially, It... | [{"type": "stdin_stdout", "input": "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n18\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\n2\n2\n11\n12\n15\n13\n6\n2\n11\n1\n8\n3\n13\n6\n15\n6\n4\n3\n4\n15\n15\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, \"AZ\", \"AA\", \"ZA\" — three distinct two-grams.\n\nYou are given a string $s$ consisting of $n$ capital Latin letters. Your... | [{"type": "stdin_stdout", "input": "100\nURXCAIZFIBNJTPCZHBQIBCILLPXZCFGMKKZMNPLCYGAVJVIBMCZEBSJWPSCPQDYCTTKPOKIJRSKIZPDGCHVOUTMPNECYORSFZFNC\n", "output": "IB\n"}, {"type": "stdin_stdout", "input": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.\n\nThe pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y... | [{"type": "stdin_stdout", "input": "100\n10 12 512917373\n6 9 512917366\n66 44 512917421\n49 18 512917412\n57 96 512917426\n65 72 512917442\n62 59 512917440\n27 77 512917437\n31 13 512917395\n38 39 512917428\n15 72 512917430\n0 69 512917418\n22 22 512917395\n9 69 512917427\n37 96 512917428\n12 23 512917386\n100 90 5129... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day.\n\nToday, the online news thundered with terrible information. The R1... | [{"type": "stdin_stdout", "input": "gerald.agapov1991@gmail.com\n", "output": " 18"}, {"type": "stdin_stdout", "input": "x@x.x@x.x_e_@r1.com\n", "output": " 8"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVanya has a scales for weighing loads and weights of masses w^0, w^1, w^2, ..., w^100 grams where w is some integer not less than 2 (exactly one weight of each nominal value). Vanya wonders whether he can weight an item w... | [{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1100000000 1000000000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "441890232 441890232\n", "output": "YES\n"}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a_1,... | [{"type": "stdin_stdout", "input": "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "output": "TRUTH\n"}, {"type": "stdin_stdout", "input": "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "output": "TRUTH\n"}, {"type": "stdin_stdout", "input": "8 3 6\n5 3 1 1 1 1 1 10\n3 3 1 1 1 1 5 5\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPrint the circumference of a circle of radius R.\n\n-----Constraints-----\n - 1 \\leq R \\leq 100\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nR\n\... | [{"type": "stdin_stdout", "input": "100\n", "output": "628.31853071795865162130\n"}, {"type": "stdin_stdout", "input": "73\n", "output": "458.67252742410977361942\n"}, {"type": "stdin_stdout", "input": "20\n", "output": "125.66370614359172463992\n"}, {"type": "stdin_stdout", "input": "38\n", "output": "238.761041672824... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows: \n - ... | [{"type": "stdin_stdout", "input": "2002\n2017\n", "output": "2032\n"}, {"type": "stdin_stdout", "input": "4500\n-140", "output": "-4780\n"}, {"type": "stdin_stdout", "input": "4500\n-148", "output": "-4796\n"}, {"type": "stdin_stdout", "input": "4500\n-237", "output": "-4974\n"}, {"type": "stdin_stdout", "input": "200... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.\n\nLet $f(x)$ be the number of distinct integers ... | [{"type": "stdin_stdout", "input": "997674659 11231 35496\n", "output": "497677363010575988\n"}, {"type": "stdin_stdout", "input": "881706694 5710 46369\n", "output": "388703347089502553\n"}, {"type": "stdin_stdout", "input": "952549276 31416 33000\n", "output": "1718466614644254\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) h... | [{"type": "stdin_stdout", "input": "3\n3\n011\n5\n10001\n7\n0000000", "output": "0\n1\n7\n"}, {"type": "stdin_stdout", "input": "3\n3\n010\n5\n10001\n7\n0010000", "output": "0\n1\n4\n"}, {"type": "stdin_stdout", "input": "3\n3\n010\n5\n10001\n7\n1010000", "output": "0\n1\n3\n"}, {"type": "stdin_stdout", "input": "3\n3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of $n$ pairs of integers: $(a_1, b_1), (a_2, b_2), \\dots , (a_n, b_n)$. This sequence is called bad if it is sorted in non-descending order by first elements or if it is sorted in non-descending ... | [{"type": "stdin_stdout", "input": "4\n2 3\n1 2\n2 1\n2 4\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "4\n2 3\n1 2\n2 1\n0 4\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "4\n3 3\n2 3\n2 1\n2 4\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "4\n2 3\n4 2\n2 1\n4 4\n", "output": "19\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSherlock and Watson are playing swapping game. Watson gives to Sherlock a string S on which he has performed K swaps. You need to help Sherlock in finding the original string. \nOne swap on a string is performed in this ... | [{"type": "stdin_stdout", "input": "1000000000\nrsiufeylcjcvvyaxuknaxpjmelvugtuymftujsimekkallagxngxgplmdjhkedlsifpuaajfmthxhkgiaogghtukedwkikfspvpsxbxlvhlfrsnshwbqqwcwcbhkondglvylwywuhjbbeqtnpxfhwjgymqjbeoirkhdijddqogrsxoiponylwgkmwvndkvwxgcipflivucqusakhpkunqfcndpsoopourwmakuvfypasplafvvuodwehpwxemmbglpivmfclucemphrl... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challenge to the ABBYY Cup ... | [{"type": "stdin_stdout", "input": "4\n-64322865 -60701256 -53458038 -42593211 -38971602 -31728384 -24485166 -17241948 -2755512 4487706 11730924 18974142 22595751 33460578 40703796 44325405\n", "output": "-39994920\n-60701256 -64322865 44325405 40703796\n-2755512 33460578 -53458038 -17241948\n18974142 -31728384 1173092... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as su... | [{"type": "stdin_stdout", "input": "((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\n))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several ... | [{"type": "stdin_stdout", "input": "hyyhddqhxhekehkwfhlnlsihzefwchzerevcjtokefplholrbvxlltdlafjxrfhleglrvlolojoqaolagtbeyogxlbgfolllslli\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "jhfbndhyzdvhbvhmhmefqllujdflwdpjbehedlsqfdsqlyelwjtyloxwsvasrbqosblzbowlqjmyeilcvotdlaouxhdpoeloaovb\n", "output": "YES\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.\n\nSimple garlands consisting of several lamps c... | [{"type": "stdin_stdout", "input": "100\n25 100 32 34 25 99 19 99 84 52 20 83 34 12 59 89 51 86 5 63 57 2 61 23 48 27 90 28 29 65 31 73 40 79 89 29 18 86 49 14 48 84 100 17 65 79 37 71 52 47 98 100 40 20 71 94 90 53 41 54 47 2 40 36 35 63 14 66 35 11 2 97 23 90 26 88 17 79 2 59 12 22 14 61 78 15 7 62 7 38 43 94 43 12 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\nWe will clos... | [{"type": "stdin_stdout", "input": "2 -777", "output": "1556\n"}, {"type": "stdin_stdout", "input": "2 -839", "output": "1680\n"}, {"type": "stdin_stdout", "input": "1 -839", "output": "1679\n"}, {"type": "stdin_stdout", "input": "100 100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "181 21", "output": "139\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have two bottles for holding water.\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\nBottle 2 contains C milliliters of water.\nWe will transfer water from Bottle 2 to Bottl... | [{"type": "stdin_stdout", "input": "20 20 20\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "6 113 -1", "output": "106\n"}, {"type": "stdin_stdout", "input": "6 228 -1", "output": "221\n"}, {"type": "stdin_stdout", "input": "2 228 -1", "output": "225\n"}, {"type": "stdin_stdout", "input": "2 396 -1", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p_1, p_2, ..., ... | [{"type": "stdin_stdout", "input": "20 20\n18 17 2 3 16 15 1 9 12 8 20 11 13 14 4 5 19 7 10 6\n13 15 15\n1 1 1\n2 2 2\n11 14 11\n10 11 10\n2 8 6\n12 18 16\n4 8 8\n2 2 2\n5 11 11\n4 18 9\n5 6 6\n3 20 12\n8 8 8\n6 16 11\n9 18 18\n8 18 17\n1 1 1\n2 6 5\n1 4 3\n", "output": "No\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nNo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a table of size $n \\times m$, initially fully white. Rows are numbered $1$ through $n$ from top to bottom, columns $1$ through $m$ from left to right. Some square inside the table with odd side length was painte... | [{"type": "stdin_stdout", "input": "96 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have some classes at the university.\n\nThere are m working hours during each Berland day, and each ... | [{"type": "stdin_stdout", "input": "4 113 370\n01110100100010110100110000000011001111110000100111111001011001110111110111001011010110000110110010101010110001000\n01101001111110001010001100101100111100111001001001001101110101100110110110001110100010111011101011101110011110100\n0110011000100111101000001010110011110001111... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.\n\nThe three frie... | [{"type": "stdin_stdout", "input": "727\nbaabbabbbababbbbaaaabaabbaabababaaababaaababbbbababbbbbbbbbbaaabaabbbbbbbbaaaabaabbaaabaabbabaa\nddcdcccccccdccdcdccdddcddcddcddddcdddcdcdccddcdddddccddcccdcdddcdcccdccccccdcdcdccccccdccccccdc\nfffeefeffeefeeeeffefffeeefffeefffefeefefeeeffefefefefefefffffffeeeeeffffeefeeeeffffee... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is an administrator of a public page of organization \"Mouse and keyboard\" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to mak... | [{"type": "stdin_stdout", "input": "2\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up $q$ questions about this song. Each question is about a subsegment of the song starting ... | [{"type": "stdin_stdout", "input": "13 7\nsonokhisumiwo\n1 5\n2 10\n7 10\n1 13\n1 8\n1 9\n3 6\n", "output": "74\n125\n62\n191\n110\n131\n48\n"}, {"type": "stdin_stdout", "input": "13 7\nowimusihkooos\n1 7\n2 10\n7 8\n2 13\n2 8\n2 4\n6 9\n", "output": "109\n128\n17\n177\n102\n45\n47\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the ... | [{"type": "stdin_stdout", "input": "10\n-1 1 2 3 2 8 6 7 14 4", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n-1 2 1 5 8 2 8 4 20 0", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n-1 2 1 5 8 4 8 4 20 0", "output": "3\n"}, {"type": "stdin_stdout", "input": "10\n-1 2 1 5 8 4 8 4 17 0", "output": "3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.\n\nThe Berland capital's map is represented by an n × m rectangular table. Each cell of the table on the map repre... | [{"type": "stdin_stdout", "input": "99 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...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkp... | [{"type": "stdin_stdout", "input": "97 -13\n-17 -11 -20 -16 -11 -18 -17 -14 -19 -13 -11 -19 -15 -17 -11 -20 -10 -19 -10 -18 -11 -14 -11 -15 -13 -13 -11 -18 -18 -18 -11 -14 -20 -19 -10 -17 -18 -19 -17 -11 -11 -11 -20 -19 -16 -15 -18 -15 -15 -20 -19 -20 -16 -13 -17 -11 -13 -18 -10 -13 -10 -14 -12 -17 -20 -10 -11 -19 -19 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\n-----... | [{"type": "stdin_stdout", "input": "12 12", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 3\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 10", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "7 10", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "7 12", "output": "Yes\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdot... | [{"type": "stdin_stdout", "input": "100 100\n100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKuro is living in a country called Uberland, consisting of $n$ towns, numbered from $1$ to $n$, and $n - 1$ bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects ... | [{"type": "stdin_stdout", "input": "70 42 32\n25 50\n51 7\n39 61\n1 33\n20 5\n1 70\n1 63\n42 35\n64 16\n1 11\n39 42\n20 54\n11 14\n57 44\n1 59\n55 40\n25 3\n31 18\n38 68\n57 23\n39 57\n28 10\n39 20\n42 26\n58 6\n20 56\n57 2\n13 21\n15 69\n39 64\n1 39\n62 53\n39 13\n1 41\n22 12\n13 30\n68 67\n20 31\n51 15\n57 32\n59 34\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPaul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including ... | [{"type": "stdin_stdout", "input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"type": "stdin_stdout", "input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"type": "stdin_stdout", "input": "10 10 10 1\n1 10\n10 8\n7 4\n7 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nB: Nakajima, let's do that! --Match Peas War -\n\nproblem\n\nNakajima \"Uhh ...\"\n\nIsono \"Nakajima, are you okay?\"\n\nNakajima \"... I feel like I was having an unpleasant dream.\"\n\nIsono \"What kind of dream do you... | [{"type": "stdin_stdout", "input": "5 1\n2 3", "output": "NAKAJIMA\n"}, {"type": "stdin_stdout", "input": "3 1\n1 0", "output": "NAKAJIMA\n"}, {"type": "stdin_stdout", "input": "2 1\n1 2", "output": "NAKAJIMA\n"}, {"type": "stdin_stdout", "input": "3 2\n1 0", "output": "NAKAJIMA\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou will receive 3 points for solving this problem.\n\nManao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein.... | [{"type": "stdin_stdout", "input": "CCCTTCACCCGGATCCAAATCCCTTAGAAATAATCCCCGACGGCGTTGTATCACCTCTGCACTTGTTAGTAAGGTCAGGCGTCCATTACGGAAGAACGTA\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "GCATTACATGGGGGGGTCCTACGAGCCCGGCATCCCGGAAACTAGCCGGTTAATTTGGTTTAAACCCTCCCACCCCGGATTGTAACCCCCCTCATTGGTT\n", "output": "17\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are a programmer on the development team for new recording media. This recording medium can be randomly accessed for reading and erasing data. On the other hand, when writing data, access is always performed in order ... | [{"type": "stdin_stdout", "input": "6\nW 0 2\nW 0 2\nD 0\nW 2 1\nR 3\nR 2\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"type": "stdin_stdout", "input": "6\nW 0 3\nW 0 2\nD 0\nW 2 1\nR 4\nR 1\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"type": "stdin_stdout", "input": "6\nW 0 2\nW 0 2\nD 0\nW 3 1\nR 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe number \"zero\" is called \"love\" (or \"l'oeuf\" to be precise, literally means \"egg\" in French), for example when denoting the zero score in a game of tennis. \n\nAki is fond of numbers, especially those with trai... | [{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 470184984576\n", "output": "33333333333333332\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the... | [{"type": "stdin_stdout", "input": "5\n30 44\n26\n18\n81\n18\n6\n", "output": "56\n"}, {"type": "stdin_stdout", "input": "5\n30 44\n26\n18\n81\n18\n10", "output": "54\n"}, {"type": "stdin_stdout", "input": "5\n30 29\n26\n18\n81\n18\n10", "output": "39\n"}, {"type": "stdin_stdout", "input": "5\n30 29\n26\n18\n81\n18\n19... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA: Information Search\n\nproblem\n\nThe posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example\n\n* Hokkaido: 1, 2, 4, 9\n* Sightseeing: 1, 3, 4, 7\n\n... | [{"type": "stdin_stdout", "input": "4 4\n0 2 10 11\n1 2 4 14", "output": "1 7\n2\n0\n1\n2\n4\n10\n11\n14\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2 5 12\n2 3 4 13", "output": "1 7\n2\n1\n2\n3\n4\n5\n12\n13\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2 4 12\n2 3 4 13", "output": "2 6\n2\n4\n1\n2\n3\n4\n12\n13\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTavas is a strange creature. Usually \"zzz\" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.\n\n<image>\n\nToday Tavas fell asleep in Malekas' place. While he was ... | [{"type": "stdin_stdout", "input": "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcbabacbbaccaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp.\n\nYou... | [{"type": "stdin_stdout", "input": "6 2 3 3\n7 10 50 12 1 8\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "6 2 3 2\n7 10 50 12 1 8\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "6 2 3 2\n5 10 50 12 1 8\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 2 2 2\n5 10 50 12 1 8\n", "output": "6\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDigits Are Not Just Characters\n\nMr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order diff... | [{"type": "stdin_stdout", "input": "2\nfile10\nfi2el0\nfile3", "output": "-\n-\n"}, {"type": "stdin_stdout", "input": "2\nfjle10\nfi2el0\niele3", "output": "-\n+\n"}, {"type": "stdin_stdout", "input": "2\n01eljf\nfi2el0\niele3", "output": "+\n+\n"}, {"type": "stdin_stdout", "input": "2\nflje10\nif3el0\n2elei", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is a harder version of the problem with bigger constraints.\n\nKorney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation [bitwise XOR](https://en.wikipedia.org/wiki/Bitw... | [{"type": "stdin_stdout", "input": "100\n4845 2410 1317 394 2977 1455 2708 1271 2918 1866 4125 534 4055 1726 1819 790 2526 836 4853 4057 1995 3178 2972 3487 3259 4324 3807 895 2308 1513 3213 3480 1131 2807 1343 3231 1277 2683 1559 825 3667 102 1491 2066 4607 1645 3421 1475 3073 2945 3933 1157 378 3238 4123 2901 2840 48... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ ($n \\ge 3$) positive integers. It is known that in this array, all the numbers except one are the same (for example, in the array $[4, 11, 4, 4]$ all numbers except one are eq... | [{"type": "stdin_stdout", "input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "\n2\n1\n5\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "2\n1\n5\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n11... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFennec is fighting with N monsters.\nThe health of the i-th monster is H_i.\nFennec can do the following two actions:\n - Attack: Fennec chooses one monster. That monster's health will decrease by 1.\n - Special Move: Fen... | [{"type": "stdin_stdout", "input": "3 0\n1000000000 1000000000 1000000000\n", "output": "3000000000\n"}, {"type": "stdin_stdout", "input": "3 0\n1000000000 1000000000 1010000000", "output": "3010000000\n"}, {"type": "stdin_stdout", "input": "3 0\n1000000000 1000000000 1110000000", "output": "3110000000\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMomiji has got a rooted tree, consisting of n nodes. The tree nodes are numbered by integers from 1 to n. The root has number 1. Momiji decided to play a game on this tree.\n\nThe game consists of several steps. On each s... | [{"type": "stdin_stdout", "input": "10\n1 2\n2 3\n3 4\n1 5\n2 6\n6 7\n4 8\n6 9\n9 10\n", "output": "3.81666666666666690000\n"}, {"type": "stdin_stdout", "input": "10\n1 2\n2 3\n3 4\n1 5\n2 6\n6 7\n7 8\n6 9\n9 10\n", "output": "3.8166666666666664\n"}, {"type": "stdin_stdout", "input": "10\n1 2\n2 3\n3 4\n1 5\n2 6\n8 7\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses (\"+\") in the line bet... | [{"type": "stdin_stdout", "input": "200 100\n56988719755815575893282254081467698462485803782142631369385180999746639622554559884281193367342283559238834106917388166048020056852911293394377949964185368886333934084399980368238188117302968424219707\n", "output": "295455656\n"}, {"type": "stdin_stdout", "input": "200 99\n9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. \n\nUCDHP stores some s... | [{"type": "stdin_stdout", "input": "6 5 30\n536048 34640 572197 62457 304174\n194764 325606 270468 784237 551632\n10580 294606 63164 543647 531895\n430397 576813 678878 323394 603231\n534567 804015 403517 886087 981939\n518845 962097 609792 877955 88610\nc 1 5\nc 2 5\nc 2 5\nr 5 3\nc 5 2\nc 4 5\nr 6 5\nc 2 1\nr 3 4\nr ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet s be some string consisting of symbols \"0\" or \"1\". Let's call a string t a substring of string s, if there exists such number 1 ≤ l ≤ |s| - |t| + 1 that t = s_l s_{l+1} … s_{l + |t| - 1}. Let's call a substring t ... | [{"type": "stdin_stdout", "input": "99985 45273\n", "output": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n\"QAQ\" is a word to denote an expression of crying. Imagine \"Q\" as eyes with tears and \"A\" as a mouth.\n\nNow Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great... | [{"type": "stdin_stdout", "input": "QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\n", "output": "13174\n"}, {"type": "stdin_stdout", "input": "QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\n", "output": "10420\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: \"There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number\".\n\... | [{"type": "stdin_stdout", "input": "1447\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1127\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1722\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1332\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1261\n", "output": "1\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is e... | [{"type": "stdin_stdout", "input": "40\n14\n10\n55\n120\n199\n61\n150\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n4 29\n3 27\n3 14\n"}, {"type": "stdin_stdout", "input": "40\n14\n10\n55\n120\n269\n61\n150\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n3 31\n3 27\n3 14\n"}, {"type": "stdin_stdout", "input": "40\n14\n10\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.\n\nAfter two hours of playing the game Vova has tracked the monster and ana... | [{"type": "stdin_stdout", "input": "1 1 100\n100 99\n", "output": "9901\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nH... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n$n$ fishermen have just returned from a fishing vacation. The $i$-th fisherman has caught a fish of weight $a_i$.\n\nFishermen are going to show off the fish they caught to each other. To do so, they firstly choose an ord... | [{"type": "stdin_stdout", "input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has $a$ coins, Barbara has $b$ coins and Cerene has $c$ coins. Recently Polycarp has returned from the trip around the wor... | [{"type": "stdin_stdout", "input": "5\n5 3 2 8\n100 101 102 105\n3 2 1 100000000\n10 20 15 14\n101 101 101 3\n", "output": "YES\nYES\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "5\n5 3 2 8\n100 101 102 105\n3 2 1 100000000\n23 20 15 14\n011 101 101 3\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.\n\nThe level you are trying to get through can be represented as a straight line segment from po... | [{"type": "stdin_stdout", "input": "53 1 27 3\n44 28 48 60 29 42 59 32 9 58 3 11 7 53 4 19 37 41 36 52 29 9 24 8 31 39 52 41 37 44 26 37 37 48 6 21 20 42 25 3 33 2 35 39 33 23 10 60 48 4 1 28 21\n1 1 11\n1 1 21\n1 1 3\n1 1 42\n1 1 16\n1 1 32\n1 1 52\n1 1 17\n1 1 39\n1 1 22\n1 1 31\n1 1 50\n1 1 23\n1 1 14\n1 1 41\n1 1 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ dormitories in Berland State University, they are numbered with integers from $1$ to $n$. Each dormitory consists of rooms, there are $a_i$ rooms in $i$-th dormitory. The rooms in $i$-th dormitory are number... | [{"type": "stdin_stdout", "input": "3 10\n1010000000 1000000000 1000000000\n330201655 567869543 1000000000 1000000001 1500000000 1999999999 2000000000 2000000001 2754432345 3000000000\n", "output": "1 330201655\n1 567869543\n1 1000000000\n1 1000000001\n2 490000000\n2 989999999\n2 990000000\n2 990000001\n3 744432345\n3 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the lo... | [{"type": "stdin_stdout", "input": "987654320023456789\n", "output": "29340299842560\n"}, {"type": "stdin_stdout", "input": "987654321123456789\n", "output": "33007837322880\n"}, {"type": "stdin_stdout", "input": "987654321123456780\n", "output": "55657759288320\n"}, {"type": "stdin_stdout", "input": "23490681737975942... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis time around, Baby Ehab will play with permutations. He has $n$ cubes arranged in a row, with numbers from $1$ to $n$ written on them. He'll make exactly $j$ operations. In each operation, he'll pick up $2$ cubes and ... | [{"type": "stdin_stdout", "input": "2 200\n", "output": "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 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 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\nKenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can b... | [{"type": "stdin_stdout", "input": "8 12 5 5\n2 8 685087149 1569714306\n6 1 298270585 209942236\n2 4 346080035 234079976\n1 5 131857300 40131411\n1 8 30723332 173476334\n2 6 447829832 706415811\n1 4 181424400 548830121\n4 4 30593148 195056405\n7 8 211146752 588024753\n1 6 127300821 203530153\n3 1 336869679 115858230\n4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGhosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.\n\nThere are $n$ ghosts in the universe, they move in the $OXY$ plane, each one of them has its own... | [{"type": "stdin_stdout", "input": "10 7 -626288749\n795312099 49439844 266151109\n-1357052512 23740808 624973405\n-513221420 -44452680 -391096559\n-350963348 -5068756 -160670209\n690883790 11897718 3356227\n-509035268 -76541374 -210137445\n-121282138 -32581578 230716703\n491731655 9500548 -13423963\n-665038289 4817024... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n\"Balloons should be captured efficiently\", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipul... | [{"type": "stdin_stdout", "input": "2\n10 100\n100 270\n2\n12 100\n100 280\n3\n100 150\n10 360\n40 450\n3\n100 150\n17 360\n40 440\n2\n100 10\n50 200\n2\n100 100\n50 110\n1\n15 10\n4\n1 10\n2 20\n3 100\n90 200\n0", "output": "OK 220\nOK 200\nOK 260\nOK 246\nNG 1\nNG 2\nNG 1\nOK 188\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlica and Bob are playing a game.\n\nInitially they have a binary string $s$ consisting of only characters 0 and 1.\n\nAlice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice mak... | [{"type": "stdin_stdout", "input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"type": "stdin_stdout", "input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"type": "stdin_stdout", "input": "1\n111111111111101110000000000000000\n", "output": "NET\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nTo the west of the Australian continent is the wide Indian Ocean. Marine researcher JOI is studying the properties of N species of fish in the Indian Ocean.\n\nFor each type of fish, a rectangular parallelepipe... | [{"type": "stdin_stdout", "input": "3 2\n26 58 0 50 135 000\n10 24 20 127 126 60\n40 60 20 90 90 131", "output": "60000\n"}, {"type": "stdin_stdout", "input": "1 1\n20 50 -2 50 70 000\n10 102 11 39 90 40\n75 100 36 102 159 8", "output": "1200\n"}, {"type": "stdin_stdout", "input": "1 1\n20 50 -3 50 70 000\n10 102 11 39... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToad Ivan has $m$ pairs of integers, each integer is between $1$ and $n$, inclusive. The pairs are $(a_1, b_1), (a_2, b_2), \\ldots, (a_m, b_m)$. \n\nHe asks you to check if there exist two integers $x$ and $y$ ($1 \\leq ... | [{"type": "stdin_stdout", "input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 6\n2 7\n2 9\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 7\n2 7\n2 9\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 3\n2 7\n2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.\n\nString ... | [{"type": "stdin_stdout", "input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na\nba\naba\naba\nabacaba\n"}, {"type": "stdin_stdout", "input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n"}, {"type": "stdin_stdout", "input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last t... | [{"type": "stdin_stdout", "input": "70 11 17929\n10313 427 268935 211 197219 148 357 179290 97 358580 475 343 175 221 286864 429 304793 179290 189 363 221 340651 376509 453 251006 141 304793 358580 235 107574 141 358580 167 181 101469 335 286864 171 107574 105 449 358580 286864 161 286864 349 89645 197219 395 358580 23... | 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 \\le ... | [{"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\nThere are n water tanks in a row, i-th of them contains a_i liters of water. The tanks are numbered from 1 to n from left to right.\n\nYou can perform the following operation: choose some subsegment [l, r] (1≤ l ≤ r ≤ n),... | [{"type": "stdin_stdout", "input": "65\n1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 16 19 20 21 22 23 44 25 26 35 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 104 59 60 61 62 63 64\n", "output": "15417.723076923077\n15417.723076923077\n15417.723076923077\n15417.7230769... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a lowercase Latin character (letter), check if it appears in the string ${codeforces}$.\n\n\n-----Input-----\n\nThe first line of the input contains an integer $t$ ($1 \\leq t \\leq 26$) — the number of test cases.\... | [{"type": "stdin_stdout", "input": "26\nq\na\nz\nw\ns\nx\ne\nd\nc\nr\nf\nv\nt\ng\nb\ny\nh\nn\nu\nj\nm\ni\nk\no\nl\np\n", "output": "NO\nNO\nNO\nNO\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "10\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Bitlandians are quite weird people. They have very peculiar customs.\n\nAs is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.\n\nThe ki... | [{"type": "stdin_stdout", "input": "10\n2 658\n5 29\n2 558\n1 1275\n2 1177\n1 1033\n1 247\n-1 4605\n0 1170\n-1 999\n", "output": "AAAAAAAAAA\n"}, {"type": "stdin_stdout", "input": "10\n2 658\n5 66\n2 784\n1 1275\n2 1177\n1 999\n1 247\n-1 4605\n0 1170\n-1 999\n", "output": "AAAAAAAAAA\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation $p_1, p_2, \\dots, p_n$. Recall that sequence of $n$ integers is called a permutation if it contains all integers from $1$ to $n$ exactly once.\n\nFind three indices $i$, $j$ and $k$ such that:... | [{"type": "stdin_stdout", "input": "3\n4\n2 1 4 3\n6\n4 12 1 2 5 3\n5\n5 7 1 2 4\n", "output": "YES\n2 3 4\nYES\n1 2 3\nYES\n1 2 3\n"}, {"type": "stdin_stdout", "input": "3\n4\n2 1 4 3\n6\n4 12 1 2 5 3\n5\n5 8 1 2 4\n", "output": "YES\n2 3 4\nYES\n1 2 3\nYES\n1 2 3\n"}, {"type": "stdin_stdout", "input": "3\n4\n2 1 4 3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\nFind the numbe... | [{"type": "stdin_stdout", "input": "-10 -2", "output": "1.1290058539e-05\n"}, {"type": "stdin_stdout", "input": "-3 -6", "output": "-0.00249895876718\n"}, {"type": "stdin_stdout", "input": "-3 -2", "output": "-0.0246913580247\n"}, {"type": "stdin_stdout", "input": "-5 9", "output": "3.43322753906e-05\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHint\n\n* One grid may be filled more than once\n* Even if it can be represented by one line segment such as '1', it may be represented by two or more line segments.\n\n\n\nSample Input 1\nFormula for Sample Input 1.\n\nS... | [{"type": "stdin_stdout", "input": "23\n1 1 3 1\n3 1 3 3\n3 3 1 3\n1 3 1 5\n1 5 3 5\n5 2 7 2\n7 2 7 4\n7 4 5 4\n5 4 5 6\n5 6 7 6\n11 4 13 4\n13 0 15 0\n15 0 15 4\n18 2 18 2\n21 5 23 5\n21 5 21 7\n21 7 23 7\n23 7 23 8\n23 9 21 9\n24 0 26 0\n24 0 24 4\n24 4 26 4\n26 0 26 4", "output": "-328\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided t... | [{"type": "stdin_stdout", "input": "7\n0 1\n0 2\n2 3\n0 4\n0 5\n0 6", "output": "2071\n"}, {"type": "stdin_stdout", "input": "7\n0 1\n0 2\n1 3\n0 4\n1 5\n0 6", "output": "1303\n"}, {"type": "stdin_stdout", "input": "7\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6", "output": "4683\n"}, {"type": "stdin_stdout", "input": "7\n0 1\n0 2\n0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n$n$ students are taking an exam. The highest possible score at this exam is $m$. Let $a_{i}$ be the score of the $i$-th student. You have access to the school database which stores the results of all students.\n\nYou can ... | [{"type": "stdin_stdout", "input": "27\n1 1\n0\n1 2\n0\n1 5\n0\n1 10\n0\n1 50\n0\n1 100\n0\n1 500\n0\n1 1000\n0\n1 5000\n0\n1 10000\n0\n1 50000\n0\n1 100000\n0\n1 5\n4\n1 5\n5\n1 10\n9\n1 10\n10\n1 100000\n9999\n1 100000\n100000\n1 4999\n386\n1 100000\n1\n4 5\n1 0 0 0\n4 5\n0 1 0 0\n4 5\n0 0 0 0\n4 5\n5 5 5 5\n4 5\n4 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a string S of length N consisting of R, G, and B.\nFind the number of triples (i,~j,~k)~(1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n - S_i \\neq S_j, S_i \\neq S_k, and S_j \\neq S_... | [{"type": "stdin_stdout", "input": "4000\nGBRBRGGRRBRGBBGGRRGBRGGBRGGGBBGRGBRBRGGBGGGGRRGGBGGRGGGGRRGGRRGBBBGGRBGRRBBGGBRRBGGGGGBGGBGGRBBBGBGRGGRBGGRGRRRBRGBBBGGGRRBGRBBGGRGGRGRBGRRBGGRBRGGBBRGBRGRRGGRBGBRGBRGRRBGBRRBGRGBBGBRBGBBRBBGBBGBGGRBBRGRRGGRRBBBBRBBGBBGGRGRBBGGGBGGGGRRBBRGBBBBBRGGGBGGBBBRGRGRBGGGGBGBRGGBRGBRRRB... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIgor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain \"some real funny stuff a... | [{"type": "stdin_stdout", "input": "10110010010001110110110111100100011101101110010100100010110101011001011101111001\n1001000100\n1011001001\n0101100101\n0001110110\n1000101101\n0110110000\n0000010011\n1101111001\n1101010111\n1110010100\n", "output": "13739427\n"}, {"type": "stdin_stdout", "input": "0001010110111011010... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. \n\nLet B be the sum of elements ... | [{"type": "stdin_stdout", "input": "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.