messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
2 values
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more comp...
[{"type": "stdin_stdout", "input": "1000000000000000000\n999999998000000000\n999999999000000000\n999999998000000000\n", "output": " 3\n"}, {"type": "stdin_stdout", "input": "1\n1000000000000000000\n1000000000\n999999999\n", "output": " ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.\n\nLet's define a subarray as a segm...
[{"type": "stdin_stdout", "input": "86 30\n16 -12 11 16 8 14 7 -29 18 30 -32 -10 20 29 -14 -21 23 -19 -15 17 -2 25 -22 2 26 15 -7 -12 -4 -28 21 -4 -2 22 28 -32 9 -20 23 38 -21 21 37 -13 -30 25 31 6 18 29 29 29 27 38 -15 -32 32 -7 -8 -33 -11 24 23 -19 -36 -36 -18 9 -1 32 -34 -26 1 -1 -16 -14 17 -17 15 -24 38 5 -27 -12 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nComrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.\n\nIlia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comra...
[{"type": "stdin_stdout", "input": "10000 10000 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 20 10000\n", "output": "500\n"}, {"type": "stdin_stdout", "input": "10000 1 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 10000 10000\n", "output": "1\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.\n\nIn this game there are n objects number...
[{"type": "stdin_stdout", "input": "7000\n7 419 1631 1925 3861 6940 379 493\n29 5389 5925 2923 4696 972 6125 3779 6044 5477 1305 6488 5059 5515 3238 3863 248 6947 4023 6168 1915 6607 2991 2220 2023 200 4457 6398 1017 447\n", "output": "Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.\n\nThough there are lots and lots of victories in history of Berland, there is ...
[{"type": "stdin_stdout", "input": "????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction <image> is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is ...
[{"type": "stdin_stdout", "input": "1000\n", "output": "499 501\n"}, {"type": "stdin_stdout", "input": "1120\n", "output": "559 561\n"}, {"type": "stdin_stdout", "input": "1010\n", "output": "503 507\n"}, {"type": "stdin_stdout", "input": "1200\n", "output": "599 601\n"}, {"type": "stdin_stdout", "input": "1764\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPig is visiting a friend.\n\nPig's house is located at point 0, and his friend's house is located at point m on an axis.\n\nPig can use teleports to move along the axis.\n\nTo use a teleport, Pig should come to a certain ...
[{"type": "stdin_stdout", "input": "70 100\n0 99\n1 87\n1 94\n1 4\n2 72\n3 39\n3 69\n4 78\n5 85\n7 14\n8 59\n12 69\n14 15\n14 76\n17 17\n19 53\n19 57\n19 21\n21 35\n21 83\n24 52\n24 33\n27 66\n27 97\n30 62\n30 74\n30 64\n32 63\n35 49\n37 60\n40 99\n40 71\n41 83\n42 66\n42 46\n45 83\n51 76\n53 69\n54 82\n54 96\n54 88\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNot to be confused with [chessboard](https://en.wikipedia.org/wiki/Chessboard).\n\n<image>\n\nInput\n\nThe first line of input contains a single integer N (1 ≀ N ≀ 100) β€” the number of cheeses you have.\n\nThe next N line...
[{"type": "stdin_stdout", "input": "42\nquxukow soft\nwcn soft\npbwg soft\nlrp hard\nphdvfz soft\nidkvymji soft\nobq soft\nyhx soft\nijygw soft\nztzz soft\nuwdhnwu soft\ndgnuuej hard\nhntyyzr soft\nqxf hard\nztg soft\nhnpq soft\nuhznu soft\nitelgl hard\nggceadhw hard\nrxq soft\nkznmshem hard\nlri hard\ndalh soft\ngyzzu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim ...
[{"type": "stdin_stdout", "input": "98\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne fine day, Benny decided to calculate the number of kilometers that she traveled by her bicycle. Therefore, she bought an odometer and installed it onto her bicycle. But the odometer was broken. It was not able to disp...
[{"type": "stdin_stdout", "input": "100\n402\n409\n278\n29\n268\n874\n527\n617\n727\n485\n616\n724\n660\n190\n286\n562\n270\n21\n75\n625\n1\n122\n579\n89\n764\n1291\n145\n847\n405\n419\n1070\n29\n126\n494\n216\n760\n662\n660\n651\n902\n7\n202\n192\n194\n908\n578\n214\n915\n711\n445\n422\n989\n651\n406\n492\n712\n866\n7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHackerMan has a message that he has coded in form of digits, which means that the message contains only numbers and nothing else. He is fearful that the enemy may get their hands on the secret message and may decode it. H...
[{"type": "stdin_stdout", "input": "994\n5407 1537\n2363 1131\n3948 2406\n4077 621\n4449 387\n406 3977\n2759 878\n1058 3651\n2356 1943\n3039 2573\n3138 2424\n1371 518\n4387 4339\n1646 2566\n387 481\n1633 2163\n3508 1815\n1011 2131\n3314 2819\n2842 3282\n4031 631\n67 4941\n3264 4893\n652 1712\n3117 4992\n2827 552\n4961 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in th...
[{"type": "stdin_stdout", "input": "6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30", "output": "11"}, {"type": "stdin_stdout", "input": "4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8", "output": "3"}, {"type": "stdin_stdout", "input": "3\n2 3 7 9 5 4 8 6 1", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a connected undirected graph with N vertices and M edges. Edge i in this graph (1 \\leq i \\leq M) connects Vertex U_i and Vertex V_i bidirectionally. We are additionally given N integers D_1, D_2, ..., D_N.\n\nDe...
[{"type": "stdin_stdout", "input": "0 13\n1 2 3 7 0\n1 4\n1 3\n1 7\n4 7\n1 3\n2 5\n5 7", "output": "\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n"}, {"type": "stdin_stdout", "input": "5 7\n1 1 3 4 5\n1 2\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and...
[{"type": "stdin_stdout", "input": "5\n138 138 232 138 138", "output": "185.0000000000\n"}, {"type": "stdin_stdout", "input": "5\n138 138 232 218 138", "output": "205.0000000000\n"}, {"type": "stdin_stdout", "input": "5\n37 138 232 218 138", "output": "198.6875000000\n"}, {"type": "stdin_stdout", "input": "5\n37 138 23...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from...
[{"type": "stdin_stdout", "input": "5\n9 -1 6 8 4", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n9 -1 4 8 4", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n4 4 10 2 4", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n1 0 -1 7 2", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n48 -1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0. Note that we are counting the ways to take out subsequences. That is, even if the conten...
[{"type": "stdin_stdout", "input": "7\n-1 -4 0 -20 -1 0 0", "output": "4\n"}, {"type": "stdin_stdout", "input": "7\n0 -1 1 -1 1 -1 1", "output": "13\n"}, {"type": "stdin_stdout", "input": "7\n0 -1 0 -5 0 -1 -3", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n0 -1 0 -5 0 -2 -3", "output": "3\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are a total of n x n squares, n rows vertically and n columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and displays the length of the side of the largest squ...
[{"type": "stdin_stdout", "input": "10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n..........\n.*........\n..........\n....*..***\n.*....*...\n10\n*****.****\n*..*.*....\n****.*....\n*....*....\n*....*****\n..........\n****.*****\n*..*...*..\n****...*..\n*..*...*..\n0", "output": "5\n3\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. A loves sweets, but recently his wife has told him to go on a diet. One day, when Mr. A went out from his home to the city hall, his wife recommended that he go by bicycle. There, Mr. A reluctantly went out on a bicyc...
[{"type": "stdin_stdout", "input": "1 1 2 5\n13\nH L1 18\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 24\n2 2 4 6\n100 112\nH L1 10\nC1 L1 12\nC1 D 11\nC2 L1 7\nC2 D 12\nL1 D 8\n0 0 0 0", "output": "23\n-24\n"}, {"type": "stdin_stdout", "input": "1 1 2 5\n25\nH L1 18\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 24\n2 2 4 6\n100 112\nH L1 10\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a teacher at Iazu High School is the Zuia Kingdom. There are $N$ cities and $N-1$ roads connecting them that allow you to move from one city to another by way of more than one road. Each of the roads allows bidire...
[{"type": "stdin_stdout", "input": "15 15\n1 2 45\n2 3 129\n1 4 29\n1 5 2\n5 6 25\n4 7 84\n7 8 56\n4 9 2\n4 10 37\n7 11 39\n1 12 11\n11 13 6\n3 14 68\n2 15 16\n10 13 14\n13 14 15\n2 14 12\n7 12 15\n10 14 15\n9 10 15\n9 14 15\n8 13 15\n10 6 13\n11 13 15\n12 13 14\n3 6 10\n5 13 13\n10 11 14\n6 8 11", "output": "203\n203\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nACM University holds its sports day in every July. The \"Roll-A-Big-Ball\" is the highlight of the day. In the game, players roll a ball on a straight course drawn on the ground. There are rectangular parallelepiped block...
[{"type": "stdin_stdout", "input": "2\n-40 -40 100 30\n-100 -100 -50 -30 1\n30 -70 90 -30 10\n2\n-4 -4 10 3\n-10 -10 -5 -3 1\n3 -7 9 -3 1\n2\n-40 -40 100 30\n-100 -100 -50 -30 3\n30 -70 90 -30 10\n2\n-400 -400 1000 300\n-800 -800 -500 -300 8\n300 -700 900 -300 20\n3\n20 70 150 70\n0 0 50 50 4\n40 100 60 120 8\n130 80 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nIn 20XX, a scientist developed a powerful android with biotechnology. This android is extremely powerful because it is made by a computer by combining the cells of combat masters.\n\nAt this rate, the earth wou...
[{"type": "stdin_stdout", "input": "3 5\nCOMPARE 1 2\nIN 1 2 9\nIN 2 1 3\nCOMPARE 2 3\nCOMPARE 1 3", "output": "WARNING\nWARNING\nWARNING\n"}, {"type": "stdin_stdout", "input": "5 5\nCOMPARE 1 2\nIN 1 4 6\nIN 2 3 2\nCOMPARE 2 3\nCOMPARE 1 3", "output": "WARNING\n2\nWARNING\n"}, {"type": "stdin_stdout", "input": "5 5\nC...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe volume of access to a web service varies from time to time in a day. Also, the hours with the highest volume of access varies from service to service. For example, a service popular in the United States may receive mo...
[{"type": "stdin_stdout", "input": "2\n4 0 2 2 5 10\n2 -1 1 2\n0", "output": "11\n"}, {"type": "stdin_stdout", "input": "2\n4 0 -1 -1 0 8\n2 1 3 3\n0", "output": "11\n"}, {"type": "stdin_stdout", "input": "2\n4 0 -2 -1 0 8\n2 1 3 3\n0", "output": "11\n"}, {"type": "stdin_stdout", "input": "2\n4 0 2 2 3 8\n2 -1 2 2\n0",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI have a lot of friends. Every friend is very small.\nI often go out with my friends. Put some friends in your backpack and go out together.\nEvery morning I decide which friends to go out with that day. Put friends one b...
[{"type": "stdin_stdout", "input": "6 50\n10\n30\n13\n18\n12\n16", "output": "15\n"}, {"type": "stdin_stdout", "input": "6 37\n6\n16\n13\n18\n12\n16", "output": "10\n"}, {"type": "stdin_stdout", "input": "6 50\n6\n16\n13\n18\n12\n16", "output": "12\n"}, {"type": "stdin_stdout", "input": "6 37\n5\n16\n13\n18\n26\n33", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven the string S and m queries. The i-th query is given by the two strings xi and yi.\n\nFor each query, answer the longest substring of the string S, starting with xi and ending with yi.\n\nFor the string S, | S | repr...
[{"type": "stdin_stdout", "input": "icpcsummertraining\n9\nmm n\nicpc summer\ntrain ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "output": "11\n10\n8\n0\n4\n16\n0\n6\n6\n"}, {"type": "stdin_stdout", "input": "icpcsummertraining\n9\nmm n\nicpc summer\nniart ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nD: Arrow / Arrow\n\nproblem\n\nrodea is in a one-dimensional coordinate system and stands at x = 0. From this position, throw an arrow of positive integer length that always moves at speed 1 towards the target at x = N. H...
[{"type": "stdin_stdout", "input": "11 1\n11\n1\n16", "output": "1\n"}, {"type": "stdin_stdout", "input": "11 1\n11\n1\n6", "output": "-1\n"}, {"type": "stdin_stdout", "input": "15 1\n3\n1\n2", "output": "13\n"}, {"type": "stdin_stdout", "input": "15 1\n6\n1\n5", "output": "10\n"}, {"type": "stdin_stdout", "input": "15...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nCryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.\n\nThe ciphertext consists of the $ N $ character string ...
[{"type": "stdin_stdout", "input": "5\nAMazA", "output": "3\nAAA\n"}, {"type": "stdin_stdout", "input": "5\nAMAza", "output": "3\nAAA\n"}, {"type": "stdin_stdout", "input": "5\nAMBza", "output": "3\nAAA\n"}, {"type": "stdin_stdout", "input": "5\nAaBzM", "output": "3\nAAA\n"}, {"type": "stdin_stdout", "input": "5\nAazBM...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\n* The total value of the items is as large as possible.\n* The item...
[{"type": "stdin_stdout", "input": "4 3\n4 0\n5 2\n2 1\n13 1", "output": "22\n"}, {"type": "stdin_stdout", "input": "4 6\n4 0\n5 2\n2 1\n13 1", "output": "24\n"}, {"type": "stdin_stdout", "input": "4 5\n0 2\n5 2\n2 1\n8 3", "output": "13\n"}, {"type": "stdin_stdout", "input": "4 5\n4 2\n5 2\n2 0\n8 3", "output": "15\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCodehorses has just hosted the second Codehorses Cup. This year, the same as the previous one, organizers are giving T-shirts for the winners.\n\nThe valid sizes of T-shirts are either \"M\" or from 0 to 3 \"X\" followed ...
[{"type": "stdin_stdout", "input": "43\nL\nXXXL\nM\nXS\nL\nXXL\nS\nL\nM\nXXXL\nXXS\nS\nXS\nS\nXS\nXL\nXXL\nXXL\nXS\nXXS\nXXL\nL\nXXXL\nL\nL\nXXL\nXXL\nM\nXXXS\nM\nXXL\nXXXS\nXXXL\nXXS\nL\nL\nXS\nL\nXS\nXS\nL\nXXL\nM\nXXXL\nXXL\nXXL\nXL\nL\nXS\nM\nXL\nXXXS\nXXXS\nS\nXXL\nXXXL\nXXL\nXS\nXXS\nL\nS\nXXXS\nXL\nL\nXL\nXXXS\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan unexpectedly saw a present from one of his previous birthdays. It is array of n numbers from 1 to 200. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbou...
[{"type": "stdin_stdout", "input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\n"}, {"type": "stdin_stdout", "input": "37\n52 52 87 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree (a connected undirected graph without cycles) of n vertices. Each of the n - 1 edges of the tree is colored in either black or red.\n\nYou are also given an integer k. Consider sequences of k vertices...
[{"type": "stdin_stdout", "input": "19 20\n8 10 1\n17 15 1\n14 5 0\n6 14 0\n7 15 0\n19 8 1\n12 14 0\n2 18 0\n13 3 0\n17 1 1\n4 2 1\n11 3 0\n4 6 0\n6 9 0\n7 11 1\n16 4 1\n5 13 1\n16 19 0\n", "output": " 928042611\n"}, {"type": "stdin_stdout", "input": "13 3\n9 13 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2).\n\nYou are given a sequence a consisting of n integers.\n\nYou are making...
[{"type": "stdin_stdout", "input": "93\n6 6 10 10 9 4 7 10 2 3 4 10 7 2 8 8 4 2 4 4 7 7 3 2 3 1 5 3 7 2 4 9 10 8 10 5 1 6 2 1 10 3 5 6 6 9 3 10 1 10 1 6 2 3 8 7 1 5 4 10 4 3 5 8 8 1 3 8 2 3 10 7 2 4 5 2 6 4 10 4 4 8 5 1 6 3 1 9 5 4 9 4 3\n", "output": "4\nRRLR\n"}, {"type": "stdin_stdout", "input": "93\n6 6 10 10 8 4 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of n non-n...
[{"type": "stdin_stdout", "input": "50 20\n592183311 362557946 154127088 616872926 395353745 675069471 509655682 79915471 356656666 937992998 304422065 724106263 472338455 792258113 796069631 663370025 201799298 566151622 722278085 508905399 703159587 690854023 925377265 11010958 69791159 990158269 535460930 167415727 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan plays an old action game called Heretic. He's stuck on one of the final levels of this game, so he needs some help with killing the monsters.\n\nThe main part of the level is a large corridor (so large and narrow tha...
[{"type": "stdin_stdout", "input": "2\n3 2\n1 3 5\n4 1\n5 2 3 5\n", "output": "2\n2\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n1 3 5\n4 1\n5 4 3 5\n", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n1 1 5\n4 1\n5 4 3 5\n", "output": "1\n3\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n0 1 5\n4 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a river of width n. The left bank of the river is cell 0 and the right bank is cell n + 1 (more formally, the river can be represented as a sequence of n + 2 cells numbered from 0 to n + 1). There are also m wood...
[{"type": "stdin_stdout", "input": "1000 232 105\n4 3 4 4 6 1 4 3 4 1 4 1 4 2 2 3 2 6 3 2 6 1 1 4 1 2 4 2 3 2 5 2 3 4 3 3 3 2 5 4 2 5 4 2 4 4 4 2 4 1 3 5 4 4 5 3 6 5 3 3 4 4 2 3 3 3 1 4 4 3 2 3 2 5 4 3 2 4 3 1 2 5 6 2 4 6 3 2 2 2 2 2 6 4 4 5 5 1 4 2 5 1 6 4 3 2 3 7 2 3 3 2 4 4 2 3 2 3 3 4 1 3 2 3 2 7 7 3 3 3 4 2 2 3 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit an...
[{"type": "stdin_stdout", "input": "1000000 1000000 1000000 1000000 1000000\n", "output": "1000000 1000000\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 999999 999998 1000000\n", "output": "999999 999998\n"}, {"type": "stdin_stdout", "input": "176902 1481077 847541 412251 587604\n", "output": "616526 283398\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:\n\nβ€”Shuf...
[{"type": "stdin_stdout", "input": "918273645\n546372819\n", "output": "WRONG_ANSWER\n"}, {"type": "stdin_stdout", "input": "111111111\n111110111\n", "output": "WRONG_ANSWER\n"}, {"type": "stdin_stdout", "input": "987235645\n206049167\n", "output": "WRONG_ANSWER\n"}, {"type": "stdin_stdout", "input": "918273645\n278718...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCatherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. Bu...
[{"type": "stdin_stdout", "input": "100\n1 2 3 4 5 6 7 15 11 10 11 5 13 14 15 16 17 18 19 20 3 22 23 24 16 26 27 28 29 29 43 32 33 34 35 36 37 38 39 40 41 76 43 44 45 46 47 48 41 50 51 52 53 54 55 97 57 58 59 60 61 62 63 64 65 66 67 68 30 70 71 72 73 74 75 76 77 78 79 80 81 88 83 84 85 86 87 88 265 90 91 92 93 94 95 96...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an array a of length n, find another array, b, of length n such that:\n\n * for each i (1 ≀ i ≀ n) MEX(\\\\{b_1, b_2, …, b_i\\})=a_i. \n\n\n\nThe MEX of a set of integers is the smallest non-negative integer that d...
[{"type": "stdin_stdout", "input": "10\n1 2 3 4 4 4 7 7 7 10\n", "output": "0 1 2 3 5 6 4 8 9 7\n"}, {"type": "stdin_stdout", "input": "7\n0 0 2 2 3 5 6\n", "output": "1 4 0 7 2 3 5 \n"}, {"type": "stdin_stdout", "input": "7\n0 0 2 2 3 5 7\n", "output": "1 4 0 6 2 3 5 \n"}, {"type": "stdin_stdout", "input": "7\n0 0 2 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKoa the Koala and her best friend want to play a game.\n\nThe game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0. ...
[{"type": "stdin_stdout", "input": "4\n5\n4 1 5 1 4\n4\n1 0 0 12\n1\n0\n2\n5 4\n", "output": "LOSE\nWIN\nDRAW\nWIN\n"}, {"type": "stdin_stdout", "input": "4\n5\n2 1 3 1 0\n4\n1 0 1 6\n1\n0\n2\n5 4\n", "output": "LOSE\nWIN\nDRAW\nWIN\n"}, {"type": "stdin_stdout", "input": "4\n5\n4 1 5 1 4\n4\n1 0 1 12\n1\n1\n2\n5 4\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a set of integers (it can contain equal elements).\n\nYou have to split it into two subsets A and B (both of them can contain equal elements or be empty). You have to maximize the value of mex(A)+mex(B).\n\nHere mex...
[{"type": "stdin_stdout", "input": "1\n100\n0 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 82 83 84 85 86 87 88 89 90 91 92 93 94 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou like playing chess tournaments online.\n\nIn your last tournament you played n games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get 0 points. When you win...
[{"type": "stdin_stdout", "input": "8\n5 2\nWLWLL\n6 5\nLLLWWL\n7 4\nLWLWLWL\n15 5\nWWWLLLWWWLLLWWW\n40 38\nLLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWWLWWL\n1 0\nL\n1 0\nL\n6 0\nWLLWLW\n", "output": "7\n11\n13\n26\n79\n0\n0\n3\n"}, {"type": "stdin_stdout", "input": "8\n5 2\nWLWLL\n6 5\nLLLWWL\n7 4\nLWLWLWL\n15 2\nWWWLLLWWWLLL...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have n distinct points (x_1, y_1),…,(x_n,y_n) on the plane and a non-negative integer parameter k. Each point is a microscopic steel ball and k is the attract power of a ball when it's charged. The attract power is th...
[{"type": "stdin_stdout", "input": "3\n3 3\n0 -1\n3 4\n1 4\n3 3\n12 7\n10 6\n6 9\n4 1\n-1 0\n0 3\n0 2\n0 3\n", "output": "-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "3\n3 3\n0 -1\n3 2\n1 4\n3 3\n6 7\n10 6\n6 9\n4 1\n-1 -1\n0 3\n0 2\n0 3\n", "output": "-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "3\n3 2\n0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaving stayed home alone, Petya decided to watch forbidden films on the Net in secret. \"What ungentlemanly behavior!\" β€” you can say that, of course, but don't be too harsh on the kid. In his country films about the Mart...
[{"type": "stdin_stdout", "input": "000:0010\n", "output": "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 "}, {"type": "stdin_stdout", "input": "001:010\n", "output": "2 3 4 5 6 7 8 9 10 11 12 13 14 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.\n\nOne day Vasya decided to collect the result...
[{"type": "stdin_stdout", "input": "100\n9999 9999 9999 9998 9998 9998 9997 9996 9996 9995 9993 9993 9991 9990 9989 9986 9984 9984 9983 9981 9981 10079 9980 9980 9979 9977 9977 9977 9977 9977 9976 9976 9975 9975 9973 9972 9972 9972 9972 9971 9969 9969 9969 9968 9967 9965 9962 9962 9962 9962 9960 9958 9958 9955 9954 995...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party ...
[{"type": "stdin_stdout", "input": "13\n78\n11 1\n10 11\n6 2\n10 1\n11 6\n11 3\n5 3\n8 1\n12 11\n4 2\n10 3\n13 8\n9 8\n11 7\n7 5\n11 2\n7 1\n4 1\n11 10\n8 3\n13 11\n9 6\n13 9\n12 7\n12 8\n12 9\n10 2\n5 2\n12 10\n9 2\n9 7\n3 2\n7 4\n11 4\n13 1\n10 5\n11 5\n8 5\n10 4\n8 2\n10 9\n4 3\n9 5\n13 12\n13 5\n7 2\n12 4\n9 1\n10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.\n\nThe canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these wall...
[{"type": "stdin_stdout", "input": "001 1\n----------------------------------------------------------------------------------------------------X\n----------------------------------------------------------------------------------------------------X\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "011 1\n------...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has got a problem β€” somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.\n\nThe Little Elephant doesn't want to call the police u...
[{"type": "stdin_stdout", "input": "128\n1 2 4 6 8 17 20 20 23 33 43 49 49 49 52 73 74 75 82 84 85 87 90 91 102 103 104 105 111 111 401 142 142 152 155 160 175 176 178 181 183 184 101 188 191 193 326 202 202 214 224 225 236 239 240 243 246 247 249 249 257 257 261 264 265 271 277 281 284 284 286 289 290 296 297 303 305 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Polycarpus has learned the \"bitwise AND\" operation (which is also called \"AND\") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.\...
[{"type": "stdin_stdout", "input": "7\n-1 1000000000 999999488 999999488 1000000000 1000000000 999999488\n1000000000 -1 999999488 999999488 1000000000 1000000000 999999488\n999999488 999999488 -1 999999999 999999488 999999488 999999999\n999999488 999999488 999999999 -1 999999488 999999488 999999999\n1000000000 10000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is addicted to Codeforces, and keeps refreshing the main page not to miss any changes in the \"recent actions\" list. He likes to read thread conversations where each thread consists of multiple messages.\n\nRece...
[{"type": "stdin_stdout", "input": "132\n13 7 33 124 118 76 94 92 16 107 130 1 46 58 28 119 42 53 102 81 99 29 57 70 125 45 100 68 10 63 34 38 19 49 56 30 103 72 106 3 121 110 78 2 31 129 128 24 77 61 87 47 15 21 88 60 5 101 82 108 84 41 86 66 79 75 54 97 55 12 69 44 83 131 9 95 11 85 52 35 115 80 111 27 109 36 39 104 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: every minute at each junction (x, y) containing at least four ants a group of four ...
[{"type": "stdin_stdout", "input": "30000 39\n2650 -1515\n-3169 4818\n-1896 2727\n1323 -2335\n-387 901\n-4299 1481\n-2114 4435\n3654 -2730\n4569 3801\n-3815 -3355\n4777 1749\n4486 -780\n-3936 -158\n717 -3518\n4765 -909\n-3032 3726\n-2970 3346\n2067 -1560\n-521 -1331\n-4953 -2098\n-849 580\n-4941 4018\n1338 -2629\n-1444...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (...
[{"type": "stdin_stdout", "input": "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOm Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all.\n\n<imag...
[{"type": "stdin_stdout", "input": "2 100 59\n....................................................................................................\n.DR.D..DLLR.LDRR..L.LDRRRDLD.LDRR.LLR.R...DRLD.RRLL.L.D..R.LD.DL....LR.LR.DRLD.....L.D..RD...D.LL.R.\n", "output": "0 0 0 1 0 0 0 1 1 0 0 2 0 0 0 1 1 1 0 1 0 0 0 1 1 2 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! \n\nHowever, there is no reason for disappointment, as Valery has found anot...
[{"type": "stdin_stdout", "input": "112 1867 1261 1606\n0 7 17 43 67 70 87 112 129 141 148 162 179 180 189 202 211 220 231 247 250 277 308 311 327 376 400 406 409 417 418 444 480 512 514 515 518 547 572 575 578 587 612 617 654 684 701 742 757 761 788 821 825 835 841 843 850 858 869 872 881 936 939 969 970 971 997 1026 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color ci, connecting vertex ai and bi.\n\nMr. Kita...
[{"type": "stdin_stdout", "input": "5 7\n1 5 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "1\n1\n1\n1\n2\n"}, {"type": "stdin_stdout", "input": "5 7\n1 1 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "0\n0\n1\n0\n1\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag...
[{"type": "stdin_stdout", "input": "47\n20\n21\n16\n18\n24\n20\n25\n13\n20\n22\n26\n24\n17\n18\n21\n22\n21\n23\n17\n15\n24\n19\n18\n21\n20\n19\n26\n25\n20\n17\n17\n17\n26\n32\n20\n21\n25\n28\n24\n21\n21\n17\n28\n20\n20\n31\n19\n", "output": "295545118\n"}, {"type": "stdin_stdout", "input": "47\n20\n21\n16\n18\n24\n20\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKefa wants to celebrate his first big salary by going to restaurant. However, he needs company. \n\nKefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amou...
[{"type": "stdin_stdout", "input": "15 1234\n2738 365370390\n1160 970909702\n2594 902749351\n3126 324754476\n3151 177963947\n3424 396145897\n5578 737768323\n3423 687640543\n381 848813098\n1058 197211286\n936 650181776\n1025 776492538\n3598 142176544\n3595 680519527\n1191 32199940\n", "output": "3677320675\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter seeing the \"ALL YOUR BASE ARE BELONG TO US\" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.\n\nYou're given a number X represented in base bx an...
[{"type": "stdin_stdout", "input": "10 40\n39 39 39 14 39 39 39 39 39 39\n10 39\n38 38 38 38 38 38 38 38 38 38\n", "output": ">\n"}, {"type": "stdin_stdout", "input": "10 40\n39 39 39 39 39 39 39 39 39 39\n10 39\n38 38 38 38 38 38 38 38 38 38\n", "output": ">"}, {"type": "stdin_stdout", "input": "10 38\n16 19 37 32 16 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.\n\nEach minute can be either interesting or boring. If 15 consecutive minutes are boring then L...
[{"type": "stdin_stdout", "input": "90\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\n", "output": "90\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tree is an undirected connected graph without cycles.\n\nLet's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represent such a tree. One way is to create an array with n ...
[{"type": "stdin_stdout", "input": "18\n2 3 4 5 2 7 8 9 10 7 11 12 14 15 13 17 18 18\n", "output": "5 \n2 3 4 5 11 7 8 9 10 11 11 11 14 15 11 17 18 11 \n"}, {"type": "stdin_stdout", "input": "18\n2 3 4 5 2 7 8 9 2 7 11 12 14 15 13 17 18 18\n", "output": "4\n2 11 4 5 2 7 8 9 2 7 11 11 11 15 13 17 18 11\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are n cockroaches living in A...
[{"type": "stdin_stdout", "input": "166\nrbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrbbbrbbbbbbbbbbbbbbrbrbbbbbbbbbbbrbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbb\n", "output": "70\n"}, {"type": "stdin_stdout", "input": "166\nrbbbbbbbbbbbrrbrrbbbbbbrbbbbbbbbbbrbbbbbbrbbbrbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + ...
[{"type": "stdin_stdout", "input": "100 100\n100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 110\n100 100\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "87 22\n119 64\n", "output": "1849\n"}, {"type": "stdin_stdout", "input": "31 74\n88 152\n", "output": "2616\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT co...
[{"type": "stdin_stdout", "input": "70 203\n1 105\n1 105\n1 105\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\nSlastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.\n\nThe game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen...
[{"type": "stdin_stdout", "input": "6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000\n", "output": "Yes\nYes\nYes\nNo\nNo\nYes\n"}, {"type": "stdin_stdout", "input": "6\n2 4\n75 45\n8 8\n16 5\n247 994\n1000000000 1000000\n", "output": "Yes\nYes\nYes\nNo\nNo\nYes"}, {"type": "stdin_stdout", "input": "6\n2 4\n75 45...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai.\n\nToday the...
[{"type": "stdin_stdout", "input": "10 5 1000000000\n1 1 1 2 2 1 2 2 2 2\n", "output": "10000000000\n"}, {"type": "stdin_stdout", "input": "10 5 1000000000\n1 1 1 2 2 1 2 2 3 2\n", "output": "10000000000\n"}, {"type": "stdin_stdout", "input": "10 5 1000000000\n1 1 1 2 0 1 2 2 3 2\n", "output": "10000000000\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a rectangular grid of n rows of m initially-white cells each.\n\nArkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and a non-empty subset ...
[{"type": "stdin_stdout", "input": "50 8\n.....#..\n........\n........\n.....#..\n.....#..\n........\n........\n........\n........\n...#....\n...#....\n........\n...#....\n#.#.#...\n...#....\n...#....\n........\n...#....\n...#....\n...#....\n........\n#.#.#...\n.....#..\n........\n#.#.#...\n#.#.#...\n#.#.#...\n...#.......
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverybody knows of [spaghetti sort](https://en.wikipedia.org/wiki/Spaghetti_sort). You decided to implement an analog sorting algorithm yourself, but as you survey your pantry you realize you're out of spaghetti! The only...
[{"type": "stdin_stdout", "input": "10\n105 39 93 63 97 40 36 38 11 97\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n105 39 79 63 97 40 36 38 11 97\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n109 91 22 29 23 22 33 42 13 96\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKuro has recently won the \"Most intelligent cat ever\" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.\n\nK...
[{"type": "stdin_stdout", "input": "50 1\n-1 -1 -1 -1 -1 0 -1 -1 -1 0 1 0 -1 0 1 -1 -1 -1 1 0 1 -1 0 1 0 1 0 0 1 1 -1 1 -1 -1 1 1 -1 -1 0 -1 -1 1 -1 1 -1 1 1 0 0 -1\n", "output": "279519499\n"}, {"type": "stdin_stdout", "input": "50 1\n-1 -1 -1 -1 -1 0 -1 -1 -1 0 1 0 -1 0 1 -1 -1 -1 1 0 1 -1 0 1 0 1 0 0 0 1 -1 1 -1 -1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n players sitting at the card table. Each player has a favorite number. The favorite number of the j-th player is f_j.\n\nThere are k β‹… n cards on the table. Each card contains a single integer: the i-th card co...
[{"type": "stdin_stdout", "input": "50 1\n995 1815 941 1716 725 1098 747 627 1728 1007 34 1001 679 1742 22 1495 1299 1696 507 631 1971 775 1052 1665 1035 203 1564 1329 1592 1295 983 177 734 1442 172 943 33 486 1078 946 947 592 1524 563 396 1541 1670 326 543 79\n176 214 1601 1758 1468 972 628 1524 1506 425 746 309 387 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYesterday, Benny decided to buy something from a television shop. She created a list that consisted of small description of N orders. The description for an order number i is a string Si.\n\nThe description may consist o...
[{"type": "stdin_stdout", "input": "4\nI want to buy Microsoft for $10000\nthhs house costs $0 5 1 00 0 tsuJ yub it\nsiejfsuhn $ 1 2 3 4 5 6 14 8 9 hello123\nshe cort is zero $ 1 0 0 0 0 0\n\nSAMPLE", "output": "$10000\n$51000\n$1234561489\n$100000\n"}, {"type": "stdin_stdout", "input": "4\nI want to buy Microsoft for ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIkshu and his class\n\nIkshu's class is very fond of playing games. Their teacher tied them with many ropes with each other, Such that each student is tied with exactly one rope. It means that if students 2 and 3 are conn...
[{"type": "stdin_stdout", "input": "-2 -3\n-1 -3\n-1 3\n\nCLOMAS", "output": "1\n"}, {"type": "stdin_stdout", "input": "-2 -3\n-1 -3\n-1 3\n\nSAMOLC", "output": "1\n"}, {"type": "stdin_stdout", "input": "-2 -3\n-1 -3\n-1 1\n\nSAMOLC", "output": "1\n"}, {"type": "stdin_stdout", "input": "-2 -4\n-1 -3\n-1 1\n\nSAMOLC", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOur friend Monk has an exam that has quite weird rules. Each question has a difficulty level in the form of an Integer. Now, Monk can only solve the problems that have difficulty level less than X . Now the rules are-\nSc...
[{"type": "stdin_stdout", "input": "7 11\n4 3 11 4 7 3 2\n\nSAMPLE", "output": "7\n"}, {"type": "stdin_stdout", "input": "7 6\n4 3 11 4 7 4 2\n\nSAMPLE", "output": "3\n"}, {"type": "stdin_stdout", "input": "7 6\n4 3 11 4 7 3 2\n\nSAMPLE", "output": "3\n"}, {"type": "stdin_stdout", "input": "7 6\n4 6 11 6 9 2 2\n\nSAMPL...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Mad King arrested Shil's comrades for participating in a rebellion against the King. Instead of punishing them with death, the King decided to play the Game of survival with them. The game is played as follows: \nAll...
[{"type": "stdin_stdout", "input": "5\n-1 76 14 1 0\n\nELPLAR", "output": "1 2 3 4 5\n"}, {"type": "stdin_stdout", "input": "5\n-1 38 30 -1 11\n\nELPLAR", "output": "1 2 3 5\n"}, {"type": "stdin_stdout", "input": "5\n-1 38 30 0 11\n\nELPLAR", "output": "1 2 3 5\n"}, {"type": "stdin_stdout", "input": "5\n-1 38 30 0 11\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\n* B is a (not necessarily continuous) subsequence of A.\n* For...
[{"type": "stdin_stdout", "input": "10 3\n1\n5\n2\n1\n1\n6\n11\n11\n4\n2", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 3\n0\n5\n4\n3\n14\n11\n9\n5\n3\n4", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 3\n0\n5\n4\n3\n11\n11\n9\n7\n6\n1", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 1\n2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a s...
[{"type": "stdin_stdout", "input": "32 5 001", "output": "1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "32 2 001", "output": "1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "18 1 010", "output": "10 11 11 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will be given an integer a and a string s consisting of lowercase English letters as input.\n\nWrite a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.\n\nConstraints\n\n* 2800...
[{"type": "stdin_stdout", "input": "3200\npinl", "output": "pinl\n"}, {"type": "stdin_stdout", "input": "3200\npiml", "output": "piml\n"}, {"type": "stdin_stdout", "input": "3200\nlmip", "output": "lmip\n"}, {"type": "stdin_stdout", "input": "3200\nkmip", "output": "kmip\n"}, {"type": "stdin_stdout", "input": "3200\nkn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that sat...
[{"type": "stdin_stdout", "input": "1260308870", "output": "26484\n"}, {"type": "stdin_stdout", "input": "1450760047", "output": "26484\n"}, {"type": "stdin_stdout", "input": "656396080", "output": "20434\n"}, {"type": "stdin_stdout", "input": "471776498", "output": "14384\n"}, {"type": "stdin_stdout", "input": "377370...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two sequences a and b, both of length 2N. The i-th elements in a and b are a_i and b_i, respectively. Using these sequences, Snuke is doing the job of calculating the beauty of pairs of balanced sequences of...
[{"type": "stdin_stdout", "input": "7 7\n49 -20 -27 42 159 29 9 11 20 44 27 19 -31 -49\n73 -50 -11 20 28 46 12 13 33 -22 -48 -27 35 -17\n7 27 34\n12 -2 22\n4 -50 -12\n3 -32 15\n8 -7 23\n3 -15 11\n4 -2 23", "output": "421\n422\n370\n396\n406\n402\n437\n"}, {"type": "stdin_stdout", "input": "7 7\n49 -20 -27 42 159 29 9 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\nThe i-th (1≀i≀M) edge connects vertex a_i and vertex b_i with a distance of c_i.\nHere, ...
[{"type": "stdin_stdout", "input": "7 1\n1 -1 0\n-1 4 1\n-1 0 4", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 1\n1 -1 0\n-1 4 2\n-1 0 4", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 1\n1 -2 0\n-1 4 2\n-1 0 4", "output": "0\n"}, {"type": "stdin_stdout", "input": "14 -1\n2 0 1\n0 3 1\n0 0 4", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStick n circular stickers with a radius of 1 on a square origami paper with a side length of 10. The stickers can be stacked. Create a program that reads the coordinates of the position where the stickers are to be attach...
[{"type": "stdin_stdout", "input": "15\n3.13979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0", "output": "4\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA set of four prime numbers arranged like (a, a + 2, a + 6, a + 8) is called a quadruplet prime number. Of the four prime numbers that make up a quadruplet prime, the largest number is called the size of the quadruplet pr...
[{"type": "stdin_stdout", "input": "13\n14\n15\n16\n17\n18\n19\n20\n10010\n0", "output": "13\n13\n13\n13\n13\n13\n19\n19\n9439\n"}, {"type": "stdin_stdout", "input": "13\n14\n15\n16\n17\n36\n19\n20\n10000\n0", "output": "13\n13\n13\n13\n13\n19\n19\n19\n9439\n"}, {"type": "stdin_stdout", "input": "13\n14\n15\n16\n27\n36...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Aizu Wakamatsu city office decided to lay a hot water pipeline covering the whole area of the city to heat houses. The pipeline starts from some hot springs and connects every district in the city. The pipeline can fo...
[{"type": "stdin_stdout", "input": "3 5\n12 15 70 19 44\n16 13 16 0 17\n20 14 16 10 22\n17 27 18 16\n9 7 0\n19 5\n21\n0 0", "output": "43\n"}, {"type": "stdin_stdout", "input": "3 5\n12 15 70 19 44\n30 13 16 0 17\n20 14 16 10 22\n17 27 18 16\n9 7 0\n19 5\n21\n0 0", "output": "43\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThree-valued logic is a logic system that has, in addition to \"true\" and \"false\", \"unknown\" as a valid value. In the following, logical values \"false\", \"unknown\" and \"true\" are represented by 0, 1 and 2 respec...
[{"type": "stdin_stdout", "input": "(Q*P)\n(--R+(Q*R))\n(P+-Q)\n2\n-1\n(-1+(((---P+Q)*(--Q+---R))+(-R+-P)))\n.", "output": "3\n9\n15\n27\n0\n19\n"}, {"type": "stdin_stdout", "input": "(P*Q)\n(--R+(P*Q))\n(P*-P)\n2\n2\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.", "output": "3\n11\n0\n27\n27\n7\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDespite urging requests of the townspeople, the municipal office cannot afford to improve many of the apparently deficient city amenities under this recession. The city swimming pool is one of the typical examples. It has...
[{"type": "stdin_stdout", "input": "2\n5 30\n15 20\n2\n10 240\n20 160\n5\n2 6\n7 2\n8 2\n4\n2 4\n13 2\n8 2\n18 1\n0", "output": "600\n6400\n105\n36\n"}, {"type": "stdin_stdout", "input": "2\n5 30\n15 20\n2\n10 240\n20 160\n5\n2 6\n7 2\n8 2\n4\n2 4\n13 2\n8 2\n28 1\n0", "output": "600\n6400\n105\n56\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSurrounding Area\n\nLand fence\n\nEnglish text is not available in this practice contest.\n\nTwo real estate agents were boarding a passenger ship to the southern island. Blue sky, refreshing breeze ... The two enjoyed a ...
[{"type": "stdin_stdout", "input": "10 10\n.....W....\n....W.W...\n...W...W..\n....W...W.\n.....W...W\n......W.W.\nBBB....W..\n..BB.BB.BB\n....B..B..\n...B.B..W.\n5 3\n...B.\n...BB\n.....\n1 1\n.\n0 0", "output": "10 21\n12 0\n0 0\n"}, {"type": "stdin_stdout", "input": "10 10\n.....W....\n....W.W...\n...W...W..\n....W....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome of you know an old story of Voronoi Island. There were N liege lords and they are always involved in territorial disputes. The residents of the island were despaired of the disputes.\n\nOne day, a clever lord propose...
[{"type": "stdin_stdout", "input": "3 3\n0 0\n8 -1\n-1 8\n2 2\n4 2\n2 4\n0 0", "output": "10.125000\n10.687500\n10.687500\n"}, {"type": "stdin_stdout", "input": "3 3\n0 0\n16 -1\n0 2\n1 2\n3 -1\n2 13\n0 0", "output": "4.222997\n11.777003\n0.000000\n"}, {"type": "stdin_stdout", "input": "3 3\n0 0\n14 0\n0 8\n2 2\n7 0\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFrom tomorrow, the long-awaited summer vacation will begin. So I decided to invite my friends to go out to the sea.\n\nHowever, many of my friends are shy. They would hate it if they knew that too many people would come w...
[{"type": "stdin_stdout", "input": "5\n8 100001\n14 100001\n12 100000\n11 100001\n3 100001", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n8 100001\n14 100001\n13 100000\n11 100001\n3 100001", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n8 000001\n14 100001\n13 100000\n11 100001\n3 100001", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the spring of 2014, a student successfully passed the university and started living alone. The problem here is what to do with the supper. He decided to plan a supper for the next N days.\n\nHe wants to maximize the to...
[{"type": "stdin_stdout", "input": "3 1 -10\n-19\n-10\n-10", "output": "-27\n"}, {"type": "stdin_stdout", "input": "2 1 -10\n-19\n-10\n-10", "output": "-19\n"}, {"type": "stdin_stdout", "input": "3 1 -19\n-19\n-10\n-10", "output": "-39\n"}, {"type": "stdin_stdout", "input": "3 1 -19\n-19\n-10\n-18", "output": "-47\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nB: Parentheses Number\n\nproblem\n\nDefine the correct parenthesis string as follows:\n\n* The empty string is the correct parenthesis string\n* For the correct parenthesis string S, `(` S `)` is the correct parenthesis s...
[{"type": "stdin_stdout", "input": "2\n2 -107", "output": ":(\n"}, {"type": "stdin_stdout", "input": "2\n2 -187", "output": ":(\n"}, {"type": "stdin_stdout", "input": "2\n2 -155", "output": ":(\n"}, {"type": "stdin_stdout", "input": "2\n2 -142", "output": ":(\n"}, {"type": "stdin_stdout", "input": "2\n2 -100", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nDefine a function $ f $ that starts with $ 1 $ and takes a sequence of finite lengths as an argument as follows.\n\n$ \\ displaystyle f (\\\\ {a_1, a_2, \\ ldots, a_n \\\\}) = \\ sum_ {i = 1} ^ n {a_i} ^ i $\n\...
[{"type": "stdin_stdout", "input": "5\n101 608 404 1494 500", "output": "969227571\n"}, {"type": "stdin_stdout", "input": "5\n001 608 404 1494 500", "output": "969225971\n"}, {"type": "stdin_stdout", "input": "5\n100 325 300 400 500", "output": "936266429\n"}, {"type": "stdin_stdout", "input": "5\n101 325 300 400 500",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≀ i0 < i1 < ... ...
[{"type": "stdin_stdout", "input": "5\n5\n1\n2\n-1\n10", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n5\n1\n0\n-1\n10", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n5\n1\n0\n-1\n11", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n8\n1\n0\n-1\n11", "output": "2\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that multiple elements can have equivalent keys.\n\n* insert($key$, $x$...
[{"type": "stdin_stdout", "input": "10\n0 blue 6\n0 red 1\n0 blue 4\n0 white 10\n1 red\n1 blue\n2 red\n1 black\n1 red\n3 w z", "output": "1\n6\n4\nwhite 10\n"}, {"type": "stdin_stdout", "input": "10\n0 blue 6\n0 red 1\n0 blue 0\n0 white 10\n1 red\n1 blue\n2 red\n1 black\n2 red\n3 w z", "output": "1\n6\n0\nwhite 10\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEnough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposal plan and stick to it.\n\nFor each of next n days Vasya kno...
[{"type": "stdin_stdout", "input": "185 2\n0 14 2 11 5 17 9 11 8 12 8 17 17 0 4 15 4 17 8 1 2 10 8 0 8 16 1 7 10 4 0 18 2 15 2 1 4 1 10 11 6 10 19 5 5 18 2 1 15 17 0 4 12 19 12 8 11 4 7 15 13 0 9 6 2 6 5 2 17 4 7 9 11 17 1 13 4 6 4 10 1 14 0 13 17 16 10 5 7 19 19 9 2 2 17 17 11 6 11 15 4 17 18 18 14 9 15 10 10 10 14 18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a playlist consisting of n songs. The i-th song is characterized by two numbers t_i and b_i β€” its length and beauty respectively. The pleasure of listening to set of songs is equal to the total length of the song...
[{"type": "stdin_stdout", "input": "10 1\n135600 59157\n2735 28902\n43406 39542\n24166 178402\n18565 14980\n69958 53925\n23473 81878\n89682 3949\n18757 31637\n35580 45873\n", "output": "8021689200\n"}, {"type": "stdin_stdout", "input": "10 1\n135600 59157\n2735 28902\n43406 39542\n24166 93361\n18565 14980\n69958 53925\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a pile, that consists of some number of stones. n times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.\n\nY...
[{"type": "stdin_stdout", "input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100\n---+-----------+-++---+----------++++++++++++++++++++++++++++++++++++++++++++-----------------------\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSoon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called \"chizhik\". One has to pay in chizhiks to buy a coco...
[{"type": "stdin_stdout", "input": "500000000000000000 500000000000000000 1000000000000000000\n", "output": "1 500000000000000000\n"}, {"type": "stdin_stdout", "input": "350919308160677995 916982339945800203 1000000000000001000\n", "output": "1 83017660054200797\n"}, {"type": "stdin_stdout", "input": "1444555415333840 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between the easy and the hard versions is the maximum value of k.\n\nYou are given an infinite sequence of form \"112123123412345...\" which consist of blocks of all consecutive positive integers writt...
[{"type": "stdin_stdout", "input": "19\n1\n10\n100\n1000\n10000\n100000\n1000000\n10000000\n100000000\n1000000000\n10000000000\n100000000000\n1000000000000\n10000000000000\n100000000000000\n1000000000000000\n10000000000000000\n100000000000000000\n1000000000000000000\n", "output": "1\n4\n1\n4\n9\n2\n6\n2\n6\n8\n1\n1\n9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.\n\nYou are given a length equal to n cent...
[{"type": "stdin_stdout", "input": "10000\n", "output": "277 9\n"}, {"type": "stdin_stdout", "input": "18864\n", "output": "524 0\n"}, {"type": "stdin_stdout", "input": "13473\n", "output": "374 3\n"}, {"type": "stdin_stdout", "input": "25368\n", "output": "704 8\n"}, {"type": "stdin_stdout", "input": "9999\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. \n\nThere is one cursor. The cursor's location β„“ i...
[{"type": "stdin_stdout", "input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "output": "1504\n1599\n1502\n1598\n1502\n1510\n1657\n1502\n1763\n"}, {"type": "stdin_stdout", "input": "9\n1676\n1212\n1500\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAyoub thinks that he is a very smart person, so he created a function f(s), where s is a binary string (a string which contains only symbols \"0\" and \"1\"). The function f(s) is equal to the number of substrings in the ...
[{"type": "stdin_stdout", "input": "5\n6 4\n5 2\n3 2\n2 1\n10 2\n", "output": "19\n12\n5\n2\n40\n"}, {"type": "stdin_stdout", "input": "5\n6 4\n5 2\n4 2\n2 1\n10 2\n", "output": "19\n12\n8\n2\n40\n"}, {"type": "stdin_stdout", "input": "5\n6 1\n0 0\n5 0\n16 1\n8 1\n", "output": "12\n0\n0\n72\n20\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.\n\nThere is an nΓ— m gr...
[{"type": "stdin_stdout", "input": "18 22\n....................#.\n...................#..\n..........#...........\n..................#...\n..................#...\n..................#...\n......................\n......................\n...........#..........\n..............#.......\n..............#.......\n................
code_stdio