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\nProblem A Secret of Chocolate Poles\n\nWendy, the master of a chocolate shop, is thinking of displaying poles of chocolate disks in the showcase. She can use three kinds of chocolate disks: white thin disks, dark thin dis...
[{"type": "stdin_stdout", "input": "88 3", "output": "2971215071\n"}, {"type": "stdin_stdout", "input": "73 3", "output": "102334153\n"}, {"type": "stdin_stdout", "input": "68 4", "output": "3956574\n"}, {"type": "stdin_stdout", "input": "87 6", "output": "8427403\n"}, {"type": "stdin_stdout", "input": "72 4", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes t...
[{"type": "stdin_stdout", "input": "20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "927799753\n"}, {"type": "stdin_stdout", "input": "10\n4 10 -1 1 6 8 9 2 -1 -1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n3 10 -1 1 6 8 9 2 -1 -1\n", "output": "6\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDr. Akita, who lives in the neighborhood, is a historical researcher in the field and recently discovered a new ancient document about Ono no Komachi.\n\nIt is widely known that Ono no Komachi has given General Fukakusa, ...
[{"type": "stdin_stdout", "input": "1 1\n3 2\n3 1+2*3-4\n3 1|2^3&4\n3 (1+2)*3\n3 1-1-1-1\n0 #", "output": "91\n92\n273\n93\n279\n88\n"}, {"type": "stdin_stdout", "input": "1 1\n3 4\n3 1+2*3-4\n3 1|2^3&4\n3 (1+2)*3\n3 1-1-1-1\n0 #", "output": "91\n94\n273\n93\n279\n88\n"}, {"type": "stdin_stdout", "input": "1 1\n3 4\n3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi wants to print a document with N pages double-sided, where two pages of data can be printed on one sheet of paper.\nAt least how many sheets of paper does he need?\n\n-----Constraints-----\n - N is an integer.\n...
[{"type": "stdin_stdout", "input": "1073", "output": "537\n"}, {"type": "stdin_stdout", "input": "100\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "282", "output": "141\n"}, {"type": "stdin_stdout", "input": "557", "output": "279\n"}, {"type": "stdin_stdout", "input": "284", "output": "142\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.\n\nThe Koch curve is well known as a kind of fractals.\n\nYou can draw a Koch curve in the following algorithm:\n\n* Di...
[{"type": "stdin_stdout", "input": "5", "output": "0 0\n0.411522633745 0.0\n0.617283950617 0.356389055055\n0.82304526749 0.0\n1.23456790123 0.0\n1.44032921811 0.356389055055\n1.23456790123 0.712778110111\n1.64609053498 0.712778110111\n1.85185185185 1.06916716517\n2.05761316872 0.712778110111\n2.46913580247 0.7127781101...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer number $n$. The following algorithm is applied to it:\n\n if $n = 0$, then end algorithm; find the smallest prime divisor $d$ of $n$; subtract $d$ from $n$ and go to step $1$. \n\nDetermine the...
[{"type": "stdin_stdout", "input": "10000000000\n", "output": "5000000000\n"}, {"type": "stdin_stdout", "input": "10000000000\n", "output": "5000000000\n"}, {"type": "stdin_stdout", "input": "10000000010\n", "output": "5000000005\n"}, {"type": "stdin_stdout", "input": "10010000010\n", "output": "5005000005\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVictor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.\n\nVictor thinks that if a word contains two consecutive vowels, then it's kinda weird an...
[{"type": "stdin_stdout", "input": "90\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", "output": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"}, {"type": "stdin_stdout", "input": "90\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equ...
[{"type": "stdin_stdout", "input": "11 16", "output": "11\n"}, {"type": "stdin_stdout", "input": "31 16", "output": "24\n"}, {"type": "stdin_stdout", "input": "27 16", "output": "22\n"}, {"type": "stdin_stdout", "input": "23 60", "output": "23\n"}, {"type": "stdin_stdout", "input": "31 23", "output": "27\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds shou...
[{"type": "stdin_stdout", "input": "1000\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1481\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1998\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1513\n", "output": "ABD\n"}, {"type": "stdin_stdout", "input": "1285\n", "output": "ABD\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.\n\nToday was the pilot la...
[{"type": "stdin_stdout", "input": "50\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is addicted to Codeforces, and keeps refreshing the main page not to miss any changes in the \"recent actions\" list. He likes to read thread conversations where each thread consists of multiple messages.\n\nRece...
[{"type": "stdin_stdout", "input": "132\n13 7 33 124 118 76 94 92 16 107 130 1 46 58 28 119 42 53 102 81 99 29 57 70 125 45 100 68 10 63 34 38 19 49 56 30 103 72 106 3 121 110 78 2 31 129 128 24 77 61 87 47 15 21 88 60 5 101 82 108 84 41 86 66 79 75 54 97 55 12 69 44 83 131 9 95 11 85 52 35 115 80 111 27 109 36 39 104 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves to play with color cards.\n\nHe has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front sid...
[{"type": "stdin_stdout", "input": "100\n1 2\n2 1\n2 1\n1 2\n1 1\n1 2\n2 1\n1 1\n2 2\n2 1\n2 1\n1 1\n1 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 1\n2 1\n1 1\n1 1\n2 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n2 2\n1 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n1 1\n1 2\n1 1\n1 1\n2 2\n2 2\n2 1\n2 1\n1 2\n2 2\n1 1\n2 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn order to make the \"Sea Battle\" game more interesting, Boris decided to add a new ship type to it. The ship consists of two rectangles. The first rectangle has a width of $w_1$ and a height of $h_1$, while the second ...
[{"type": "stdin_stdout", "input": "100000000 100000000 100000000 100000000\n", "output": "600000004\n"}, {"type": "stdin_stdout", "input": "100000000 100000000 100000000 100000000\n", "output": "600000004\n"}, {"type": "stdin_stdout", "input": "100000000 100000000 99999999 100000000\n", "output": "600000004\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ non-zero integers (i.e. $a_i \\ne 0$). \n\nYou have to calculate two following values: the number of pairs of indices $(l, r)$ $(l \\le r)$ such that $a_...
[{"type": "stdin_stdout", "input": "10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n", "output": "28 27\n"}, {"type": "stdin_stdout", "input": "10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n", "output": "28 27\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.\n\nConstraints\n\n* $2 \\leq n \\leq 100,000$\n* $0 \\leq m \\leq...
[{"type": "stdin_stdout", "input": "16 9\n0 1\n0 2\n3 4\n5 7\n5 2\n3 7\n6 13\n11 12\n8 9\n3\n0 1\n5 9\n1 3", "output": "yes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "16 9\n0 1\n0 2\n3 4\n5 7\n5 2\n3 7\n6 13\n7 8\n8 9\n3\n0 1\n5 9\n1 3", "output": "yes\nyes\nyes\n"}, {"type": "stdin_stdout", "input": "16 9\n0 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of size n, and q queries to it. There are queries of two types: 1 l_{i} r_{i} — perform a cyclic shift of the segment [l_{i}, r_{i}] to the right. That is, for every x such that l_{i} ≤ x < r_{i...
[{"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 10 6\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 3\n", "output": "3 3 1 10 2\n"}, {"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 5 12\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 4\n", "output": "3 3 1 5 12\n"}, {"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 10 6\n2 2 3\n2 3 6\n1 1 6\n2 2 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLo and Behold! For you may be surprised by what our chief chef Noodle has in mind for this season! Today, Noodle announced one of his most extra-ordinary ideas ever - Project Spoon. \nNoodle plans to deploy large spoons i...
[{"type": "stdin_stdout", "input": "2\n18\n229", "output": "6\n10\n"}, {"type": "stdin_stdout", "input": "2\n18\n344", "output": "6\n11\n"}, {"type": "stdin_stdout", "input": "2\n128\n46", "output": "10\n8\n"}, {"type": "stdin_stdout", "input": "2\n11\n493", "output": "6\n12\n"}, {"type": "stdin_stdout", "input": "2\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\nHere, a Shichi-Go-San number is a positive integer that satis...
[{"type": "stdin_stdout", "input": "999999999\n", "output": "26484\n"}, {"type": "stdin_stdout", "input": "500000000\n", "output": "14384\n"}, {"type": "stdin_stdout", "input": "777757375\n", "output": "26423\n"}, {"type": "stdin_stdout", "input": "777777752\n", "output": "26483\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^5\n\n-----Input---...
[{"type": "stdin_stdout", "input": "100000\n", "output": "90909\n"}, {"type": "stdin_stdout", "input": "45901\n", "output": "36811\n"}, {"type": "stdin_stdout", "input": "99924\n", "output": "90834\n"}, {"type": "stdin_stdout", "input": "99999\n", "output": "90909\n"}, {"type": "stdin_stdout", "input": "100010", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTernary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out ...
[{"type": "stdin_stdout", "input": "..---.-.--.-..-.-.---...--.-------..-.---.-...-.-----...-.-.....-..--.---.-.-.-----.-.-.-..----.-.----.-.---.--.-..-.----..---.-..--..------.-.-.---.-.-...--....-.--.--.-.-.-..-..-...--..---.-.------.\n", "output": "00211201011210020222101211001221001100001020211122111102201220121201...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $A$ of length $N$ weights of masses $A_1$, $A_2$...$A_N$. No two weights have the same mass. You can put every weight on one side of the balance (left or right). You don't have to put weights in ord...
[{"type": "stdin_stdout", "input": "5\n4 11 1 9 12\nLLRLL\n", "output": "9 L\n4 R\n11 R\n12 L\n1 L\n"}, {"type": "stdin_stdout", "input": "5\n5 8 2 15 10\nLLRLL\n", "output": "8 L\n5 R\n10 R\n15 L\n2 L\n"}, {"type": "stdin_stdout", "input": "5\n4 14 1 9 12\nLLRLL\n", "output": "9 L\n4 R\n12 R\n14 L\n1 L\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of length $n$ and array $b$ of length $m$ both consisting of only integers $0$ and $1$. Consider a matrix $c$ of size $n \\times m$ formed by following rule: $c_{i, j} = a_i \\cdot b_j$ (i.e. $a...
[{"type": "stdin_stdout", "input": "50 50 6\n1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1\n1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0\n", "output": "2153\n"}, {"type": "stdin_stdout", "input": "50 50 6\n1 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSanta Claus has received letters from $n$ different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the $i$-th kid asked Santa to give them one of $k_i$ different items...
[{"type": "stdin_stdout", "input": "10\n5 48258 84644 992412 548310 132019\n5 132019 556600 548310 94345 992412\n6 132019 771663 523582 548310 463969 556600\n7 556600 132019 992412 523582 548310 70239 84644\n4 504172 548310 523582 286042\n7 548310 84644 771663 556600 132019 463969 48258\n5 556600 771663 463969 523582 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is $\\frac{a}{b}$ for SmallR while $...
[{"type": "stdin_stdout", "input": "125 1283 234 1112\n", "output": "0.33904754471037046\n"}, {"type": "stdin_stdout", "input": "719 1275 626 1265\n", "output": "0.7232359328271274\n"}, {"type": "stdin_stdout", "input": "125 1283 148 603\n", "output": "0.30545998322249646\n"}, {"type": "stdin_stdout", "input": "125 128...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a given integer $n$. Find the number of ways to fill all $3 \\times n$ tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap. $\\square$ This pictur...
[{"type": "stdin_stdout", "input": "60\n", "output": "1073741824"}, {"type": "stdin_stdout", "input": "60\n", "output": "1073741824"}, {"type": "stdin_stdout", "input": "54\n", "output": "134217728\n"}, {"type": "stdin_stdout", "input": "58\n", "output": "536870912\n"}, {"type": "stdin_stdout", "input": "56\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYoung boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.\n\nArtem wants to paint an $n \\times m$ board. Each cell of the board should b...
[{"type": "stdin_stdout", "input": "19\n15 73\n16 92\n22 97\n13 64\n49 127\n79 79\n66 13\n49 48\n173 75\n64 77\n27 95\n27 156\n29 53\n48 10\n265 151\n26 37\n13 2\n44 13\n85 70\n", "output": "WBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a progra...
[{"type": "stdin_stdout", "input": "1\n", "output": "Hello World\n"}, {"type": "stdin_stdout", "input": "2\n-2\n116", "output": "114\n"}, {"type": "stdin_stdout", "input": "2\n-2\n178", "output": "176\n"}, {"type": "stdin_stdout", "input": "2\n-2\n184", "output": "182\n"}, {"type": "stdin_stdout", "input": "2\n-2\n143"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer $D$. Let's build the following graph from it: each vertex is a divisor of $D$ (not necessarily prime, $1$ and $D$ itself are also included); two vertices $x$ and $y$ ($x > y$) have an u...
[{"type": "stdin_stdout", "input": "18\n36\n1 1\n1 2\n1 3\n1 6\n1 9\n1 18\n2 1\n2 2\n2 3\n2 6\n2 9\n2 18\n3 1\n3 2\n3 3\n3 6\n3 9\n3 18\n6 1\n6 2\n6 3\n6 6\n6 9\n6 18\n9 1\n9 2\n9 3\n9 6\n9 9\n9 18\n18 1\n18 2\n18 3\n18 6\n18 9\n18 18\n", "output": "1\n1\n1\n2\n1\n3\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n2\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper, the Little Elephant ought to delete ex...
[{"type": "stdin_stdout", "input": "11100010010010000110101101101100111111001010001101101001001111010110010111001011010000001100110101000101111000001111101111110010000010101110011110101101010110001100011101111011100010011101100111110010111111100110101000000111101000000000110100100101111101000110101010101101001110001110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nConstraints\n\n* 1...
[{"type": "stdin_stdout", "input": "9 6\n1 1\n1 0\n1 4\n2 4\n4 3\n4 2\n4\n1 1\n-1 3\n2 -1\n3 4", "output": "1\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "5 6\n0 1\n1 0\n1 0\n2 4\n4 1\n3 2\n4\n0 1\n-1 0\n2 0\n3 4", "output": "1\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "9 6\n0 1\n1 0\n1 2\n2 4\n4 3\n4 2\n4\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nINTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequenc...
[{"type": "stdin_stdout", "input": "aMCT]:0hDJ*Up5g_l:O&>>%gjQkZkb(mi&;\\7dL\"nWOGz/;,6h*@Q0R53MS2<}F~+Ms\\\"cF-lgF0>C&y7)72\\.T\"8*#VO=|^OtYs\n", "output": "122\n212\n240\n152\n112\n94\n80\n246\n244\n208\n254\n170\n156\n98\n198\n236\n196\n218\n106\n142\n232\n0\n216\n190\n144\n204\n180\n124\n132\n144\n50\n94\n32\n50\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOverlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.\n\nArkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dime...
[{"type": "stdin_stdout", "input": "100\nC?M?M?M?YM??YMYC?MCYMYM??Y??YC?CYC???YM?YM??MYMY?CYCYMYC?YC?C?CYCMY??CMC?YMCMYCYCYMYM?CYM?M?MCMCMY?Y\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can p...
[{"type": "stdin_stdout", "input": "5\n0 91 14 2 11", "output": "120\n"}, {"type": "stdin_stdout", "input": "5\n0 91 14 3 11", "output": "122\n"}, {"type": "stdin_stdout", "input": "5\n1 25 13 2 11", "output": "55\n"}, {"type": "stdin_stdout", "input": "5\n0 91 9 2 11", "output": "106\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is preparing the first programming contest for robots. There are $n$ problems in it, and a lot of robots are going to participate in it. Each robot solving the problem $i$ gets $p_i$ points, and the score of each...
[{"type": "stdin_stdout", "input": "100\n0 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 1 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\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial ...
[{"type": "stdin_stdout", "input": "1\nben mikes bananas eht best among many fruits bec`use bananas are sweet and cheao\nb\n1\nwinners get to visit aizu and eht uvinersity of ahuz amd maje amnx friends as wlel\na\n3\nask alex about\nthe answer for the\nassignmdnt pn diordn` `pps\na\n2\ngnimmargorp si both\na sport aod ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if...
[{"type": "stdin_stdout", "input": "187 64\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then ...
[{"type": "stdin_stdout", "input": "100 50 11\n7 15 0 1 6 7 9 2 4 6 7 7 3 9 4 5 0 7 8 19 4 1 3 6 8 10 4 6 6 1 6 6 7 4 10 3 10 1 3 1 10 6 9 9 5 2 9 2 9 8 10 2 10 3 3 2 3 8 6 2 7 10 7 2 7 2 8 9 6 2 5 4 4 5 3 3 9 10 9 4 9 3 9 5 3 11 6 2 3 6 10 3 10 2 6 13 10 10 4 8\n3 3 2 9 4 4 10 2 7 3 3 2 6 3 3 4 7 4 1 2 3 8 1 6 14 7 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.\n\nYou decided to rob a town's blacksmith ...
[{"type": "stdin_stdout", "input": "9\n475033014 267058742\n26843 148652\n850113755 279316120\n871120869 885251487\n51363 15651\n220811492 256297120\n473761699 194406678\n38725 23371\n167395720 333327477\n107541472 19164492\n74340 1113\n654389849 224345301\n663158140 437349008\n332 5052\n971865476 538450184\n959712803 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.\n\nSimple cake is a cylinder of some radius and height. The volume of the simple cake is equal to...
[{"type": "stdin_stdout", "input": "24\n14 3600\n105 64\n40 441\n15 3136\n24 1225\n42 400\n84 100\n12 4900\n120 49\n56 225\n140 36\n70 144\n168 25\n60 196\n30 784\n280 9\n10 7056\n21 1600\n28 579\n210 16\n420 4\n840 1\n35 576\n20 1764\n", "output": "3642789.7791728945\n"}, {"type": "stdin_stdout", "input": "24\n14 3600...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a ...
[{"type": "stdin_stdout", "input": "1000000000000 68088352351238212 100000 99999\n", "output": "680883461725 61788 319116476487\n"}, {"type": "stdin_stdout", "input": "1108577267933 48182461851369906 125899 19927\n", "output": "382707249106 95156 725869923671\n"}, {"type": "stdin_stdout", "input": "1252579684821 112616...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third lev...
[{"type": "stdin_stdout", "input": "10000\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "10001\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "4115\n", "output": "28\n"}, {"type": "stdin_stdout", "input": "9894\n", "output": "38\n"}, {"type": "stdin_stdout", "input": "7969\n", "output": "35\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N bags of biscuits. The i-th bag contains A_i biscuits.\n\nTakaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags.\n\nHe would like ...
[{"type": "stdin_stdout", "input": "45 1\n17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26", "output": "17592186044416\n"}, {"type": "stdin_stdout", "input": "45 1\n17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.\n\nBut I also don't want to use many numbers, so I'll choose three positi...
[{"type": "stdin_stdout", "input": "1000000\n", "output": "999996000003000000\n"}, {"type": "stdin_stdout", "input": "862795\n", "output": "642275489615199390\n"}, {"type": "stdin_stdout", "input": "763116\n", "output": "444394078546562430\n"}, {"type": "stdin_stdout", "input": "756604\n", "output": "433115377058855412...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\n-----Constraints-----\n - 2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n - S consists of lo...
[{"type": "stdin_stdout", "input": "uncopyrightable\n", "output": "yes\n"}, {"type": "stdin_stdout", "input": "uncopyrightacle", "output": "no\n"}, {"type": "stdin_stdout", "input": "elcathgirypocnu", "output": "no\n"}, {"type": "stdin_stdout", "input": "elcathgirxpocnu", "output": "no\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "666666667\n"}, {"type": "stdin_stdout", "input": "1001000000\n", "output": "667333333\n"}, {"type": "stdin_stdout", "input": "1001100000\n", "output": "667400000\n"}, {"type": "stdin_stdout", "input": "1001001000\n", "output": "667334000\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help th...
[{"type": "stdin_stdout", "input": "4\n6\n1 1 2 3 1 1\n5\n1 1 1 2 2\n8\n7 7 2 7 7 1 4 7\n10\n1 2 3 10 1 1 2 3 4 1\n", "output": "-1\n3\n-1\n2\n"}, {"type": "stdin_stdout", "input": "4\n6\n2 2 2 3 1 2\n5\n1 1 1 2 2\n8\n7 7 2 7 7 1 8 7\n10\n1 2 6 4 1 1 2 4 4 1\n", "output": "-1\n3\n-1\n2\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has been collecting rare magazines for quite a while, and now he has decided to sell them. He distributed the magazines between $n$ boxes, arranged in a row. The $i$-th box contains $a_i$ magazines. Some of the b...
[{"type": "stdin_stdout", "input": "9\n5\n01110\n10 5 8 9 6\n6\n011011\n20 10 9 30 20 19\n4\n0000\n100 100 100 100\n4\n0111\n5 4 5 1\n5\n01110\n10 5 8 9 6\n6\n011011\n20 10 9 30 20 19\n4\n0000\n100 100 100 100\n4\n0111\n5 4 5 1\n4\n0111\n5 4 5 1\n", "output": "27\n80\n0\n14\n27\n80\n0\n14\n14\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnalyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different...
[{"type": "stdin_stdout", "input": "250\niiffiehchidfgigdbcciahdehjjfacbbaaadagaibjjcehjcbjdhaadebaejiicgidbhajfbfejcdicgfbcchgbahfccbefdcddbjjhejigiafhdjbiiehadfficicbebeeegcebideijidbgdecffeaegjfjbbcfiabfbaiddbjgidebdiccfcgfbcbbfhaejaibeicghecchjbiaceaibfgibhgcfgifiedcbhhfadhccfdhejeggcah\njbadcfjffcfabbecfabgcafgfcg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a city that can be represented as a square grid with corner points in $(0, 0)$ and $(10^6, 10^6)$.\n\nThe city has $n$ vertical and $m$ horizontal streets that goes across the whole city, i. e. the $i$-th vertica...
[{"type": "stdin_stdout", "input": "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 3\n2 2\n6 3\n1000000 1\n3 8\n2 8\n10 8\n1 15\n", "output": "2\n7\n"}, {"type": "stdin_stdout", "input": "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n172846 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the minimum number with the given sum of digits $s$ such that all digits in it are distinct (i.e. all digits are unique).\n\nFor example, if $s=20$, then the answer is $389$. This is the minimum number in which all d...
[{"type": "stdin_stdout", "input": "45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n45\n", "output": "123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789\n123456789...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group of $n$ students doing yet another trick. \n\nLet's assume that all these stud...
[{"type": "stdin_stdout", "input": "100\n73 81 39 85 48 49 37 20 66 41 79 32 54 71 31 50 48 29 10 85 81 20 20 20 48 54 70 40 71 31 49 77 50 33 12 87 19 12 54 39 87 10 20 39 81 18 70 53 86 7 33 37 62 9 77 54 50 30 70 81 66 12 41 12 20 23 87 73 91 75 94 49 18 71 81 32 79 85 30 94 48 10 41 62 73 90 40 70 90 91 33 100 79 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students....
[{"type": "stdin_stdout", "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
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": "9 20\n**.......\n****.....\n******...\n*******..\n..******.\n....****.\n......***\n*.....***\n*********\n*********\n*********\n*********\n....**...\n...****..\n..******.\n.********\n****..***\n***...***\n**.....**\n*.......*\n", "output": "********......**********........********\n**...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBeing tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.\...
[{"type": "stdin_stdout", "input": "5\n-1 10 0 3\n1 10 2 0\n900000000 1000000000 1 9999999\n0 2 1 2\n1 3 1 2\n", "output": "-1\n-1\n10\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "5\n-1 1 0 3\n1 13 2 -1\n900000000 1000000000 1 2570333\n0 2 1 2\n1 3 1 2\n", "output": "-1\n12\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are some rabbits in Singapore Zoo. To feed them, Zookeeper bought $n$ carrots with lengths $a_1, a_2, a_3, \\ldots, a_n$. However, rabbits are very fertile and multiply very quickly. Zookeeper now has $k$ rabbits an...
[{"type": "stdin_stdout", "input": "54 42164\n810471 434523 262846 930807 148016 633714 247313 376546 142288 30094 599543 829013 182512 647950 512266 827248 452285 531124 257259 453752 114536 833190 737596 267349 598567 781294 390500 318098 354290 725051 978831 905185 849542 761886 55532 608148 631077 557070 355245 929...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider all binary strings of length $m$ ($1 \\le m \\le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exact...
[{"type": "stdin_stdout", "input": "5\n3 3\n010\n001\n111\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"type": "stdin_stdout", "input": "5\n3 3\n010\n001\n110\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given p...
[{"type": "stdin_stdout", "input": "20\n713900269 224495293 592111899 609607891 585084800 601258511 223103775 876894656 751583891 230837577 971499807 312977833 344314550 397998873 558637732 216574673 913028292 762852863 464376621 61315042\n", "output": "375537226\n"}, {"type": "stdin_stdout", "input": "20\n713900269 22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.\n\nTo get rid of the oddity and rec...
[{"type": "stdin_stdout", "input": "100 5\n175 30 124 0 12 111 6 0 119 108 0 38 127 3 151 114 95 54 4 128 91 11 168 120 80 107 18 21 149 169 0 141 195 20 78 157 33 118 17 69 105 130 197 57 74 110 138 84 71 172 132 93 191 44 152 156 24 101 146 26 2 36 143 122 104 42 103 97 39 116 115 0 155 87 53 85 7 43 65 196 136 154 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a prime number $p$, $n$ integers $a_1, a_2, \\ldots, a_n$, and an integer $k$. \n\nFind the number of pairs of indexes $(i, j)$ ($1 \\le i < j \\le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \\equiv k \\bmod ...
[{"type": "stdin_stdout", "input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0"}, {"type": "stdin_stdout", "input": "6 7 2\n1 2 3 4 5 6\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 7 2\n1 2 3 4 5 6\n", "output": "3"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.\nIt takes us A_i minutes to read the i-th book from the top on Desk A (1 \\leq i \\leq N), and B_i minutes ...
[{"type": "stdin_stdout", "input": "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000010 1000000000", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \n\nHe has n dollars. Ho...
[{"type": "stdin_stdout", "input": "1000 61465564 1000\n", "output": "439034436\n"}, {"type": "stdin_stdout", "input": "859 453892 543\n", "output": "126416972\n"}, {"type": "stdin_stdout", "input": "859 453892 889\n", "output": "339370803\n"}, {"type": "stdin_stdout", "input": "859 267939 889\n", "output": "339556756\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is playing a card game with her friend Jiro.\n\nJiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known th...
[{"type": "stdin_stdout", "input": "36 30\nATK 116\nATK 120\nATK 122\nATK 120\nATK 116\nATK 118\nATK 123\nDEF 2564\nATK 123\nDEF 1810\nATK 124\nATK 120\nDEF 2598\nATK 119\nDEF 2103\nATK 123\nATK 118\nATK 118\nATK 123\nDEF 1988\nATK 122\nATK 120\nDEF 2494\nATK 122\nATK 124\nATK 117\nATK 121\nATK 118\nATK 117\nATK 122\nA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous ...
[{"type": "stdin_stdout", "input": "100\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\...
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 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"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a building consisting of $10~000$ apartments numbered from $1$ to $10~000$, inclusive.\n\nCall an apartment boring, if its number consists of the same digit. Examples of boring apartments are $11, 2, 777, 9999$ a...
[{"type": "stdin_stdout", "input": "36\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n9999\n", "output": "90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90\n90...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEzzat has an array of $n$ integers (maybe negative). He wants to split it into two non-empty subsequences $a$ and $b$, such that every element from the array belongs to exactly one subsequence, and the value of $f(a) + f(...
[{"type": "stdin_stdout", "input": "4\n3\n3 1 2\n3\n-7 -6 -6\n3\n2 2 2\n4\n17 3 5 -3\n", "output": "4.500000000\n-12.500000000\n4.000000000\n18.666666667\n"}, {"type": "stdin_stdout", "input": "4\n3\n3 1 3\n3\n-10 -3 -5\n3\n2 3 0\n4\n14 3 2 -1\n", "output": "5.0\n-10.5\n4.0\n15.333333333333334\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disappeared while writing ...
[{"type": "stdin_stdout", "input": "55\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "383381198\n55\n1\n"}, {"type": "stdin_stdout", "input": "55\naaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nReal variables $ x_1, x_2, ..., x_N $ satisfy the following conditions.\n\n1. $ 0 \\ leq x_i \\ leq 1 $ ($ 1 \\ leq i \\ leq N $)\n2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \\ leq W $\n\n\n\nAt this time, f...
[{"type": "stdin_stdout", "input": "2 1\n-1 0\n3 10", "output": "6.66666666667\n"}, {"type": "stdin_stdout", "input": "1 1\n3 2", "output": "0.666666666667\n"}, {"type": "stdin_stdout", "input": "1 2\n6 1", "output": "0.333333333333\n"}, {"type": "stdin_stdout", "input": "2 1\n-1 -3\n3 10", "output": "3.666667"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N.\n\nTakahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i o...
[{"type": "stdin_stdout", "input": "107 137", "output": "944428092\n"}, {"type": "stdin_stdout", "input": "21 300", "output": "213825142\n"}, {"type": "stdin_stdout", "input": "13 300", "output": "572293777\n"}, {"type": "stdin_stdout", "input": "13 146", "output": "392822654\n"}, {"type": "stdin_stdout", "input": "62 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBertown is a city with $n$ buildings in a straight line.\n\nThe city's security service discovered that some buildings were mined. A map was compiled, which is a string of length $n$, where the $i$-th character is \"1\" i...
[{"type": "stdin_stdout", "input": "2\n1 1\n01000010\n10 1\n01101110\n", "output": "2\n11\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n11000110\n10 1\n01101111\n", "output": "4\n11\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n01010010\n10 1\n01101100\n", "output": "3\n11\n"}, {"type": "stdin_stdout", "input": "2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n beacons located at distinct positions on a number line. The i-th beacon has position a_{i} and power level b_{i}. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing...
[{"type": "stdin_stdout", "input": "11\n110 90\n100 70\n148 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "11\n110 90\n100 70\n90 10\n80 10\n70 1\n60 1\n50 10\n40 1\n30 1\n10 1\n20 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "11\n110 61\n100 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is playing a new computer game. This game has $n$ stones in a row. The stone on the position $i$ has integer power $a_i$. The powers of all stones are distinct.\n\nEach turn Polycarp can destroy either stone on t...
[{"type": "stdin_stdout", "input": "1\n52\n1 3 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 48 29 30 31 32 49 34 35 36 37 38 39 40 41 42 43 21 45 46 47 48 49 50 51 52\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n52\n1 3 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:\n\n\"Once upon a time, there lived an emperor. He was very rich and had much grain. O...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1100000000000000000\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N people living on a number line.\nThe i-th person lives at coordinate X_i.\nYou are going to hold a meeting that all N people have to attend.\nThe meeting can be held at any integer coordinate. If you choose to...
[{"type": "stdin_stdout", "input": "100\n1 1 1 100 100 1 100 1 100 100 100 1 100 1 1 1 100 1 100 100 100 1 1 100 100 100 100 100 100 1 1 100 100 100 100 100 1 100 1 1 1 100 100 100 1 100 1 100 100 1 1 1 1 1 1 100 1 1 100 1 1 1 100 100 1 1 100 100 100 100 100 1 100 1 1 100 1 1 1 100 1 100 100 100 1 1 1 100 1 1 100 100 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$.\n\nA binary string is a string consisting of characters $0$ and $1$.\n\nYou can change any character of the string $s$ (the stri...
[{"type": "stdin_stdout", "input": "7\n10 3 1 1\n1000000110\n1 10 1 1000\n0\n1 1 10 2\n1\n4 4 4 1\n1001\n1 1 1 1\n1\n2 1000 500 1000\n11\n3 500 500 1\n101\n", "output": "17\n10\n3\n16\n1\n1000\n1500\n"}, {"type": "stdin_stdout", "input": "7\n10 3 1 1\n1000000110\n1 10 1 1000\n0\n1 1 10 2\n1\n4 4 4 1\n1001\n1 1 1 1\n1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of length n.\n\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (...
[{"type": "stdin_stdout", "input": "3\n5\n0 4 1 5 3\n5\n10 3 0 4 1\n2\n1 1 1 1\n", "output": "1\n2\n0\n"}, {"type": "stdin_stdout", "input": "3\n5\n0 4 1 5 3\n5\n10 3 0 5 1\n2\n1 1 1 1\n", "output": "1\n2\n0\n"}, {"type": "stdin_stdout", "input": "3\n5\n2 4 1 5 3\n5\n5 3 2 0 1\n4\n1 1 1 1\n", "output": "1\n3\n0\n"}, {"...
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 48 65 13 43 9 77 1 58 28 49 95 12 11 7 36 51 25 78 20 6 2 69 76 1 47 17 6 91 54 50 66 69 122 74 31 19 96 35 84 163 15 65 73 66 73 29 53 17 47 3 19 4 16 85 6 49 6 57 70 96 19 66 92 86 61 10 21 11 82 13 98 59 96 85 1 13 65 28 34 143 16 88 32 60 50 33 37 36 57 97 28...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven the string S, which consists of lowercase letters and numbers. Follow the steps below to compress the length of string S.\n\n1. Change the order of the characters in the character string to any order.\nEx...
[{"type": "stdin_stdout", "input": "0ig3hd12fz99", "output": "10\n"}, {"type": "stdin_stdout", "input": "0hg3hd12fz99", "output": "11\n"}, {"type": "stdin_stdout", "input": "0hg3hd13fz99", "output": "12\n"}, {"type": "stdin_stdout", "input": "0hf3hd12fz99", "output": "11\n"}, {"type": "stdin_stdout", "input": "99zf21dh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya owns three big integers — $a, l, r$. Let's define a partition of $x$ such a sequence of strings $s_1, s_2, \\dots, s_k$ that $s_1 + s_2 + \\dots + s_k = x$, where $+$ is a concatanation of strings. $s_i$ is the $i$-...
[{"type": "stdin_stdout", "input": "12212222221212222221221221222222121222222122\n22222111112222222222221221222222121222222122\n22222111112222222222221221222222121222222122\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "12212222221212222221221221222222121222222122\n28110439567417001223290131317494419039608149...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMemory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - ...
[{"type": "stdin_stdout", "input": "87 100 200 80\n", "output": " 913761305\n"}, {"type": "stdin_stdout", "input": "38 38 701 74\n", "output": " 496603581\n"}, {"type": "stdin_stdout", "input": "40 94 510 53\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nGiven the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence:\n\n* $ 1 \\ leq i \\ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $...
[{"type": "stdin_stdout", "input": "5\n2 10 5 22 4", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 6 7 31 10", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n1 8 7 31 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2 10 5 22 8", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.\n\nFirst he gave Amr two...
[{"type": "stdin_stdout", "input": "1000 100 777767777\n", "output": "577920877\n"}, {"type": "stdin_stdout", "input": "1000 100 777767777\n", "output": "577920877"}, {"type": "stdin_stdout", "input": "886 10 902171654\n", "output": "134375492\n"}, {"type": "stdin_stdout", "input": "712 53 592302770\n", "output": "1476...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are ...
[{"type": "stdin_stdout", "input": "4 20 18\n7 2\n9 1\n12 1\n18 1", "output": "10\n16\n7\n9\n"}, {"type": "stdin_stdout", "input": "4 20 18\n3 2\n9 1\n12 1\n18 1", "output": "10\n16\n5\n7\n"}, {"type": "stdin_stdout", "input": "4 20 18\n3 2\n9 1\n12 1\n18 2", "output": "5\n7\n10\n0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.\n\nLike many other bulletin board systems, JAG-channel is th...
[{"type": "stdin_stdout", "input": "1\n0\nccpi", "output": "ccpi\n"}, {"type": "stdin_stdout", "input": "1\n0\nipcc", "output": "ipcc\n"}, {"type": "stdin_stdout", "input": "1\n0\njpcc", "output": "jpcc\n"}, {"type": "stdin_stdout", "input": "1\n0\ncbpi", "output": "cbpi\n"}, {"type": "stdin_stdout", "input": "1\n0\nio...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Borys are playing tennis.\n\nA tennis match consists of games. In each game, one of the players is serving and the other one is receiving.\n\nPlayers serve in turns: after a game where Alice is serving follows a...
[{"type": "stdin_stdout", "input": "2\n99998 1\n1 99998\n", "output": "4\n49998 49999 50000 50001\n4\n49998 49999 50000 50001\n"}, {"type": "stdin_stdout", "input": "2\n99999 0\n0 99999\n", "output": "2\n49999 50000\n2\n49999 50000\n"}, {"type": "stdin_stdout", "input": "2\n99999 1\n1 99999\n", "output": "2\n49999 5000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a sequence of integers $x_1, x_2, \\dots, x_k$ MEX-correct if for all $i$ ($1 \\le i \\le k$) $|x_i - \\operatorname{MEX}(x_1, x_2, \\dots, x_i)| \\le 1$ holds. Where $\\operatorname{MEX}(x_1, \\dots, x_k)$ is ...
[{"type": "stdin_stdout", "input": "1\n30\n0 0 0 2 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "998244352\n"}, {"type": "stdin_stdout", "input": "1\n30\n0 0 0 2 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "998244352\n"}, {"type": "stdin_stdout", "input": "1\n30\n0 0 0 1 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven the string S and m queries. The i-th query is given by the two strings xi and yi.\n\nFor each query, answer the longest substring of the string S, starting with xi and ending with yi.\n\nFor the string S, | S | repr...
[{"type": "stdin_stdout", "input": "icpcsummertraining\n9\nmm n\nicpc summer\ntrain ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "output": "11\n10\n8\n0\n4\n16\n0\n6\n6\n"}, {"type": "stdin_stdout", "input": "icpcsummertraining\n9\nmm n\nicpc summer\nniart ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a chess board with $n$ rows and $n$ columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board.\n\nA knight is a chess piece that can attac...
[{"type": "stdin_stdout", "input": "104\n", "output": "WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\nBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\n\nPaul and Mary have a favorite string $s$ which consists of lowercase letters of the Latin alphabet. Th...
[{"type": "stdin_stdout", "input": "61\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same se...
[{"type": "stdin_stdout", "input": "9 3 23\n10 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1\n5\n0\n20\n32200\n5448\n10222\n0\n0\n"}, {"type": "stdin_stdout", "input": "9 3 23\n9 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes,...
[{"type": "stdin_stdout", "input": "1000000000 -1000\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "1000000000 -1000\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "1000000010 -1000\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "1010000000 -1000\n", "output": "15\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\nTakahashi will begin the travel at town 1, with no app...
[{"type": "stdin_stdout", "input": "10 100\n7 10 4 5 9 3 6 8 2 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 100\n7 10 4 5 9 3 6 8 1 1", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 100\n7 10 4 5 9 3 6 8 2 1", "output": "2"}, {"type": "stdin_stdout", "input": "5 8\n50 30 40 10 20\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaruna is a high school student. She must remember the seating arrangements in her class because she is a class president. It is too difficult task to remember if there are so many students.\n\nThat is the reason why seat...
[{"type": "stdin_stdout", "input": "1 2\n11 0\n0 0", "output": "yes\nyes\n"}, {"type": "stdin_stdout", "input": "2 1\n10 0\n0 0", "output": "yes\nyes\n"}, {"type": "stdin_stdout", "input": "1 4\n11 0\n0 0", "output": "yes\nyes\n"}, {"type": "stdin_stdout", "input": "2 -1\n8 0\n0 0", "output": "yes\nyes\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string, containing only characters \"(\", \")\", \"[\" and \"]\".\n\nA correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting chara...
[{"type": "stdin_stdout", "input": "[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[[(())]]][]()(([([])(([[[]]()])(()))]((())))([()]([()[[[]([][[[[][(())([[]()])]]][[(())]([])]()][[](())]()[])]()[][]]([[]])[]])[(()[()((()[][()]))][])[]()()([]())](()[][][])()()[]()))[]()[]\n", "output": "61\n[()][([[]])][[[]()]][()[]]...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNot long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Billy studied the co...
[{"type": "stdin_stdout", "input": "1000000\n", "output": "111111074060178115\n"}, {"type": "stdin_stdout", "input": "987572\n", "output": "107019643962508968\n"}, {"type": "stdin_stdout", "input": "983242\n", "output": "105618162572849728\n"}, {"type": "stdin_stdout", "input": "600000\n", "output": "23999973325791164\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share...
[{"type": "stdin_stdout", "input": "100\n411 642 560 340 276 440 515 519 182 314 35 227 390 136 97 5 502 584 567 79 543 444 413 463 455 316 545 329 437 443 9 435 291 384 328 501 603 234 285 297 453 587 550 72 130 163 282 298 605 349 270 198 24 179 243 92 115 56 83 26 3 456 622 325 366 360 299 153 140 552 216 117 61 307...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monster is attacking the Cyberland!\n\nMaster Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).\n\nDuring the bat...
[{"type": "stdin_stdout", "input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to...
[{"type": "stdin_stdout", "input": "500\n())()())((()(()((())())(())())()((()(()()))())())))()())())())()())))(()))))((((())(((()(())))()()(()))())(((((()()(((())()((()((())()))()())()))))()))()(((()(())((()()((()())()))((((())(())))()(()(())((((((()()()())))((()())(((((()()(((()))((()((()))())(((())((((()))))))))()()(...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array of integers $p_1, p_2, \\dots, p_n$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays are permutations: $[3, 1, 2]$, $[1]$, $[1, 2, 3, 4, 5]$ and $...
[{"type": "stdin_stdout", "input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"type": "stdin_stdout", "input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"type": "stdin_stdout", "input": "5\n3 -2 1 -3\n", "output": "2 5 3 4 1 "}, {"type": "stdin_stdout", "input": "5\n-4 1 2 -1\n", "output": "5 1 2 4 3 "}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUser ainta has a permutation p_1, p_2, ..., p_{n}. As the New Year is coming, he wants to make his permutation as pretty as possible.\n\nPermutation a_1, a_2, ..., a_{n} is prettier than permutation b_1, b_2, ..., b_{n}, ...
[{"type": "stdin_stdout", "input": "15\n6 1 2 7 9 13 14 8 4 5 3 12 10 15 11\n000100100100100\n000010010010010\n000001001001001\n100000100100100\n010000010010010\n001000001001001\n100100000100100\n010010000010010\n001001000001001\n100100100000100\n010010010000010\n001001001000001\n100100100100000\n010010010010000\n00100...
code_stdio