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\nN of us are going on a trip, by train or taxi.\nThe train will cost each of us A yen (the currency of Japan).\nThe taxi will cost us a total of B yen.\nHow much is our minimum total travel expense?\n\n-----Constraints----... | [{"type": "stdin_stdout", "input": "12 -13 -107", "output": "-156\n"}, {"type": "stdin_stdout", "input": "-1719 1 -2", "output": "-1719\n"}, {"type": "stdin_stdout", "input": "10 -2 -141", "output": "-141\n"}, {"type": "stdin_stdout", "input": "10 -2 -162", "output": "-162\n"}, {"type": "stdin_stdout", "input": "10 -7 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is c_{i}. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.\n... | [{"type": "stdin_stdout", "input": "9 436\n1 2 4 8 14 32 27 128 256\n", "output": "160\n0 1 2 3 4 6 8 9 10 11 14 15 16 17 18 20 22 23 24 25 27 28 29 30 32 34 35 36 37 38 41 42 43 44 46 48 49 50 51 52 128 129 130 131 132 134 136 137 138 139 142 143 144 145 146 148 150 151 152 153 155 156 157 158 160 162 163 164 165 166 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nConstraints\n\n* 0 ≤ a, b, c ≤ 100\n\nInput\n\nThree integers a, b and c separated by a single space are given i... | [{"type": "stdin_stdout", "input": "-1 -1 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "-1 -1 -2", "output": "No\n"}, {"type": "stdin_stdout", "input": "18 10 10", "output": "No\n"}, {"type": "stdin_stdout", "input": "-1 0 2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-1 -1 2", "output": "No\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of n numbers p1, p2, ..., pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l ≤ r) and reverse the order of the elements pl, pl + 1, ..., pr. Yo... | [{"type": "stdin_stdout", "input": "30 153\n18 5 24 7 12 6 25 14 21 20 27 4 30 8 23 19 11 13 17 1 29 28 15 22 16 9 2 10 26 3\n", "output": "217.500536909325035\n"}, {"type": "stdin_stdout", "input": "30 136\n1 29 20 25 15 2 3 16 24 30 17 14 7 10 11 22 6 8 23 18 12 5 19 9 26 21 28 13 27 4\n", "output": "217.499666343987... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDante is engaged in a fight with \"The Savior\". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.\n\... | [{"type": "stdin_stdout", "input": "63 100 1960\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "73 100 3111\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "26 100 5582\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "128 81 3880\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArithmetic Progressions\n\nAn arithmetic progression is a sequence of numbers $a_1, a_2, ..., a_k$ where the difference of consecutive members $a_{i+1} - a_i$ is a constant ($1 \\leq i \\leq k-1$). For example, the sequen... | [{"type": "stdin_stdout", "input": "6\n-2 11 12 30 3 0", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n-4 1 6 2 13 -1", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n-2 1 -1 8 13 9", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n-2 11 5 20 8 0", "output": "3\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherw... | [{"type": "stdin_stdout", "input": "1 -2 -2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 -2 -2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5 7 5\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3 3 4\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "6 1 6\n", "output": "Yes... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you ... | [{"type": "stdin_stdout", "input": "2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n3\n1 2 3\n3\n4 1 6\n", "output": "B 4\nA 4\nC -1\nB 2\nC 1\n"}, {"type": "stdin_stdout", "input": "2\n6\n5 3 2 8 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 3 2 4 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan unexpectedly saw a present from one of his previous birthdays. It is array of $n$ numbers from $1$ to $200$. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its ne... | [{"type": "stdin_stdout", "input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\n"}, {"type": "stdin_stdout", "input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKarafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. [Image] \n\nEach Karafs has a positive ... | [{"type": "stdin_stdout", "input": "447 74474 4\n47 777474 1358\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"type": "stdin_stdout", "input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ v... | [{"type": "stdin_stdout", "input": "100\n8650752 65536 131072 134217728 2112 8 0 0 0 0 0 1 0 0 268435456 1024 0 18890756 0 0 0 135364608 6291464 0 0 0 0 0 32 0 16384 0 0 0 0 33554560 256 0 16 0 0 536870912 536870912 0 0 128 0 0 4096 2048 0 0 0 0 268435456 64 1 0 0 262144 524288 0 11769 0 0 0 2 2 512 131072 0 0 67108864... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\l... | [{"type": "stdin_stdout", "input": "8 2\n13 0 11 2 14 4 11 8", "output": "55\n"}, {"type": "stdin_stdout", "input": "8 4\n10 2 18 7 21 1 10 1", "output": "58\n"}, {"type": "stdin_stdout", "input": "8 4\n10 2 28 7 23 0 10 3", "output": "70\n"}, {"type": "stdin_stdout", "input": "8 2\n18 0 28 5 17 1 16 1", "output": "84\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKing of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.\n\nThe ma... | [{"type": "stdin_stdout", "input": "30 50\n17 >= 29\n19 <= 18\n3 > 50\n54 >= 56\n47 < 15\n50 <= 33\n49 < 8\n57 <= 16\n30 > 35\n49 < 21\n3 >= 37\n56 <= 51\n46 > 51\n35 >= 48\n32 < 15\n12 <= 4\n38 > 57\n55 < 9\n49 <= 1\n9 >= 38\n60 = 60\n1 > 12\n40 >= 43\n13 > 38\n24 >= 39\n9 < 2\n12 > 58\n15 >= 30\n13 > 50\n42 <= 16\n23... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProfessor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the univ... | [{"type": "stdin_stdout", "input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100001 100\n-1 -1", "output": "42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274\n"}, {"type": "stdin_stdout", "input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 1\n11 1\n11 2\n11 3\n100001 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the Bus of Characters there are $n$ rows of seat, each having $2$ seats. The width of both seats in the $i$-th row is $w_i$ centimeters. All integers $w_i$ are distinct.\n\nInitially the bus is empty. On each of $2n$ s... | [{"type": "stdin_stdout", "input": "10\n24 53 10 128 141 9 15 62 32 47\n00100000000111111111\n", "output": "6 3 3 7 1 9 10 2 8 4 5 5 4 8 2 10 9 1 7 6\n"}, {"type": "stdin_stdout", "input": "10\n24 53 10 128 141 9 15 97 32 47\n00100000000111111111\n", "output": "6 3 3 7 1 9 10 2 8 4 5 5 4 8 2 10 9 1 7 6\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n - We will make a sequen... | [{"type": "stdin_stdout", "input": "10\n1 2 4 2 11 1 7 11 0 4\n1 3\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n2\n2\n4\n2\n3\n2\n2\n3\n"}, {"type": "stdin_stdout", "input": "10\n1 2 4 0 12 1 7 11 0 4\n1 5\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n3\n3\n2\n2\n2\n2\n2\n3\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings \"ab\" in the string and replace it with the string \"bba\". If we have no \"ab\" as a substring,... | [{"type": "stdin_stdout", "input": "abaaaaaabaaaabbabbaaabbbbabababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabaababbabababbabbbbabbbaabbabbbabaabbaabbaaaaaab\n", "output": "502032780\n"}, {"type": "stdin_stdout", "input": "abaaaaaabaaaabbabbaaabbababababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabbababbabababbabbbbabbbaab... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.\nShe will concatenate all of the strings in some order, to produce a long string.\nAmong all strings that she can produce in this way, ... | [{"type": "stdin_stdout", "input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n"}, {"type": "stdin_stdout", "input": "3 3\ndxx\naxx\ndxx", "output": "axxdxxdxx\n"}, {"type": "stdin_stdout", "input": "3 3\ndxx\naxx\nxxd", "output": "axxdxxxxd\n"}, {"type": "stdin_stdout", "input": "3 3\ndxx\nxxa\nxxd", "output": "dxxx... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSuppose there is a $h \\times w$ grid consisting of empty or full cells. Let's make some definitions:\n\n $r_{i}$ is the number of consecutive full cells connected to the left side in the $i$-th row ($1 \\le i \\le h$). ... | [{"type": "stdin_stdout", "input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 12 16 10 11 15 4\n", "output": "974740338\n"}, {"type": "stdin_stdout", "input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4\n", "output": "797922655\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.... | [{"type": "stdin_stdout", "input": "3\n14\n11\n14\n2\n58\n0", "output": "Case 1: 3\nCase 2: 14\nCase 3: 11\nCase 4: 14\nCase 5: 2\nCase 6: 58\n"}, {"type": "stdin_stdout", "input": "3\n5\n11\n14\n26\n34\n0", "output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 14\nCase 5: 26\nCase 6: 34\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n<image> <image>\n\n*The two images are equivalent, feel free to use either one.\n\nInput\n\nThe input contains a single integer a (-100 ≤ a ≤ 100).\n\nOutput\n\nOutput the result – an integer number.\n\nExample\n\nInput\n... | [{"type": "stdin_stdout", "input": "-1079\n", "output": "-1164239\n"}, {"type": "stdin_stdout", "input": "-340\n", "output": "-115598\n"}, {"type": "stdin_stdout", "input": "-449\n", "output": "-201599\n"}, {"type": "stdin_stdout", "input": "-685\n", "output": "-469223\n"}, {"type": "stdin_stdout", "input": "-432\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are S sheep and W wolves.\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\n-----Cons... | [{"type": "stdin_stdout", "input": "100 100\n", "output": "unsafe\n"}, {"type": "stdin_stdout", "input": "10 10\n", "output": "unsafe\n"}, {"type": "stdin_stdout", "input": "99 99\n", "output": "unsafe\n"}, {"type": "stdin_stdout", "input": "74 74\n", "output": "unsafe\n"}, {"type": "stdin_stdout", "input": "63 64\n", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may... | [{"type": "stdin_stdout", "input": "38823 9265", "output": "550080294\n"}, {"type": "stdin_stdout", "input": "11695 7143", "output": "10362628\n"}, {"type": "stdin_stdout", "input": "31415 9265", "output": "287927211"}, {"type": "stdin_stdout", "input": "11695 9265", "output": "2953665\n"}, {"type": "stdin_stdout", "in... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFood contains three nutrients called \"protein\", \"fat\" and \"carbohydrate\", which are called three major nutrients. It is calculated that protein and carbohydrate are 4 kcal (kilocalories) and fat is 9 kcal per 1 g (g... | [{"type": "stdin_stdout", "input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 116\n-1 4 18 33\n10 10 50 300\n0", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 116\n0 4 18 33\n10 10 50 300\n0", "output": "NA\nNA\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nI'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. City i is a point on the coordinate plane (xi, yi) ).\n\nRabbits travel to meet the follo... | [{"type": "stdin_stdout", "input": "5\n101.13623414746552 91.04161232454778\n1 -1\n1 10\n0 3\n19 -1\n20 7", "output": "9\n"}, {"type": "stdin_stdout", "input": "5\n100.60853142327974 90.65666260699702\n1 0\n1 10\n8 3\n10 -1\n12 10", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n100.60853142327974 90.656662606... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNumbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two g... | [{"type": "stdin_stdout", "input": "3 3\n100 700\n200 200\n600 600\n500 100\n605 300\n800 578\n3 3\n100 300\n400 600\n400 100\n600 400\n500 900\n300 300\n3 4\n300 300\n935 300\n400 600\n100 100\n200 900\n500 900\n158 110\n1 2\n300 300\n100 100\n500 500\n1 1\n100 100\n200 100\n2 2\n0 0\n500 700\n1000 1400\n1500 2100\n2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a tic-tac-toe on a 3x3 board. Tic-tac-toe is a two-player battle game. Decide the first attack and the second attack, one hits Kuroishi and one hits Shiraishi. The winner is the person who puts stones one by one ... | [{"type": "stdin_stdout", "input": "bbw\nbww\n+b+\nbwb\nwbx\nwbw\n0", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "caw\nwbw\n+b+\nbwb\nwxb\nwbw\n0", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "bbw\nbww\n+b+\nbwb\nwbx\nwbv\n0", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "cbw\nbww... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.\n\nThe exam consists of $n$ problems that can be solved in $T$ minutes... | [{"type": "stdin_stdout", "input": "10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 12 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 12\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 8 0 11 15 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 11 2 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is reading a e-book. The file of the book consists of $n$ pages, numbered from $1$ to $n$. The screen is currently displaying the contents of page $x$, and Vasya wants to read the page $y$. There are two buttons on ... | [{"type": "stdin_stdout", "input": "5\n20 10 2 9\n1000000000 2 89 4\n1000000000 2 89 8\n1000000000 142 1 1000000000\n1000000000 1000000000 4 3\n", "output": "4\n23\n12\n1\n333333332\n"}, {"type": "stdin_stdout", "input": "5\n20 10 2 9\n1000000000 2 89 4\n1000000000 2 89 5\n1000000000 142 1 1000000000\n1000000000 100000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nChef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so.\n\nChef ha... | [{"type": "stdin_stdout", "input": "2\n3\n3 14 3\n4\n1 2 3 3", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 14 3\n4\n1 2 3 3", "output": "3\n3\n"}, {"type": "stdin_stdout", "input": "2\n2\n3 3 1\n4\n1 12 3 3", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n3\n6 14 3\n4\n1 2 3 3", "output"... | 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\nThere are $n$ kids, each of them is reading a unique book. At the end of any day, the $i$-th kid will give his book to the $p_i$-th kid (in case of $i ... | [{"type": "stdin_stdout", "input": "20\n10\n3 8 1 4 9 6 10 2 7 5\n10\n10 4 8 6 5 3 1 2 9 7\n1\n1\n2\n2 1\n10\n2 5 3 6 9 7 4 10 8 1\n10\n1 7 4 6 9 10 8 2 3 5\n8\n3 8 1 7 6 4 2 5\n8\n7 4 5 2 8 1 6 3\n5\n1 2 4 3 5\n6\n4 2 5 6 3 1\n5\n5 3 2 4 1\n5\n4 3 5 1 2\n7\n6 5 1 7 4 2 3\n6\n6 2 4 1 5 3\n3\n3 1 2\n4\n1 3 4 2\n3\n3 1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe define $x \\bmod y$ as the remainder of division of $x$ by $y$ ($\\%$ operator in C++ or Java, mod operator in Pascal).\n\nLet's call an array of positive integers $[a_1, a_2, \\dots, a_k]$ stable if for every permutat... | [{"type": "stdin_stdout", "input": "500000 250000\n", "output": "803991687\n"}, {"type": "stdin_stdout", "input": "500000 250000\n", "output": "803991687\n"}, {"type": "stdin_stdout", "input": "500000 471528\n", "output": "588862109\n"}, {"type": "stdin_stdout", "input": "500000 121854\n", "output": "377057930\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n boys and m girls attending a theatre club. To set a play \"The Big Bang Theory\", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways... | [{"type": "stdin_stdout", "input": "30 30 30\n", "output": "118264581548187697"}, {"type": "stdin_stdout", "input": "30 29 19\n", "output": "1396982287132530\n"}, {"type": "stdin_stdout", "input": "30 30 19\n", "output": "2044156982307300\n"}, {"type": "stdin_stdout", "input": "30 29 42\n", "output": "277508869722315\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times.\n\nVasya currently h... | [{"type": "stdin_stdout", "input": "16\n1 1 1 1\n1 1 1 1000000000\n1 1 1000000000 1\n1 1 1000000000 1000000000\n1 1000000000 1 1\n1 1000000000 1 1000000000\n1 1000000000 1000000000 1\n1 1000000000 1000000000 1000000000\n1000000000 1 1 1\n1000000000 1 1 1000000000\n1000000000 1 1000000000 1\n1000000000 1 1000000000 1000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHeading ##There are two integers A and B. You are required to compute the bitwise AND amongst all natural numbers lying between A and B, both inclusive.\nInput Format\n\nFirst line of the input contains T, the number of t... | [{"type": "stdin_stdout", "input": "124\n1476395008 1493172223\n1275068416 1291845631\n4009754624 4026531839\n2516582400 2533359615\n50331648 67108863\n2566914048 2583691263\n2952790016 2969567231\n3892314112 3909091327\n3489660928 3506438143\n33554432 50331647\n1694498816 1711276031\n3623878656 3640655871\n1308622848 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJ: City\n\nSanta decides to deliver a present to a city.\n\nThe city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel.\n\nThe $ X $ t... | [{"type": "stdin_stdout", "input": "2 -2 11 0", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 -1 12 1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-1 2 0 14", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 -1 1 11", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 -2 11 0", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character — non-empty string s, consisting of ... | [{"type": "stdin_stdout", "input": "emrvvhupytoxzhqxmuop 1\n49\ng g -558\nd g 845\nd k -745\nb g -773\nf f -733\nb s -491\na s -894\ng d -565\ns k -756\nb a 373\nb d 398\nk f 250\na b 531\nf g -27\nf b 125\na g -555\ns f 540\ng b 194\nk s -636\ns b -955\nd a -520\ng f -97\nf s -204\ns a 171\nb k -304\ns g -160\na a -56... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\n-----Constraints-----\n - 2 \\leq K \\leq 10^5\n - K is an integer.\n\n-----Input-----\nInput is given from Standard Inp... | [{"type": "stdin_stdout", "input": "79992\n", "output": "36\n"}, {"type": "stdin_stdout", "input": "10989", "output": "27\n"}, {"type": "stdin_stdout", "input": "37450", "output": "3\n"}, {"type": "stdin_stdout", "input": "70620", "output": "6\n"}, {"type": "stdin_stdout", "input": "11849", "output": "5\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\nSnuke can perform the following operation when all integers on the blackboard are even:\n - Replace each integer X on the blackboard by X divided by 2... | [{"type": "stdin_stdout", "input": "6\n382253568 723152896 37802240 379425024 404894720 471526144\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "6\n348324507 1154626501 32183854 379425024 590201381 471526144", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\n586050932 1154626501 32183854 379425024 5902... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n integers b_1, b_2, ..., b_{n} written in a row. For all i from 1 to n, values a_{i} are defined by the crows performing the following procedure:\n\n The crow sets a_{i} initially 0. The crow then adds b_{i} ... | [{"type": "stdin_stdout", "input": "10\n-38980 0001000000 -1000000000 1000000000 -1000000000 1000010010 -1000000000 1010000010 -1556535198 1000000000\n", "output": "961020 -999000000 0 0 10010 10010 10000010 -546535188 -556535198 1000000000\n"}, {"type": "stdin_stdout", "input": "10\n-38980 0001000000 -1000000000 10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different... | [{"type": "stdin_stdout", "input": "100\nababbaaabaaabaabbabbaaabbabaaabbbabbbbbbbbababbbbbabbaaaabbbabbaababaabaababbbabababbbababbbbaabbbba\n", "output": "34\nababbaabababbabaabbabaabbababababaabbabaabababababbabababababaabba\n"}, {"type": "stdin_stdout", "input": "100\nabbbbaabbbbababbbabababbbabaabaababaabbabbbaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a directed graph $G$ which can contain loops (edges from a vertex to itself). Multi-edges are absent in $G$ which means that for all ordered pairs $(u, v)$ exists at most one edge from $u$ to $v$. Vertices a... | [{"type": "stdin_stdout", "input": "1\n\n000110 0\n", "output": "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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHow many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally an... | [{"type": "stdin_stdout", "input": "3\n29 5\n2 2\n16 7", "output": "20112\n12\n11796\n"}, {"type": "stdin_stdout", "input": "3\n16 3\n4 3\n12 4", "output": "2084\n104\n2048\n"}, {"type": "stdin_stdout", "input": "3\n29 3\n2 2\n16 7", "output": "7154\n12\n11796\n"}, {"type": "stdin_stdout", "input": "3\n16 2\n4 3\n12 3"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter learning a lot about space exploration, a little girl named Ana wants to change the subject.\n\nAna is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to che... | [{"type": "stdin_stdout", "input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\num\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\nmu\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a String(only lower case letters) , check if any substring has occured Twice :\n\n Example : iwsagoodboody\nHere, substring \"ood\" occurs twice.\n\nOutput \"YES\" if there is any such substring else output \"NO\"... | [{"type": "stdin_stdout", "input": "100\nhqghumeaylnlfdxfircvscxggbwkfnqduxwfnfozvs\ntkjprepggxrpnrvystmwcysyycqpevikeffmznimkkasvwsrenzkycxfxtlsgypsfadpooefxzbcoejuvpvaboygpoeylfpbnpljvrvipyamyehwqnqrqpmxujjloovaowuxwhmsncbxcoksfzkvatxdknlyjyhfixjswnkkufnuxxzrzbmnmgqooketlyhnkoaugzqrcddiuteiojwayyzpvscmpsajlfvgubfaaov... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nn fish, numbered from 1 to n, live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with... | [{"type": "stdin_stdout", "input": "8\n0.000 0.147 0.783 0.224 0.220 0.651 0.453 0.209\n0.853 0.000 0.246 0.076 0.018 0.349 0.896 0.315\n0.217 0.754 0.000 0.307 0.968 0.400 0.531 0.086\n0.776 0.924 0.693 0.000 0.707 0.842 0.116 0.949\n0.780 0.982 0.032 0.293 0.000 0.908 0.307 0.266\n0.349 0.651 0.600 0.158 0.092 0.000 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a binary string $s$ consisting of $n$ zeros and ones.\n\nYour task is to divide the given string into the minimum number of subsequences in such a way that each character of the string belongs to exactly one... | [{"type": "stdin_stdout", "input": "4\n4\n0011\n6\n111111\n5\n10101\n8\n01010000\n", "output": "2\n1 2 2 1 \n6\n1 2 3 4 5 6 \n1\n1 1 1 1 1 \n4\n1 1 1 1 1 2 3 4 \n"}, {"type": "stdin_stdout", "input": "4\n4\n0011\n6\n111111\n5\n10101\n8\n01010000\n", "output": "2\n1 2 2 1 \n6\n1 2 3 4 5 6 \n1\n1 1 1 1 1 \n4\n1 1 1 1 1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.\n\nThe Little Elephant has K favorite lucky strings A_{1}, A_{2}, ..., A_{K}. He thinks that the... | [{"type": "stdin_stdout", "input": "2 4\n2\n752\n25003\n1329\n10896\n39952297003683893618248919566249112695937429123", "output": "Good\nGood\nBad\nGood\n"}, {"type": "stdin_stdout", "input": "2 4\n1\n752\n28466\n1329\n10896\n95142413585696281004906476796906063037090967865", "output": "Bad\nGood\nGood\nGood\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n\"Search\" is an operation to obtain the desired information from a large amount of information. Familiar examples include \"finding your own exam number from a large number of exam numbers\" when announcing your success,... | [{"type": "stdin_stdout", "input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n1\n2\n3\n10\n-1\n0", "output": "3\n2\n"}, {"type": "stdin_stdout", "input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n1\n2\n3\n10\n-2\n0", "output": "3\n2\n"}, {"type": "stdin_stdout", "input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n2\n2\n3\n10\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may b... | [{"type": "stdin_stdout", "input": "???????????????2?????????????8???????????6????????5?6?5????1???8????1???????????????????????????????????3??????9????????????3??6???????????6???????????????????3???????????9???????3????6?5?????????????????2???????????5418??????????8????????9????????????0????????????????????????9??????... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"a\", \"o\", \"u\", \"i\", and \"e\". Other letters are consonant.\n\nIn Berlanese, there has to b... | [{"type": "stdin_stdout", "input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit an... | [{"type": "stdin_stdout", "input": "1000000 1000000 1000000 1000000 1000000\n", "output": "1000000 1000000\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 999999 999998 1000000\n", "output": "999999 999998\n"}, {"type": "stdin_stdout", "input": "129630 805489 631548 761110 577559\n", "output": "227930 447929\n"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given four integers $a$, $b$, $x$ and $y$. Initially, $a \\ge x$ and $b \\ge y$. You can do the following operation no more than $n$ times:\n\n Choose either $a$ or $b$ and decrease it by one. However, as a resul... | [{"type": "stdin_stdout", "input": "7\n10 10 8 5 3\n12 8 8 7 2\n12343 43 4543 39 123212\n1000000000 1000000000 1 1 1\n1000000000 1000000000 1 1 1000000000\n10 11 2 1 5\n10 11 9 1 10\n", "output": "70\n77\n177177\n999999999000000000\n999999999\n55\n10\n"}, {"type": "stdin_stdout", "input": "7\n10 10 8 5 3\n12 8 0 7 2\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe grasshopper is located on the numeric axis at the point with coordinate $x_0$.\n\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate $x$ with a d... | [{"type": "stdin_stdout", "input": "9\n0 1\n0 2\n10 10\n10 197\n177 25\n10000000000 1895528572\n-433494437 87178291199\n1 0\n-1 1\n", "output": "-1\n1\n11\n-187\n202\n10000000000\n-87611785637\n1\n0\n"}, {"type": "stdin_stdout", "input": "9\n0 1\n0 2\n10 11\n10 197\n177 25\n10000000000 1895528572\n-433494437 8717829119... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediat... | [{"type": "stdin_stdout", "input": "13 21 1\n2 11\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S of length N-1. Each character in S is `<` or `>`.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq ... | [{"type": "stdin_stdout", "input": "<>>><<<<<><<>>><", "output": "29\n"}, {"type": "stdin_stdout", "input": "<>>>><<<<><<<>><", "output": "28\n"}, {"type": "stdin_stdout", "input": "<>><<<><<<<>>>><", "output": "26\n"}, {"type": "stdin_stdout", "input": "<<>><<><<<<>>>><", "output": "24\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, \"abcba\", \"a\", and \"abba\" are palindromes, while \"abab\" and \"xy\" are not.\n\nA... | [{"type": "stdin_stdout", "input": "21\narozaupalanalapuazora\n", "output": "aaaaaaaallnoopprruuzz\n"}, {"type": "stdin_stdout", "input": "16\ngagadbcgghhchbdf\n", "output": "aabbccddfgggghhh\n"}, {"type": "stdin_stdout", "input": "15\nabacabadabacaba\n", "output": "aaaaaaaabbbbccd\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNezzar's favorite digit among $1,\\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.\n\nGiven $q$ integers $a_1,a_2,\\ldots,a_q$, for each $1 \\le i \\le q$ Nezz... | [{"type": "stdin_stdout", "input": "2\n3 3\n24 21 27\n10 4\n74 13 26 95 102 51 34 58 42 60\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "2\n3 3\n27 21 27\n10 4\n74 13 26 95 102 51 34 58 42 60\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYE... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.\n\nLet we represent their base with an array, where each position can be occupied by many avengers, but one avenger ca... | [{"type": "stdin_stdout", "input": "5 3 10000 3241\n5 12 2\n", "output": "58892\n"}, {"type": "stdin_stdout", "input": "5 3 3521 10000\n5 12 2\n", "output": "58168\n"}, {"type": "stdin_stdout", "input": "5 3 10000 2737\n5 12 2\n", "output": "52844\n"}, {"type": "stdin_stdout", "input": "5 3 3521 10010\n5 12 2\n", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift $X[i]$ grams on day $i$. In order to improve his ... | [{"type": "stdin_stdout", "input": "5 00000\n10000 30000 30000 40000 19505\n27261\n14 2 8 5 6\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "5 00000\n10000 30000 30000 40000 19505\n27261\n14 0 8 5 6\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "5 10000\n10000 40000 30000 30000 20000\n10000\n5 2 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed e... | [{"type": "stdin_stdout", "input": "267 111\n", "output": "0.7727518243505415\n"}, {"type": "stdin_stdout", "input": "768 487\n", "output": "0.7203654732552364\n"}, {"type": "stdin_stdout", "input": "377 205\n", "output": "0.7393583121158366\n"}, {"type": "stdin_stdout", "input": "815 180\n", "output": "0.8467179193191... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProfessor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he i... | [{"type": "stdin_stdout", "input": "43 959134961 -868367850 142426380\n921743429 63959718 -797293233 122041422 -407576197 700139744 299598010 168207043 362252658 591926075 941946099 812263640 -76679927 -824267725 89529990 -73303355 83596189 -982699817 -235197848 654773327 125211479 -497091570 -2301804 203486596 -126652... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equa... | [{"type": "stdin_stdout", "input": "100 100\n", "output": "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 "}, {"type": "stdin_stdout", "input": "100 100\n", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Byteland they have a very strange monetary system.\n\nEach Bytelandian gold coin has an integer number written on it. A coin n\ncan be exchanged in a bank into three coins: n/2, n/3 and n/4.\nBut these numbers are all ... | [{"type": "stdin_stdout", "input": "12\n10", "output": "13\n10\n"}, {"type": "stdin_stdout", "input": "12\n19", "output": "13\n19\n"}, {"type": "stdin_stdout", "input": "12\n11", "output": "13\n11\n"}, {"type": "stdin_stdout", "input": "12\n21", "output": "13\n22\n"}, {"type": "stdin_stdout", "input": "12\n27", "output... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square... | [{"type": "stdin_stdout", "input": "12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBackground\n\nThe kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves darts as much as programming. Yu-kun was addicted... | [{"type": "stdin_stdout", "input": "4 3 4 2\n3 1\n0 1\n3 3\n1 5\n4 2\n2 0\n5 0\n4 0\n3 2\n3 3\n4 3\n6 0\n6 10\n4 1\n3 4\n4 4\n5 10\n2 9", "output": "0.7490695671\n"}, {"type": "stdin_stdout", "input": "4 3 4 2\n3 1\n0 1\n3 3\n1 5\n4 2\n3 0\n5 0\n4 0\n3 2\n3 0\n4 3\n6 0\n6 10\n4 1\n3 4\n4 4\n5 10\n2 9", "output": "0.400... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have $2n$ integers $1, 2, \\dots, 2n$. You have to redistribute these $2n$ elements into $n$ pairs. After that, you choose $x$ pairs and take minimum elements from them, and from the other $n - x$ pairs, you take maxi... | [{"type": "stdin_stdout", "input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "\n1\n3\n1\n"}, {"type": "stdin_stdout", "input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "1\n3\n1\n"}, {"type": "stdin_stdout", "input": "3\n1\n1\n5\n1 4 5 9 10\n2\n1 4\n", "output": "1\n3\n1\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\nA red point and a blue point can for... | [{"type": "stdin_stdout", "input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n6 3\n-1 4\n8 4\n14 17", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n6 3\n-1 4\n8 4\n9 17", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n8 3\n-1 4\n14 4\n9 4", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhen the curtains are opened, a canvas unfolds outside. Kanno marvels at all the blonde colours along the riverside — not tangerines, but blossoms instead.\n\n\"What a pity it's already late spring,\" sighs Mino with regr... | [{"type": "stdin_stdout", "input": ".CAACCBBA.CBB.AC..BABCCBCCB..B.BC..CBC.CA.CC.C.CC.B.A.CC.BBCCBB..ACAACAC.CBCCB.AABAAC.CBCC.BA..CCBC.\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "CC.AAAC.BA.BBB.AABABBCCAA.A.CBCCB.B.BC.ABCBCBBAA.CACA.CCCA.CB.CCB.A.BCCCB...C.A.BCCBC..B.ABABB.C.BCB\n", "output": "Yes\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n* 1\\leq N \\leq 10^{16}\n* N is an integer.\n\nInput\n\nInput is given from Standard Input in the follo... | [{"type": "stdin_stdout", "input": "1265641936938969", "output": "135\n"}, {"type": "stdin_stdout", "input": "2005985506723837", "output": "136\n"}, {"type": "stdin_stdout", "input": "5193523582167964", "output": "139\n"}, {"type": "stdin_stdout", "input": "4944180382968715", "output": "138\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAttention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given ... | [{"type": "stdin_stdout", "input": "100000\n", "output": "199998 2\n1 2\n"}, {"type": "stdin_stdout", "input": "99991\n", "output": "199980 2\n1 2\n"}, {"type": "stdin_stdout", "input": "99992\n", "output": "199982 2\n1 2\n"}, {"type": "stdin_stdout", "input": "99971\n", "output": "199940 2\n1 2\n"}, {"type": "stdin_st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integ... | [{"type": "stdin_stdout", "input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1100000\n1 2 1000000\n1 2 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 1000000\n", "output": "CAN 999999\nCAN 999999\nCAN 1099999\nCAN 999999\nYES\nCAN 999999\nCAN 999999\nCAN 999999\nCAN 999999\n"}, {"type": "stdin_stdout", "input": "2 9 1 2\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N rabbits, numbered 1, 2, \\ldots, N.\n\nFor each i, j (1 \\leq i, j \\leq N), the compatibility of Rabbit i and j is described by an integer a_{i, j}. Here, a_{i, i} = 0 for each i (1 \\leq i \\leq N), and a_{i... | [{"type": "stdin_stdout", "input": "16\n0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7\n5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9\n-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9\n-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1\n-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3\n-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2\n7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5\n2 -7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration $\\frac{a_{i}}{1000}$. Today, on the party in honour of Sergiy of ... | [{"type": "stdin_stdout", "input": "971 108\n706 706 991 706 988 997 996 997 991 996 706 706 996 706 996 984 1000 991 996 1000 724 724 997 991 997 984 997 1000 984 996 996 997 724 997 997 1000 997 724 984 997 996 988 997 706 706 997 1000 991 706 988 997 724 988 706 996 706 724 997 988 996 991 1000 1000 724 988 996 1000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGenos needs your help. He was asked to solve the following programming problem by Saitama:\n\nThe length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as $\\s... | [{"type": "stdin_stdout", "input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", "output": "321\n"}, {"type": "stdin_stdout", "input": "1110010001000101001011111\n00011011000000100001010000010100110011010001111010\n", "output": "316\n"}, {"type": "stdin_stdout", "input": "1001101001... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "3000000003000000001\n"}, {"type": "stdin_stdout", "input": "1147564610\n", "output": "3950713605816050131\n"}, {"type": "stdin_stdout", "input": "1000010000\n", "output": "3000060003300030001\n"}, {"type": "stdin_stdout", "input": "1065935402\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Chris is participating in a graph cutting contest. He's a pro. The time has come to test his skills to the fullest.\n\nChris is given a simple undirected connected graph with n vertices (numbered from 1 to n) and m... | [{"type": "stdin_stdout", "input": "8 30\n10 4\n3 8\n3 2\n10 1\n3 5\n3 4\n5 1\n8 2\n8 4\n3 10\n7 9\n3 6\n9 5\n5 10\n7 6\n7 5\n9 1\n2 7\n9 10\n1 4\n9 8\n6 2\n2 1\n7 1\n6 4\n4 5\n2 14\n10 8\n7 8\n5 2\n", "output": "3 5 1\n10 5 7\n4 5 2\n5 9 1\n10 9 8\n3 6 2\n4 6 7\n9 7 1\n8 7 2\n3 2 1\n14 2 8\n4 8 10\n8 3 10\n3 4 1\n4 10... | 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\nAllen and Bessie are playing a simple number game. They both know a function f: \\{0, 1\\}^n → R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ...... | [{"type": "stdin_stdout", "input": "2 2\n0 1 2 3\n2 5\n0 4\n", "output": "1.5000000000\n2.2500000000\n3.2500000000\n"}, {"type": "stdin_stdout", "input": "2 2\n0 2 0 3\n2 0\n0 13\n", "output": "1.25\n1.25\n4.5\n"}, {"type": "stdin_stdout", "input": "2 2\n0 1 2 2\n2 2\n0 2\n", "output": "1.25\n1.25\n1.75\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThere are the following games.\n\nN characters are lined up in a vertical row. The color of these characters is red, blue, or yellow, and in the initial state, four or more characters of the same color are not ... | [{"type": "stdin_stdout", "input": "12\n3\n2\n1\n1\n1\n3\n2\n1\n2\n1\n1\n5\n2\n3\n2\n1\n2\n2\n5\n0\n0\n3\n2\n-1\n0\n0", "output": "8\n2\n1\n2\n"}, {"type": "stdin_stdout", "input": "12\n3\n2\n1\n1\n1\n3\n2\n2\n2\n2\n1\n5\n2\n3\n2\n1\n2\n2\n5\n1\n0\n3\n2\n-1\n0\n0", "output": "3\n2\n1\n2\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the righ... | [{"type": "stdin_stdout", "input": "5\n29\n0", "output": "5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n29\n28 1\n27 2\n27 1 1\n26 3\n26 2 1\n26 1 1 1\n25 4\n25 3 1\n25 2 2\n25 2 1 1\n25 1 1 1 1\n24 5\n24 4 1\n24 3 2\n24 3 1 1\n24 2 2 1\n24 2 1 1 1\n24 1 1 1 1 1\n23 6\n23 5 1\n23 4 2\n23 4 1 1\n23 3 3\n23 3 2 1\n23 3 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor given two circles $c1$ and $c2$, print\n\n\n4\n\n\nif they do not cross (there are 4 common tangent lines),\n\n\n3\n\n\nif they are circumscribed (there are 3 common tangent lines),\n\n\n2\n\n\nif they intersect (ther... | [{"type": "stdin_stdout", "input": "-26 -2 -2\n15 2 -1", "output": "4\n"}, {"type": "stdin_stdout", "input": "-26 -2 -2\n15 2 -2", "output": "4\n"}, {"type": "stdin_stdout", "input": "-26 -2 -1\n15 2 -2", "output": "4\n"}, {"type": "stdin_stdout", "input": "-26 -2 -1\n21 2 -2", "output": "4\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a_1, a_2, ..., a_{n} in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The gr... | [{"type": "stdin_stdout", "input": "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regul... | [{"type": "stdin_stdout", "input": "5\n-1 -1 1 1 321", "output": "APPROVED\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 1 1 337", "output": "APPROVED\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 1 1 200", "output": "APPROVED\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 1 1 385", "output": "APPROVED\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:\n\n In any right-angled triangle, the area of the square whose... | [{"type": "stdin_stdout", "input": "10000\n", "output": "12471\n"}, {"type": "stdin_stdout", "input": "9999\n", "output": "12467\n"}, {"type": "stdin_stdout", "input": "10000\n", "output": "12471"}, {"type": "stdin_stdout", "input": "9999\n", "output": "12467"}, {"type": "stdin_stdout", "input": "1000\n", "output": "88... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi the Jumbo will practice golf.\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\nIf he can achieve the objective, print OK... | [{"type": "stdin_stdout", "input": "1000\n2 1000\n", "output": "OK\n"}, {"type": "stdin_stdout", "input": "279\n691 872\n", "output": "OK\n"}, {"type": "stdin_stdout", "input": "379\n400 757\n", "output": "NG\n"}, {"type": "stdin_stdout", "input": "1000\n1 999\n", "output": "NG\n"}, {"type": "stdin_stdout", "input": "1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters ... | [{"type": "stdin_stdout", "input": "((((()())))())((((((()(()())(()())()((()()))(((())()()()(())))))()())())))(()()(()))))()(((()(((())()))())())))))(()()()((((((())(()())())()())(()))))()(()))(((()()()))())()(((()(()(((()))(()))()(()))((((((((())))))()))())(())))))()(()(()(((()((()()()())(((())())((()())(((((()()(())(... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ integers $a_1, a_2, \\ldots, a_n$. Find the maximum value of $max(a_l, a_{l + 1}, \\ldots, a_r) \\cdot min(a_l, a_{l + 1}, \\ldots, a_r)$ over all pairs $(l, r)$ of integers for which $1 \\le l < r \\le ... | [{"type": "stdin_stdout", "input": "4\n3\n2 3 3\n4\n3 0 10 1\n2\n359 139\n6\n229275 372495 402638 1125346 388084 422281\n", "output": "9\n10\n49901\n453107062748\n"}, {"type": "stdin_stdout", "input": "4\n3\n2 5 3\n4\n3 0 12 1\n2\n359 80\n6\n229275 718820 272407 1125346 388084 775159\n", "output": "15\n12\n28720\n43672... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.\n\nConsider that m (m ≤ 4n) peopl... | [{"type": "stdin_stdout", "input": "100 400\n", "output": "201 1 202 2 203 3 204 4 205 5 206 6 207 7 208 8 209 9 210 10 211 11 212 12 213 13 214 14 215 15 216 16 217 17 218 18 219 19 220 20 221 21 222 22 223 23 224 24 225 25 226 26 227 27 228 28 229 29 230 30 231 31 232 32 233 33 234 34 235 35 236 36 237 37 238 38 239 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJulia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on.\n\nDuring cooking, Julia goes to the kitchen every d min... | [{"type": "stdin_stdout", "input": "1000000000000000000 1001000000000000000 1000000000000000000\n", "output": "1000000000000000000.000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000.000000000000000"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the c... | [{"type": "stdin_stdout", "input": "-827584 -680412 -103147\n897186 313672 388429\n892050 717946 505625 200144 311983 606037\n", "output": "1709658\n"}, {"type": "stdin_stdout", "input": "-827584 -680412 -103147\n897186 313672 388429\n892050 717946 505625 278931 311983 606037\n", "output": "1709658\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. C... | [{"type": "stdin_stdout", "input": "6 7\n2 1\n1 1\n2 2\n1 2\n1 1\n1 2\n2 1\n1 1\n1 1\n1 1\n1 2\n2 2\n1 1\n", "output": "5 5\n"}, {"type": "stdin_stdout", "input": "6 7\n1 1\n1 1\n1 2\n1 2\n2 2\n1 2\n2 1\n2 1\n2 1\n2 1\n1 1\n1 1\n1 2\n", "output": "3 3\n"}, {"type": "stdin_stdout", "input": "6 7\n2 1\n2 2\n2 1\n1 1\n2 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its s... | [{"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "5\n3 1 4 2 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian as well. \nYour friend Сhef has prepared a rectangular cake for you. Both of you want to divide the cake among yourselves. Your friend is generous enough to let you... | [{"type": "stdin_stdout", "input": "2\n1 1 10 32\n11 11 20 20\n1 1 20 20\n11 11 30 76", "output": "360\n1515\n"}, {"type": "stdin_stdout", "input": "2\n1 1 10 10\n11 7 20 20\n1 1 20 20\n11 11 30 55", "output": "198\n1116\n"}, {"type": "stdin_stdout", "input": "2\n1 1 10 20\n11 7 20 20\n1 1 20 20\n11 11 30 55", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn this problem we consider a very simplified model of Barcelona city.\n\nBarcelona can be represented as a plane with streets of kind x = c and y = c for every integer c (that is, the rectangular grid). However, there is... | [{"type": "stdin_stdout", "input": "912738218 530309782 -939253776\n592805323 -930297022 -567581994 -829432319\n", "output": "1218437463.3854325\n"}, {"type": "stdin_stdout", "input": "137446306 341377513 -633738092\n244004352 -854692242 60795776 822516783\n", "output": "1800945736.2511592\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by th... | [{"type": "stdin_stdout", "input": "10 45 9\n2 1 428\n3 1 610\n3 2 357\n4 1 855\n4 2 528\n4 3 508\n5 1 425\n5 2 185\n5 3 349\n5 4 845\n6 1 206\n6 2 969\n6 3 153\n6 4 854\n6 5 640\n7 1 87\n7 2 250\n7 3 953\n7 4 456\n7 5 742\n7 6 588\n8 1 641\n8 2 898\n8 3 396\n8 4 960\n8 5 654\n8 6 410\n8 7 640\n9 1 707\n9 2 707\n9 3 70... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ elements numbered from $1$ to $n$, the element $i$ has value $a_i$ and color $c_i$, initially, $c_i = 0$ for all $i$.\n\nThe following operation can be applied:\n\nSelect three elements $i$, $j$ and $k$ ... | [{"type": "stdin_stdout", "input": "13\n1 2 3 2 1 3 3 4 5 5 5 4 7\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n1 2 1 2 7 4 7\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n1 1 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points ... | [{"type": "stdin_stdout", "input": "20\n-2967010 48581504\n-2967318 48581765\n-2967443 48581988\n-2967541 48582265\n-2967443 48582542\n-2967318 48582765\n-2967010 48583026\n-2966691 48583154\n-2966252 48583234\n-2965813 48583154\n-2965494 48583026\n-2965186 48582765\n-2965061 48582542\n-2964963 48582265\n-2965061 48581... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors.\n\nTheofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should fir... | [{"type": "stdin_stdout", "input": "5\n9\n31 yellow\n30 green\n26 yellow\n13 red\n2 red\n22 white\n12 red\n6 orange\n29 blue\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n9\n31 yellow\n30 green\n26 yellow\n13 red\n2 red\n22 white\n12 red\n6 orange\n29 blue\n", "output": "0\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a re... | [{"type": "stdin_stdout", "input": "001010 001011", "output": "931093537\n"}, {"type": "stdin_stdout", "input": "000101 000101", "output": "414723868\n"}, {"type": "stdin_stdout", "input": "000110 000111", "output": "399920258\n"}, {"type": "stdin_stdout", "input": "001111 001110", "output": "292820538\n"}, {"type": "s... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.