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\nAlice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"...
[{"type": "stdin_stdout", "input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeedeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\n", "output": "4\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The r...
[{"type": "stdin_stdout", "input": "50\njcg\nvle\njopb\nepdb\nnkef\nfv\nxj\nufe\nfuy\noqta\ngbc\nyuz\nec\nyji\nkuux\ncwm\ntq\nnno\nhp\nzry\nxxpp\ntjvo\ngyz\nkwo\nvwqz\nyaqc\njnj\nwoav\nqcv\ndcu\ngc\nhovn\nop\nevy\ndc\ntrpu\nyb\nuzfa\npca\noq\nnhxy\nsiqu\nde\nhphy\nc\nwovu\nf\nbvv\ndsik\nlwyg\n", "output": "lwyg\ndsik\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.\n\nSo imagine Monocarp got recommended $n$ songs, number...
[{"type": "stdin_stdout", "input": "1\n50\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\n10101010101010101010101010101010101010101010101010\n", "output": "26 1 27 2 28 3 29 4 30 5 31 6 32 7 33 8 34 9 35 10 36 11 37 12 38 13 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an array $a$ of length $n$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.\n\nA sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained fro...
[{"type": "stdin_stdout", "input": "1\n69\n1 1 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 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": "YES\n"}, {"type": "stdin_stdout", "input": "1\n69\n1 1 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 0 1 1 1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a large electronic screen which can display up to $998244353$ decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of $7$ segments whic...
[{"type": "stdin_stdout", "input": "1\n140047\n", "output": "7111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has pa...
[{"type": "stdin_stdout", "input": "22 22\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "75 75\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "26 26\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "45 45\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "72 72\n", "output": "Yes...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ segments on a $Ox$ axis $[l_1, r_1]$, $[l_2, r_2]$, ..., $[l_n, r_n]$. Segment $[l, r]$ covers all points from $l$ to $r$ inclusive, so all $x$ such that $l \\le x \\le r$.\n\nSegments can be placed arbitrar...
[{"type": "stdin_stdout", "input": "4\n2\n-1000000000 1000000000\n-1000000000 1000000000\n2\n-1000000000 -1\n0 1000000000\n2\n-1000000000 -1\n1 1000000000\n2\n-1000000000 1\n-1 1000000000\n", "output": "1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "4\n2\n-1000000000 1000000000\n-1000000000 1000000000\n2\n-10000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns...
[{"type": "stdin_stdout", "input": "5 93\n00000000000000000000000000000000000000000000000000000000100000000000000000000000000000000001010\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n000000100000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOkabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.\n\nConsider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. The...
[{"type": "stdin_stdout", "input": "1000 10000\n", "output": "74133360011484445\n"}, {"type": "stdin_stdout", "input": "1000 10000\n", "output": "74133360011484445"}, {"type": "stdin_stdout", "input": "1581 6030\n", "output": "40628923515290265\n"}, {"type": "stdin_stdout", "input": "1061 8096\n", "output": "4428677959...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediat...
[{"type": "stdin_stdout", "input": "5 12 1\n1 5\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "5 10 2\n1 2\n3 1 7 5\n", "output": "0 0 0 0 0 0 5 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy.\n\nEach planet of the galaxy has a government. Some governme...
[{"type": "stdin_stdout", "input": "6 6\n1 2\n1 5\n1 3\n4 5\n5 4\n4 6\n1\n3\n-1\n2\n2\n10", "output": "0\n"}, {"type": "stdin_stdout", "input": "6 6\n1 2\n1 5\n2 2\n4 5\n5 4\n2 1\n1\n1\n5\n2\n2\n6", "output": "13\n"}, {"type": "stdin_stdout", "input": "6 6\n1 2\n2 3\n1 3\n2 5\n5 2\n4 4\n1\n2\n8\n3\n4\n6", "output": "11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n-----Problem description-----\nAs a holiday gift, Tojo received a probability problem. The problem read as follows\nConsider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from ...
[{"type": "stdin_stdout", "input": "2\n2 2\n1 6\n", "output": "3.000000\n6.000000\n"}, {"type": "stdin_stdout", "input": "2\n2 2\n1 6", "output": "3.000000\n6.000000\n"}, {"type": "stdin_stdout", "input": "2\n-1 21\n-1 13", "output": "19.0\n11.0\n"}, {"type": "stdin_stdout", "input": "2\n0 1\n18 101", "output": "0.0\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen you enter 8 numbers from 0 to 9, write a program that outputs the difference between the largest integer and the smallest integer that can sort the 8 numbers. The number that can be sorted may start from 0, such as 0...
[{"type": "stdin_stdout", "input": "2\n65539010\n102034250", "output": "96417531\n543098655\n"}, {"type": "stdin_stdout", "input": "2\n124008976\n66277190", "output": "986395311\n96499431\n"}, {"type": "stdin_stdout", "input": "2\n188122632\n66277190", "output": "774098523\n96499431\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"It all started with a kiss.\"\n\nChotu was up all night, planning for his first kiss. He has collected the data about all the kissing spots in Allahabad.\nAccording to his survey there are N kissing spots in the city, e...
[{"type": "stdin_stdout", "input": "3000\n23295338 17341870 1800768 4339125 24688800 393432044 128136174 69457920 300338187 37790025 358007100 138139768 27657045 3574080 4554552 2407790 358704 2701283 80503008 216417600 159893600 10268874 40697856 6444438 83200390 5617752 29905568 66617460 37598066 145330344 35650804 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each ot...
[{"type": "stdin_stdout", "input": "100\n3\n6 5\n1 5\n2 1\n5 1\n6 5\n5 1\n6 2\n1 2\n6 5\n5 1\n5 1\n1 5\n2 6\n6 2\n5 6\n1 2\n1 5\n5 6\n1 5\n1 2\n2 6\n1 2\n6 2\n1 5\n6 2\n2 6\n1 5\n6 2\n6 5\n5 6\n1 5\n5 6\n5 1\n5 1\n2 1\n1 2\n5 6\n6 5\n1 5\n5 1\n1 2\n1 5\n1 2\n2 6\n5 1\n2 6\n2 6\n5 6\n2 6\n6 5\n6 5\n1 5\n2 1\n5 6\n5 6\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSomeday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance...
[{"type": "stdin_stdout", "input": "-1000000000 -1000000000 2000000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-1000000000 1000000000 2000000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-1000000000 -1000000000 1000000000\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "-100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so ...
[{"type": "stdin_stdout", "input": "52 38 22\n9 25 D\n28 29 C\n29 25 D\n4 28 D\n23 29 D\n24 25 D\n17 12 C\n11 19 C\n13 14 C\n12 15 D\n7 25 C\n2 25 C\n6 17 C\n2 20 C\n15 23 D\n8 21 C\n13 15 D\n29 15 C\n25 20 D\n22 20 C\n2 13 D\n13 22 D\n27 20 C\n1 21 D\n22 17 C\n14 21 D\n4 25 D\n5 23 C\n9 21 C\n2 20 C\n14 18 C\n29 24 C\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a. Some element of this array a_{i} is a local minimum iff it is strictly less than both of its neighbours (that is, a_{i} < a_{i} - 1 and a_{i} < a_{i} + 1). Also the element can be called local ma...
[{"type": "stdin_stdout", "input": "4\n1 5 2 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n1 5 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4\n1 7 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n-1 1100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n1 3 2 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of size n × m, where the height of the cell (i, j) is a_{i, j}.\n\nYou are in the cell (1, 1) r...
[{"type": "stdin_stdout", "input": "1\n8 6\n1 2 3 4 5 6\n7 8 9 10 11 12\n13 14 15 16 17 18\n19 20 21 22 23 24\n26 27 28 29 30 31\n33 34 35 36 34 35\n37 38 39 40 41 42\n44 45 46 47 48 49\n", "output": " 141\n"}, {"type": "stdin_stdout", "input": "5\n3 4\n1 2 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOmkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.\n\nOmkar currently has $n$ supports arranged in a line, the $i$-th of which has height $a_i$. ...
[{"type": "stdin_stdout", "input": "3\n4\n5 3 2 1\n5\n1 2 3 10 3\n3\n1 1 1\n", "output": "4\n7\n0\n"}, {"type": "stdin_stdout", "input": "3\n4\n5 3 2 0\n5\n1 2 3 10 3\n3\n1 1 1\n", "output": "5\n7\n0\n"}, {"type": "stdin_stdout", "input": "3\n4\n5 3 2 0\n5\n1 2 3 10 3\n3\n2 1 1\n", "output": "5\n7\n1\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.\n\nMarmot brought Mole n ordered piles of worms such that i-th pile contains a_{i} worms. He labeled all these worms with consecutive inte...
[{"type": "stdin_stdout", "input": "5\n2 12 3 4 9\n3\n1 25 11\n", "output": "1\n5\n2\n"}, {"type": "stdin_stdout", "input": "5\n2 12 3 4 9\n3\n1 25 17\n", "output": "1\n5\n3\n"}, {"type": "stdin_stdout", "input": "5\n2 17 3 4 9\n3\n1 25 13\n", "output": "1\n4\n2\n"}, {"type": "stdin_stdout", "input": "5\n2 12 3 4 9\n3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAshish has a tree consisting of $n$ nodes numbered $1$ to $n$ rooted at node $1$. The $i$-th node in the tree has a cost $a_i$, and binary digit $b_i$ is written in it. He wants to have binary digit $c_i$ written in the $...
[{"type": "stdin_stdout", "input": "10\n64 0 0\n10 0 0\n17 0 1\n90 1 1\n97 1 1\n19 1 0\n26 1 1\n95 1 1\n46 0 0\n86 0 0\n5 4\n7 1\n9 5\n6 8\n1 6\n7 5\n8 10\n3 7\n3 2\n", "output": "128"}, {"type": "stdin_stdout", "input": "10\n92 0 1\n19 1 0\n46 1 0\n53 1 0\n13 1 0\n63 0 1\n3 0 1\n67 1 0\n20 0 1\n82 0 1\n6 5\n9 1\n3 7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian...
[{"type": "stdin_stdout", "input": "6 389\n0.0303\n0.7536\n0.7225\n0.2404\n0.2432\n0.57407891942809\n3\n979.9372 478.06119955606886\n469.9804 408.1158\n924.0113575468439 220.5522\n", "output": "469.98040000 7.08571971\n15409.70354778 0.00000000\n469.98040000 401.57781402\n469.98040000 107.62902712\n469.98040000 109.014...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA-Aun's breathing\n\nProblem Statement\n\nMaeda-san and Goto-san, who will both turn 70 years old in 2060, are long-time friends and friends who fought together at the ACM-ICPC in college.\n\nThe two are still excited abo...
[{"type": "stdin_stdout", "input": "4\nA\nUn\nB\nUn", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4\n@\nUn\nB\nUn", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4\n@\nUn\nB\nnU", "output": "NO\n"}, {"type": "stdin_stdout", "input": "4\n@\nUn\nB\noU", "output": "NO\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCalculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.\n\nString s consists only of lowercase Latin letters, and it...
[{"type": "stdin_stdout", "input": "smaxpqplaqqbxuqxalqmbmmgubbpspxhawbxsuqhhegpmmpebqmqpbbeplwaepxmsahuepuhuhwxeqmmlgqubuaxehwuwasgxpqmugbmuawuhwqlswllssueglbxepbmwgs\n1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "smaxpqplaqqbxuqxalqmbmmgubbpspxhawbxsuqhhegpmmpebqmqpbbeplwaepxmsahuepuhuhwxeqmmlgqubuaxehwu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.\n\nDetermine the longest time segment when Polycarp can sleep, i. e. no...
[{"type": "stdin_stdout", "input": "70\n03:33\n23:36\n03:16\n18:18\n06:36\n06:58\n17:27\n04:07\n14:39\n15:53\n17:09\n05:16\n20:28\n09:34\n02:41\n14:18\n20:00\n04:14\n00:25\n20:18\n16:34\n10:13\n21:45\n11:08\n16:19\n20:50\n03:08\n05:06\n02:08\n02:51\n15:16\n11:02\n18:13\n18:35\n00:04\n08:50\n06:12\n20:16\n12:05\n04:01\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers $l$ and $r$, $l\\le r$. Find the largest possible value of $a mod b$ over all pairs $(a, b)$ of integers for which $r\\ge a \\ge b \\ge l$.\n\nAs a reminder, $a mod b$ is a remainder we get when...
[{"type": "stdin_stdout", "input": "4\n1 1\n117772020 1000000000\n13 102\n1 1716228987\n", "output": "0\n499999999\n50\n858114493\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n117772020 1010000000\n16 102\n2 1716228987\n", "output": "0\n504999999\n50\n858114493\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n11777202...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRelative B man came to A child's house. He is 3 years old and loves singing. He is singing the song \"Kobutanuki Tsuneko\" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the ...
[{"type": "stdin_stdout", "input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nOK\n"}, {"type": "stdin_stdout", "input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nzellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nNG\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a garland consisting of $n$ lamps. Each lamp is colored red, green or blue. The color of the $i$-th lamp is $s_i$ ('R', 'G' and 'B' — colors of lamps in the garland).\n\nYou have to recolor some lamps in this gar...
[{"type": "stdin_stdout", "input": "500\nBRGRRBBGGRBBRBBGGGRBGBGRGRRBRRRBGRBGBRGGGRBBRRBBBRGGBGBBBGGGRGRBBBRBGGBRGGGBRGGRBRGBBGBRRGGBGRGBGGGGGRBBRGBGGRBGGGRBRGGBBGRBBRRRGBRRBGGBGBGGGGRBGRGRRGGGBRBRRGBGGGRBRBBGBBGGBRBGBRRGGRRBGGRRRRBRGRBBBRRBGRBBGBGBRRGGBRRBBRRGGRRRBGBRBBGRRRRBGGGBRGRRBRRRRGGRBRRBBRRGRGBGRRRBRRGGBBGRRBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday you are going to lead a group of elven archers to defend the castle that is attacked by an army of angry orcs. Three sides of the castle are protected by impassable mountains and the remaining side is occupied by a ...
[{"type": "stdin_stdout", "input": "100 100 1000\n814 165 709 628 263 653 940 749 331 437 129 547 575 73 480 429 396 688 489 312 425 946 444 228 547 512 477 849 53 241 643 416 141 502 449 58 686 111 171 844 113 790 79 107 399 846 945 427 361 68 295 630 260 939 679 458 485 738 202 141 166 940 5 73 108 351 245 998 640 77...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from al...
[{"type": "stdin_stdout", "input": "01\nzbrronwaofovklkopelo\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "01\nzbrronwaofovklkopelo\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "01\nzbrronwaofovklkopeln\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "01\nzbrrnnwaofovklkopeln\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nТри брата договорились о встрече. Пронумеруем братьев следующим образом: пусть старший брат имеет номер 1, средний брат имеет номер 2, а младший брат — номер 3. \n\nКогда пришло время встречи, один из братьев опоздал. По ...
[{"type": "stdin_stdout", "input": "3 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 3\n", "output": "2\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the arr...
[{"type": "stdin_stdout", "input": "3\n2\n1 2\n6\n0 0 3 10 4 3\n5\n3 6 3 1 10\n", "output": "2 1\n3 4 10 3 0 0\n10 1 3 6 3\n"}, {"type": "stdin_stdout", "input": "3\n2\n1 2\n6\n0 1 10 5 4 3\n5\n2 6 3 1 10\n", "output": "2 1\n3 4 5 10 1 0\n10 1 3 6 2\n"}, {"type": "stdin_stdout", "input": "3\n2\n1 2\n6\n2 1 6 5 4 3\n5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi's house has only one socket.\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\nOne power strip with A sockets can extend one empty socket into A ...
[{"type": "stdin_stdout", "input": "13 17\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 19\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "20 19\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 20\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "4 10\n", "output": "3\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakayuki and Kazuyuki are good twins, but their behavior is exactly the opposite. For example, if Takayuki goes west, Kazuyuki goes east, and if Kazuyuki goes north, Takayuki goes south. Currently the two are in a departm...
[{"type": "stdin_stdout", "input": "6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 1 0 0 0\n0 1 0 0 0 0\n0 0 0 1 0 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0", "output": "3\nNA\n"}, {"type": "stdin_stdout", "input": "6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 0 0 1 0\n0 1 0 0 0 0\n0 1 0 1 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a forest that we model as a plane and live $n$ rare animals. Animal number $i$ has its lair in the point $(x_{i}, y_{i})$. In order to protect them, a decision to build a nature reserve has been made.\n\nThe rese...
[{"type": "stdin_stdout", "input": "20\n7571542 9868879\n3634934 5986987\n2297651 5538795\n9701582 8250721\n-2913168 4968483\n8838674 5771883\n-3348778 8326335\n-577797 750161\n-7223138 9113512\n-1808146 6044926\n-756446 417388\n4700417 1550148\n-5568937 20029\n-9170707 6103893\n7445655 7161843\n8820510 4145867\n-44669...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnd again a misfortune fell on Poor Student. He is being late for an exam.\n\nHaving rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the dire...
[{"type": "stdin_stdout", "input": "94 2 1\n0 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows.\n\n* Separated into questioners and respondents.\n* The questioner decides a 4-digit number (correct answer) that does not include dupli...
[{"type": "stdin_stdout", "input": "1234 10660\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 1\n4 0\n1 3\n0 3\n"}, {"type": "stdin_stdout", "input": "1234 10660\n1964 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 0\n4 0\n1 3\n0 3\n"}, {"type": "stdin_stdout", "input": "1234 10660...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnton likes to play chess, and so does his friend Danik.\n\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\n\nNow Anton wonders, w...
[{"type": "stdin_stdout", "input": "379\nAADAAAAAADDAAAAAADAADADADDAAAAADADDAADAAAADDDADAAAAAAADAADAAAAAAADAAAAAAAAADAAAAAAADAAAAAAAAAAADDDADAAAAAAAADAADADAAAADAAAAAAAAAAAAAAAAADAAAADDDAADAAAAAAADAAADAAADAADDDADDAAADAAAAAADDDADDDAAADAAAADAAAAAAAAADAAADAAAAAAAAADAAAAAAAAAAAAAAAAAADADAAAAAAAAAAADAAAAADAAAADAAAAAAAAAAAAAD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string is called beautiful if no two consecutive characters are equal. For example, \"ababcb\", \"a\" and \"abab\" are beautiful strings, while \"aaaaaa\", \"abaa\" and \"bb\" are not.\n\nAhcl wants to construct a beaut...
[{"type": "stdin_stdout", "input": "23\n?\n??\n???\n????\n????\n?a\n?b\n?c\na?\nb?\nc?\n?a?\n?b?\n?c?\na?a\na?b\na?c\nb?a\nb?b\nb?c\nc?a\nc?b\nc?c\n", "output": "a\nab\naba\nabab\nabab\nba\nab\nac\nab\nba\nca\nbab\naba\naca\naba\nacb\nabc\nbca\nbab\nbac\ncba\ncab\ncac\n"}, {"type": "stdin_stdout", "input": "23\n?\n??\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \\leq i \\leq N) from the left and j-th row (1 \\leq j \\leq 10^9) from the bottom.\n\nSnuke has cut out some ...
[{"type": "stdin_stdout", "input": "9\n17 18 51 18 28 45 112 45 23", "output": "917046249"}, {"type": "stdin_stdout", "input": "9\n17 18 51 18 34 45 112 45 23", "output": "938229436"}, {"type": "stdin_stdout", "input": "9\n17 18 51 18 34 45 190 45 23", "output": "353713429"}, {"type": "stdin_stdout", "input": "9\n17 18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a digital clock with $n$ digits. Each digit shows an integer from $0$ to $9$, so the whole clock shows an integer from $0$ to $10^n-1$. The clock will show leading zeroes if the number is smaller than $10^{n...
[{"type": "stdin_stdout", "input": "7\n3\n007\n4\n1000\n5\n00000\n3\n153\n4\n1247\n9\n123456789\n30\n001678294039710047203946100020\n", "output": "7\n2\n0\n11\n17\n53\n115\n"}, {"type": "stdin_stdout", "input": "7\n3\n007\n4\n1000\n5\n00000\n3\n153\n4\n1293\n9\n123456789\n30\n001678294039710047203946100020\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`.\n\nTakahashi, who hates the string `ST`, will perform the following operation 10^{10000} times:\n\n* Amo...
[{"type": "stdin_stdout", "input": "SSTTTSST", "output": "2\n"}, {"type": "stdin_stdout", "input": "TTTTSSSS", "output": "8\n"}, {"type": "stdin_stdout", "input": "TSSTTSST", "output": "2\n"}, {"type": "stdin_stdout", "input": "TTSTSSST", "output": "4\n"}, {"type": "stdin_stdout", "input": "SSTTSTST", "output": "0\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).\n\nThe flying saucer, on which the brave pioneers set off, consists...
[{"type": "stdin_stdout", "input": "1050034174 1181487066\n", "output": "544888754\n"}, {"type": "stdin_stdout", "input": "880162386 1131317357\n", "output": "508228391\n"}, {"type": "stdin_stdout", "input": "1511923181 994962872\n", "output": "797030938\n"}, {"type": "stdin_stdout", "input": "596386879 1071021379\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMaxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.\n\nMaxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant fr...
[{"type": "stdin_stdout", "input": "50\n15 28 34 29 17 21 20 34 37 17 10 20 37 10 18 25 31 25 16 1 37 27 39 3 5 18 2 32 10 35 20 17 29 20 3 29 3 25 9 32 37 5 25 23 25 33 35 8 31 29\n39\n", "output": "1.499798753"}, {"type": "stdin_stdout", "input": "50\n15 28 34 29 17 21 20 34 37 17 10 20 37 10 18 25 31 25 16 1 37 27 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAll space-time unified dimension sugoroku tournament. You are representing the Earth in the 21st century in the tournament, which decides only one Sugoroku absolute champion out of more than 500 trillion participants.\n\n...
[{"type": "stdin_stdout", "input": "12\n0\n-1\n7\n0\n2\n-1\n-1\n3\n-10\n-2\n1\n0", "output": "1\n"}, {"type": "stdin_stdout", "input": "12\n0\n-1\n7\n0\n2\n0\n-1\n3\n-10\n-2\n1\n0", "output": "1\n"}, {"type": "stdin_stdout", "input": "12\n0\n-1\n7\n0\n2\n0\n-2\n3\n-10\n-2\n1\n0", "output": "1\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name $s$ can transform to another superhero with name $t$ if $s$ can ...
[{"type": "stdin_stdout", "input": "eieoiiieaiuiiauieeuoueeoudljpjrpxdtqkrdfmhktpqrnkmyggywglpfpfmhrbaiioeuaieaouaoioaiuoiuueuaoouaeeoaaaueauueeiuaueuaeouiaaaieeaeiuouoiooauuoeauaiaoouuauuuuocqschpcxrxrgrcsjmwcbyfvtdxqtwha\naoeaoaoueieeioooiaooeoeoitvplxwkprykbhvxylcnxrhpgqclyjgfpzdpqwlcvouooeueoouieioeuouieoaaueuiiiae...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sittin...
[{"type": "stdin_stdout", "input": "5\n\n3 3\n1 1 1\n0 0\n0 1\n\n3 3\n1 1 1\n1 0\n2 1\n\n3 3\n1 1 1\n1 0\n0 1\n\n3 3\n1 1 1\n0 0\n1 0\n\n3 3\n1 1 1\n0 0\n1 1\n", "output": "YYY\nYYN\nYYY\nYYY\nYYY\n"}, {"type": "stdin_stdout", "input": "5\n\n3 3\n1 1 1\n0 0\n0 1\n\n3 3\n1 1 1\n1 0\n2 1\n\n3 3\n1 1 1\n1 0\n0 1\n\n3 3\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday's morning was exceptionally snowy. Meshanya decided to go outside and noticed a huge snowball rolling down the mountain! Luckily, there are two stones on that mountain.\n\nInitially, snowball is at height $h$ and it...
[{"type": "stdin_stdout", "input": "71 100\n56 44\n12 85\n", "output": "5053\n"}, {"type": "stdin_stdout", "input": "46 100\n36 81\n99 28\n", "output": "4961\n"}, {"type": "stdin_stdout", "input": "29 100\n30 51\n28 92\n", "output": "5021\n"}, {"type": "stdin_stdout", "input": "93 80\n13 49\n100 21\n", "output": "3220\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.\n\nMultiset...
[{"type": "stdin_stdout", "input": "50\n-38 -107\n-34 -75\n-200 -143\n-222 -139\n-34 55\n-102 -79\n48 -99\n2 -237\n-118 -167\n-56 -41\n10 17\n68 -89\n-32 41\n-100 -93\n84 -1\n86 -15\n46 -145\n-58 -117\n8 31\n-36 -61\n-12 21\n-116 79\n88 -205\n70 -103\n-78 -37\n106 -5\n-96 -201\n-60 -103\n-54 45\n-138 -177\n-178 -47\n-1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a teacher at a cram school for elementary school pupils.\n\nOne day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everyth...
[{"type": "stdin_stdout", "input": "2 6\n1 16\n3 9\n2 334\n34 79\n0 0", "output": "0 1\n4 0\n0 1\n0 166\n0 13\n"}, {"type": "stdin_stdout", "input": "3 8\n1 5\n3 10\n2 218\n36 198\n0 0", "output": "3 0\n1 0\n1 0\n0 108\n0 2\n"}, {"type": "stdin_stdout", "input": "2 6\n1 16\n3 15\n2 200\n34 62\n0 0", "output": "0 1\n4 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given positive integers A and B.\nFind the K-th largest positive integer that divides both A and B.\nThe input guarantees that there exists such a number.\n\n-----Constraints-----\n - All values in input are integ...
[{"type": "stdin_stdout", "input": "100 100 1\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 50 4\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "96 96 12\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "60 60 11\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "93 31 1\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates $\\operatorname{occ}(s^{\\prime}, p)$ that is defined as the maximal number ...
[{"type": "stdin_stdout", "input": "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.\n\nSerge...
[{"type": "stdin_stdout", "input": "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaaaaaaaaaaaaa\n61 52 5 43 53 81 7 96 6 9 34 78 79 12 8 63 22 76 18 46 41 56 3 20 57 21 75 73 100 94 35 69 32 4 70 95 88 44 68 10 71 98 23 89 36 62 28 51 24 30 74 55 27 80 38 48 93 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.\n\nOver the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbere...
[{"type": "stdin_stdout", "input": "20 15\n6 8719.787178\n10 13066.663722\n15 58623.690996\n9 184321.819759\n3 227999.294560\n2 279836.330518\n9 282806.308675\n8 311056.507765\n1 312315.562927\n5 459200.373445\n14 563454.265947\n7 647364.984868\n13 679762.0281866578\n4 684192.647497\n1 733119.607626\n7 748637.778398\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each ...
[{"type": "stdin_stdout", "input": "10 10\n8530 -3814\n-9330 -6035\n3951 -217\n-9276 8291\n636 -3118\n5024 -2403\n4601 7977\n-3620 -1428\n4954 -9632\n-9852 6553\n-3457 5430\n-8866 -7343\n1020 -5748\n5043 -3820\n-2832 1528\n-5058 -825\n2406 -3530\n9152 -7463\n-8547 7108\n2492 8953\n", "output": "Yes\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInput Format\n\n\nN K\na_1 a_2 a_3 ... a_N\n\n\nOutput Format\n\nPrint the minimum cost in one line. In the end put a line break.\n\n\nConstraints\n\n* 1 ≤ K ≤ N ≤ 15\n* 1 ≤ a_i ≤ 10^9\n\n\n\nScoring\n\nSubtask 1 [120 poi...
[{"type": "stdin_stdout", "input": "5 5\n11683 3774 3598 4173 3424", "output": "31773\n"}, {"type": "stdin_stdout", "input": "5 4\n11683 3774 3598 4173 3424", "output": "23510\n"}, {"type": "stdin_stdout", "input": "5 5\n3949 3208 13644 3469 3424", "output": "21140\n"}, {"type": "stdin_stdout", "input": "5 5\n4931 3208...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b.\n\nYou have a sequence of positive integer numbers a_1, a_2, ..., a...
[{"type": "stdin_stdout", "input": "1000000000000 1000000000000 116\n1587924000 7 2 3 4 5 6 1 56 9 10 1 12 13 2 105 16 1 18 1 620 3 14 1 24 25 26 27 4 203 30 1 32 3 2 5 252 1 2 39 40 1 6 7 4 45 2 1 48 1 350 93 52 1 54 5 8 21 58 1 60 1 2 9 224 65 6 1 4 3 10 7 72 1 2 75 4 1 546 1 80 81 62 1 12 35 2 87 8 1 90 13 28 3 2 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes. \n\nAft...
[{"type": "stdin_stdout", "input": "31 31 31 4\n15 26\n29 15\n17 31\n29 21\n21 3\n9 27\n19 20\n8 19\n5 4\n1 16\n6 17\n5 24\n1 4\n27 30\n16 24\n14 29\n24 31\n6 20\n2 20\n12 26\n26 15\n23 8\n29 10\n11 8\n3 7\n2 26\n15 10\n15 24\n6 10\n31 22\n12 2\n10 3\n6 24\n23 12\n19 1\n", "output": "Grapes\nCarrots\nCarrots\nCarrots\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn open-top box having a square bottom is placed on the floor. You see a number of needles vertically planted on its bottom.\n\nYou want to place a largest possible spheric balloon touching the box bottom, interfering wit...
[{"type": "stdin_stdout", "input": "5 12\n70 66 70\n0 52 20\n15 27 10\n78 45 10\n20 60 13\n1 100\n54 75 200\n1 10\n90 14 1\n1 11\n54 149 200\n3 10\n53 60 0\n61 38 1\n45 44 1\n4 10\n20 21 10\n20 80 10\n80 20 10\n140 80 10\n0 0", "output": "44.661667\n39.000000\n130.000000\n102.978551\n107.095894\n99.314575\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ people in this world, conveniently numbered $1$ through $n$. They are using burles to buy goods and services. Occasionally, a person might not have enough currency to buy what he wants or needs, so he borrow...
[{"type": "stdin_stdout", "input": "12 20\n1 3 1000000000\n3 2 1000000000\n1 4 1000000000\n4 2 1000000000\n1 5 1000000000\n5 2 1000000000\n1 6 1000000010\n6 2 1000000000\n1 7 1000000000\n7 2 1000000000\n1 8 1000000000\n8 4 1000000000\n1 9 1000000000\n9 2 1000000000\n1 10 1000000000\n10 2 1000000000\n1 11 1000000000\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTic-tac-toe is a game in which you win when you put ○ and × alternately in the 3 × 3 squares and line up ○ or × in one of the vertical, horizontal, and diagonal lines (Fig.). 1 to Fig. 3)\n\n<image> | <image> | <image>\n-...
[{"type": "stdin_stdout", "input": "ooosxssxs\nxooswsosx\nooxxxooxo", "output": "o\nd\nd\n"}, {"type": "stdin_stdout", "input": "oopsxssxs\nxooswsosx\noxooxxxoo", "output": "d\nd\nd\n"}, {"type": "stdin_stdout", "input": "oopsxrsxs\nxsoswsoox\nooooxxxox", "output": "d\nd\no\n"}, {"type": "stdin_stdout", "input": "xprmn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).\n\nKilljoy's account is already i...
[{"type": "stdin_stdout", "input": "7\n2 7\n7 1313\n2 14\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n136 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n2\n2\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "7\n2 7\n7 1313\n2 8\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n312 121\n2 7\n1313 7\n2 8\n1211 8\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices.\n\nA set of edges is called a matching if no two edges share an endpoint.\n\nA set of vert...
[{"type": "stdin_stdout", "input": "1\n8 39\n1 2\n3 4\n5 6\n7 8\n1 9\n3 10\n3 11\n5 12\n5 13\n10 14\n7 15\n9 4\n10 2\n11 2\n12 1\n13 3\n14 2\n15 2\n9 4\n10 4\n11 4\n12 4\n13 4\n14 4\n15 4\n14 6\n10 6\n11 6\n12 6\n13 6\n14 6\n15 6\n9 8\n7 8\n11 8\n12 14\n13 8\n14 8\n15 8\n", "output": "IndSet\n9 11 12 13 15 16 17 18\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBizon the Champion isn't just charming, he also is very smart.\n\nWhile some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication t...
[{"type": "stdin_stdout", "input": "500000 500000 250000000000\n", "output": "250000000000\n"}, {"type": "stdin_stdout", "input": "499997 499989 248758432143\n", "output": "225563648440\n"}, {"type": "stdin_stdout", "input": "499997 499989 248758432143\n", "output": "225563648440"}, {"type": "stdin_stdout", "input": "5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$, consisting of lowercase Latin letters. While there is at least one character in the string $s$ that is repeated at least twice, you perform the following operation:\n\nyou choose the index $i$ ...
[{"type": "stdin_stdout", "input": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "ba\n"}, {"type": "stdin_stdout",...
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\nBob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang) \n\nThe journey can be represented as a straight line, consisting of $n$ segmen...
[{"type": "stdin_stdout", "input": "10\n324839129156 133475576222 1946579156099 185514358673 88712073883 243757012712 950854402304 21947060440 598567289966 674328002732\nGLLLLLLLLW\n", "output": "26365097587258\n"}, {"type": "stdin_stdout", "input": "10\n324839129156 133475576222 987711341463 185514358673 88712073883 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). \n\nNote that a bracket sequence is correct if it is possible to get a correct mathematical expressio...
[{"type": "stdin_stdout", "input": "92 51 18\n(()(((()())(()())())())(()())()()()())((()()())(())(())(()((())()())())(())())((())()())()()\nLRLRLLLLRRRLLRRLDLRLRRLRDLDLDLDDRRLRRRLLRDRLDDRLRRD\n", "output": "(()()()()())((()()())(())(())(()((())()())())(())())((())()())()()\n"}, {"type": "stdin_stdout", "input": "86 11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands \"T\" (\"turn around\") and \"F\" (\"move 1 unit forward\").\n\nYou are ...
[{"type": "stdin_stdout", "input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n50\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n40\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:\n\n To make a \"red bouquet\", it needs 3 red flowers....
[{"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 1100000000 1000000000\n", "output": "1033333333\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions).\n\nu - union of two sets, AuB = {x ∈ U : x ∈ A or x ∈ ...
[{"type": "stdin_stdout", "input": "A 3\n1 2 -1\nB 4\n4 0 0 11\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 7 8 0\nB 3\n3 6 21\nR 0\n(As(AiB))uB", "output": "0 4 11\n0 2 3 6 7 8 21\n"}, {"type": "stdin_stdout", "input": "A 3\n2 3 -1\nB 4\n3 1 10 11\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 10 8 3\nB 3\n2 4 7\nR 0\n(As(AiB))...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the ...
[{"type": "stdin_stdout", "input": "1000 1 1000\n", "output": "999000\n"}, {"type": "stdin_stdout", "input": "1286 123 1043\n", "output": "9862\n"}, {"type": "stdin_stdout", "input": "1286 187 1043\n", "output": "6130\n"}, {"type": "stdin_stdout", "input": "1705 812 917\n", "output": "1009\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:\n\n* A consists of integers between X and Y (inclusive).\n* For each 1\\leq ...
[{"type": "stdin_stdout", "input": "15043200 358979323846264338", "output": "35\n"}, {"type": "stdin_stdout", "input": "12899738 158337027091717102", "output": "34\n"}, {"type": "stdin_stdout", "input": "12899738 686618920047839292", "output": "36\n"}, {"type": "stdin_stdout", "input": "1565492 1138463356571161467", "o...
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 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_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt all started with a black-and-white picture, that can be represented as an $n \\times m$ matrix such that all its elements are either $0$ or $1$. The rows are numbered from $1$ to $n$, the columns are numbered from $1$ ...
[{"type": "stdin_stdout", "input": "6 4 7\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is wondering about buying a new computer, which costs $c$ tugriks. To do this, he wants to get a job as a programmer in a big company.\n\nThere are $n$ positions in Polycarp's company, numbered starting from one....
[{"type": "stdin_stdout", "input": "3\n4 15\n1 3 20 11\n1 2 13\n4 100\n2 5 10 50\n3 26 12\n2 1000000000\n1 1\n1\n", "output": "5\n14\n1000000000\n"}, {"type": "stdin_stdout", "input": "3\n4 15\n1 6 20 11\n1 2 13\n4 100\n2 7 10 50\n3 26 12\n2 1000000000\n1 1\n1\n", "output": "5\n12\n1000000000\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a binary string $a$ of length $n$. In one operation, you can select any prefix of $a$ with an equal number of $0$ and $1$ symbols. Then all symbols in the prefix are inverted: each $0$ becomes $1$ and each $1$ be...
[{"type": "stdin_stdout", "input": "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n000\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n", "output": "YES\nYES\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "5\n10\n0101011000\n1001101000\n4\n0000\n0000\n3\n010\n100\n12\n010101010101\n100110011010\n6\n000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize...
[{"type": "stdin_stdout", "input": "100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 765 957 898 545 977 751 740 869 885 831 834 702 934 954 500 626 605 921 755 661 707 952...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA browser-based puzzle game called \"Bubble Puzzle\" is now popular on the Internet.\n\nThe puzzle is played on a 4 × 4 grid, and initially there are several bubbles in the grid squares. Each bubble has a state expressed ...
[{"type": "stdin_stdout", "input": "2 4 3 4\n2 1 2 4\n3 3 2 2\n0 3 3 3", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 4 3 4\n2 1 2 0\n3 3 2 2\n0 3 3 3", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 1 4 1\n2 2 4 2\n2 4 4 1\n0 4 4 1", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 4 3 3\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Fire City, there are n intersections and m one-way roads. The i-th road goes from intersection a_i to b_i and has length l_i miles. \n\nThere are q cars that may only drive along those roads. The i-th car starts at int...
[{"type": "stdin_stdout", "input": "4 4\n1 2 0\n2 3 1\n3 1 2\n1 4 3\n3\n1 1 2\n1 2 1\n4 0 1\n", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2 1\n2 3 1\n3 1 2\n1 4 3\n3\n1 1 3\n1 2 4\n4 0 1\n", "output": "\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2 1\n2 3 1\n3 1 2\n1 4 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\nWhen traveli...
[{"type": "stdin_stdout", "input": "20 3\n5 10 15\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "37 3\n-1 0 91", "output": "-54\n"}, {"type": "stdin_stdout", "input": "10 3\n-2 9 50", "output": "-31\n"}, {"type": "stdin_stdout", "input": "10 3\n-2 5 50", "output": "-35\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour math teacher gave you the following problem:\n\nThere are $n$ segments on the $x$-axis, $[l_1; r_1], [l_2; r_2], \\ldots, [l_n; r_n]$. The segment $[l; r]$ includes the bounds, i.e. it is a set of such $x$ that $l \\...
[{"type": "stdin_stdout", "input": "1\n10\n132182352 630066892\n906984407 923129673\n100213482 882571434\n191064823 398771294\n243750814 1483105037\n322757488 608184251\n241900265 682732740\n197067927 815099563\n17475338 866870249\n271628366 729808874\n", "output": "508213113\n"}, {"type": "stdin_stdout", "input": "1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote a $k$-step ladder as the following structure: exactly $k + 2$ wooden planks, of which\n\n two planks of length at least $k+1$ — the base of the ladder; $k$ planks of length at least $1$ — the steps of the l...
[{"type": "stdin_stdout", "input": "4\n4\n1 12 1 3\n3\n1 3 1\n5\n2 1 3 1 2\n3\n1 1 2\n", "output": "2\n0\n1\n0\n"}, {"type": "stdin_stdout", "input": "4\n4\n1 12 1 3\n3\n1 3 1\n5\n2 1 3 4 2\n3\n1 1 2\n", "output": "2\n0\n2\n0\n"}, {"type": "stdin_stdout", "input": "4\n4\n1 3 1 3\n3\n3 3 2\n5\n2 3 3 4 2\n3\n1 1 2\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nChef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied ...
[{"type": "stdin_stdout", "input": "2\n109\n1", "output": "110\n1\n"}, {"type": "stdin_stdout", "input": "2\n185\n1", "output": "228\n1\n"}, {"type": "stdin_stdout", "input": "2\n15\n12", "output": "24\n28\n"}, {"type": "stdin_stdout", "input": "2\n208\n1", "output": "434\n1\n"}, {"type": "stdin_stdout", "input": "2\n7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a fraction $\\frac{a}{b}$. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.\n\n\n-----Input-----\n\nThe first contains three single positive integers a, ...
[{"type": "stdin_stdout", "input": "99999 100000 13\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "69168 84860 4\n", "output": "107\n"}, {"type": "stdin_stdout", "input": "25102 31579 2\n", "output": "174\n"}, {"type": "stdin_stdout", "input": "13805 15538 3\n", "output": "164\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOhana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: ...
[{"type": "stdin_stdout", "input": "20\n10101011101000011010\n11111010001100110101\n01011100010000001111\n10110100000101010011\n11010001110111101101\n00100110011011101010\n01000110101011001100\n01101100111101101101\n10111010010100111100\n00010010110001101110\n10111110010000101010\n10010111110100100100\n1101011100111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands ...
[{"type": "stdin_stdout", "input": "3\n3 6\nabDefb\nbSooon\nNIKHil\n6 6\naaaaaa\nssssst\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\njhfdb\ncacac\nopqrs\nddddd\nindia\nyucky", "output": "There is indeed no spoon!\nThere is indeed no spoon!\nThere is indeed no spoon!\n"}, {"type": "stdin_stdout", "input": "3\n3 6\nbfeDba\nbnpo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much.\n\nOne can get to the shore only by hills that are situated along a straight line ...
[{"type": "stdin_stdout", "input": "200 72 29\n201 145 169 163 32 126 131 71 26 130 2 61 110 17 179 114 79 30 192 91 141 70 101 119 185 66 72 76 164 144 106 162 122 146 119 181 184 61 131 131 140 152 60 65 183 154 32 33 108 77 29 102 67 5 125 26 126 104 20 89 183 21 126 195 198 24 123 173 135 164 141 32\n160 65 136 22 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe year of 2012 is coming...\n\nAccording to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the hu...
[{"type": "stdin_stdout", "input": "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes Cleo\nSnowy likes Chapay\nDracul likes Troll\nAnka likes Hexadecimal\nSnowy likes Anka\nHexadecimal likes Cleo\nHexadecimal likes Troll\nDracul likes ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\n\nThe main exhibit is a construction of n matryoshka dolls that can be nested one in...
[{"type": "stdin_stdout", "input": "100 19\n6 62 72 83 91 94 97\n3 61 84 99\n1 63\n5 46 53 56 69 78\n5 41 43 49 74 89\n5 55 57 79 85 87\n3 47 59 98\n3 64 76 82\n3 48 66 75\n2 60 88\n2 67 77\n4 40 51 73 95\n41 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 44 71 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (...
[{"type": "stdin_stdout", "input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 156\n22 183", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 294\n22 183", "output": "Impossible\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows.\n\n* 3 Play the game...
[{"type": "stdin_stdout", "input": "AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0", "output": "11 8\n10 12\n11 7\n11 8\n11 0\n0 11\n"}, {"type": "stdin_stdout", "input": "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $s$ and a number $k$ ($0 \\le k < |s|$).\n\nAt the beg...
[{"type": "stdin_stdout", "input": "wfyjbwcuxjrvmunfbrhethdmepeampvjcypavwoolteucetnqntytdfstvunnfyvngydjcohnwgtfddcnvuewxcafwureiupfeljqydwtickfbokoytlxtuwmvmvflemfvcksszlwgcwtamzovectkzxuzdtvbujyfpvcruvzvgglozwktwawcbkkwkookmuhjlcyjvfrnzmgpglvnbrujtbvtwrsqbulusfwzulxnadaqbijfrsvteqqoirfaolhfbgorxdwigwxcydbfxhvhqzjqir...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: \n- Let's call the nodes' l...
[{"type": "stdin_stdout", "input": "4\nlrl\nrll\nr\nlllr\n\n", "output": "10\n14\n4\n13\n"}, {"type": "stdin_stdout", "input": "4\nrll\nrll\nr\nlllr", "output": "14\n14\n4\n13\n"}, {"type": "stdin_stdout", "input": "4\nlrl\nrll\nr\nrlll", "output": "10\n14\n4\n27\n"}, {"type": "stdin_stdout", "input": "4\nlrl\nrll\nr\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices ...
[{"type": "stdin_stdout", "input": "12 12\n5 1\n5 11\n1 11\n8 11\n8 9\n5 12\n6 9\n7 11\n9 3\n9 10\n4 12\n10 2\n78\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 10\n1 11\n1 12\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 9\n2 10\n2 11\n2 12\n3 3\n3 4\n3 5\n3 6\n4 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 4\n4 5\n4 6\n4 7\n4 8\n4 10\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt many competitions that have a word «cup» in its official name the winner is presented with an actual cup. This time the organizers of one unusual programming competition have decided to please the winner even more and ...
[{"type": "stdin_stdout", "input": "QDpiNBmCRFWxpdbfGOzvvOcemjructoAdEwegTvbVbfWWRPGyEAxGdDRWVlqNyGWMWHMrHAIZpyxvgaflrsVZhhZRouvpxrKXFZa\n", "output": "5 20\nQDpiNBmCRFWxpdbfGOzv\nvOcemjructoAdEwegTvb\nVbfWWRPGyEAxGdDRWVlq\nNyGWMWHMrHAIZpyxvgaf\nlrsVZhhZRouvpxrKXFZa\n"}, {"type": "stdin_stdout", "input": "QDpiNBmCRFWxp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what ...
[{"type": "stdin_stdout", "input": "50\n69 6 6\n22 1 1\n23 3 3\n60 13 13\n13 3 3\n7 4 7\n6 1 1\n49 7 9\n68 8 8\n20 2 2\n34 1 1\n143 5 5\n22 1 1\n77 58 65\n10 3 3\n72 5 5\n47 1 1\n82 3 3\n92 8 8\n34 1 1\n42 9 10\n63 14 14\n10 3 3\n38 2 2\n80 6 6\n79 5 5\n53 5 5\n44 7 7\n85 2 2\n24 2 2\n57 3 3\n95 29 145\n77 6 6\n24 1 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nAOR Ika is studying to pass the test.\n\nAOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure.\n\n1. Check the correctness of the answer.\n2. If the ...
[{"type": "stdin_stdout", "input": "3\nnxx", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\nnwx", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\nxxo", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\nxwn", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\nowx", "output": "3\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, whil...
[{"type": "stdin_stdout", "input": "))())))))))())))))()()))()()))))())))))()))))))))))))(()))())(()))))(()))))())))((((()()))))()))()))\n", "output": "48\n"}, {"type": "stdin_stdout", "input": ")))()))()))))()((((())))()))))(()))))(())()))(()))))))))))))())))))()))))()()))()())))))())))))))())\n", "output": "48\n"}, {...
code_stdio