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\nNiwel is a little golden bear. As everyone knows, bears live in forests, but Niwel got tired of seeing all the trees so he decided to move to the city.\n\nIn the city, Niwel took on a job managing bears to deliver goods. ...
[{"type": "stdin_stdout", "input": "7 15 10\n1 3 776124\n6 7 769968\n2 1 797048\n4 3 53774\n2 7 305724\n4 1 963904\n4 6 877656\n4 5 971901\n1 4 803781\n3 1 457050\n3 7 915891\n1 7 8626\n5 7 961155\n3 4 891456\n5 4 756977\n", "output": "1552248.0000000000\n"}, {"type": "stdin_stdout", "input": "10 16 63\n1 2 1\n2 10 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWherever the destination is, whoever we meet, let's render this song together.\n\nOn a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and ...
[{"type": "stdin_stdout", "input": "20 50000 50000\n2 45955 55488\n1 19804 29337\n2 3767 90811\n2 24025 33558\n1 46985 56518\n2 21094 30627\n2 5787 15320\n1 4262 91306\n2 37231 46764\n1 18125 27658\n1 36532 12317\n1 31330 40863\n1 18992 28525\n1 29387 38920\n1 44654 54187\n2 45485 55018\n2 36850 46383\n1 44649 54182\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor the multiset of positive integers $s=\\{s_1,s_2,\\dots,s_k\\}$, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of $s$ as follow: $\\gcd(s)$ is the maximum positive integer $x$, such that all ...
[{"type": "stdin_stdout", "input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"type": "stdin_stdout", "input": "10\n540 648 810 648 720 540 594 864 972 648\n", "output": "54\n"}, {"type": "stdin_stdout", "input": "3\n166299 110866 86856\n", "output": "332598\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to...
[{"type": "stdin_stdout", "input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n11146 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": "928433852\n"}, {"type": "stdin_stdout", "input": "6 6\n1 2 0\n2 3 1\n3 4 0\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub mi...
[{"type": "stdin_stdout", "input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0\n", "output": "1446"}, {"type": "stdin_stdout", "input": "50\n1 1 0 1 1 1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one station at a time and travels around the netwo...
[{"type": "stdin_stdout", "input": "100 50\n29 35\n10 75\n29 34\n10 87\n29 13\n29 38\n41 21\n10 6\n29 94\n10 47\n31 27\n41 24\n41 8\n10 93\n41 52\n41 36\n31 32\n85 81\n31 32\n41 79\n41 99\n85 88\n41 25\n31 68\n41 93\n10 87\n85 97\n41 85\n10 64\n10 68\n85 22\n10 45\n85 15\n10 16\n10 21\n41 66\n29 68\n41 96\n29 34\n10 22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag...
[{"type": "stdin_stdout", "input": "47\n20\n21\n16\n18\n24\n20\n25\n13\n20\n22\n26\n24\n17\n18\n21\n22\n21\n23\n17\n15\n24\n19\n18\n21\n20\n19\n26\n25\n20\n17\n17\n17\n26\n32\n20\n21\n25\n28\n24\n21\n21\n17\n28\n20\n20\n31\n19\n", "output": "295545118\n"}, {"type": "stdin_stdout", "input": "25\n35\n43\n38\n33\n47\n44\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups t...
[{"type": "stdin_stdout", "input": "50\n36 36 45 44 -1 -1 13 -1 36 -1 44 36 -1 -1 -1 35 -1 36 36 35 -1 -1 -1 14 36 36 22 36 13 -1 35 -1 35 36 -1 -1 13 13 45 36 14 -1 36 -1 -1 -1 22 36 -1 13\n", "output": "949472419\n"}, {"type": "stdin_stdout", "input": "40\n3 3 -1 -1 4 4 -1 -1 -1 -1 -1 10 10 10 10 10 10 4 20 -1 -1 -1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNauuo is a girl who loves drawing circles.\n\nOne day she has drawn a circle and wanted to draw a tree on it.\n\nThe tree is a connected undirected graph consisting of $n$ nodes and $n-1$ edges. The nodes are numbered fro...
[{"type": "stdin_stdout", "input": "10\n5 4\n5 2\n3 7\n9 3\n3 2\n3 1\n3 8\n9 10\n1 6\n", "output": "19200"}, {"type": "stdin_stdout", "input": "9\n5 6\n1 3\n2 3\n7 6\n4 1\n3 6\n8 1\n1 9\n", "output": "7776"}, {"type": "stdin_stdout", "input": "8\n4 5\n1 2\n6 3\n2 3\n2 8\n4 7\n2 4\n", "output": "2304"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMitya has a rooted tree with $n$ vertices indexed from $1$ to $n$, where the root has index $1$. Each vertex $v$ initially had an integer number $a_v \\ge 0$ written on it. For every vertex $v$ Mitya has computed $s_v$: t...
[{"type": "stdin_stdout", "input": "25\n1 2 1 4 4 4 1 2 8 5 1 8 1 6 9 6 10 10 7 10 8 17 14 6\n846 -1 941 -1 1126 1803 988 -1 1352 1235 -1 -1 864 -1 -1 -1 -1 -1 -1 -1 -1 1508 1802 1713 -1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 1 2 3 4 5 1\n3 -1 -1 -1 -1 3 3 3 3 -1\n", "output": "3\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are...
[{"type": "stdin_stdout", "input": "200\nNESENEESEESWWWNWWSWSWNWNNWNNESWSWNNWNWNENESENNESSWSESWWSSSEEEESSENNNESSWWSSSSESWSWWNNEESSWWNNWSWSSWWNWNNEENNENWWNESSSENWNESWNESWNESEESSWNESSSSSESESSWNNENENESSWWNNWWSWWNESEENWWWWNWWNWWNENESESSWWSWWSES\nNWNESESSENNNESWNWWSWWWNWSESSSWWNWWNNWSENWSWNENNNWWSWWSWNNNESWWWSSESSWWWSSENWSE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).\...
[{"type": "stdin_stdout", "input": "16\n998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244362 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers $a_1, a_2, \\ldots, a_n$. Since the talk was long and not promising, Kostya created a new cyclic array $b_1, b...
[{"type": "stdin_stdout", "input": "100\n57 5 28 44 99 10 66 93 76 32 67 92 67 81 33 3 6 6 67 10 41 72 5 71 27 22 21 54 21 59 36 62 43 39 28 49 55 65 21 73 87 40 0 62 67 59 40 18 56 71 15 97 73 73 2 61 54 44 6 52 25 34 13 20 18 13 25 51 19 66 63 87 50 63 82 60 11 11 54 58 88 20 33 40 85 68 13 74 37 51 63 32 45 20 30 28...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvlampiy was gifted a rooted tree. The vertices of the tree are numbered from $1$ to $n$. Each of its vertices also has an integer $a_i$ written on it. For each vertex $i$, Evlampiy calculated $c_i$ — the number of vertic...
[{"type": "stdin_stdout", "input": "5\n0 1\n1 3\n2 1\n3 0\n2 0\n", "output": "YES\n2 5 3 1 4 \n"}, {"type": "stdin_stdout", "input": "3\n2 0\n0 2\n2 0\n", "output": "YES\n1 3 2 \n"}, {"type": "stdin_stdout", "input": "3\n0 0\n1 0\n1 0\n", "output": "YES\n1 2 3 \n"}, {"type": "stdin_stdout", "input": "3\n0 1\n3 0\n1 0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Polycarpus has learned the \"bitwise AND\" operation (which is also called \"AND\") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.\...
[{"type": "stdin_stdout", "input": "7\n-1 1000000000 999999488 999999488 1000000000 1000000000 999999488\n1000000000 -1 999999488 999999488 1000000000 1000000000 999999488\n999999488 999999488 -1 999999999 999999488 999999488 999999999\n999999488 999999488 999999999 -1 999999488 999999488 999999999\n1000000000 10000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so ...
[{"type": "stdin_stdout", "input": "52 38 22\n9 25 D\n28 29 C\n29 25 D\n4 28 D\n23 29 D\n24 25 D\n17 12 C\n11 19 C\n13 14 C\n12 15 D\n7 25 C\n2 25 C\n6 17 C\n2 20 C\n15 23 D\n8 21 C\n13 15 D\n29 15 C\n25 20 D\n22 20 C\n2 13 D\n13 22 D\n27 20 C\n1 21 D\n22 17 C\n14 21 D\n4 25 D\n5 23 C\n9 21 C\n2 20 C\n14 18 C\n29 24 C\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUjan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.\n\nThere are $k$ boxes numbered from $1$ to $k$. The $i$-th box contains $n_i$ integer numbers. The integers can be...
[{"type": "stdin_stdout", "input": "5\n10 -251 650 475 -114 364 -75754 -982 -532 -151 -484\n10 -623 -132 -317561 -438 20 -275 -323 -530089 -311 -587\n10 450900 -519 903 -401 -789 -606529 277 -267 -682 -161\n10 -246 873 -641 838 719 234 789 -74 -287288 -772972\n10 186 741 -927 -866 -855 578 -1057019 202 162962 -458\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following...
[{"type": "stdin_stdout", "input": "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv\n", "output": "2728075\n"}, {"type": "stdin_stdout", "input": "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns\n", "output": "943392\n"}, {"type": "stdin_stdout", "input": "kpjmawawawawawawawawawawawawawawawawa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHave you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.\n\nIn Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.\n\n...
[{"type": "stdin_stdout", "input": "100 61 71\n11 18 0 47 33 75 91 13 8 21 73 64 50 97 62 50 2 36 68 32 64 74 32 77 81 41 23 44 40 36 45 33 21 68 57 79 75 23 67 37 99 27 30 56 75 62 75 63 46 19 79 42 11 66 21 25 2 12 89 48 75 7 57 85 80 14 82 29 66 47 29 10 1 84 79 39 33 81 73 51 80 67 52 25 38 68 57 53 38 83 83 3 86 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZiota found a video game called \"Monster Invaders\".\n\nSimilar to every other shooting RPG game, \"Monster Invaders\" involves killing monsters and bosses with guns.\n\nFor the sake of simplicity, we only consider two d...
[{"type": "stdin_stdout", "input": "100 5 5 9 3\n3 4 2 3 4 3 8 5 2 1 1 4 1 1 10 10 7 5 2 9 4 2 10 10 8 2 4 9 6 2 6 7 7 5 7 7 1 8 10 9 9 3 10 3 10 1 1 8 3 6 4 5 5 4 9 5 9 4 8 2 10 8 9 1 5 9 7 2 1 7 9 3 2 9 1 5 4 2 3 10 6 7 8 2 10 1 6 2 1 6 10 9 1 2 2 7 2 8 4 4\n", "output": "1597"}, {"type": "stdin_stdout", "input": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given several queries. Each query consists of three integers $p$, $q$ and $b$. You need to answer whether the result of $p/q$ in notation with base $b$ is a finite fraction.\n\nA fraction in notation with base $b$...
[{"type": "stdin_stdout", "input": "11\n1 1000000000000000000 10000000\n2 999 9\n2 999 333111\n0 9 7\n17 128 2\n13 311992186885373952 18\n1971402979058461 750473176484995605 75\n14 19 23\n3 21914624432020321 23\n3 21914624432020321 46\n3 21914624432020321 47\n", "output": "Finite\nInfinite\nFinite\nFinite\nFinite\nFini...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of size $m$ with integer elements between $0$ and $2^{n}-1$ inclusive. Let's build an undirected graph on these integers in the following way: connect two integers $x$ and $y$ with an edge if and only ...
[{"type": "stdin_stdout", "input": "6 35\n5 7 10 11 13 14 17 18 25 27 28 29 30 31 33 35 36 37 39 40 41 43 46 47 50 52 55 56 57 58 59 60 61 62 63\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "6 30\n3 8 13 16 18 19 21 22 24 25 26 28 29 31 33 42 44 46 49 50 51 53 54 57 58 59 60 61 62 63\n", "output": "10\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the ...
[{"type": "stdin_stdout", "input": "50\n01110100101100100100011001100001110010010000000101\n50\n27 18 7\n22 35 2\n50 35 1\n41 16 1\n27 5 5\n11 6 33\n7 19 2\n9 12 33\n14 37 4\n1 22 8\n22 3 5\n50 42 1\n50 38 1\n29 20 2\n20 34 17\n20 4 29\n16 21 3\n11 43 3\n15 45 1\n12 28 3\n31 34 13\n43 1 8\n3 41 1\n18 3 13\n29 44 6\n47 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of $n$ integers and an integer $s$. It is guaranteed that $n$ is odd.\n\nIn one operation you can either increase or decrease any single element by one. Calculate the minimum number of operation...
[{"type": "stdin_stdout", "input": "7 20\n21 15 12 11 20 19 12\n", "output": "6"}, {"type": "stdin_stdout", "input": "1 1\n100000\n", "output": "99999"}, {"type": "stdin_stdout", "input": "5 1\n2 2 4 6 1\n", "output": "2"}, {"type": "stdin_stdout", "input": "3 10\n5 5 10\n", "output": "5"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn order to fly to the Moon Mister B just needs to solve the following problem.\n\nThere is a complete indirected graph with n vertices. You need to cover it with several simple cycles of length 3 and 4 so that each edge ...
[{"type": "stdin_stdout", "input": "11\n", "output": "30\n4 2 3 1 4\n4 1 4 11 5\n4 3 4 2 5\n4 2 5 1 6\n4 4 5 3 6\n4 3 6 2 7\n4 5 6 4 7\n4 4 7 3 8\n4 6 7 5 8\n4 5 8 4 9\n4 7 8 6 9\n4 6 9 5 10\n4 8 9 7 10\n4 7 10 6 11\n4 9 10 8 11\n4 8 11 7 1\n4 10 11 9 1\n4 9 1 8 2\n4 11 1 10 2\n4 10 2 9 3\n3 2 7 8\n3 1 7 6\n3 3 8 9\n3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. ...
[{"type": "stdin_stdout", "input": "7 10\n100\n200\n300\n400\n500\n600\n700\n800\n900\n1000\n", "output": "9\n10\n11\n12\n13\n14\n14\n15\n16\n17\n"}, {"type": "stdin_stdout", "input": "8 10\n50\n150\n250\n350\n450\n550\n650\n750\n850\n950\n", "output": "10\n12\n13\n14\n15\n16\n17\n18\n19\n19\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSummer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned...
[{"type": "stdin_stdout", "input": "4 5\n87882 40786 3691 85313 46694\n28884 16067 3242 97367 78518\n4250 35501 9780 14435 19004\n64673 65438 56977 64495 27280\n", "output": "747898"}, {"type": "stdin_stdout", "input": "3 3\n100000 100000 100000\n1 100000 100000\n1 1 100000\n", "output": "500003"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles ca...
[{"type": "stdin_stdout", "input": "25\n0 0 7 7\n0 18 7 29\n7 36 12 41\n7 18 12 29\n15 29 26 36\n7 7 12 18\n12 36 15 41\n15 7 26 18\n12 0 15 7\n12 7 15 18\n7 29 12 36\n12 29 15 36\n15 18 26 29\n26 18 27 29\n12 18 15 29\n26 29 27 36\n0 7 7 18\n26 0 27 7\n7 0 12 7\n15 36 26 41\n26 7 27 18\n26 36 27 41\n15 0 26 7\n0 36 7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set Y of n distinct positive integers y_1, y_2, ..., y_{n}.\n\nSet X of n distinct positive integers x_1, x_2, ..., x_{n} is said to generate set Y if one can transform X to Y by applying some number of th...
[{"type": "stdin_stdout", "input": "100\n713 716 230 416 3 2 597 216 779 839 13 156 723 793 168 368 232 316 98 257 170 27 746 9 616 147 792 890 796 362 852 117 993 556 885 73 131 475 121 753 508 158 473 931 527 282 541 325 606 321 159 17 682 290 586 685 529 11 645 224 821 53 152 966 269 754 672 523 386 347 719 525 92 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a sequence [a_1, a_2, ... , a_{n}]. Define its prefix product sequence $[ a_{1} \\operatorname{mod} n,(a_{1} a_{2}) \\operatorname{mod} n, \\cdots,(a_{1} a_{2} \\cdots a_{n}) \\operatorname{mod} n ]$.\n\nNow give...
[{"type": "stdin_stdout", "input": "7\n", "output": "YES\n1\n2\n5\n6\n3\n4\n7\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "YES\n1\n2\n4\n3\n5\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "YES\n1\n3\n2\n4"}, {"type": "stdin_stdout", "input": "3\n", "output": "YES\n1\n2\n3\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is ...
[{"type": "stdin_stdout", "input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 "}, {"type": "stdin_stdout", "input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 "}, {"type": "stdin_stdout", "input": "3 1\n1 10 100\n", "output": "Yes\n3 "}, {"type": "stdin_stdout", "input": "2 1\n1 3\n", "output": "Yes\n2 "}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJust to remind, girls in Arpa's land are really nice.\n\nMehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight w_{i} and some beauty b_{i}. Also each Hos may have some friends. Hos...
[{"type": "stdin_stdout", "input": "10 5 100\n48 73 30 46 95 19 98 73 94 24\n501216 675859 843572 565104 879875 828759 80776 766980 213551 492652\n1 2\n6 5\n7 6\n10 3\n8 1\n", "output": "2237435\n"}, {"type": "stdin_stdout", "input": "10 5 100\n68 55 15 94 53 100 52 68 24 3\n286803 660813 226501 624597 215418 290774 41...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a tree $T$ (that is, a connected graph without cycles) with $n$ vertices labelled $1$ through $n$. We start the following process with $T$: while $T$ has more than one vertex, do the following:\n\n\n\n choose a r...
[{"type": "stdin_stdout", "input": "30\n15 21\n21 3\n22 4\n5 18\n26 25\n12 24\n11 2\n27 13\n11 14\n7 29\n10 26\n16 17\n16 27\n16 1\n3 22\n5 19\n2 23\n4 10\n8 4\n1 20\n30 22\n9 3\n28 15\n23 4\n4 1\n2 7\n5 27\n6 26\n6 24\n", "output": "0.0047521072\n0.0089582002\n0.0091024503\n0.0005692947\n0.0158713738\n0.0231639046\n0....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKoa the Koala has a binary string $s$ of length $n$. Koa can perform no more than $n-1$ (possibly zero) operations of the following form:\n\nIn one operation Koa selects positions $i$ and $i+1$ for some $i$ with $1 \\le i...
[{"type": "stdin_stdout", "input": "0100111100100101001101111001011101011001111100110111101110001001010111100010011100011011101111010111111010010101000001110110111110010001100010101110111111000011101110000000001101010011000111111100000000000000001010011111010111\n", "output": "975171002\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the ...
[{"type": "stdin_stdout", "input": "36 81\n4 5 7 8 13 14 16 17 22 23 25 26 31 32 34 35 40 41 43 44 49 50 52 53 58 59 61 62 67 68 70 71 76 77 79 80\n", "output": "9\n3 12 21 30 39 48 57 66 75\n"}, {"type": "stdin_stdout", "input": "14 34\n1 2 4 7 10 12 13 18 19 21 24 27 29 30\n", "output": "2\n14 31\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells ...
[{"type": "stdin_stdout", "input": "100 10 30\n40 4\n15 3\n75 3\n88 10\n32 1\n16 5\n81 8\n45 2\n72 8\n11 6\n86 4\n50 2\n9 4\n11 1\n20 3\n47 3\n2 4\n68 3\n90 5\n85 2\n88 1\n88 5\n86 3\n70 9\n49 3\n34 4\n5 7\n77 5\n50 1\n87 5\n", "output": "402737011\n"}, {"type": "stdin_stdout", "input": "100000 100000 4\n50001 50001\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.\n\nIn this game there are n objects number...
[{"type": "stdin_stdout", "input": "23\n1 20\n3 9 2 12\n", "output": "Lose Lose Win Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose Lose\nWin Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win Win\n"}, {"type": "stdin_stdout", "input": "20\n1 1\n1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA function $f : R \\rightarrow R$ is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all $x, y \\in R$. We'll deal with a more... discrete version of ...
[{"type": "stdin_stdout", "input": "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n119405200\n49016134\n21372932\n49016134\n119405200\n"}, {"type": "stdin_stdout", "input": "3 6\n100000000 99999999 0\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "1\n199999999\n99999999\n1\n99999999...
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"}, {"type": "stdin_stdout", "input": "6 7 2\n1 2 3 4 5 6\n", "output": "3"}, {"type": "stdin_stdout", "input": "5 5 3\n3 0 4 1 2\n", "output": "1"}, {"type": "stdin_stdout", "input": "3 3 0\n0 1 2\n", "output": "1"}, {"type": "stdin_stdout", "inp...
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\nLet's assume that v(n) is the largest prime number, that does not exceed n;\n\n u(n) is the smallest prime number strictly greater than n. \n\nFind $\\sum_{i = 2}^{n} \\frac{1}{v(i) u(i)}$.\n\n\n-----Input-----\n\nThe f...
[{"type": "stdin_stdout", "input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"type": "stdin_stdout", "input": "5\n79\n149\n136\n194\n124\n", "output": "6393/13114\n22199/44998\n135/274\n37631/76042\n14121/28702\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAppleman has a very big sheet of paper. This sheet has a form of rectangle with dimensions 1 × n. Your task is help Appleman with folding of such a sheet. Actually, you need to perform q queries. Each query will have one ...
[{"type": "stdin_stdout", "input": "10 10\n2 5 9\n2 2 9\n2 1 7\n2 3 9\n2 3 4\n2 0 6\n2 3 9\n2 2 8\n2 5 9\n1 9\n", "output": "4\n7\n6\n6\n1\n6\n6\n6\n4\n"}, {"type": "stdin_stdout", "input": "10 9\n2 2 9\n1 1\n2 0 1\n1 8\n2 0 8\n1 2\n2 1 3\n1 4\n2 2 4\n", "output": "7\n2\n10\n4\n5\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has a sequence, consisting of n non-negative integers: a_1, a_2, ..., a_{n}.\n\nLet's define function f(l, r) (l, r are integer, 1 ≤ l ≤ r ≤ n) for sequence a as an operation of bitwise OR of all the sequence e...
[{"type": "stdin_stdout", "input": "10\n375813 659427 484038 348181 432640 368050 271089 721588 345312 630771\n", "output": "29"}, {"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 1 2 9 10\n", "output": "11"}, {"type": "stdin_stdout", "input": "10\n6 8 4 5 1 9 10 2 3 7\n", "output": "15"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) a...
[{"type": "stdin_stdout", "input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944938\nACCEPT 40032655\nADD 79373162\nACCEPT 79373162\nADD 55424250\nACCEPT 55424250\nADD 67468892\nACCEPT 67468892\nADD 51815959\nADD 13976252\nADD 2040654\nADD 74300637\nACCEPT 51815959\n", "output": "32\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them.\n\nVasily decide...
[{"type": "stdin_stdout", "input": "100\n9 9 72 55 14 8 55 58 35 67 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 34 48 96 79 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12 4 32 69 89 85 66 13 92 54 38 5 26 56 17 55 29 4 17 39 29 94 3 67 85 98 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves permutations of integers from 1 to n very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a pe...
[{"type": "stdin_stdout", "input": "125 8\n111 69 3 82 24 38 4 39 42 22 92 6 16 10 8 45 17 91 84 53 5 46 124 47 18 57 43 73 114 102 121 105 118 95 104 98 72 20 56 60 123 80 103 70 65 107 67 112 101 108 99 49 12 94 2 68 119 109 59 40 86 116 88 63 110 14 13 120 41 64 89 71 15 35 81 51 113 90 55 122 1 75 54 33 28 7 125 9 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.\n\nOleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery ...
[{"type": "stdin_stdout", "input": "5 3 8\n12\n8 3 4 5 7 6 8 3 5 4 7 6\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "5 3 7\n8\n4 7 5 5 3 6 2 8\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "6 5 7\n5\n1 5 7 92 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 3 10\n5\n3 3 3 3 3\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediat...
[{"type": "stdin_stdout", "input": "97 60 1 1\n5 6 6 7 9 10 10 11 11 11 12 13 13 13 13 14 14 15 16 18 20 23 23 24 25 26 29 31 32 35 38 41 43 43 46 47 48 48 49 52 53 54 55 56 58 59 68 70 72 74 78 81 81 82 91 92 96 96 97 98\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "100 30 36 47\n44 155 275 390 464 532 118...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last n minutes and in the ...
[{"type": "stdin_stdout", "input": "100\n9997 9615 4045 2846 7656 2941 2233 9214 837 2369 5832 578 6146 8773 164 7303 3260 8684 2511 6608 9061 9224 7263 7279 1361 1823 8075 5946 2236 6529 6783 7494 510 1217 1135 8745 6517 182 8180 2675 6827 6091 2730 897 1254 471 1990 1806 1706 2571 8355 5542 5536 1527 886 2093 1532 48...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.\n\nTo settle this ...
[{"type": "stdin_stdout", "input": "tinkoff\nzscoder\n", "output": "fzfsirk\n"}, {"type": "stdin_stdout", "input": "xxxxxx\nxxxxxx\n", "output": "xxxxxx\n"}, {"type": "stdin_stdout", "input": "reddit\nabcdef\n", "output": "dfdeed\n"}, {"type": "stdin_stdout", "input": "bcdef\nabbbc\n", "output": "bccdb\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe start with a string $s$ consisting only of the digits $1$, $2$, or $3$. The length of $s$ is denoted by $|s|$. For each $i$ from $1$ to $|s|$, the $i$-th character of $s$ is denoted by $s_i$. \n\nThere is one cursor. T...
[{"type": "stdin_stdout", "input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "output": "1504\n1599\n1502\n1598\n1502\n1510\n1657\n1502\n1763\n"}, {"type": "stdin_stdout", "input": "4\n5\n231\n7\n2323\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an easier version of the next problem. In this version, $q = 0$.\n\nA sequence of integers is called nice if its elements are arranged in blocks like in $[3, 3, 3, 4, 1, 1]$. Formally, if two elements are equal, e...
[{"type": "stdin_stdout", "input": "100 0\n6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62 77 91 86 14 25 48 77 83 65 39 61 78 77 45 46 90 74 100 91 86 98 55 5 84 42 91 69 100 4 74 98 60 37 75 44 41 12 15 34 36 1 99 16 7 87 36 26 79 42 41 84 17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova and Marina love offering puzzles to each other. Today Marina offered Vova to cope with the following task.\n\nVova has a non-directed graph consisting of n vertices and m edges without loops and multiple edges. Let's...
[{"type": "stdin_stdout", "input": "14 30\n12 10\n1 7\n12 13\n7 3\n14 10\n3 12\n11 1\n2 12\n2 5\n14 3\n14 1\n14 4\n6 7\n12 6\n9 5\n7 10\n8 5\n6 14\n13 7\n4 12\n9 10\n1 9\n14 5\n1 8\n2 13\n5 11\n8 6\n4 9\n9 13\n2 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "59 24\n40 3\n14 10\n17 5\n40 15\n22 40\n9 40\n46...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to an apple store. \n\nJzzhu will pack his apples into groups and then sell them. Each group must conta...
[{"type": "stdin_stdout", "input": "100\n", "output": "44\n33 27\n22 11\n25 5\n64 66\n42 44\n31 62\n58 29\n43 86\n15 21\n6 99\n8 12\n85 65\n7 49\n23 46\n16 14\n20 18\n90 92\n48 50\n40 36\n74 37\n35 55\n10 95\n56 60\n47 94\n45 39\n93 87\n88 84\n72 76\n28 24\n75 81\n78 80\n54 52\n38 19\n3 9\n32 30\n91 77\n70 68\n63 69\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type: + a_{i} — add no...
[{"type": "stdin_stdout", "input": "10\n+ 870566619432760298\n+ 869797178280285214\n+ 609920823721618090\n+ 221159591436767023\n+ 730599542279836538\n? 101001100111001011\n? 001111010101010011\n? 100010100011101110\n? 100110010110001100\n? 110000011101110011\n", "output": "0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence a consisting of n integers. Find the maximum possible value of $a_{i} \\operatorname{mod} a_{j}$ (integer remainder of a_{i} divided by a_{j}), where 1 ≤ i, j ≤ n and a_{i} ≥ a_{j}.\n\n\n-----Inpu...
[{"type": "stdin_stdout", "input": "12\n4 4 10 13 28 30 41 43 58 61 70 88\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "7\n2 13 22 32 72 91 96\n", "output": "27\n"}, {"type": "stdin_stdout", "input": "5\n5 11 12 109 110\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "2\n1000000 999999\n", "output"...
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\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": "7\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 1\n2 1\n3 1\n4 1\n5 1\n6 6\n7 7\n", "output": "4\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJohn Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was fo...
[{"type": "stdin_stdout", "input": "18\n68 32 84 6\n44 53 11 21\n61 34 77 82\n19 36 47 58\n47 73 31 96\n17 50 82 16\n57 90 64 8\n14 37 45 69\n48 1 18 58\n42 34 96 14\n56 82 33 77\n40 66 30 53\n33 31 44 95\n0 90 24 8\n7 85 39 1\n76 77 93 35\n98 9 62 13\n24 84 60 51\n", "output": "8\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBarney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the...
[{"type": "stdin_stdout", "input": "85\n1 1 2 2 4 6 1 3 6 3 3 11 9 14 12 5 8 11 16 19 12 17 2 19 1 24 6 2 6 6 24 3 20 1 1 1 17 8 4 25 31 32 39 12 35 23 31 26 46 9 37 7 5 23 41 41 39 9 11 54 36 54 28 15 25 58 56 18 23 70 68 18 3 48 57 70 15 65 22 35 25 13 49 34\n", "output": "1.0 28.5 27.0 38.0 38.5 39.5 44.5 40.0 40.5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the m...
[{"type": "stdin_stdout", "input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 7 8 9 10\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "7\n10 1 1 1 5 5 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "7\n3 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length n with each character being one of the first m lowercase English letters. \n\nCalculate how many different strings T of length n composed from the first m lowercase English letters exist...
[{"type": "stdin_stdout", "input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"type": "stdin_stdout", "input": "15 3\nabababababababa\n", "output": "345\n"}, {"type": "stdin_stdout", "input": "10 9\nabacadefgh\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are some ambiguities when one writes Berland names with the letters of the Latin alphabet.\n\nFor example, the Berland sound u can be written in the Latin alphabet as \"u\", and can be written as \"oo\". For this re...
[{"type": "stdin_stdout", "input": "100\nuh\nu\nou\nhk\nokh\nuou\nk\no\nuhh\nk\noku\nk\nou\nhuh\nkoo\nuo\nkk\nkok\nhhu\nuu\noou\nk\nk\noh\nhk\nk\nu\no\nuo\no\no\no\nhoh\nkuo\nhuh\nkhu\nuu\nk\noku\nk\nh\nuu\nuo\nhuo\noo\nhu\nukk\nok\no\noh\nuo\nkko\nok\nouh\nkoh\nhhu\nku\nko\nhho\nkho\nkho\nkhk\nho\nhk\nuko\nukh\nh\nkh\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWriting light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the q...
[{"type": "stdin_stdout", "input": "20 7\n9 7\n3 7\n15 9\n1 3\n11 9\n18 7\n17 18\n20 1\n4 11\n2 11\n12 18\n8 18\n13 2\n19 2\n10 9\n6 13\n5 8\n14 1\n16 13\n", "output": "38"}, {"type": "stdin_stdout", "input": "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5\n", "output": "9"}, {"type": "stdin_stdout", "input": "7 4\n1 2\n1 3\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of n integers a_1, a_2, ..., a_{n}. \n\nDetermine a real number x such that the weakness of the sequence a_1 - x, a_2 - x, ..., a_{n} - x is as small as possible.\n\nThe weakness of a sequence is ...
[{"type": "stdin_stdout", "input": "20\n-16 -23 29 44 -40 -50 -41 34 -38 30 -12 28 -44 -49 15 50 -28 38 -2 0\n", "output": "113.875000000000000\n"}, {"type": "stdin_stdout", "input": "10\n-405 -230 252 -393 -390 -259 97 163 81 -129\n", "output": "702.333333333333370\n"}, {"type": "stdin_stdout", "input": "3\n10000 -100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array of integers $p_{1},p_{2}, \\ldots,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 $[4,3,...
[{"type": "stdin_stdout", "input": "100\n0 0 57 121 57 0 19 251 19 301 19 160 57 578 664 57 19 50 0 621 91 5 263 34 5 96 713 649 22 22 22 5 108 198 1412 1147 84 1326 1777 0 1780 132 2000 479 1314 525 68 690 1689 1431 1288 54 1514 1593 1037 1655 807 465 1674 1747 1982 423 837 139 1249 1997 1635 1309 661 334 3307 2691 21...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as p_{i}. For all pairs of distinct integers i, j between 1 and n, he wrote the number a_{i}, j = min(p_{i...
[{"type": "stdin_stdout", "input": "13\n0 5 5 2 5 4 5 5 3 5 5 5 1\n5 0 6 2 6 4 6 6 3 6 6 6 1\n5 6 0 2 10 4 7 10 3 8 10 9 1\n2 2 2 0 2 2 2 2 2 2 2 2 1\n5 6 10 2 0 4 7 12 3 8 11 9 1\n4 4 4 2 4 0 4 4 3 4 4 4 1\n5 6 7 2 7 4 0 7 3 7 7 7 1\n5 6 10 2 12 4 7 0 3 8 11 9 1\n3 3 3 2 3 3 3 3 0 3 3 3 1\n5 6 8 2 8 4 7 8 3 0 8 8 1\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants h...
[{"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\nPolycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands \"ping a\" and \"ping b\". Each ping command s...
[{"type": "stdin_stdout", "input": "14\n1 7 3\n1 0 10\n1 7 3\n1 1 9\n2 2 8\n2 0 10\n1 1 9\n2 8 2\n2 6 4\n1 3 7\n1 3 7\n2 6 4\n2 1 9\n2 7 3\n", "output": "DEAD\nDEAD\n"}, {"type": "stdin_stdout", "input": "13\n1 8 2\n1 4 6\n1 5 5\n1 5 5\n2 10 0\n2 9 1\n1 3 7\n2 6 4\n2 6 4\n2 5 5\n1 7 3\n2 3 7\n2 9 1\n", "output": "LIVE\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo!\n\nThere are $n$ sn...
[{"type": "stdin_stdout", "input": "10 15\n1 2\n2 3\n3 4\n4 5\n5 1\n1 6\n2 7\n3 8\n4 9\n5 10\n6 8\n7 9\n8 10\n9 6\n10 7\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "100000 12\n8 7\n1 9\n5 4\n11 12\n7 8\n3 4\n3 5\n12 15\n15 13\n13 14\n7 8\n11 14\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "6 5\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence a = \\{a_1, ..., a_N\\} with all zeros, and a sequence b = \\{b_1, ..., b_N\\} consisting of 0 and 1. The length of both is N.\nYou can perform Q kinds of operations. The i-th operation is as foll...
[{"type": "stdin_stdout", "input": "15\n1 1 0 0 0 0 0 0 1 0 1 1 1 0 0\n9\n4 10\n13 14\n1 7\n4 14\n9 11\n2 6\n7 8\n3 12\n7 13\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n0 0 0 1 0 0 1 1 1 0\n7\n1 4\n2 5\n1 3\n6 7\n9 9\n1 5\n7 9\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "9\n0 1 0 1 1 1 0 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions o...
[{"type": "stdin_stdout", "input": "12 12\n9\n11\n5\n3\n7\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n6\n3\n2\n4\n7\n12\n8\n10\n9\n11\n1\n"}, {"type": "stdin_stdout", "input": "13 4\n10\n5\n4\n8\n", "output": "13\n3\n8\n9\n"}, {"type": "stdin_stdout", "input": "4 3\n2\n3\n4\n", "output": "3\n2\n4\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined...
[{"type": "stdin_stdout", "input": "10\n669924290 408119795 804030560\n663737793 250734602 29671646\n431160679 146708815 289491233\n189259304 606497663 379372476\n707829111 49504411 81710658\n54555019 65618101 626948607\n578351356 288589794 974275296\n400531973 205638174 323247740\n219131617 178762989 799964854\n825160...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe country has n cities and n - 1 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to n inclusive.\n\nAll the road...
[{"type": "stdin_stdout", "input": "31\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\n", "output": "73741817 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city u_{i} to v_{i} (and vise versa) u...
[{"type": "stdin_stdout", "input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 3 999999999\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "5 5 3\n1 2 999999999\n2 3 1000000000\n3 4 529529529\n5 1 524524524\n5 3 1000000000\n5 524444444\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q_1q_2... q_{k}. The algorithm consists of ...
[{"type": "stdin_stdout", "input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\n10\n17 67\n6 35\n12 45\n56 56\n14 30\n25 54\n1 1\n46 54\n3 33\n19 40\n", "output": "NO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "zxyzxyzyyzxzzxyzxyzx\n15\n7 10\n17 17\n6 7\n8 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a ...
[{"type": "stdin_stdout", "input": "10\n7 9 4 4 7 6 3 7 9 8\n10\n1 3 2\n1 10 5\n1 5 3\n1 5 2\n1 2 9\n1 2 9\n1 2 10\n1 5 7\n1 6 10\n1 10 9\n", "output": "7 10 2 4 7 10 3 7 9 9 \n"}, {"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 7 8 9 10\n10\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n", "output": "10 10 10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these bel...
[{"type": "stdin_stdout", "input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "2 10\nuh\n+ 1 h\n+ 2 u\n+ 3 h\n- 1\n- 2\n+ 2 h\n+ 3 u\n- 2\n+ 1 u\n- 3\n", "output": "YES\nYE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSerge came to the school dining room and discovered that there is a big queue here. There are $m$ pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he wi...
[{"type": "stdin_stdout", "input": "5 1\n8 4 8 7 3\n9\n5\n2 1 3\n1 5 1\n2 1 8\n2 1 7\n2 1 3\n", "output": "8\n8\n8\n8\n8\n"}, {"type": "stdin_stdout", "input": "3 5\n3 2 8\n1 2 8 1 1\n4\n1 3 3\n1 2 2\n2 2 10\n1 1 5\n", "output": "3\n3\n2\n2\n"}, {"type": "stdin_stdout", "input": "4 6\n1 8 2 4\n3 3 6 1 5 2\n3\n1 1 1\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.\n\nSereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each tim...
[{"type": "stdin_stdout", "input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520\n1 84185\n2 6 1\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "output": "53989 47249 71935 53989 53989 53989 84520 84185 53989 47249 71935 53989 53989 53989\n"}, {"type": "stdin_stdout", "input": "10\n1 57757\n1 45234\n1 80807\n1 38496\n1 2746...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe mobile application store has a new game called \"Subway Roller\".\n\nThe protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field cons...
[{"type": "stdin_stdout", "input": "1\n100 26\ns................PPPP.CCCCC..UUUUUU.........YYYQQQQQQQ...GGGGG............MMM.....JJJJ..............\n.OOOOOO....EEE....................................................SSSSSS........LLLLLL......NNNIIII.\n......FFFFFF...VVVV..ZZZBBB...KKKKK..WWWWWWWXXX..RRRRRRR......AAAAADD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got a list of program warning logs. Each record of a log stream is a string in this format: \"2012-MM-DD HH:MM:SS:MESSAGE\" (without the quotes). \n\nString \"MESSAGE\" consists of spaces, uppercase and lowercase ...
[{"type": "stdin_stdout", "input": "60 3\n2012-03-16 16:15:25: Disk size is\n2012-03-16 16:15:25: Network failute\n2012-03-16 16:16:29: Cant write varlog\n2012-03-16 16:16:42: Unable to start process\n2012-03-16 16:16:43: Disk size is too small\n2012-03-16 16:16:53: Timeout detected\n", "output": "2012-03-16 16:16:43\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:\n\nGiven two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (on...
[{"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"type": "stdin_stdout", "input": "10\n0110101101\n1010000101\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "6\n011000\n010011\n", "output": "6\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor strings s and t, we will say that s and t are prefix-free when neither is a prefix of the other.\nLet L be a positive integer. A set of strings S is a good string set when the following conditions hold true:\n - Each ...
[{"type": "stdin_stdout", "input": "3 3\n0\n10\n110\n", "output": "Alice\n"}, {"type": "stdin_stdout", "input": "2 2\n00\n01\n", "output": "Alice\n"}, {"type": "stdin_stdout", "input": "2 3\n101\n11\n", "output": "Bob\n"}, {"type": "stdin_stdout", "input": "2 2\n00\n11\n", "output": "Bob\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZookeeper is buying a carton of fruit to feed his pet wabbit. The fruits are a sequence of apples and oranges, which is represented by a binary string $s_1s_2\\ldots s_n$ of length $n$. $1$ represents an apple and $0$ rep...
[{"type": "stdin_stdout", "input": "100\n0110110011011111001110000110010010000111111001100001011101101000001011001101100111011111100111101110\n", "output": "23254\n"}, {"type": "stdin_stdout", "input": "12\n011100011100\n", "output": "156\n"}, {"type": "stdin_stdout", "input": "7\n1101001\n", "output": "30\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"...
[{"type": "stdin_stdout", "input": "40 30\n((((((((()()()))))))))((())((()())))(())\n", "output": "((((((((()()()))))))))(())()()\n"}, {"type": "stdin_stdout", "input": "20 10\n((()))()((()()(())))\n", "output": "((()))()()\n"}, {"type": "stdin_stdout", "input": "8 8\n(()(()))\n", "output": "(()(()))\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.\n\nWe want to plan a trip for every evening of $m$ days. On each trip, you have to sele...
[{"type": "stdin_stdout", "input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n7\n7\n7\n7\n7\n11\n11\n11\n11\n15\n15\n15\n15\n16\n"}, {"type": "stdin_stdout", "input": "5 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.\n\nSerge...
[{"type": "stdin_stdout", "input": "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaaaaaaaaaaaaa\n61 52 5 43 53 81 7 96 6 9 34 78 79 12 8 63 22 76 18 46 41 56 3 20 57 21 75 73 100 94 35 69 32 4 70 95 88 44 68 10 71 98 23 89 36 62 28 51 24 30 74 55 27 80 38 48 93 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers p_{i}, a_{i} and b_{i}, where p_{i} is the price of the i-th t-shirt, a_{i} is front color of the i-th t-shirt and b_{i} is ...
[{"type": "stdin_stdout", "input": "20\n414468312 20329584 106106409 584924603 666547477 670032002 726095027 276840253 368277336 940941705 531635095 213813062 440421387 959075599 240727854 495316522 838268432 786936631 586382273 806443734\n3 1 2 3 3 2 2 1 3 2 3 2 3 3 3 2 1 3 1 2\n3 1 2 2 2 2 3 1 2 3 2 1 1 2 3 1 2 3 3 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $r \\times c$ grid. Each cell on the grid represents a country. Each country has a ...
[{"type": "stdin_stdout", "input": "4\n7 8\nAAPAAAAA\nPPPPAAAA\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP\n", "output": "2\n1\nMORTAL\n4\n"}, {"type": "stdin_stdout", "input": "1\n4 4\nAAAA\nAAAA\nAAAA\nAAAA\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '$\\sqrt{}$' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels ...
[{"type": "stdin_stdout", "input": "7\n", "output": "2\n17\n46\n97\n176\n289\n442\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "2\n17\n46\n97\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "2\n17\n46\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "2\n17\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Bubble Cup hypothesis stood unsolved for $130$ years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesi...
[{"type": "stdin_stdout", "input": "8\n1 1 7 6 1 5 8 7\n", "output": "1\n1\n6\n6\n1\n4\n9\n6\n"}, {"type": "stdin_stdout", "input": "7\n9 6 3 1 3 1 7\n", "output": "9\n6\n2\n1\n2\n1\n6\n"}, {"type": "stdin_stdout", "input": "6\n8 7 8 6 8 9\n", "output": "9\n6\n9\n6\n9\n9\n"}, {"type": "stdin_stdout", "input": "5\n4 1 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMeanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not ...
[{"type": "stdin_stdout", "input": "30\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n4 8\n4 9\n6 10\n6 11\n11 30\n11 23\n30 24\n30 25\n25 26\n25 27\n27 29\n27 28\n23 20\n23 22\n20 21\n20 19\n3 12\n3 13\n13 14\n13 15\n15 16\n15 17\n15 18\n2\n6 17 25 20 5 9 13\n10 2 4 3 14 16 18 22 29 30 19\n", "output": "3\n6\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and ther...
[{"type": "stdin_stdout", "input": "10\n2 3\n3 9\n6 3\n9 8\n9 10\n4 8\n3 1\n3 5\n7 1\n", "output": "67\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n1 3\n1 4\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n2 3\n3 4\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3\n2 1\n3 2\n", "output": "3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote as $\\text{popcount}(x)$ the number of bits set ('1' bits) in the binary representation of the non-negative integer x.\n\nYou are given multiple queries consisting of pairs of integers l and r. For each query...
[{"type": "stdin_stdout", "input": "18\n1 10\n1 100\n1 1000\n1 10000\n1 100000\n1 1000000\n1 10000000\n1 100000000\n1 1000000000\n1 10000000000\n1 100000000000\n1 1000000000000\n1 10000000000000\n1 100000000000000\n1 1000000000000000\n1 10000000000000000\n1 100000000000000000\n1 1000000000000000000\n", "output": "7\n63...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed a...
[{"type": "stdin_stdout", "input": "8 20\n2 4 a\n1 8 a\n1 2 v\n8 4 h\n1 7 w\n5 4 h\n2 8 h\n7 4 i\n4 3 w\n6 8 l\n1 4 v\n1 3 g\n5 3 b\n1 6 a\n7 3 w\n6 4 f\n6 7 g\n7 8 n\n5 8 g\n2 6 j\n", "output": "BAAAAAAA\nBBAAAABA\nBBBBBBBB\nBAABAABA\nBAAABABA\nBAAAABAA\nBAAAAABA\nBAAABABB\n"}, {"type": "stdin_stdout", "input": "5 8\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are 2N balls in the xy-plane. The coordinates of the i-th of them is (x_i, y_i).\nHere, x_i and y_i are integers between 1 and N (inclusive) for all i, and no two balls occupy the same coordinates.\nIn order to coll...
[{"type": "stdin_stdout", "input": "8\n6 2\n5 1\n6 8\n7 8\n6 5\n5 7\n4 3\n1 4\n7 6\n8 3\n2 8\n3 6\n3 2\n8 5\n1 5\n5 8\n", "output": "82060779\n"}, {"type": "stdin_stdout", "input": "4\n3 2\n1 2\n4 1\n4 2\n2 2\n4 4\n2 1\n1 3\n", "output": "7392\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n2 2\n3 3\n4 4\n1 2\n2 1\n3 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N robots and M exits on a number line.\nThe N + M coordinates of these are all integers and all distinct.\nFor each i (1 \\leq i \\leq N), the coordinate of the i-th robot from the left is x_i.\nAlso, for each j...
[{"type": "stdin_stdout", "input": "10 10\n4 13 15 18 19 20 21 22 25 27\n1 5 11 12 14 16 23 26 29 30\n", "output": "22\n"}, {"type": "stdin_stdout", "input": "4 5\n2 5 7 11\n1 3 6 9 13\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3 4\n2 5 10\n1 3 7 13\n", "output": "8\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer found N rectangle lying on the table, each with height 1.\nIf we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the hori...
[{"type": "stdin_stdout", "input": "5\n999999999 1000000000\n1 2\n314 315\n500000 500001\n999999999 1000000000\n", "output": "1999999680\n"}, {"type": "stdin_stdout", "input": "5\n123456 789012\n123 456\n12 345678901\n123456 789012\n1 23\n", "output": "246433\n"}, {"type": "stdin_stdout", "input": "3\n1 3\n5 7\n1 3\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.\n\nMore precisely, two different numbers $a$ and $b$ are friends if $gcd(a,b)$, $\\frac{a}{gcd(a,b)}$, $...
[{"type": "stdin_stdout", "input": "100\n42 486 341 527 189 740 490 388 989 489 711 174 305 844 971 492 998 954 832 442 424 619 906 154 293 395 439 735 738 915 453 748 786 550 871 932 693 326 53 904 732 835 354 364 691 669 157 719 282 875 573 672 695 790 58 872 732 751 557 779 329 39 213 844 289 137 50 951 284 671 474 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<cont...
[{"type": "stdin_stdout", "input": "httpftphttptphttphrururuhpftphtpftphtpftphtptpft\n", "output": "http://ftphttptphttph.ru/ruruhpftphtpftphtpftphtptpft\n"}, {"type": "stdin_stdout", "input": "httpuurrruurruuruuruuurrrurururuurruuuuuuruurr\n", "output": "http://uurr.ru/urruuruuruuurrrurururuurruuuuuuruurr\n"}, {"type"...
code_stdio