messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKarafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. [Image] \n\nEach Karafs has a positive ... | [{"type": "stdin_stdout", "input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"type": "stdin_stdout", "input": "1 1 4\n1 1000000 1000000\n1 1 1000000\n1 1000000 1\n1 1 1\n", "output": "1000000\n1\n1413\n1\n"}, {"type": "stdin_stdout", "input": "10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \\neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.\n\nYou should find such a cycle in $K_n$... | [{"type": "stdin_stdout", "input": "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "output": "1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n"}, {"type": "stdin_stdout", "input": "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n", "output": "1 2 1 \n1 3 2 3 \... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2^{N} teams participating in the tournament, numbered from 1 to 2^{N}. The... | [{"type": "stdin_stdout", "input": "3\n0 53 31 33 2 34 22 21\n47 0 72 36 11 16 3 86\n69 28 0 49 25 6 92 54\n67 64 51 0 54 65 15 24\n98 89 75 46 0 48 65 31\n66 84 94 35 52 0 64 46\n78 97 8 85 35 36 0 62\n79 14 46 76 69 54 38 0\n", "output": "4.23995819508\n"}, {"type": "stdin_stdout", "input": "3\n0 7 38 22 3 66 32 77\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price ... | [{"type": "stdin_stdout", "input": "4\n4 1\n3 2\n2 3\n1 4\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "3\n3 3\n1 2\n2 1\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "3\n2 3\n1 1\n3 2\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "3\n3 2\n1 1\n2 3\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMisha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used o... | [{"type": "stdin_stdout", "input": "14\nTPdoztSZROpjZe z6F8bYFvnER4V5SP0n\n8Aa3PQY3hzHZTPEUz fhrZZPJ3iUS\nm9p888KaZAoQaO KNmdRSAlUVn8zXOM0\nAO s1VGWTCbHzM\ni 4F\nfhrZZPJ3iUS j0OVZQF6MvNcKN9xDZFJ\nDnlkXtaKNlYEI2ApBuwu DMA9i8ScKRxwhe72a3\nj0OVZQF6MvNcKN9xDZFJ DzjmeNqN0H4Teq0Awr\n4F wJcdxt1kwqfDeJ\nqxXlsa5t RHCL1K6aUyns\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exhibition. However they know that no element should be present in the sets of both compan... | [{"type": "stdin_stdout", "input": "10\n598654597 488228616\n544064902 21923894\n329635457 980089248\n988262691 654502493\n967529230 543358150\n835120075 128123793\n809901567 613170206\n152157661 479980560\n859252956 318029856\n614959273 735298093\n10\n849172317 361325206\n341655282 740807372\n453949939 809030434\n8131... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice's hair is growing by leaps and bounds. Maybe the cause of it is the excess of vitamins, or maybe it is some black magic...\n\nTo prevent this, Alice decided to go to the hairdresser. She wants for her hair length to... | [{"type": "stdin_stdout", "input": "4 20 1000000000\n1000000000 1000000000 1000000000 1000000000\n1 1 1\n1 4 1\n0\n1 1 1000000000\n1 4 1000000000\n0\n1 1 1000000000\n1 4 1000000000\n1 1 1000000000\n1 4 1000000000\n1 1 1000000000\n1 4 1000000000\n1 1 1000000000\n1 4 1000000000\n0\n1 2 1\n0\n1 3 1\n0\n1 2 1\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTenten runs a weapon shop for ninjas. Today she is willing to sell $n$ shurikens which cost $1$, $2$, ..., $n$ ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the b... | [{"type": "stdin_stdout", "input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 4\n- 5\n- 8\n+\n- 6\n+\n- 2\n", "output": "YES\n3 10 9 7 1 8 5 4 6 2 \n"}, {"type": "stdin_stdout", "input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 4\n- 5\n- 8\n+\n+\n- 6\n- 2\n", "output": "NO\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSo you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the ea... | [{"type": "stdin_stdout", "input": "100 50\n20 13 10 38 7 22 40 15 27 32 37 44 42 50 33 46 7 47 43 5 18 29 26 3 32 5 1 29 17 1 1 43 2 38 23 23 49 36 14 18 36 3 49 47 11 19 6 29 14 9 6 46 15 22 31 45 24 5 31 2 24 14 7 15 21 44 8 7 38 50 17 1 29 39 16 35 10 22 19 8 6 42 44 45 25 26 16 34 36 23 17 11 41 15 19 28 44 27 46 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is g... | [{"type": "stdin_stdout", "input": "40\n37 15\n48 10\n16 5\n25 23\n32 20\n24 4\n46 19\n16 13\n1 1\n37 22\n44 29\n24 6\n27 10\n39 16\n28 13\n5 4\n31 22\n9 2\n30 26\n23 16\n16 12\n43 5\n29 1\n20 5\n40 12\n18 14\n22 15\n29 2\n3 2\n6 3\n45 28\n42 34\n43 32\n10 10\n12 8\n10 8\n4 1\n17 17\n16 7\n8 7\n", "output": "796297179\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.\n\nAbout every day we know exam for which one of m subjects can be passed on that day. Perh... | [{"type": "stdin_stdout", "input": "100 10\n1 1 6 6 6 2 5 7 6 5 3 7 10 10 8 9 7 6 9 2 6 7 8 6 7 5 2 5 10 1 10 1 8 10 2 9 7 1 6 8 3 10 9 4 4 8 8 6 6 1 5 5 6 5 6 6 6 9 4 7 5 4 6 6 1 1 2 1 8 10 6 2 1 7 2 1 8 10 9 2 7 3 1 5 10 2 8 10 10 10 8 9 5 4 6 10 8 9 6 6\n2 4 10 11 5 2 6 7 2 15\n", "output": "74\n"}, {"type": "stdin_... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called \"Critic\"...\n\nThe game ... | [{"type": "stdin_stdout", "input": "6\n216986951114298167 235031205335543871\n148302405431848579 455670351549314242\n506251128322958430 575521452907339082\n1 768614336404564650\n189336074809158272 622104412002885672\n588320087414024192 662540324268197150\n", "output": "1 0\n"}, {"type": "stdin_stdout", "input": "20\n1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArkady wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for $n$ flowers and so it looks like a pipe with $n$ holes. Arkady can only use the water that flows from the firs... | [{"type": "stdin_stdout", "input": "10 300 100\n20 25 68 40 60 37 44 85 23 96\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "10 300 100\n20 1 3 10 8 5 3 6 4 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5 10 10\n1000 1 1 1 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "2 10000 1\n1 99... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGrandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.\n\nShe precisely remembers she had n b... | [{"type": "stdin_stdout", "input": "40 562\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalf\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalf... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEugeny has n cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd integers, and that al... | [{"type": "stdin_stdout", "input": "100 20\n28 42 37 40 26 40 46 46 25 28 36 36 35 38 45 40 21 38 36 22 30 24 40 38 27 50 47 40 30 45 39 20 18 32 34 24 34 26 27 37 18 40 42 41 26 50 22 27 37 21 30 30 49 36 16 48 46 26 33 22 47 32 38 50 29 46 31 42 26 24 50 26 40 42 26 34 18 32 44 24 16 32 50 30 20 48 26 41 32 30 32 41 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe next \"Data Structures and Algorithms\" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.\n\nNam created... | [{"type": "stdin_stdout", "input": "100\n102 157 177 149 138 193 19 74 127 156 128 122 6 101 154 92 24 188 51 89 18 77 112 100 65 11 113 173 79 124 102 81 11 171 114 43 60 168 44 86 87 82 177 8 12 181 139 121 140 28 108 17 173 63 18 4 148 125 117 153 193 180 188 142 46 75 163 126 128 22 32 163 164 1 161 19 162 59 190 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStudent Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give u... | [{"type": "stdin_stdout", "input": "8 8\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n", "output": "NO"}, {"type": "stdin_stdout", "input": "5 8\n........\n.######.\n.######.\n.######.\n........\n", "output": "YES"}, {"type": "stdin_stdout", "input": "5 7\n.......\n.#####.\n.#.#.#.\n.... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSimon has an array a_1, a_2, ..., a_{n}, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), ... | [{"type": "stdin_stdout", "input": "5\n2 3 5 7 11\n", "output": "5 0\n1 2 3 4 5 \n"}, {"type": "stdin_stdout", "input": "2\n999999 1000000\n", "output": "2 0\n1 2 \n"}, {"type": "stdin_stdout", "input": "5\n4 6 9 3 6\n", "output": "1 3\n2 \n"}, {"type": "stdin_stdout", "input": "5\n1 3 5 7 9\n", "output": "1 4\n1 \n"},... | 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 8\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n312 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n1\n2\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "3\n2 69\n68 70\n6 4\n4 4 4 4 4 4\n9 38\n-21 83 50 -59 -77 15 -71 -78 20\n", "output": "1\n0\n2\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMagnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were ... | [{"type": "stdin_stdout", "input": "3\n000\n000\n000\n\n111\n111\n111\n\n111\n111\n111\n\n000\n000\n000\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "3\n101\n010\n101\n\n101\n010\n101\n\n101\n010\n101\n\n101\n010\n101\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "3\n101\n010\n101\n\n101\n000\n10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmet... | [{"type": "stdin_stdout", "input": "1 100\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nValera is a collector. Once he wanted to expand his collection with exactly one antique item.\n\nValera knows n sellers of antiques, the i-th of them auctioned k_{i} items. Currently the auction price of the j-th object o... | [{"type": "stdin_stdout", "input": "3 999999\n22 1000000 1000000 999999 999999 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 999999 1000000 1000000 999999 1000000 1000000 1000000 352800 999999 1000000\n14 999999 999999 999999 999999 999999 1000000 999999 999999 999999 999999 702638 999999 1000000 9999... | 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\nA boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and ... | [{"type": "stdin_stdout", "input": "6\nK.......\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\n..####.K\n\n.......K\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\nK.####..\n\nK.......\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\nK.####..\n\n.......K\n........\n.##..##.\n#..##... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q... | [{"type": "stdin_stdout", "input": "100\n94 22 24 99 58 97 20 29 67 30 38 64 77 50 15 44 92 88 39 42 25 70 2 76 84 6 37 49 17 71 31 19 26 79 10 35 65 63 32 95 5 8 52 27 83 18 53 93 13 81 48 68 54 82 34 60 87 23 16 86 55 40 61 45 28 7 74 41 14 91 3 72 33 11 98 89 90 69 78 36 80 59 56 21 43 1 75 46 47 12 96 73 57 51 4 85... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $500000$ integers (numbered from $1$ to $500000$). Initially all elements of $a$ are zero.\n\nYou have to process two types of queries to this array: $1$ $x$ $y$ — increase $a_x$ ... | [{"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 500000 1\n2 800 0\n", "output": "4\n4\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 4 -4\n2 1 0\n", "output": "4\n4\n0\n"}, {"type": "stdin_stdout", "input": "2\n1 500000 228\n2 250001 249999\n", "output": "228\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so... | [{"type": "stdin_stdout", "input": "13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n", "output": "13"}, {"type": "stdin_stdout", "input": "10\n4 10 4 4 5 10 10 4 10 10\n", "output": "9"}, {"type": "stdin_stdout", "input": "10\n9 2 9 10 10 10 2 5 6 6\n", "output": "7"}, {"type": "stdin_stdout", "input": "10\n8 8 8 8 8 8 8 8 8 8\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides,... | [{"type": "stdin_stdout", "input": "25 5\n", "output": "29\n1 1\n1 2\n1 3\n1 4\n1 5\n25 5\n24 5\n23 5\n22 5\n21 5\n20 5\n19 5\n18 5\n17 5\n16 5\n15 5\n14 5\n13 5\n12 5\n11 5\n10 5\n9 5\n8 5\n7 5\n6 5\n5 5\n4 5\n3 5\n2 5\n"}, {"type": "stdin_stdout", "input": "24 6\n", "output": "29\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n24 6\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Luba bought a monitor. Monitor is a rectangular matrix of size n × m. But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when ... | [{"type": "stdin_stdout", "input": "29 50 5 29\n21 42 1565821\n21 43 53275635\n21 44 2717830\n21 45 9579585\n21 46 20725775\n22 42 2568372\n22 43 9584662\n22 44 31411635\n22 45 5089311\n22 46 4960702\n23 42 11362237\n23 43 42200296\n23 44 18762146\n23 45 8553819\n23 46 4819516\n24 42 10226552\n24 43 21022685\n24 44 329... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a matrix of size $n \\times n$ filled with lowercase English letters. You can change no more than $k$ letters in this matrix.\n\nConsider all paths from the upper left corner to the lower right corner that m... | [{"type": "stdin_stdout", "input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutsnz\n", "output": "aaaaaaadudsnz\n"}, {"type": "stdin_stdout", "input": "5 3\nbwwwz\nhrhdh\nsepsp\nsqfaf\najbvw\n", "output": "aaaepfafw\n"}, {"type": "stdin_stdout", "input": "4 16\ndfhs\nvgca\ndfgd\nvscd\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe main characters have been omitted to be short.\n\nYou are given a directed unweighted graph without loops with $n$ vertexes and a path in it (that path is not necessary simple) given by a sequence $p_1, p_2, \\ldots, ... | [{"type": "stdin_stdout", "input": "20\n01001100001100011011\n00111101001100001101\n01010010000010000110\n10101001000000000110\n00110110111101100000\n00111010110011100011\n01101000111001110100\n11111100011110000100\n11111010011110011000\n10001100000101100101\n11001111010010100011\n00001111001001111111\n1001111000010100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $n$. Let's cal... | [{"type": "stdin_stdout", "input": "20\n9 15 11 8 10 5 19 13 12 18 3 20 17 14 2 16 7 4 1 6\n12 6 7 5 4 20 15 14 1 18 10 17 9 19 16 3 13 11 2 8\n", "output": "2"}, {"type": "stdin_stdout", "input": "18\n11 16 18 3 7 12 10 6 14 15 5 13 9 17 4 8 1 2\n16 9 8 7 4 13 6 17 3 18 14 11 5 1 15 12 10 2\n", "output": "3"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit.\n\nVasya has $n$ problems to choose from. They are numbered from $1$ to $n$.... | [{"type": "stdin_stdout", "input": "22 936\n20 743\n55 46\n83 282\n157 3\n168 979\n241 338\n293 113\n312 292\n333 509\n339 632\n345 149\n347 109\n384 846\n420 151\n619 923\n647 336\n706 935\n726 600\n760 45\n804 126\n810 739\n906 341\n", "output": "3371\n"}, {"type": "stdin_stdout", "input": "9 985\n227 166\n325 695\n4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKefa decided to celebrate his first big salary by going to the restaurant. \n\nHe lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house... | [{"type": "stdin_stdout", "input": "15 2\n1 0 1 0 1 0 0 0 0 0 0 0 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n4 8\n4 9\n5 10\n5 11\n6 12\n6 13\n7 14\n7 15\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "12 3\n1 0 1 0 1 1 1 1 0 0 0 0\n6 7\n12 1\n9 7\n1 4\n10 7\n7 1\n11 8\n5 1\n3 7\n5 8\n4 2\n", "output": "7\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEhab has an array $a$ of length $n$. He has just enough free time to make a new array consisting of $n$ copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subseque... | [{"type": "stdin_stdout", "input": "4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n", "output": "2\n1\n5\n5\n"}, {"type": "stdin_stdout", "input": "2\n3\n3 2 1\n6\n3 1 4 1 5 9\n", "output": "3\n5\n"}, {"type": "stdin_stdout", "input": "2\n5\n1 2 3 4 5\n4\n2 3 4 5\n", "output": "5\n4\n"}, {"type": "stdin_st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDuring the loading of the game \"Dungeons and Candies\" you are required to get descriptions of k levels from the server. Each description is a map of an n × m checkered rectangular field. Some cells of the field contain ... | [{"type": "stdin_stdout", "input": "3 3 10 2\nBA.\n..A\n.BB\nB..\n..B\n.AA\nB..\nAB.\n..A\nBAB\n.A.\n.B.\n..B\nA..\n...\n...\n.B.\nBA.\n..B\n.AB\n.B.\nB.A\n.A.\n.BA\n..B\n...\n.A.\n.AA\n..A\n.B.\n", "output": "67\n1 0\n10 1\n2 1\n3 2\n4 1\n7 4\n9 7\n5 9\n6 9\n8 4\n"}, {"type": "stdin_stdout", "input": "3 2 10 1\nAB\nBA... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the... | [{"type": "stdin_stdout", "input": "20 20\n-1012 625 39 -1747 -1626 898 -1261 180 -876 -1417 -1853 -1510 -1499 -561 -1824 442 -895 13 1857 1860\n-1269013 -1270956 -1264151 -1266004 -1268121 -1258341 -1269574 -1271851 -1258302 -1271838 -1260049 -1258966 -1271398 -1267514 -1269981 -1262038 -1261675 -1262734 -1260777 -126... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.\n\nTickets for group of x pe... | [{"type": "stdin_stdout", "input": "100 1000 1000\n0000010100101100110100101111001111111111100101111100111011110001011110110111111010000000101000111000\n", "output": "100000\n"}, {"type": "stdin_stdout", "input": "50 13 44\n11101110100110111100010110001111001001110010111011\n", "output": "1270\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \\leq k \\leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For... | [{"type": "stdin_stdout", "input": "1\n440\ntcjbjlbtjfmvzdqutuwzvmgqrqtrvxwrdacxcowbmbwvwssihttgdsjntiawqavwspzmybakxmwpbcgaffpyhvjrulqsorkcuozvtdbkkmasxtemrrbhqnmkpgewwphdvcyhxmatrfjkesacujihmtyqtqcjfqhpsjhgzimegvkjylapylqprykvkjavlmipewlzqsfefjzecadsqmfutgnegngmwchqttcyklocfcyuhghvtygdbsxaoxkvtgdcnsqddzzakhgrribwxkua... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe development of a text editor is a hard problem. You need to implement an extra module for brackets coloring in text.\n\nYour editor consists of a line with infinite length and cursor, which points to the current chara... | [{"type": "stdin_stdout", "input": "21\n(RRRRR)LLLL(RRR)LL(R)\n", "output": "-1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 2 2 2 -1 -1 3 "}, {"type": "stdin_stdout", "input": "11\n(RaRbR)L)L(\n", "output": "-1 -1 -1 -1 -1 -1 1 1 -1 -1 2 "}, {"type": "stdin_stdout", "input": "11\n(R)R(R)Ra)c\n", "output": "-1 -1 1 1 -1 -1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k ic... | [{"type": "stdin_stdout", "input": "71 96 75634\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71\n27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent ... | [{"type": "stdin_stdout", "input": "10 10\n*.*...*.**\n..*...*.**\n.**.***...\n....*.*.**\n***....***\n.*..*...*.\n.***.*..*.\n.*****.*.*\n*.***.*...\n..*..*....\n", "output": "9.9...5.71\n..9...5.77\n.99.997...\n....9.5.77\n299....513\n.2..0...1.\n.490.0..9.\n.71120.7.1\n7.434.8...\n..6..2....\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nValentin participates in a show called \"Shockers\". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the sele... | [{"type": "stdin_stdout", "input": "15\n. r\n? e\n. s\n. rw\n? y\n. fj\n. zftyd\n? r\n! wq\n? w\n? p\n. ours\n. dto\n. lbyfru\n? q\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n! ababahalamaha\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDemiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.\n\nThere is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that d... | [{"type": "stdin_stdout", "input": "50\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 33\n33 34\n34 35\n35 36\n36 37\n37 38\n38 39\n39 40\n40 41\n41 42\n42 43\n43 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value $x$ that occurs in the array $2$ or more times. Take the firs... | [{"type": "stdin_stdout", "input": "34\n967614464 967614464 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given n integers a_1, a_2, ..., a_{n}. Find the number of pairs of indexes i, j (i < j) that a_{i} + a_{j} is a power of 2 (i. e. some integer x exists so that a_{i} + a_{j} = 2^{x}).\n\n\n-----Input-----\n\nThe f... | [{"type": "stdin_stdout", "input": "100\n3 6 12 1 16 4 9 5 4 4 5 8 12 4 6 14 5 1 2 2 2 1 7 1 9 10 6 13 7 8 3 11 8 11 7 5 15 6 14 10 4 2 10 9 1 8 14 9 5 11 3 4 1 12 6 8 13 4 8 5 4 13 13 1 3 9 14 7 14 10 7 3 12 8 9 8 6 15 9 10 12 14 15 4 16 8 8 4 8 7 5 10 16 4 10 13 6 16 16 5\n", "output": "532\n"}, {"type": "stdin_stdou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.\n\nFirst, he splits the... | [{"type": "stdin_stdout", "input": "10 8\n0110000110\n3 3\n1 10\n4 4\n1 8\n1 2\n9 10\n2 10\n3 9\n", "output": "1\n960\n0\n224\n2\n2\n480\n112\n"}, {"type": "stdin_stdout", "input": "6 5\n111101\n1 1\n4 6\n3 6\n1 2\n4 4\n", "output": "1\n6\n14\n3\n1\n"}, {"type": "stdin_stdout", "input": "10 4\n1110101101\n3 5\n7 8\n8 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKamil likes streaming the competitive programming videos. His MeTube channel has recently reached $100$ million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet.... | [{"type": "stdin_stdout", "input": "32\n402528994560 0 0 0 0 0 0 932646223872 893192888700 0 813583026900 0 0 0 0 143521875000 0 177570054144 186624000000 0 517655600000 202145625000 341007975000 0 116252718750 0 148561875000 0 304819200000 248474688000 0 103125000000\n29 25\n20 24\n8 21\n23 3\n32 14\n29 30\n31 24\n28 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAuthor has gone out of the stories about Vasiliy, so here is just a formal task description.\n\nYou are given q queries and a multiset A, initially containing only integer 0. There are three types of queries: \"+ x\" — a... | [{"type": "stdin_stdout", "input": "7\n? 1\n+ 941492387\n+ 72235422\n+ 449924898\n+ 783332532\n- 941492387\n- 72235422\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "14\n+ 4\n+ 4\n+ 4\n+ 4\n? 3\n- 4\n- 4\n- 4\n? 3\n+ 5\n? 3\n- 4\n+ 4\n? 3\n", "output": "7\n7\n7\n7\n"}, {"type": "stdin_stdout", "input": "12\n+... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSlava plays his favorite game \"Peace Lightning\". Now he is flying a bomber on a very specific map.\n\nFormally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can... | [{"type": "stdin_stdout", "input": "100\n", "output": "150\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLocal authorities have heard a lot about combinatorial abilities of Ostap Bender so they decided to ask his help in the question of urbanization. There are n people who plan to move to the cities. The wealth of the i of t... | [{"type": "stdin_stdout", "input": "69 6 63\n53475 22876 79144 6335 33763 79104 65441 45527 65847 94406 74670 43529 75330 19403 67629 56187 57949 23071 64910 54409 55348 18056 855 24961 50565 6622 26467 33989 22660 79469 41246 13965 79706 14422 16075 93378 81313 48173 13470 97348 2346 27452 59427 29925 29847 73823 3202... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInna likes sweets and a game called the \"Candy Matrix\". Today, she came up with the new game \"Candy Matrix 2: Reload\".\n\nThe field for the new game is a rectangle table of size n × m. Each line of the table contains ... | [{"type": "stdin_stdout", "input": "10 10\nG********S\n*G*******S\n**G******S\n***G*****S\n****G****S\n*****G***S\n******G**S\n*******G*S\n********GS\nG********S\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "5 10\nG***S*****\nG****S****\n***GS*****\nG*S*******\nG***S*****\n", "output": "4\n"}, {"type": "stdi... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a graph with $n$ nodes and $m$ directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path... | [{"type": "stdin_stdout", "input": "10 50\nebibwbjihv\n1 10\n1 2\n5 4\n1 8\n9 7\n5 6\n1 8\n8 7\n2 6\n5 4\n1 9\n3 2\n8 3\n5 6\n5 9\n2 4\n2 7\n3 9\n1 2\n1 7\n1 10\n3 7\n1 8\n3 10\n8 6\n1 7\n10 6\n1 6\n5 8\n1 5\n2 10\n3 9\n5 8\n8 3\n3 7\n5 2\n1 10\n1 4\n5 3\n3 2\n1 2\n5 8\n10 4\n2 10\n8 2\n1 9\n1 8\n1 2\n3 4\n1 8\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDuring a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student... | [{"type": "stdin_stdout", "input": "30\n61 23\n30 93\n4 18\n34 97\n63 77\n45 95\n51 13\n41 8\n86 19\n38 24\n2 67\n20 82\n95 48\n95 1\n28 93\n92 100\n26 78\n85 28\n1 82\n61 37\n77 35\n81 21\n10 24\n52 12\n80 90\n64 61\n12 87\n78 19\n21 34\n54 49\n", "output": "30909"}, {"type": "stdin_stdout", "input": "18\n19 24\n49 18... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice lives on a flat planet that can be modeled as a square grid of size $n \\times n$, with rows and columns enumerated from $1$ to $n$. We represent the cell at the intersection of row $r$ and column $c$ with ordered p... | [{"type": "stdin_stdout", "input": "10\n2 2\n9 9\n1111111111\n1000111111\n1000111111\n1111111111\n1111000001\n1111011111\n1111010001\n1111010101\n1111000101\n1111111111\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n9 9\n2 2\n1111111111\n1000111111\n1000111111\n1111111111\n1111000001\n1111011111\n11110100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSereja has got an array, consisting of n integers, a_1, a_2, ..., a_{n}. Sereja is an active boy, so he is now going to complete m operations. Each operation will have one of the three forms: Make v_{i}-th array element ... | [{"type": "stdin_stdout", "input": "6 6\n202714501 613423725 367325359 862808465 182588146 745008828\n2 492\n2 1943\n1 3 173984392\n1 3 9356383\n3 4\n1 5 472683539\n", "output": "862810900\n"}, {"type": "stdin_stdout", "input": "5 5\n286163265 724763447 761775891 215352371 491215007\n1 4 780579549\n1 2 638546757\n3 4\n... | 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 1000000000\n6 2 1000000000\n1 7 1000000000\n7 2 1000000000\n1 8 1000000000\n8 2 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\nStepan had a favorite string s which consisted of the lowercase letters of the Latin alphabet. \n\nAfter graduation, he decided to remember it, but it was a long time ago, so he can't now remember it. But Stepan remembers... | [{"type": "stdin_stdout", "input": "200\n200 180 160 140 122 106 92 79 69 60 52 45 38 32 26 20 14 8 4 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya has a rectangular Board of size $n \\times m$. Initially, $k$ chips are placed on the board, $i$-th chip is located in the cell at the intersection of $sx_i$-th row and $sy_i$-th column.\n\nIn one action, Petya can ... | [{"type": "stdin_stdout", "input": "10 10 20\n7 5\n4 5\n5 4\n7 4\n1 5\n6 7\n9 5\n8 4\n1 4\n2 10\n3 10\n4 10\n3 6\n5 7\n6 2\n1 1\n10 9\n7 6\n1 4\n6 4\n8 2\n8 3\n5 1\n10 4\n4 2\n1 9\n1 10\n9 5\n2 2\n6 7\n8 6\n8 9\n4 2\n7 8\n3 3\n4 2\n6 10\n9 4\n10 2\n7 7\n", "output": "117\nUUUUUUUUULLLLLLLLLRRRRRRRRRDLLLLLLLLLDRRRRRRRRR... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in som... | [{"type": "stdin_stdout", "input": "41 4\n24 15 17 35 13 41 4 14 23 5 8 16 21 18 30 36 6 22 11 29 26 1 40 31 7 3 32 10 28 38 12 20 39 37 34 19 33 27 2 25 9\n22 13 25 24 38 35 29 12 15 8 11 37 3 19 4 23 18 32 30 40 36 21 16 34 27 9 5 41 39 2 14 17 31 33 26 7 1 10 20 6 28\n31 27 39 16 22 12 13 32 6 10 19 29 37 7 18 33 24... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.\n\nThe local store introduced a new service thi... | [{"type": "stdin_stdout", "input": "11\n1000000000 500000000 500000000\n1000000000 500000000 499999999\n1000000000 499999999 499999999\n500000000 1000000000 500000000\n500000000 1000000000 499999999\n499999999 1000000000 499999999\n500000000 500000000 1000000000\n500000000 499999999 1000000000\n499999999 499999999 1000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells.\n\nVova's character can learn new spells during the game. Every spell is ch... | [{"type": "stdin_stdout", "input": "15 100\n1 8 8\n2 200 101\n2 10 99\n1 9 9\n2 10 99\n2 200 101\n1 14 4\n2 194 195\n2 194 194\n2 990 290\n1 2 999992\n2 6 256\n2 7 256\n1 2 999988\n2 2 252\n", "output": "NO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "12 100\n1 8 8\n2 200 101\n2 10 99... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, ...}. We performed n swap operations with this sequence. A swap(a, b) is an operation of swapping the elements of th... | [{"type": "stdin_stdout", "input": "30\n1 200000\n2 199999\n3 199998\n4 199997\n5 199996\n200001 399996\n200002 399997\n200003 399998\n200004 399999\n200005 400000\n400001 599998\n400002 599999\n400003 600000\n400004 599996\n400005 599995\n600001 800000\n600002 799999\n600003 799998\n600004 799997\n600005 799996\n60000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAmugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by $n$ sectors, and the outer area is equally divided by $m$ sectors. A wall exists between each pair of sect... | [{"type": "stdin_stdout", "input": "1 1 10\n1 1 1 1\n1 1 1 1\n1 1 2 1\n1 1 1 1\n2 1 2 1\n2 1 1 1\n1 1 2 1\n1 1 2 1\n2 1 1 1\n2 1 1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "2 3 5\n2 3 1 2\n2 3 2 3\n1 1 1 1\n1 2 1 2\n2 1 2 1\n", "output": "YES\nYES\nYES\nYE... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlica and Bob are playing a game.\n\nInitially they have a binary string $s$ consisting of only characters 0 and 1.\n\nAlice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice mak... | [{"type": "stdin_stdout", "input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"type": "stdin_stdout", "input": "2\n11111111111\n11111111111\n", "output": "NET\nNET\n"}, {"type": "stdin_stdout", "input": "3\n01\n1111\n0011\n", "output": "DA\nNET\nNET\n"}, {"type": "stdin_stdout", "input": "1\n1111111... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a connected undirected graph with $n$ vertices and an integer $k$, you have to either: either find an independent set that has exactly $\\lceil\\frac{k}{2}\\rceil$ vertices. or find a simple cycle of length at most... | [{"type": "stdin_stdout", "input": "6 15 3\n4 5\n4 6\n4 1\n4 3\n4 2\n5 6\n5 1\n5 3\n5 2\n6 1\n6 3\n6 2\n1 3\n1 2\n3 2\n", "output": "2\n3\n1 4 5 "}, {"type": "stdin_stdout", "input": "6 6 6\n4 2\n2 5\n5 3\n3 6\n6 1\n1 4\n", "output": "2\n6\n1 6 3 5 2 4 "}, {"type": "stdin_stdout", "input": "4 6 3\n1 2\n2 3\n3 4\n4 1\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n$n$ fishermen have just returned from a fishing vacation. The $i$-th fisherman has caught a fish of weight $a_i$.\n\nFishermen are going to show off the fish they caught to each other. To do so, they firstly choose an ord... | [{"type": "stdin_stdout", "input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8\n42 1337 13 37 420 666 616 97\n", "output": "19200\n"}, {"type": "stdin_stdout", "input": "2\n500000000 1000000000\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n integers b_1, b_2, ..., b_{n} written in a row. For all i from 1 to n, values a_{i} are defined by the crows performing the following procedure:\n\n The crow sets a_{i} initially 0. The crow then adds b_{i} ... | [{"type": "stdin_stdout", "input": "10\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000\n", "output": "0 0 0 0 0 0 0 0 0 1000000000 \n"}, {"type": "stdin_stdout", "input": "10\n1294 35852 32749 537295 12048 53729 29357 58320 64739 1240\n", "output": "37... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree (an undirected connected graph without cycles) and an integer $s$.\n\nVanya wants to put weights on all edges of the tree so that all weights are non-negative real numbers and their sum is $s$. At the... | [{"type": "stdin_stdout", "input": "3 1000000000\n3 2\n2 1\n", "output": "1000000000.000000000000000000"}, {"type": "stdin_stdout", "input": "2 1000000000\n2 1\n", "output": "1000000000.000000000000000000"}, {"type": "stdin_stdout", "input": "6 1\n2 1\n2 3\n2 5\n5 4\n5 6\n", "output": "0.500000000000000000"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them.\n\nConsider two dices. When thrown each dice shows some integer from 1 to n i... | [{"type": "stdin_stdout", "input": "8\n0.09597231 0.11315755 0.32077119 0.22643005 0.03791746 0.04296694 0.10284494 0.05993956\n0.52402769 0.19814245 0.20452881 0.06686995 0.00468254 0.00103306 0.00055506 0.00016044\n", "output": "0.29869999999999886 0.07920000000000116 0.32760000000000133 0.0734999999999989 0.02229999... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is the easier version of the problem. In this version $1 \\le n, m \\le 100$. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers $a=[a_1,a_2,\\dots,a_n]$ of le... | [{"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "7\n1 2 1 3 1 2 1\n9\n2 1\n2 2\n3 1\n3 2\n3 3\n1 1\n7 1\n7 7\n7 4\n", "output": "2\n3\n2\n3\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou play a strategic video game (yeah, we ran out of good problem legends). In this game you control a large army, and your goal is to conquer $n$ castles of your opponent.\n\nLet's describe the game process in detail. In... | [{"type": "stdin_stdout", "input": "10 10 2\n2 1 1615\n2 1 1326\n0 0 3880\n2 0 1596\n1 2 4118\n0 0 4795\n0 1 814\n0 0 4555\n0 1 3284\n2 2 1910\n10 6\n2 1\n8 3\n8 7\n6 3\n4 1\n7 4\n6 4\n7 2\n10 9\n", "output": "27079\n"}, {"type": "stdin_stdout", "input": "10 10 0\n0 2 1413\n0 0 4466\n0 0 2681\n0 0 2959\n0 2 1182\n0 0 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe map of Bertown can be represented as a set of $n$ intersections, numbered from $1$ to $n$ and connected by $m$ one-way roads. It is possible to move along the roads from any intersection to any other intersection. The... | [{"type": "stdin_stdout", "input": "20 50\n20 3\n5 16\n1 3\n10 11\n10 15\n15 9\n20 9\n14 6\n16 5\n13 4\n11 5\n3 20\n13 17\n11 8\n11 6\n12 14\n16 18\n17 13\n18 7\n3 1\n8 10\n17 15\n7 2\n9 13\n5 11\n6 1\n2 16\n8 18\n10 8\n4 13\n9 15\n14 12\n1 6\n9 20\n7 18\n6 14\n7 6\n18 16\n2 7\n3 11\n15 17\n3 12\n14 10\n4 14\n19 4\n11 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other o... | [{"type": "stdin_stdout", "input": "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5 7\n2 1\n3 7\n5 10\n6 1\n9 4\n3 6\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 9\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n4 10\n4 1\n10 7\n1 3\n1 8\n10 2\n4 5\n", "output": "0\n"}, {"type": "stdin_stdout... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe map of the capital of Berland can be viewed on the infinite coordinate plane. Each point with integer coordinates contains a building, and there are streets connecting every building to four neighbouring buildings. Al... | [{"type": "stdin_stdout", "input": "2 1000000000 100000\n1000000000 1000000\n1000000000 10000\n", "output": "1\n1000000000 99999\n"}, {"type": "stdin_stdout", "input": "7 10 12\n5 6\n20 23\n15 4\n16 5\n4 54\n12 1\n4 15\n", "output": "4\n10 11\n"}, {"type": "stdin_stdout", "input": "1 1000000000 7\n1000000000 9\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBoboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.\n\nYou are a new applicant for his company. Boboniu will test you with t... | [{"type": "stdin_stdout", "input": "4 4 2 3\n", "output": "2 3\n1 3\n1 1\n1 2\n1 4\n2 4\n2 2\n2 1\n3 1\n3 2\n3 3\n3 4\n4 4\n4 3\n4 2\n4 1\n"}, {"type": "stdin_stdout", "input": "4 4 3 2\n", "output": "3 2\n1 2\n1 1\n1 3\n1 4\n2 4\n2 3\n2 2\n2 1\n3 1\n3 3\n3 4\n4 4\n4 3\n4 2\n4 1\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArkady coordinates rounds on some not really famous competitive programming platform. Each round features $n$ problems of distinct difficulty, the difficulties are numbered from $1$ to $n$.\n\nTo hold a round Arkady needs... | [{"type": "stdin_stdout", "input": "10000 10\n10000 9999 9998 9997 9996 9995 9994 9993 9992 9991\n", "output": "0000000000\n"}, {"type": "stdin_stdout", "input": "5 20\n1 4 4 2 1 1 3 5 4 2 2 4 5 2 3 3 4 5 1 4\n", "output": "00000001000000100100\n"}, {"type": "stdin_stdout", "input": "1 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation $p$ of integers from $1$ to $n$, where $n$ is an even number. \n\nYour goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: take two indic... | [{"type": "stdin_stdout", "input": "50\n50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n", "output": "73\n1 50\n2 49\n3 48\n4 47\n5 46\n6 45\n7 44\n8 43\n9 42\n10 41\n11 40\n12 39\n13 38\n14 50\n37 1\n1 50\n37 1\n14 50\n15 50\... | 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": "2\n1 1000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n1 2 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n3 2 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1 2 1\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya had a strictly increasing sequence of positive integers a_1, ..., a_{n}. Vasya used it to build a new sequence b_1, ..., b_{n}, where b_{i} is the sum of digits of a_{i}'s decimal representation. Then sequence a_{i}... | [{"type": "stdin_stdout", "input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n8\n9\n10\n11\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is the harder version of the problem. In this version, $1 \\le n, m \\le 2\\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nYou are gi... | [{"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "7\n1 2 1 3 1 2 1\n9\n2 1\n2 2\n3 1\n3 2\n3 3\n1 1\n7 1\n7 7\n7 4\n", "output": "2\n3\n2\n3\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIgor is in the museum and he wants to see as many pictures as possible.\n\nMuseum can be represented as a rectangular field of n × m cells. Each cell is either empty or impassable. Empty cells are marked with '.', impassa... | [{"type": "stdin_stdout", "input": "10 10 50\n**********\n*......***\n***..**..*\n***....***\n**..***..*\n**..**.*.*\n*****..***\n*.***..***\n*..****.**\n**********\n5 9\n5 9\n7 7\n6 4\n6 7\n8 7\n6 7\n9 2\n3 9\n9 2\n4 7\n4 6\n2 7\n9 2\n7 7\n5 8\n8 7\n8 6\n7 7\n5 9\n8 7\n3 8\n3 8\n5 9\n9 8\n9 3\n8 7\n5 9\n9 2\n9 8\n9 3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he can obtain his name from some string by rem... | [{"type": "stdin_stdout", "input": "mars\nsunvenusearthmarsjupitersaturnuranusneptune\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "abcaba\nabcabaabcabaabcabaabcaba\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "rry\nsorrymercuryismissedabove\n", "output": "3\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: \"You have to write names in this notebook during $n$ con... | [{"type": "stdin_stdout", "input": "16 2\n999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999\n", "output": "499999999 500000000 499999999 500000000 499999999 500000000 499999999 500000000 499999999 500000000 499... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAmugae has a sentence consisting of $n$ words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word ... | [{"type": "stdin_stdout", "input": "9\nM M5 M5D M5DAYBl0r6gmttCTR M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAc M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re\n", "output": "M5DA... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAccording to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents s... | [{"type": "stdin_stdout", "input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIgor is a post-graduate student of chemistry faculty in Berland State University (BerSU). He needs to conduct a complicated experiment to write his thesis, but laboratory of BerSU doesn't contain all the materials require... | [{"type": "stdin_stdout", "input": "11\n1 1 1 1 1 1 1 1 1 1 1\n1 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem.\n\nThere are $n$ displays placed along a road,... | [{"type": "stdin_stdout", "input": "20\n452405440 586588704 509061481 552472140 16115810 148658854 66743034 628305150 677780684 519361360 208050516 401554301 954478790 346543678 387546138 832279893 641889899 80960260 717802881 588066499\n61699500 83254572 59454419 27833657 55743179 99661234 94729965 75591136 62937826 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou've got an array, consisting of n integers a_1, a_2, ..., a_{n}. Also, you've got m queries, the i-th query is described by two integers l_{i}, r_{i}. Numbers l_{i}, r_{i} define a subsegment of the original array, tha... | [{"type": "stdin_stdout", "input": "100 10\n53 72 2 58 6 29 65 7 43 9 77 10 58 25 49 95 88 11 7 36 51 25 78 20 15 2 69 76 1 66 17 4 91 66 50 66 69 94 74 31 19 96 35 84 83 15 33 73 39 73 29 53 9 47 3 19 4 16 85 6 49 6 57 70 96 19 66 63 86 61 27 21 33 82 13 98 59 48 85 1 13 65 28 34 93 16 88 32 60 50 33 37 36 57 97 28 18... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDreamoon likes to play with sets, integers and $gcd$. $\\operatorname{gcd}(a, b)$ is defined as the largest positive integer that divides both a and b.\n\nLet S be a set of exactly four distinct integers greater than 0. D... | [{"type": "stdin_stdout", "input": "19 21\n", "output": "2373\n21 63 84 105\n147 189 210 231\n273 315 336 357\n399 441 462 483\n525 567 588 609\n651 693 714 735\n777 819 840 861\n903 945 966 987\n1029 1071 1092 1113\n1155 1197 1218 1239\n1281 1323 1344 1365\n1407 1449 1470 1491\n1533 1575 1596 1617\n1659 1701 1722 1743... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. \n\nTen minutes befo... | [{"type": "stdin_stdout", "input": "10 3 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 3 2\n2 1 1 2 1 1 2 1 2 2\n4 10\n9 3\n5 7\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 3 2\n1 1 2 2\n1 2\n3 4\n2 3\n", "output": "2\n"}, {"type": "stdin_stdout", "inp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some st... | [{"type": "stdin_stdout", "input": "100 34\n16 0 10 11 12 13 0 5 4 14 6 15 4 9 1 20 19 14 1 7 14 11 10 20 6 9 12 8 3 19 20 4 17 17 8 11 14 18 5 20 17 0 3 18 14 12 11 12 5 5 11 7 9 17 4 8 4 10 0 0 12 9 15 3 15 14 19 12 6 8 17 19 4 18 19 3 8 3 9 1 6 15 4 16 1 18 13 16 3 5 20 11 10 9 9 17 20 15 12\n", "output": "312\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProfessor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a s_{a} as close as possible to the sum of the elements in the array b s_{b}. So he wants to minimize the v... | [{"type": "stdin_stdout", "input": "10\n87 -92 -67 -100 -88 80 -82 -59 81 -72\n10\n-50 30 30 77 65 92 -60 -76 -29 -15\n", "output": "0\n2\n4 4\n9 6\n"}, {"type": "stdin_stdout", "input": "1\n-21\n10\n-43 6 -46 79 -21 93 -36 -38 -67 1\n", "output": "1\n1\n1 3\n"}, {"type": "stdin_stdout", "input": "5\n5 4 3 2 1\n4\n1 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe government of Berland decided to improve network coverage in his country. Berland has a unique structure: the capital in the center and $n$ cities in a circle around the capital. The capital already has a good network... | [{"type": "stdin_stdout", "input": "3\n10\n3 3 2 3 2 5 1 2 6 3\n6 5 2 5 6 2 4 2 1 2\n20\n9 1 10 1 17 7 5 5 8 1 1 2 7 1 4 2 3 7 6 3\n2 6 3 2 37 1 5 5 2 5 1 3 21 15 1 7 7 5 1 1\n20\n9 1 9 5 5 1 3 2 6 3 6 1 2 5 11 7 3 5 14 2\n11 14 6 4 6 8 8 2 9 9 6 5 3 2 5 7 1 9 14 1\n", "output": "NO\nNO\nNO\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGottfried learned about binary number representation. He then came up with this task and presented it to you.\n\nYou are given a collection of $n$ non-negative integers $a_1, \\ldots, a_n$. You are allowed to perform the ... | [{"type": "stdin_stdout", "input": "37\n1048575 327657 1046479 686078 513773 589787 387035 736754 1038077 1048056 59263 753353 784318 647131 519679 294910 185560 604141 456668 849789 521404 782287 6137 1047551 849874 523933 521721 278491 1042415 581468 1013705 439526 1011709 917469 655311 327646 917499\n", "output": "2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional pa... | [{"type": "stdin_stdout", "input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13\n", "output": "66\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGenos needs your help. He was asked to solve the following programming problem by Saitama:\n\nThe length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as $\\s... | [{"type": "stdin_stdout", "input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", "output": "321\n"}, {"type": "stdin_stdout", "input": "1110010001000101001011111\n00011011000000100001010000010100110011010001111010\n", "output": "316\n"}, {"type": "stdin_stdout", "input": "0011\n0110... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call an array of non-negative integers $a_1, a_2, \\ldots, a_n$ a $k$-extension for some non-negative integer $k$ if for all possible pairs of indices $1 \\leq i, j \\leq n$ the inequality $k \\cdot |i - j| \\leq mi... | [{"type": "stdin_stdout", "input": "3\n1000000000 1000000000 1000000000\n", "output": "500000000"}, {"type": "stdin_stdout", "input": "3\n425950796 368258337 278906507\n", "output": "139453253"}, {"type": "stdin_stdout", "input": "2\n1000000000 1000000000\n", "output": "1000000000"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. \n\nLakes are the maximal regions of water cells, connecte... | [{"type": "stdin_stdout", "input": "50 3 4\n***\n*.*\n*.*\n*.*\n***\n***\n*.*\n***\n.**\n***\n..*\n***\n***\n*.*\n***\n*.*\n***\n***\n*.*\n***\n*.*\n*.*\n*.*\n*.*\n***\n*.*\n*.*\n*.*\n*.*\n***\n***\n*.*\n*.*\n*.*\n*.*\n*.*\n***\n***\n***\n*.*\n***\n***\n***\n*.*\n*.*\n*.*\n***\n***\n***\n***\n", "output": "8\n***\n***\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs t... | [{"type": "stdin_stdout", "input": "100\n881 479 355 759 257 497 690 598 275 446 439 787 257 326 584 713 322 5 253 781 434 307 164 154 241 381 38 942 680 906 240 11 431 478 628 959 346 74 493 964 455 746 950 41 585 549 892 687 264 41 487 676 63 453 861 980 477 901 80 907 285 506 619 748 773 743 56 925 651 685 845 313 4... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.