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\nLet's call a positive integer $n$ ordinary if in the decimal notation all its digits are the same. For example, $1$, $2$ and $99$ are ordinary numbers, but $719$ and $2021$ are not ordinary numbers.\n\nFor a given number ... | [{"type": "stdin_stdout", "input": "6\n2\n2\n3\n8\n10\n100\n", "output": "2\n2\n3\n8\n9\n18\n"}, {"type": "stdin_stdout", "input": "6\n2\n2\n3\n4\n10\n100\n", "output": "2\n2\n3\n4\n9\n18\n"}, {"type": "stdin_stdout", "input": "6\n1\n2\n3\n4\n5\n100\n", "output": "\n1\n2\n3\n4\n5\n18\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which prints the central coordinate ($cx$,$cy$) and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points ($x_1$, $y_1$), ($x_2$, $y_2$) and ($x_3$, $y_3$) on the plan... | [{"type": "stdin_stdout", "input": "1 -2\n3 2\n-2 0", "output": "0.62500000000000000000 0.68750000000000000000 2.71353666826155124291"}, {"type": "stdin_stdout", "input": "0 3\n4 0\n0 0", "output": "2.00000000000000000000 1.50000000000000000000 2.50000000000000000000"}, {"type": "stdin_stdout", "input": "7 -3\n1 0\n-13... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\... | [{"type": "stdin_stdout", "input": "987654215 1000000000 9854874 854888120 270\n", "output": "3.1951405575880256686e-08"}, {"type": "stdin_stdout", "input": "777777776 778777777 777777775 1000000000 1\n", "output": "2.013495963778572506e-06"}, {"type": "stdin_stdout", "input": "987654215 1000000000 5640296 854888120 27... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider the set of all nonnegative integers: ${0, 1, 2, \\dots}$. Given two integers $a$ and $b$ ($1 \\le a, b \\le 10^4$). We paint all the numbers in increasing number first we paint $0$, then we paint $1$, then $2$ an... | [{"type": "stdin_stdout", "input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"type": "stdin_stdout", "input": "4\n10 10\n1 10\n3 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"type": "stdin_stdout", "input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFini... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nGiven the squares of $ R * C $. Each square is either an empty square or a square with a hole. The given square meets the following conditions.\n\n* The cells with holes are connected. (You can move a square wi... | [{"type": "stdin_stdout", "input": "3 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "3\n"}, {"type": "stdin_stdout", "input": "3 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c_1, c_2, ..., c_{n}. The Old Peykan wants to travel from city c_1 to c_{n... | [{"type": "stdin_stdout", "input": "100 6\n15 20 32 8 29 10 33 15 9 26 28 21 34 7 41 23 9 17 16 15 14 29 25 31 24 26 13 18 19 40 9 16 36 32 39 11 4 31 37 28 32 40 7 18 45 21 15 45 6 15 27 22 27 41 28 7 22 43 25 40 6 7 32 31 36 14 5 27 31 28 23 9 13 14 7 25 28 33 40 22 44 9 29 26 41 30 16 15 31 42 13 40 36 44 17 29 32 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been pr... | [{"type": "stdin_stdout", "input": "...\nX.X\n...\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "X.X\n.X.\nX.X\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "...\nXXX\n...\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "X..\n.X.\n..X\n", "output": "YES\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTheofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\n\nYou are given an integer $n$. You need to find two integers $l$ and $r$ such that $-10^... | [{"type": "stdin_stdout", "input": "7\n1\n3\n20\n2\n110\n23\n4838829180358\n", "output": "0 1\n-2 3\n-19 20\n-1 2\n-109 110\n-22 23\n-4838829180357 4838829180358\n"}, {"type": "stdin_stdout", "input": "7\n1\n2\n12\n2\n101\n56\n3000000000000\n", "output": "0 1\n-1 2\n-11 12\n-1 2\n-100 101\n-55 56\n-2999999999999 300000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n4\nDurett 7\nGayles 3\nFacenda 6\nDaughtery 0\n1\n+ Mccourtney 2\n\n\nOutput\n\nMccourtney is not working now.\nDurett is working hard now.\n\nThe input will be stdin and you should print your solution... | [{"type": "stdin_stdout", "input": "4\nDurett 10\nGayles 4\nF`cenda 10\nyrethguaD 0\n1\n+ Mccourtney 1", "output": "Mccourtney is not working now.\nF`cenda is working hard now.\n"}, {"type": "stdin_stdout", "input": "4\nDurett 10\nGaxles 4\nFacenda 10\nyrethguaD 0\n1\n+ yentruoccM 2", "output": "yentruoccM is not worki... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nUjan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.\n\nIt ... | [{"type": "stdin_stdout", "input": "15 10\n2 3\n5 4\n5 12\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "15 10\n2 3\n6 4\n5 12\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "15 10\n2 3\n5 8\n5 6\n5 7\n3 8\n3 10\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a robot on a coordinate plane. Initially, the robot is located at the point $(0, 0)$. Its path is described as a string $s$ of length $n$ consisting of characters 'L', 'R', 'U', 'D'.\n\nEach of these characters c... | [{"type": "stdin_stdout", "input": "4\n4\nLRUD\n4\nLURD\n5\nRRUDU\n5\nLRDDL\n", "output": "1 2 \n1 4 \n3 4 \n1 2 \n"}, {"type": "stdin_stdout", "input": "4\n4\nLRUD\n4\nLURD\n5\nRURDU\n5\nLRDDL\n", "output": "1 2 \n1 4 \n4 5 \n1 2 \n"}, {"type": "stdin_stdout", "input": "4\n4\nDURL\n4\nLURD\n5\nUDURR\n5\nLRDDL\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOnce Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics o... | [{"type": "stdin_stdout", "input": "99\n10 -84 -100 -100 73 -64 -100 -94 33 -100 -100 -100 -100 71 64 24 7 -100 -32 -100 -100 77 -100 62 -12 55 45 -100 -100 -80 -100 -100 -100 -100 -100 -100 -100 -100 -100 -39 -48 -100 -34 47 -100 -100 -100 -100 -100 -77 -100 -100 -100 -100 -100 -100 -52 40 -55 -100 -44 -100 72 33 70 -... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays $a$ and $b$, both of length $n$.\n\nYou can perform the following operation any number of times (possibly zero): select an index $i$ ($1 \\leq i \\leq n$) and swap $a_i$ and $b_i$.\n\nLet's define... | [{"type": "stdin_stdout", "input": "1\n100\n77 18 18 20 58 11 45 18 21 15 44 87 77 65 94 83 68 73 43 84 75 100 66 39 63 44 60 16 100 4 83 53 37 11 95 71 38 57 66 31 40 60 36 37 92 79 30 55 46 25 54 45 85 38 29 82 60 11 11 69 30 1 53 100 62 61 17 75 99 9 31 8 100 53 57 8 11 26 95 72 50 77 90 88 80 84 53 50 23 3 78 27 76... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly... | [{"type": "stdin_stdout", "input": "58\nesgdfmf\nxfkluadj\nqhvh\njwhuyhm\nmgi\nysgc\nvhhenku\npb\ntr\nu\njyrpjnpd\nkluadjo\nopb\ncopb\ngcyhceo\nr\ndjo\nxfklu\neo\nadjo\nfkluadjo\nybe\nwljwh\nqhvhh\nrhgotp\nyhceo\nuyhm\nvdd\nyhm\nysgcyhc\nvddrhg\nril\nwljwhu\nx\nqh\nhceo\ntfcopb\nmgitfc\nvddrh\nmgitfco\nxf\nmgitf\ncyoyb... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions are constraints on $n$ and $k$.\n\nYou are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversat... | [{"type": "stdin_stdout", "input": "10 4\n2 3 3 1 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"type": "stdin_stdout", "input": "10 4\n2 3 3 1 1 2 1 2 5 3\n", "output": "4\n5 1 3 2\n"}, {"type": "stdin_stdout", "input": "10 4\n2 3 3 2 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"type": "stdin_stdout", "input": "10 4\n2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.\n\nA bar of chocolate can be presented as an n × n table, where each cell represents one piece... | [{"type": "stdin_stdout", "input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"type": "stdin_stdout", "input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using ... | [{"type": "stdin_stdout", "input": "2\n2 0 2 1 89 0 26 7\n13 11 25 8 -1 3 0 -2\n0", "output": "119 -12 230 103\n-30 -22 21 -109\n"}, {"type": "stdin_stdout", "input": "2\n2 0 2 5 89 0 26 4\n7 11 25 8 -1 3 0 -2\n0", "output": "106 -122 230 453\n-24 -40 21 -97\n"}, {"type": "stdin_stdout", "input": "2\n2 0 2 5 89 0 26 4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be repr... | [{"type": "stdin_stdout", "input": "26\nabcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\n", "output": "abcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\n"}, {"type": "stdin_stdout", "input": "26\nab?defg??j??mnopqrs... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.\n\nYou are g... | [{"type": "stdin_stdout", "input": "CODDFESTIVAL", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "EDOCLAVFTSEI", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ECOFLAVDTSEI", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "DOECSDKSIVAF", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "DOEC... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some posit... | [{"type": "stdin_stdout", "input": "? + ? + ? - ? + ? - ? - ? - ? - ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? + ? - ? - ? - ? + ? - ? - ? + ? - ? - ? + ? - ? + ? + ? - ? + ? - ? - ? + ? + ? - ? - ? - ? + ? - ? - ? - ? + ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? - ? - ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is becau... | [{"type": "stdin_stdout", "input": "BYOVRR\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "OVBRYG\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "RRYOGB\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "VOBYGO\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "GRBYVO\n", "output": "30... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\n0 2 7\n2 0 4\n5 8 0\n\n\nOutput\n\n11\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this probl... | [{"type": "stdin_stdout", "input": "3\n0 3 10\n1 0 4\n19 11 0", "output": "15\n"}, {"type": "stdin_stdout", "input": "3\n0 6 13\n4 0 3\n24 12 0", "output": "20\n"}, {"type": "stdin_stdout", "input": "3\n0 12 13\n6 0 6\n27 8 0", "output": "25\n"}, {"type": "stdin_stdout", "input": "3\n0 12 18\n6 0 6\n27 8 0", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\n* The string... | [{"type": "stdin_stdout", "input": "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300"}, {"type": "stdin_stdout", "input": "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`aaaa", "output": "0\n"}, {"type": "stdin_stdout", "input": "18\naaaaaaaaaaaaaaaaaaaaaaabaaaaaaa`aaaa", "output": "0\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday's Random Number\n\nE869120 You ran a campaign called \"Today's Random Numbers\" for N days. This is a project to generate a random number once a day and post the value on Twitter.\n\nThe \"random numbers of the day\... | [{"type": "stdin_stdout", "input": "5\n15 -1 21 0 20", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n15 -1 21 0 22", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n-2 -1 -1 14 2", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n-2 -1 -1 21 2", "output": "2\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCurrently Tiny is learning Computational Geometry. When trying to solve a problem called \"The Closest Pair Of Points In The Plane\", he found that a code which gave a wrong time complexity got Accepted instead of Time Li... | [{"type": "stdin_stdout", "input": "3119 2029631\n", "output": "0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n0 13\n0 14\n0 15\n0 16\n0 17\n0 18\n0 19\n0 20\n0 21\n0 22\n0 23\n0 24\n0 25\n0 26\n0 27\n0 28\n0 29\n0 30\n0 31\n0 32\n0 33\n0 34\n0 35\n0 36\n0 37\n0 38\n0 39\n0 40\n0 41\n0 42\n0 43\n0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 10000... | [{"type": "stdin_stdout", "input": "2684354990\n", "output": "2684354990\n"}, {"type": "stdin_stdout", "input": "2539579656\n", "output": "2539579656\n"}, {"type": "stdin_stdout", "input": "9663677133\n", "output": "9663677133\n"}, {"type": "stdin_stdout", "input": "6530347911\n", "output": "6530347911\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTurbulent times are coming, so you decided to buy sugar in advance. There are $n$ shops around that sell sugar: the $i$-th shop sells one pack of sugar for $a_i$ coins, but only one pack to one customer each day. So in or... | [{"type": "stdin_stdout", "input": "1\n100 37\n29 33 45 64 95 33 45 76 86 5 52 16 27 24 80 5 44 19 96 8 77 67 21 17 22 56 28 3 84 27 39 12 60 35 75 6 68 71 81 5 76 85 73 54 8 4 58 4 22 5 11 51 72 31 67 93 38 94 96 22 73 34 33 84 21 60 89 88 30 21 44 57 5 16 11 65 20 68 68 41 25 78 43 96 61 10 40 98 55 35 19 79 21 4 62 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou can not just take the file and send it. When Polycarp trying to send a file in the social network \"Codehorses\", he encountered an unexpected problem. If the name of the file contains three or more \"x\" (lowercase L... | [{"type": "stdin_stdout", "input": "100\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", "output": "98\n"}, {"type": "stdin_stdout", "input": "100\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxxxxmrx\n", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through $n \\cdot k$ cities. The cities are numerated from $1$ to $n \\cdot k$, the distance between the neighboring cities is exact... | [{"type": "stdin_stdout", "input": "100000 100000\n50000 6424\n", "output": "1250000000 1250000000\n"}, {"type": "stdin_stdout", "input": "100000 101000\n50000 6424\n", "output": "39453125 1262500000\n"}, {"type": "stdin_stdout", "input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSereja has an n × m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with... | [{"type": "stdin_stdout", "input": "21 10 8\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n0 0 1 1 1 0 0 0 0 0\n0 0 0 1 1 0 0 0 0 0\n1 1 1 0 0 1 1 1 1 1\n0 0 0 1 1 0 0 0 0 0\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n0 0 0 1 1 0 0 0 0 0\n1 0 1 0 0 1 1 1 1 1\n0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDrazil likes heap very much. So he created a problem with heap:\n\nThere is a max heap with a height h implemented on the array. The details of this heap are the following:\n\nThis heap contains exactly 2^h - 1 distinct p... | [{"type": "stdin_stdout", "input": "2\n3 1\n7 6 3 5 4 2 1\n3 1\n23 6 5 4 3 2 1\n", "output": "1\n1 1 1 1 1 1\n1\n1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "2\n3 1\n14 10 3 5 4 2 1\n3 2\n23 12 9 4 3 2 1\n", "output": "1\n1 1 1 1 1 1\n8\n1 1 1 3\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n14 6 3 5 4 2 1\n3 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n integers. We denote the subarray a[l..r] as the array [a_l, a_{l + 1}, ..., a_r] (1 ≤ l ≤ r ≤ n).\n\nA subarray is considered good if every integer that occurs in this subarray occ... | [{"type": "stdin_stdout", "input": "100\n79 79 79 97 97 97 64 64 64 2 2 2 38 38 38 65 65 65 10 10 10 25 24 25 53 53 53 73 73 73 11 11 11 29 29 29 93 93 93 73 73 73 89 89 89 72 72 72 49 49 49 78 78 78 92 92 92 90 90 90 95 95 95 92 92 92 12 12 12 65 65 65 81 81 81 5 5 5 21 21 21 94 94 94 51 51 51 44 44 44 55 55 55 47 47 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn Bertown's main street n trees are growing, the tree number i has the height of ai meters (1 ≤ i ≤ n). By the arrival of the President of Berland these trees were decided to be changed so that their heights formed a bea... | [{"type": "stdin_stdout", "input": "10\n73905 73906 73907 85732 73909 73909 73908 73907 73906 73905\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10\n60718 99414 65042 65043 65044 38495 95782 65042 65041 65040\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n60718 99414 65042 89001 65044 38495 95... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTime Limit: 8 sec / Memory Limit: 64 MB\n\n\n\n\n\nExample\n\nInput\n\neggchickenegg\n\n\nOutput\n\negg\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the cod... | [{"type": "stdin_stdout", "input": "egechmilfgcgg", "output": "chicken\n"}, {"type": "stdin_stdout", "input": "egichgckenegg", "output": "egg\n"}, {"type": "stdin_stdout", "input": "egichnckegegg", "output": "egg\n"}, {"type": "stdin_stdout", "input": "egechickgnegg", "output": "egg\n"}, {"type": "stdin_stdout", "input... | 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\nn people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends amo... | [{"type": "stdin_stdout", "input": "1\n108\n", "output": "106\n"}, {"type": "stdin_stdout", "input": "1\n157\n", "output": "155\n"}, {"type": "stdin_stdout", "input": "1\n168\n", "output": "166\n"}, {"type": "stdin_stdout", "input": "1\n299\n", "output": "297\n"}, {"type": "stdin_stdout", "input": "1\n111\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\n\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to h... | [{"type": "stdin_stdout", "input": "10 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "11 12\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 43\n", "output": "10\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGildong's town has a train system that has $100$ trains that travel from the bottom end to the top end and $100$ trains that travel from the left end to the right end. The trains starting from each side are numbered from ... | [{"type": "stdin_stdout", "input": "3\n1 2\n1\n3 4\n3 2\n2 3 11\n2 1\n9 14\n2 12 16 28 42 57 59 86 99\n3 9 14 19 25 26 20 35 41 59 85 87 99 100\n", "output": "0\n1\n2\n"}, {"type": "stdin_stdout", "input": "3\n1 2\n1\n1 4\n3 2\n1 3 4\n2 4\n9 14\n2 14 16 28 33 57 59 92 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ chips arranged in a circle, numbered from $1$ to $n$. \n\nInitially each chip has black or white color. Then $k$ iterations occur. During each iteration the chips change their colors according to the followi... | [{"type": "stdin_stdout", "input": "101 2\nBWBWBWWWBWBWBWWWBWWWBWWWBWBBBBBWBWBBBWBWBWWBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWB\n", "output": "BBBWWWWWWWBWWWWWWWWWWWWWWBBBBBBBBBBBBBBWWWWBBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWWWWWBWBBB\n"}, {"type": "stdin_stdout", "input": "101 2\nBWBWBWBWWWB... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nMobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follo... | [{"type": "stdin_stdout", "input": "1\n7 22 0 0\n4\n2 2 0 4\n1 3 0 0\n9 10 2 1\n3 2 0 0\n0", "output": "29\n190\n"}, {"type": "stdin_stdout", "input": "1\n7 11 0 0\n4\n2 2 0 4\n1 3 0 0\n3 8 2 1\n3 2 0 0\n0", "output": "18\n110\n"}, {"type": "stdin_stdout", "input": "1\n7 22 0 0\n4\n2 2 0 4\n1 3 0 0\n3 8 2 1\n3 2 0 0\n0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nReading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are my names in many countries. Mithrandir a... | [{"type": "stdin_stdout", "input": "tttdddssstttssstttdddddddddttttttdddsssdddtttsssdddsssssstttddddddtttdddssstttsssttttttdddtttsssssstttssssssssstttsssssstttssstttdddddddddsssdddssssssdddssstttsssdddssstttdddttttttdddddddddsssssstttdddtttssssssdddddddddttttttdddtttsssdddssstttsssdddssssssdddsssdddddddddtttssstttsssss... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coo... | [{"type": "stdin_stdout", "input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\n3 0 1\n\n\nOutput\n\n2\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Your progra... | [{"type": "stdin_stdout", "input": "3\n152 -3 2", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n-1 -1 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n13 -2 3", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n25 -2 3", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n25 -2 4", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges.\n\nInput\n\nThe first input line cont... | [{"type": "stdin_stdout", "input": "2\n2\n10 15\n5 7\n20 18\n1\n0 0\n", "output": "YES\n1 3 \nYES\n1 \n"}, {"type": "stdin_stdout", "input": "2\n2\n10 15\n5 7\n20 18\n1\n0 0\n", "output": "YES\n1 3 \nYES\n1 \n"}, {"type": "stdin_stdout", "input": "2\n2\n10 15\n5 11\n20 22\n1\n0 0\n", "output": "YES\n1 3\nYES\n1\n"}, {"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA: four tea\n\nproblem\n\nTea is indispensable for programming contests. Tea has the effect of relieving constant tension [citation needed]\n\nThere are N players participating in the contest, so I would like to prepare t... | [{"type": "stdin_stdout", "input": "10\n1 2 10 2\n0 0 0 15", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n1 1 3 2\n0 2 3 16", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n0 1 3 2\n1 2 3 16", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n0 1 6 1\n0 0 1 50", "output": "1\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPresident of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides ... | [{"type": "stdin_stdout", "input": "24 11 N\n.NNNNNNNNNN\n.NNNNNNNNNN\n........RRR\n........RRR\n........RRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMM...\n....XXXXXXX\n...........\n.....CCCCCC\n.....CCCCCC\n.HHHHHHHHHH\n..VVVVV....\n..VVVVV....\n..VVVVV....\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nModern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.\n\nIn this problem you should implement the simila... | [{"type": "stdin_stdout", "input": "255\nT___J(M_XZJlr_lH___mqJA_p__kW)ko__F_M_Aro__ZA_G_M_P_____j_V(J_Jk_dkR_ta_lbIUhKFfo_y_DluW)IVFj_gouRfMhabn()_e___q_vo__QPEGBI_TpVVI_clPwwb_m_yL_cMVKgi___RJb_J_f____tPCyntLOr_s_x_N_SyqQw_zP_mycsW_o_c_o_Yzb_UVa_ATd(BYH_gl___Y__Uzok_Y_IA_XL_D__bkJ____e__K_quk)\n", "output": "10 25\n"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a currency system in which there are notes of six denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100.\nIf the sum of Rs. N is input, write a program to computer smallest number of notes that will... | [{"type": "stdin_stdout", "input": "3 \n1200\n1258\n242", "output": "12\n16\n7\n"}, {"type": "stdin_stdout", "input": "3 \n1200\n493\n380", "output": "12\n11\n7\n"}, {"type": "stdin_stdout", "input": "3 \n1200\n806\n380", "output": "12\n10\n7\n"}, {"type": "stdin_stdout", "input": "3\n1200\n500\n242\n", "output": "12\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.\n\nThere are n schools numerated from 1 to n. One can travel... | [{"type": "stdin_stdout", "input": "300997\n", "output": "150498\n"}, {"type": "stdin_stdout", "input": "273658\n", "output": "136828\n"}, {"type": "stdin_stdout", "input": "222057\n", "output": "111028\n"}, {"type": "stdin_stdout", "input": "456496\n", "output": "228247\n"}, {"type": "stdin_stdout", "input": "220343\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of $n$ positive integers $a_1, a_2, \\ldots, a_n$. Your task is to calculate the number of arrays of $n$ positive integers $b_1, b_2, \\ldots, b_n$ such that:\n\n$1 \\le b_i \\le a_i$ for every $i$ ... | [{"type": "stdin_stdout", "input": "100\n23 39 85 46 97 72 41 70 37 18 8 40 33 61 12 79 51 78 61 66 85 97 78 14 70 47 100 40 15 40 61 52 19 30 14 91 82 56 10 6 68 24 97 61 31 78 18 45 88 6 37 38 51 86 37 42 58 30 79 56 50 14 61 18 13 20 57 3 93 15 24 74 32 21 71 93 2 66 25 75 75 10 86 82 30 31 6 49 15 33 100 35 1 96 87... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai. \n\nAdditionally the Little Elephant has m queries to the ... | [{"type": "stdin_stdout", "input": "6 6\n1 2 2 3 3 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 6\n", "output": "1\n0\n2\n1\n1\n3\n"}, {"type": "stdin_stdout", "input": "6 6\n1 2 2 3 3 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 3\n", "output": "1\n0\n2\n1\n1\n2\n"}, {"type": "stdin_stdout", "input": "6 6\n1 2 2 3 2 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 6... | 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 ... | [{"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\nFilled with optimism, Hyunuk will host a conference about how great this new year will be!\n\nThe conference will have $n$ lectures. Hyunuk has two candidate venues $a$ and $b$. For each of the $n$ lectures, the speaker s... | [{"type": "stdin_stdout", "input": "4\n544431836 544432042 793496989 793497079\n544429970 544430041 793496343 793496350\n544432412 544432541 793497670 793498269\n544431029 544431033 793494552 793494859\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4\n922033367 922033530 246113700 246113747\n922034178 92203... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $k$ ($k \\ge 3$). Nastya was very confused by this present, so she ... | [{"type": "stdin_stdout", "input": "5\n8 6\n1 2 4 1 2 7 1 2\n5 3\n3 2 3 2 1\n10 8\n7 4 7 6 2 3 0 1 -1 1\n15 10\n3 14 4 8 2 1 4 5 21 2 0 4 2 1 3\n7 5\n1 2 3 4 2 6 2\n", "output": "3 2\n2 2\n4 2\n4 1\n3 3\n"}, {"type": "stdin_stdout", "input": "5\n8 6\n1 2 4 1 2 7 1 2\n5 3\n3 2 3 2 1\n10 8\n7 4 7 6 2 3 0 1 -1 1\n15 10\n3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for \"hardness\".)\n\nThis year, 2^N stones participated. The hardness of the i-th stone is A_i.\n\nIn the con... | [{"type": "stdin_stdout", "input": "3\n2\n1\n-3\n4\n-1\n25\n110\n1014", "output": "872\n"}, {"type": "stdin_stdout", "input": "3\n2\n1\n-3\n4\n-1\n25\n111\n1014", "output": "871\n"}, {"type": "stdin_stdout", "input": "3\n2\n1\n-3\n4\n-2\n25\n111\n1014", "output": "870\n"}, {"type": "stdin_stdout", "input": "3\n2\n1\n-3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k. \n\nJzzhu wonders, how many groups exists such that ai1 & ai2 & ... & ... | [{"type": "stdin_stdout", "input": "55\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 7 8 9 8 9 9\n", "output": "621247139\n"}, {"type": "stdin_stdout", "input": "55\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 10 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 7 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: if the last digit of the ... | [{"type": "stdin_stdout", "input": "1000000000 0\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "1559848638 5\n", "output": "1559848633\n"}, {"type": "stdin_stdout", "input": "1100000000 0\n", "output": "1100000000\n"}, {"type": "stdin_stdout", "input": "1086932676 10\n", "output": "108693264\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have an axis-aligned rectangle room with width $W$ and height $H$, so the lower left corner is in point $(0, 0)$ and the upper right corner is in $(W, H)$.\n\nThere is a rectangular table standing in this room. The si... | [{"type": "stdin_stdout", "input": "5\n8 5\n2 1 7 4\n4 2\n5 4\n2 2 5 4\n3 3\n1 8\n0 3 1 6\n1 5\n8 1\n3 0 6 1\n5 1\n8 10\n4 5 7 8\n8 5\n", "output": "1.000000000\n-1\n2.000000000\n2.000000000\n0.000000000\n"}, {"type": "stdin_stdout", "input": "5\n8 5\n2 1 7 4\n4 2\n5 4\n2 2 5 4\n3 3\n1 8\n0 3 1 6\n1 5\n8 1\n3 0 6 1\n5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nParsa has a humongous tree on $n$ vertices.\n\nOn each vertex $v$ he has written two integers $l_v$ and $r_v$.\n\nTo make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \\le a_v \\le r_v$)... | [{"type": "stdin_stdout", "input": "3\n2\n2 10\n6 6\n1 2\n3\n1 3\n13 6\n7 15\n1 2\n2 3\n6\n10 14\n12 20\n21 19\n2 12\n10 17\n3 17\n3 2\n6 5\n1 5\n2 6\n4 6\n", "output": "4\n18\n48\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 6\n3 13\n1 2\n3\n1 3\n10 6\n12 9\n1 2\n2 3\n6\n3 14\n9 20\n12 19\n1 12\n11 17\n3 17\n3 3\n6 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem is a complicated version of D1, but it has significant differences, so read the whole statement.\n\nPolycarp has an array of $n$ ($n$ is even) integers $a_1, a_2, \\dots, a_n$. Polycarp conceived of a positiv... | [{"type": "stdin_stdout", "input": "10\n10\n-30 45 -37 -11 25 61 97 7 7 35\n10\n48 -2 13 88 97 -27 40 88 41 -67\n10\n-13 -31 94 -43 19 95 -35 5 41 10\n10\n-28 -88 17 17 2 -43 -73 -73 -13 2\n10\n46 -73 47 54 -13 67 7 -33 1 -33\n10\n60 92 -100 -76 -12 -52 4 84 -38 36\n10\n50 62 56 -58 -10 87 29 52 14 -22\n10\n-78 50 -52 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe phantom thief \"Lupin IV\" is told by the beautiful \"Fujiko Mine\", a descendant of the Aizu clan, that the military funds left by the Aizu clan are sleeping in Aizuwakamatsu city. According to a report by Lupine's l... | [{"type": "stdin_stdout", "input": "5\n13 199 1\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "output": "93 37 27 13 123\n"}, {"type": "stdin_stdout", "input": "5\n11 199 0\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "output": "93 37 27 11 123\n"}, {"type": "stdin_stdout", "input": "5\n11 91 0\n124 1000 1\n37 350... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<cont... | [{"type": "stdin_stdout", "input": "ftpprutpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n", "output": "ftp://p.ru/tpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n"}, {"type": "stdin_stdout", "input": "ftpprutufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu\n", "output": "ftp://p.ru/tufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is built in the following way: at first the number 1 is written out, then the numbers from 1 to 2, then the numbers ... | [{"type": "stdin_stdout", "input": "100000000000000\n", "output": "1749820\n"}, {"type": "stdin_stdout", "input": "99999998250180\n", "output": "14142135\n"}, {"type": "stdin_stdout", "input": "99999998250180\n", "output": "14142135\n"}, {"type": "stdin_stdout", "input": "100000000000000\n", "output": "1749820\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMonocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $a$ and screen height not greater than $b$. Mono... | [{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGuy-Manuel and Thomas are going to build a polygon spaceship.\n\nYou're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon o... | [{"type": "stdin_stdout", "input": "8\n-440365664 -897818514\n107345267 -994221803\n248590739 -968608613\n473576011 -880752952\n105203574 994450706\n-164464580 1061907476\n-522092561 852888831\n-874210729 485546704\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "8\n-845415846 -897818514\n107345267 -994221803\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLunar New Year is approaching, and you bought a matrix with lots of \"crosses\".\n\nThis matrix $M$ of size $n \\times n$ contains only 'X' and '.' (without quotes). The element in the $i$-th row and the $j$-th column $(i... | [{"type": "stdin_stdout", "input": "14\nXXX.XXXXX..X.X\nX..XX..X...X..\n.....X.XX..XXX\n.X..X..XXX.XX.\n...XXXX.XX..XX\n.X..XX...XXX..\nXX.XX.XX..XXX.\n.X..X.....X.XX\n...XXX...XX.XX\nXXX.XX.XX.X.XX\nX.XXXX..XX.XX.\n.X.XX....X....\nX..XX..X.XX.X.\n..X...XX....XX\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInput\n\nThe first line of the input contains a single integer N (1 ≤ N ≤ 24). The next N lines contain 5 space-separated integers each. The first three integers will be between 0 and 2, inclusive. The last two integers w... | [{"type": "stdin_stdout", "input": "10\n2 0 0 1 1\n1 1 1 2 1\n2 1 0 1 2\n1 1 0 1 1\n2 1 0 2 1\n1 1 1 2 1\n1 2 1 3 1\n2 0 0 1 1\n1 1 0 1 1\n1 1 2 2 2\n", "output": "\ncodeforcez\n"}, {"type": "stdin_stdout", "input": "1\n1 0 0 1 0\n", "output": "codeforcez\n"}, {"type": "stdin_stdout", "input": "1\n1 0 0 1 0\n", "output... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya has an array of integers a_1, a_2, …, a_n. He only likes sorted arrays. Unfortunately, the given array could be arbitrary, so Petya wants to sort it.\n\nPetya likes to challenge himself, so he wants to sort array us... | [{"type": "stdin_stdout", "input": "7\n1\n1\n2\n2 2\n2\n2 2\n3\n1 2 3\n3\n1 1 1\n3\n3 1 2\n4\n2 1 4 3\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "7\n1\n1\n2\n1 2\n2\n1 1\n3\n1 2 3\n3\n2 1 1\n3\n3 1 1\n4\n4 1 4 3\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a picture consisting of $n$ rows and $m$ columns. Rows are numbered from $1$ to $n$ from the top to the bottom, columns are numbered from $1$ to $m$ from the left to the right. Each cell is painted either bl... | [{"type": "stdin_stdout", "input": "9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n*.**\n", "output": "0\n0\n0\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThere are coins with front and back sides and dice with rolls from $ 1 $ to $ N $. Gacho decided to play the following games using these.\n\nThe game starts with a score of $ 0 $ and proceeds as follows.\n\n\n1... | [{"type": "stdin_stdout", "input": "12 110 467", "output": "469611202\n"}, {"type": "stdin_stdout", "input": "12 100 467", "output": "732809678\n"}, {"type": "stdin_stdout", "input": "12 13 187", "output": "455459798\n"}, {"type": "stdin_stdout", "input": "12 60 467", "output": "654858060\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a \"plus\") and negative (a \"minus\"). If t... | [{"type": "stdin_stdout", "input": "115\n10\n10\n10\n10\n01\n01\n10\n10\n10\n01\n01\n10\n01\n01\n10\n10\n10\n01\n10\n01\n10\n10\n01\n01\n10\n10\n10\n10\n01\n10\n01\n01\n10\n10\n10\n10\n01\n10\n10\n10\n01\n10\n01\n10\n10\n10\n10\n01\n01\n01\n10\n10\n01\n01\n01\n10\n10\n01\n10\n01\n01\n01\n01\n10\n10\n01\n10\n01\n01\n01\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's introduce some definitions that will be needed later.\n\nLet $prime(x)$ be the set of prime divisors of $x$. For example, $prime(140) = \\{ 2, 5, 7 \\}$, $prime(169) = \\{ 13 \\}$.\n\nLet $g(x, p)$ be the maximum po... | [{"type": "stdin_stdout", "input": "1000000000 1000000000000000000\n", "output": "997440007\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000000000000\n", "output": "997440007\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000010000000\n", "output": "778038345\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice has just learned addition. However, she hasn't learned the concept of \"carrying\" fully — instead of carrying to the next column, she carries to the column two columns to the left.\n\nFor example, the regular way t... | [{"type": "stdin_stdout", "input": "2\n352942581\n1100110000\n", "output": "192407906\n102030199\n"}, {"type": "stdin_stdout", "input": "2\n178886702\n1100110000\n", "output": "148360651\n102030199\n"}, {"type": "stdin_stdout", "input": "2\n139544809\n1100110000\n", "output": "69014088\n102030199\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.\n\nA bar is represented as n ... | [{"type": "stdin_stdout", "input": "100 101 100\n", "output": "101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he ... | [{"type": "stdin_stdout", "input": "100 20\n.....G.#.#..................#.........##....#...................#.#..........#...#.#.T..#.......#...\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100 33\nG..................................................................................................T\n", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal ... | [{"type": "stdin_stdout", "input": "5\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n", "output": "899999999100000001\n449999999550000002\n899999999100000001\n4499999... | 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 100\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConnect the countless points with lines, till we reach the faraway yonder.\n\nThere are n points on a coordinate plane, the i-th of which being (i, y_{i}).\n\nDetermine whether it's possible to draw two parallel and non-o... | [{"type": "stdin_stdout", "input": "20\n-975467170 758268840 -975467171 758268839 -975467172 758268838 -975467173 758268837 -975467174 1015089897 -975467175 758268835 -975467176 758268834 -975467177 967684266 -975467178 758268832 -975467179 1082851919\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "20\n-97546... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nОсновой любой социальной сети является отношение дружбы между двумя пользователями в том или ином смысле. В одной известной социальной сети дружба симметрична, то есть если a является другом b, то b также является другом ... | [{"type": "stdin_stdout", "input": "10 50\n946010975 207263044\n923545573 749203275\n862015642 426425906\n749203275 839134958\n910721783 289091881\n827003531 333726912\n49704846 538788252\n382891592 207263044\n333726912 438209022\n974360048 49704846\n", "output": "49704846: 0\n207263044: 0\n289091881: 0\n333726912: 0\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAbsent-minded Masha got set of n cubes for her birthday.\n\nAt each of 6 faces of each cube, there is exactly one digit from 0 to 9. Masha became interested what is the largest natural x such she can make using her new cu... | [{"type": "stdin_stdout", "input": "3\n5 1 2 9 6 4\n9 0 6 4 2 8\n4 6 2 8 3 7\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1 0 2 3\n4 5 6 7 8 9\n0 0 0 0 0 0\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1 1 1 1\n0 2 3 4 5 6\n7 8 9 2 3 4\n", "output": "10\n"}, {"type": "stdin_stdout... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMeikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many... | [{"type": "stdin_stdout", "input": "8\n2\nomura\ntoshio\nraku\ntanaka\ninura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqrst\nabdxcef\n0", "output": "inura,miura\ninura,omura\nmiura,omura\ntoshio,yoshoi\n4\ntanaka,tasaka\n1\n0\nabcdef,abdxcef\nabcdef,abzdefa\npqrst,p... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ cities and $m$ roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.\n\nWhat is the minimum number of new roads that need to be built to make all the cities reachable from ... | [{"type": "stdin_stdout", "input": "39 40 38\n4 8\n24 28\n16 17\n7 25\n4 29\n34 35\n16 24\n21 10\n23 36\n36 14\n28 16\n34 19\n15 21\n22 38\n22 37\n37 27\n28 33\n3 29\n32 22\n12 30\n9 15\n5 19\n23 27\n19 17\n25 17\n24 11\n39 10\n6 20\n16 6\n3 18\n34 21\n15 38\n11 19\n11 3\n32 4\n15 13\n16 11\n11 7\n33 7\n3 33\n", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by... | [{"type": "stdin_stdout", "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n1 8\n2 14\n7 0\n11 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0", "output": "NG\nOK\n"}, {"type": "stdin_stdout", "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n3 8\n6 14\n7 0\n8 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIlya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number written on... | [{"type": "stdin_stdout", "input": "10\n2 3 4 5 6 7 11 9 10 11\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n4 8\n8 9\n9 10\n", "output": "2 3 2 1 1 1 1 1 1 1 \n"}, {"type": "stdin_stdout", "input": "10\n2 3 4 5 6 7 11 9 10 11\n1 2\n2 3\n3 4\n4 5\n5 6\n9 7\n4 8\n8 9\n9 10\n", "output": "2 3 2 1 1 1 1 1 1 1 \n"}, {"type": "stdin_stdou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, a... | [{"type": "stdin_stdout", "input": "23 23\n", "output": "22\n"}, {"type": "stdin_stdout", "input": "405 14", "output": "11\n"}, {"type": "stdin_stdout", "input": "9 12\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "19 0\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "22 1\n", "output": "23\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInput\n\nThe input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.\n\nOutput\n\nOutput \"YES\" or \"NO\".\n\nExamples\n\nInput\n\n\n2 3\n\n\nOutput\n\n\nYES\n\n\nInput\n\n\n3 2\n\n\nOut... | [{"type": "stdin_stdout", "input": "33 16\n", "output": "\nYES\n"}, {"type": "stdin_stdout", "input": "11 11\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "12 16\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "11 20\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15 11\n", "output": "Y... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDid you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eager... | [{"type": "stdin_stdout", "input": "2\nQ 0\nP 14\n\n2\nO -1\nM -16\n\n0", "output": "13\n15\n"}, {"type": "stdin_stdout", "input": "2\nQ -1\nP 14\n\n2\nN -1\nM -3\n\n0", "output": "13\n2\n"}, {"type": "stdin_stdout", "input": "2\nQ -1\nP 8\n\n2\nM -1\nM -14\n\n0", "output": "7\n13\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi has two integers X and Y.\nHe computed X + Y and X - Y, and the results were A and B, respectively.\nNow he cannot remember what X and Y were. Find X and Y for him.\n\n-----Constraints-----\n - -100 \\leq A, B \... | [{"type": "stdin_stdout", "input": "-100 -100\n", "output": "-100 0\n"}, {"type": "stdin_stdout", "input": "-100 100\n", "output": "0 -100\n"}, {"type": "stdin_stdout", "input": "-39 -69\n", "output": "-54 15\n"}, {"type": "stdin_stdout", "input": "100 -100\n", "output": "0 100\n"}, {"type": "stdin_stdout", "input": "-... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offers $n$ pieces of sushi aligned in a row, and a customer has to choose a continuous subsegment of these sushi to buy.\n\nThe p... | [{"type": "stdin_stdout", "input": "100\n2 2 2 2 2 2 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 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 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\n", "output": "54\n"}, {"type": "stdin_stdout", "input": "100\n1 2 2 2 2 2 2 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPeter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it w... | [{"type": "stdin_stdout", "input": "29 -999961 689169\n-999960 689169\n-999927 -938525\n-999735 -989464\n-993714 -997911\n-870186 -999686\n-796253 -999950\n-139940 -1023635\n969552 -999972\n985446 -999398\n992690 -997295\n999706 -973137\n999898 -848630\n999997 -192297\n999969 773408\n999495 960350\n1685305 981671\n9983... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the minimum area of a square land on which you can place two identical rectangular $a \\times b$ houses. The sides of the houses should be parallel to the sides of the desired square land.\n\nFormally, You are give... | [{"type": "stdin_stdout", "input": "8\n3 2\n4 2\n1 1\n3 1\n4 13\n1 3\n12 4\n100 100\n", "output": "16\n16\n4\n9\n169\n9\n144\n40000\n"}, {"type": "stdin_stdout", "input": "8\n3 2\n2 2\n1 1\n4 2\n2 11\n1 4\n7 4\n100 101\n", "output": "16\n16\n4\n16\n121\n16\n64\n40000\n"}, {"type": "stdin_stdout", "input": "8\n3 2\n4 2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\n* Select a pair of integers, A_i and A_j, that have the same parity ... | [{"type": "stdin_stdout", "input": "5\n1 18 1 14 0", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n2 18 0 14 0", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n4 3 -1 16 4", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n2 3 -1 16 4", "output": "YES\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nAt IOI Confectionery, rice crackers are baked using the traditional method since the company was founded. This traditional method is to bake the front side for a certain period of time with charcoal, turn it ov... | [{"type": "stdin_stdout", "input": "2 5\n0 1 1 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0", "output": "10\n15\n"}, {"type": "stdin_stdout", "input": "2 5\n1 1 1 1 0\n0 0 0 0 1\n3 6\n1 0 0 0 0 1\n0 1 1 0 1 0\n1 0 1 1 0 1\n0 0", "output": "10\n16\n"}, {"type": "stdin_stdout", "input": "2 5\n1 1 1 1 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEverybody in Russia uses Gregorian calendar. In this calendar there are 31 days in January, 28 or 29 days in February (depending on whether the year is leap or not), 31 days in March, 30 days in April, 31 days in May, 30 ... | [{"type": "stdin_stdout", "input": "24\n31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\n", "output": "Yes\n\n"}, {"type": "stdin_stdout", "input": "24\n31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\n", "output": "Yes\n\n"}, {"type": "stdin_stdout", "input": "24\n28 31 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a present to Bob. However, she wants to find the set of photos with maximum beauty and she ne... | [{"type": "stdin_stdout", "input": "50\n5 42 16 13 20 2 39 49 33 1 11 4 46 3 48 44 12 7 27 41 35 38 26 6 31 37 10 50 24 9 32 15 47 30 17 28 22 29 23 34 8 18 40 21 19 36 25 43 45 14\n427 -3 -165 -161 302 -337 285 -418 227 -78 -453 -122 -162 -249 -194 119 -127 322 -238 467 -236 254 263 -57 225 391 270 -96 -173 329 -45 13... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\n-----Constrai... | [{"type": "stdin_stdout", "input": "1729\n", "output": "294867501\n"}, {"type": "stdin_stdout", "input": "2000\n", "output": "883312678\n"}, {"type": "stdin_stdout", "input": "1445\n", "output": "157799856\n"}, {"type": "stdin_stdout", "input": "1447\n", "output": "185357934\n"}, {"type": "stdin_stdout", "input": "1497... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a building with 2N floors, numbered 1, 2, \\ldots, 2N from bottom to top.\nThe elevator in this building moved from Floor 1 to Floor 2N just once.\nOn the way, N persons got on and off the elevator. Each person i... | [{"type": "stdin_stdout", "input": "100\n65 165\n6 106\n41 141\n1 101\n4 104\n33 133\n5 105\n57 157\n98 198\n15 115\n52 152\n53 153\n46 146\n29 129\n42 142\n8 108\n12 112\n69 169\n47 147\n87 187\n79 179\n88 188\n67 167\n26 126\n55 155\n73 173\n72 172\n74 174\n95 195\n36 136\n61 161\n10 110\n17 117\n7 107\n23 123\n30 13... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has recently got a job as a cashier at a local store. His day at work is $L$ minutes long. Vasya has already memorized $n$ regular customers, the $i$-th of which comes after $t_{i}$ minutes after the beginning of th... | [{"type": "stdin_stdout", "input": "1 1000000000 1\n0 1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1000000000 1\n0 1000000000\n", "output": "0"}, {"type": "stdin_stdout", "input": "0 1000000000 1\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "0 1000000000 1000000000\n", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBridge Removal\n\nICPC islands once had been a popular tourist destination. For nature preservation, however, the government decided to prohibit entrance to the islands, and to remove all the man-made structures there. Th... | [{"type": "stdin_stdout", "input": "4\n1 2 3\n10 37 30\n10\n1 2 2 1 1 5 1 10 8\n10 2 1 20 2 1 30 1 1\n3\n1 1\n1 1\n0", "output": "114\n139\n2\n"}, {"type": "stdin_stdout", "input": "4\n1 2 3\n10 37 52\n10\n1 2 2 1 1 5 1 10 8\n10 2 1 20 2 1 30 1 1\n3\n1 1\n1 1\n0", "output": "136\n139\n2\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAri the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects ... | [{"type": "stdin_stdout", "input": "63 20\n35 26\n54 5\n32 56\n56 53\n59 46\n37 31\n46 8\n4 1\n2 47\n59 42\n55 11\n62 6\n30 7\n60 24\n41 36\n34 22\n24 34\n21 2\n12 52\n8 44\n60 21\n24 30\n48 35\n48 25\n32 57\n20 37\n11 54\n11 62\n42 58\n31 43\n12 23\n55 48\n51 55\n41 27\n25 33\n21 18\n42 12\n4 15\n51 60\n62 39\n46 41\n... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.