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\nNavi got a task at school to collect N stones. Each day he can collect only one stone. As N can be a very large number so it could take many days to complete the task, but then he remembers that his mother gave him a ma...
[{"type": "stdin_stdout", "input": "10000\n30712\n29260\n18391\n27280\n1418\n9121\n21242\n25603\n24535\n31483\n27489\n19374\n29055\n23121\n17850\n13263\n13007\n2951\n11242\n2065\n17626\n16180\n4279\n8810\n17099\n26792\n3012\n10052\n15737\n6958\n20931\n27867\n5436\n19598\n31974\n29158\n9728\n8406\n14742\n10105\n31127\n9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA binary string of length N is a string of N characters, where each character is either 0 or 1. \n\nWet Shark makes a list binStrings, consisting of all 2^N N-digit binary strings. For each string X in binStrings, Wet Sha...
[{"type": "stdin_stdout", "input": "10\n387\n56\n92\n349\n648\n137\n864\n75\n654\n456", "output": "133853253\n44250378\n164529950\n957748646\n556133947\n969336549\n582130551\n9141395\n116809184\n439071984\n"}, {"type": "stdin_stdout", "input": "10\n387\n56\n92\n346\n648\n76\n864\n75\n654\n456", "output": "133853253\n44...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a string S consisting of the uppercase English letters `P` and `D`, let the doctoral and postdoctoral quotient of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S =...
[{"type": "stdin_stdout", "input": "PDPD???", "output": "PDPDDDD\n"}, {"type": "stdin_stdout", "input": "DDPP???", "output": "DDPPDDD\n"}, {"type": "stdin_stdout", "input": "DDPO???", "output": "DDPODDD\n"}, {"type": "stdin_stdout", "input": "DDPO?>?", "output": "DDPOD>D\n"}, {"type": "stdin_stdout", "input": "?>?OPDD"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.\n\nConstraints\n\n* 0 \\leq N \\leq 10^4\n* |a_i| \\leq ...
[{"type": "stdin_stdout", "input": "0\n461740266", "output": "2\n3\n13\n1327\n1487\n"}, {"type": "stdin_stdout", "input": "0\n1326078230", "output": "2\n5\n1051\n126173\n"}, {"type": "stdin_stdout", "input": "0\n754892205", "output": "3\n5\n41\n853\n1439\n"}, {"type": "stdin_stdout", "input": "0\n732779016", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorat...
[{"type": "stdin_stdout", "input": "3 3\n10\n15\n33\n14\n12", "output": "23\n"}, {"type": "stdin_stdout", "input": "4 3\n10\n21\n21\n-1\n10", "output": "11\n"}, {"type": "stdin_stdout", "input": "4 3\n10\n21\n21\n-2\n10", "output": "11\n"}, {"type": "stdin_stdout", "input": "4 3\n10\n8\n21\n-2\n10", "output": "12\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\n* At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of...
[{"type": "stdin_stdout", "input": "abcb\naabb\nbccc", "output": "B\n"}, {"type": "stdin_stdout", "input": "aaca\naabb\ncccc", "output": "C\n"}, {"type": "stdin_stdout", "input": "abcb\nbbaa\nbccc", "output": "B\n"}, {"type": "stdin_stdout", "input": "aacb\nbbaa\nbccc", "output": "A\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by...
[{"type": "stdin_stdout", "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n1 8\n2 14\n7 0\n11 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0", "output": "NG\nOK\n"}, {"type": "stdin_stdout", "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n3 8\n6 14\n7 0\n8 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt Aizu Shingakujuku, students are divided into classes by conducting a proficiency test when they enter the cram school. The test consists of three subjects: Mathematics, English, and Japanese, and students are divided i...
[{"type": "stdin_stdout", "input": "4\n100 217 28\n253 43 197\n18 34 24\n19 22 189\n2\n190 106 20\n66 72 171\n0", "output": "A\nA\nC\nB\nA\nA\n"}, {"type": "stdin_stdout", "input": "4\n100 137 28\n143 43 197\n18 34 24\n19 19 65\n2\n196 106 20\n66 72 171\n0", "output": "A\nA\nC\nC\nA\nA\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have had record hot temperatures this summer. To avoid heat stroke, you decided to buy a quantity of drinking water at the nearby supermarket. Two types of bottled water, 1 and 0.5 liter, are on sale at respective pric...
[{"type": "stdin_stdout", "input": "467 101 10577", "output": "2222\n"}, {"type": "stdin_stdout", "input": "467 100 16500", "output": "3300\n"}, {"type": "stdin_stdout", "input": "467 100 12758", "output": "2600\n"}, {"type": "stdin_stdout", "input": "467 101 12758", "output": "2626\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[0, 0]\n[0, 1] [1, 1]\n[0, 2] [1, 2] [2, 2]\n[0, 3] [1, 3] [2, 3] [3, 3]\n[0, 4] [1, 4] [2, 4] [3, 4] [4, 4]\n[0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5]\n[0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6...
[{"type": "stdin_stdout", "input": "6\n16 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n13 23 14 16 15 25\n10\n00 01 11 02 12 30 03 13 36 33", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n11 23 16 16 15 25\n10\n00 01 11 02 12 22 03 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe postal system in the area where Masa lives has changed a bit. In this area, each post office is numbered consecutively from 1 to a different number, and mail delivered to a post office is intended from that post offic...
[{"type": "stdin_stdout", "input": "4 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 13 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0", "output": "Greetings 18\nLoveLetter 26\n\nBusinessMailA 2\nBusinessMailB 2\nBusinessMailC 2\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem C: Earn Big\n\nA group of N people is trying to challenge the following game to earn big money.\n\nFirst, N participants are isolated from each other. From this point, they are not allowed to contact each other, o...
[{"type": "stdin_stdout", "input": "110 50", "output": "0.224802593637\n"}, {"type": "stdin_stdout", "input": "010 50", "output": "1.000000000000\n"}, {"type": "stdin_stdout", "input": "110 89", "output": "0.789224893493\n"}, {"type": "stdin_stdout", "input": "110 12", "output": "0.000000001745\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSunuke received a d-dimensional hypercube with a side length of l1 × ... × ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and...
[{"type": "stdin_stdout", "input": "5\n12\n27\n15\n17\n149\n123", "output": "867510000\n"}, {"type": "stdin_stdout", "input": "5\n12\n34\n15\n17\n149\n119", "output": "998784000\n"}, {"type": "stdin_stdout", "input": "5\n12\n34\n15\n23\n149\n119", "output": "300622393\n"}, {"type": "stdin_stdout", "input": "5\n12\n27\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThere are $ M $ type characters. Use them to create a string of length $ N $. How many strings are used that have $ K $ or more? Find too much divided by $ 998244353 $.\n\nHere, the difference between two strin...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1001", "output": "824796085\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 0001", "output": "276774580\n"}, {"type": "stdin_stdout", "input": "1000000000000000001 1000000000000000000 0001", "output": "314695265\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the tangent lines between a point $p$ and a circle $c$.\n\nConstraints\n\n* $-1,000 \\leq px, py, cx, cy \\leq 1,000$\n* $1 \\leq r \\leq 1,000$\n* Distance between $p$ and the center of $c$ is greater than the radiu...
[{"type": "stdin_stdout", "input": "-3 0\n2 2 2", "output": "0.6206896552 3.4482758621\n2.0000000000 0.0000000000"}, {"type": "stdin_stdout", "input": "0 0\n2 2 2", "output": "0.0000000000 2.0000000000\n2.0000000000 0.0000000000"}, {"type": "stdin_stdout", "input": "-21 -2\n12 1 6", "output": "10.38379768 6.77822551\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after ...
[{"type": "stdin_stdout", "input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n0 2\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n4\n1\n5\n1\n1\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n2\n1\n4\n1\n1\n3\n4\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChildan is making up a legendary story and trying to sell his forgery — a necklace with a strong sense of \"Wu\" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few qu...
[{"type": "stdin_stdout", "input": "12 1 1\n0 1 2 3 2 5 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "12 1 1\n0 1 2 3 2 6 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "12 1 1\n0 1 2 3 2 2 6 11 0 10 10 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere was an electronic store heist last night.\n\nAll keyboards which were in the store yesterday were numbered in ascending order from some integer number x. For example, if x = 4 and there were 3 keyboards in the store...
[{"type": "stdin_stdout", "input": "40\n194 121 110 134 172 142 195 135 186 187 128 161 185 132 117 175 178 131 143 151 170 181 188 140 133 145 119 129 179 149 109 123 124 106 100 199 197 155 141 183\n", "output": "60\n"}, {"type": "stdin_stdout", "input": "40\n194 121 110 134 172 142 195 135 186 130 128 161 185 132 11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAyoub had an array a of integers of size n and this array had two interesting properties: \n\n * All the integers in the array were between l and r (inclusive). \n * The sum of all the elements was divisible by 3. \n\n\...
[{"type": "stdin_stdout", "input": "101149 1300011130 1476544836\n", "output": "156648241\n"}, {"type": "stdin_stdout", "input": "101149 686320621 1476544836\n", "output": "113944181\n"}, {"type": "stdin_stdout", "input": "101149 686320621 866589707\n", "output": "238349763\n"}, {"type": "stdin_stdout", "input": "17890...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLuckily, Serval got onto the right bus, and he came to the kindergarten on time. After coming to kindergarten, he found the toy bricks very funny.\n\nHe has a special interest to create difficult problems for others to so...
[{"type": "stdin_stdout", "input": "2 58 77\n0 0 0 0 6 0 0 0 40 0 0 0 0 22 0 0 41 74 0 0 0 0 0 0 0 15 0 0 60 5 69 0 0 30 0 0 23 60 0 35 0 0 0 0 0 0 69 0 0 0 0 0 0 0 0 0 0 0\n0 74\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 1 0 0 0 1 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer n and an integer k.\n\nIn one step you can do one of the following moves: \n\n * decrease n by 1; \n * divide n by k if n is divisible by k. \n\n\n\nFor example, if n = 27 and k = 3 you can do t...
[{"type": "stdin_stdout", "input": "93\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, a n × m rectangular matrix a is called increasing if, for each row of i, when go from left to right, the values strictly increase (that is, a_{i,1}<a_{i,2}<...<a_{i,m}) and for each column j, when go from...
[{"type": "stdin_stdout", "input": "10 4\n4 9 11 12\n8 11 13 18\n13 16 18 21\n15 21 0 24\n17 0 21 29\n21 26 0 33\n26 31 33 35\n30 32 35 37\n33 37 40 43\n34 41 46 51\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 4\n4 9 11 12\n8 11 13 18\n13 16 18 21\n15 21 0 24\n17 0 21 29\n17 26 0 33\n26 31 33 35\n30 32 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n integers. In one move, you can jump from the position i to the position i - a_i (if 1 ≤ i - a_i) or to the position i + a_i (if i + a_i ≤ n).\n\nFor each position i from 1 to n you...
[{"type": "stdin_stdout", "input": "150\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared n problems; and since the platform is very popular, 998244351 coder from all over the world is going ...
[{"type": "stdin_stdout", "input": "50\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n89 199\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the minimum area of a square land on which you can place two identical rectangular a × b houses. The sides of the houses should be parallel to the sides of the desired square land.\n\nFormally, \n\n * You are given ...
[{"type": "stdin_stdout", "input": "8\n3 2\n4 2\n1 1\n3 1\n4 13\n1 3\n12 4\n100 100\n", "output": "16\n16\n4\n9\n169\n9\n144\n40000\n"}, {"type": "stdin_stdout", "input": "8\n3 2\n2 2\n1 1\n4 2\n2 11\n1 4\n7 4\n100 101\n", "output": "16\n16\n4\n16\n121\n16\n64\n40000\n"}, {"type": "stdin_stdout", "input": "8\n3 2\n4 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, you found a bot to play \"Rock paper scissors\" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string s = s_1 s_2 ... s_{n} of length n where each letter is either R, S or P.\n\nWhi...
[{"type": "stdin_stdout", "input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"type": "stdin_stdout", "input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"type": "stdin_stdout", "input": "3\nRRRR\nSSP\nS\n", "output": "PPPP\nRRR\nR\n"}, {"type": "stdin_stdout", "input": "3\nQRRR\nRSP\nS\n", "output": "P...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.\n\nYou decided to rob a town's blacksmith ...
[{"type": "stdin_stdout", "input": "9\n475033014 267058742\n26843 148652\n850113755 279316120\n871120869 885251487\n51363 15651\n220811492 256297120\n473761699 194406678\n38725 23371\n167395720 333327477\n107541472 19164492\n74340 1113\n654389849 224345301\n663158140 437349008\n332 5052\n971865476 538450184\n959712803 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe pandemic is upon us, and the world is in shortage of the most important resource: toilet paper. As one of the best prepared nations for this crisis, BubbleLand promised to help all other world nations with this valuab...
[{"type": "stdin_stdout", "input": "7 29\n6 2 627\n7 6 580\n6 6 624\n2 7 381\n4 6 894\n7 7 776\n3 5 929\n1 4 313\n7 5 699\n4 4 977\n3 2 586\n5 5 456\n4 5 13\n4 3 935\n3 7 946\n1 5 950\n2 1 597\n1 3 338\n3 4 844\n6 5 523\n7 1 152\n6 7 981\n1 6 947\n5 3 49\n4 2 948\n5 6 734\n1 1 214\n4 7 747\n6 1 533\n", "output": "586\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either h...
[{"type": "stdin_stdout", "input": "3\n5\n1 2 3 1 2\n4\n11 2 28 5\n1\n998244353\n", "output": "11\n8\n1\n"}, {"type": "stdin_stdout", "input": "3\n5\n1 2 3 0 1\n4\n11 3 28 5\n1\n998244353\n", "output": "10\n8\n1\n"}, {"type": "stdin_stdout", "input": "3\n5\n1 2 3 1 2\n4\n11 2 15 5\n1\n998244353\n", "output": "11\n7\n1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a bus stop near the university. The lessons are over, and n students come to the stop. The i-th student will appear at the bus stop at time ti (all ti's are distinct).\n\nWe shall assume that the stop is located ...
[{"type": "stdin_stdout", "input": "32 5\n15 12\n24 6\n30 13\n35 7\n38 6\n46 6\n47 12\n60 6\n66 9\n71 26\n74 6\n76 15\n104 6\n105 6\n110 15\n124 12\n126 12\n129 9\n131 12\n134 15\n135 15\n141 12\n154 13\n167 9\n171 9\n179 17\n181 15\n185 12\n189 12\n191 6\n192 6\n196 12\n", "output": "53 44 55 47 44 77 86 77 82 101 134...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize...
[{"type": "stdin_stdout", "input": "100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 765 957 898 545 977 751 740 869 885 831 834 702 934 954 500 626 605 921 755 661 707 952...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPaw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web.\n\n<image>\n\nThere are n main threads going from the center of the web. Al...
[{"type": "stdin_stdout", "input": "20\n5 15 40 35 68 22\n6 70 19 28 69 63 1\n4 37 154 41 90\n7 11 148 35 94 55 59 64\n7 46 28 22 90 97 37 13\n5 62 45 34 50 94\n6 85 83 37 72 27 53\n6 46 56 116 71 49 33\n7 17 35 91 24 50 30 38\n2 75 12\n2 46 38\n1 61\n11 15 79 14 89 20 96 84 26 93 132 18\n1 75\n6 4 100 55 59 62 83\n5 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSquirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.\n\nNow Liss ...
[{"type": "stdin_stdout", "input": "5\n2\n1\n2\n1\n1\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "5\n2\n1\n2\n2\n1\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "5\n3\n1\n2\n2\n1\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "5\n3\n1\n2\n3\n1\n", "output": "18\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle penguin Polo has an n × m matrix, consisting of integers. Let's index the matrix rows from 1 to n from top to bottom and let's index the columns from 1 to m from left to right. Let's represent the matrix element on...
[{"type": "stdin_stdout", "input": "7 5 47\n9583 1734 4601 5353 2110\n3802 5165 7985 6293 324\n7045 653 9160 7891 4930\n1781 3520 4178 2298 3943\n1405 2956 5447 5494 6528\n3097 1640 7750 4883 8032\n4225 8455 1875 4789 4366\n", "output": "1508\n"}, {"type": "stdin_stdout", "input": "7 5 47\n9583 1734 4601 5353 2110\n380...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's introduce the designation <image>, where x is a string, n is a positive integer and operation \" + \" is the string concatenation operation. For example, [abc, 2] = abcabc.\n\nWe'll say that string s can be obtained...
[{"type": "stdin_stdout", "input": "10000000 10000000\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10000...
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\n22972 40786 3691 85313 46694\n33077 16067 3134 97367 68508\n4250 35501 17327 14435 32518\n64673 65438 56977 123599 27280\n", "output": "753143\n"}, {"type": "stdin_stdout", "input": "4 5\n22972 40786 3691 85313 46694\n33077 16067 3134 97367 129038\n4250 35501 17327 14435 32518\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.\n...
[{"type": "stdin_stdout", "input": "100001 100000\n", "output": "100000.41802404786\n"}, {"type": "stdin_stdout", "input": "100000 100000\n", "output": "99999.41803325451\n"}, {"type": "stdin_stdout", "input": "99999 100000\n", "output": "99998.41804246113\n"}, {"type": "stdin_stdout", "input": "15919 51469\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe determinant of a matrix 2 × 2 is defined as follows:\n\n<image>\n\nA matrix is called degenerate if its determinant is equal to zero. \n\nThe norm ||A|| of a matrix A is defined as a maximum of absolute values of its ...
[{"type": "stdin_stdout", "input": "1000000000 -1000000000\n1000000000 1000000000\n", "output": "1000000000.0000000001\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000\n1000000000 -1000000000\n", "output": "1000000000.0000000001\n"}, {"type": "stdin_stdout", "input": "-621967643 610314360\n-660274542 -7726...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's now 260 AD. Shapur, being extremely smart, became the King of Persia. He is now called Shapur, His majesty King of kings of Iran and Aniran.\n\nRecently the Romans declared war on Persia. They dreamed to occupy Armen...
[{"type": "stdin_stdout", "input": "17 17\n00000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "34 17\n00000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a strategic computer game \"Settlers II\" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers....
[{"type": "stdin_stdout", "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGroup of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a pla...
[{"type": "stdin_stdout", "input": "1\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100010000\n", "output": "5000\n-100000000 -99995000\n-100000000 100005000\n100000000 -99995000\n100000000 100005000\n"}, {"type": "stdin_stdout", "input": "1\n-100000000 -100000000\n-100000000 100000000\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.\n\nFilya is given an array of non-negative integers a1, a2, ..., an. First, h...
[{"type": "stdin_stdout", "input": "10\n1 1 1 1 1 2 2 2 2 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 1 1 3 2 2 2 2\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2\n100000001 100000003\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "3\n99999999 1 50000000\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph.\n\nThere are n vertices in the tree, each of them is painted black or white. Anton doesn't like multicolored tre...
[{"type": "stdin_stdout", "input": "42\n1 0 0 1 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0\n35 6\n35 39\n4 31\n31 5\n14 35\n1 2\n40 32\n35 31\n37 35\n32 38\n1 36\n3 25\n35 11\n26 35\n24 35\n3 2\n35 23\n21 1\n20 27\n16 26\n2 18\n34 39\n39 28\n3 32\n26 30\n41 7\n13 35\n1 8\n31 22\n33 21\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given the array of integer numbers a0, a1, ..., an - 1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array.\n\nInput...
[{"type": "stdin_stdout", "input": "15\n1000000000 -1000000000 -1000000000 1000000000 -1000000000 -1000000000 -1000000000 1000000000 1000000000 -1000000000 -1000000000 -1000000000 -1000000000 1000000000 0\n", "output": "14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 "}, {"type": "stdin_stdout", "input": "15\n1000000000 -1000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has several phone books, in which he recorded the telephone numbers of his friends. Each of his friends can have one or several phone numbers.\n\nVasya decided to organize information about the phone numbers of frie...
[{"type": "stdin_stdout", "input": "20\no 10 6 6 97 45 6 6 6 6 5 6\nl 8 5 5 5 19 59 5 8 5\nj 9 2 30 58 2 2 1 0 30 4\nc 10 1 1 7 51 5 7 51 1 1 1\no 9 7 97 87 70 2 19 2 14 6\nd 6 26 6 6 6 26 5\ng 9 3 3 3 3 3 78 69 8 9\nl 8 8 01 1 5 8 41 72 3\nz 10 1 2 2 2 12 1 9 1 6 7\ng 8 7 78 8 14 7 3 67 9\no 5 6 9 9 7 7\ne 10 30 2 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are...
[{"type": "stdin_stdout", "input": "10 50\nebibwbjihv\n1 10\n1 2\n5 4\n1 8\n9 7\n5 6\n1 8\n8 7\n2 6\n5 4\n1 9\n3 2\n3 3\n5 6\n5 9\n2 4\n2 7\n3 9\n1 2\n1 7\n1 10\n3 7\n1 8\n3 10\n8 6\n1 7\n10 6\n1 6\n10 8\n1 5\n2 10\n3 9\n1 8\n8 3\n3 7\n5 2\n1 10\n1 4\n5 3\n3 2\n1 2\n5 8\n10 4\n2 10\n8 2\n1 9\n1 8\n1 2\n3 4\n1 8\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s consisting of |s| small english letters.\n\nIn one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with...
[{"type": "stdin_stdout", "input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzabcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Aramic language words can only represent objects.\n\nWords in Aramic have special properties: \n\n * A word is a root if it does not contain the same letter more than once. \n * A root and all its permutations repres...
[{"type": "stdin_stdout", "input": "10\nbda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "10\ncda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\nbda bbb cda dca dda dcb bcd dcb ada edd\n", "output": "6\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBubli and shivani are in lab. Bubli wants to send a message to shivani. But he can't send it directly. Bubli is on 1st computer and shivani is on the nth computer. Now the computer's are connected in a chain. 1st is conne...
[{"type": "stdin_stdout", "input": "1234\n14 6497127\n28 4107028\n24 8965184\n17 8442797\n10 3146702\n3 5796012\n21 5012444\n24 9797639\n1 7827747\n23 8199001\n12 7447657\n28 6539086\n3 812859\n3 6253636\n8 3992704\n50 2462811\n13 2925875\n30 8615640\n14 2765241\n2 5272891\n10 2172222\n22 6265912\n15 5451882\n9 5990581...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJames has decided to take a break from his work. He makes a plan to visit India for a few days with his family. He knows a lot about India, and also about the various cities he could visit. He decides to write down all th...
[{"type": "stdin_stdout", "input": "47\n100\n1\n2\n7\n4\n5\n12\n9\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n21\n19\n27\n20\n20\n20\n20\n20\n34\n20\n20\n20\n21\n22\n32\n24\n25\n26\n46\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37", "output": "976371284\n1\n3\n127\n15\n31\n4095\n511\n255\n511\n1023\n2047\n4095\n8191\n16383\n32767...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\...
[{"type": "stdin_stdout", "input": "200000 0000001000", "output": "525127456\n"}, {"type": "stdin_stdout", "input": "200000 0000001001", "output": "578341203\n"}, {"type": "stdin_stdout", "input": "200000 0001001001", "output": "607923868\n"}, {"type": "stdin_stdout", "input": "140753 0011001000", "output": "810481869\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.\n\nIf we place...
[{"type": "stdin_stdout", "input": "100 100 4270", "output": "600569999\n"}, {"type": "stdin_stdout", "input": "100 110 5000", "output": "369906225\n"}, {"type": "stdin_stdout", "input": "100 111 5000", "output": "836863849\n"}, {"type": "stdin_stdout", "input": "110 101 1184", "output": "502440414\n"}, {"type": "stdin...
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\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacen...
[{"type": "stdin_stdout", "input": "120 3210", "output": "4772385\n"}, {"type": "stdin_stdout", "input": "118 3210", "output": "4778568\n"}, {"type": "stdin_stdout", "input": "118 2165", "output": "2093963\n"}, {"type": "stdin_stdout", "input": "118 2837", "output": "3695003\n"}, {"type": "stdin_stdout", "input": "118 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc.\n\nA Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\\leq i\\leq N-1) connects Vertex...
[{"type": "stdin_stdout", "input": "10\n1 2\n1 3\n1 4\n2 5\n6 10\n6 7\n7 8\n4 9\n10 5", "output": "2 6\n"}, {"type": "stdin_stdout", "input": "10\n1 2\n1 3\n3 4\n2 5\n6 5\n6 7\n7 8\n5 9\n10 5", "output": "2 5\n"}, {"type": "stdin_stdout", "input": "10\n1 2\n1 3\n3 4\n2 5\n7 5\n6 7\n7 8\n5 9\n10 5", "output": "3 5\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the sam...
[{"type": "stdin_stdout", "input": "10\n1000 193 256 777 -1 3 2173 4898286181422 34 221", "output": "4898286186026\n"}, {"type": "stdin_stdout", "input": "10\n1000 193 256 777 -2 3 1355 4898286181422 34 224", "output": "4898286185212\n"}, {"type": "stdin_stdout", "input": "10\n1000 193 256 777 -2 3 2159 4898286181422 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,...
[{"type": "stdin_stdout", "input": "7 3\n1 6\n4 7\n3 4\n4 5\n1 12\n0 10\n6 14", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 3\n1 6\n1 7\n3 4\n4 5\n1 12\n0 10\n6 14", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 3\n1 6\n3 7\n3 4\n4 5\n1 12\n5 6\n6 14", "output": "0\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.\n\nMr. Takahashi, the shop owner, has decided on the followi...
[{"type": "stdin_stdout", "input": "15\n4\n1\n4\n1\n3\n18\n4\n12\n5\n3\n6\n8\n15\n12\n9", "output": "43\n"}, {"type": "stdin_stdout", "input": "15\n4\n1\n4\n1\n3\n18\n4\n12\n5\n3\n3\n8\n15\n12\n9", "output": "42\n"}, {"type": "stdin_stdout", "input": "15\n4\n1\n4\n1\n3\n31\n4\n8\n5\n3\n6\n8\n15\n7\n9", "output": "46\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider creating the following number pattern.\n\n\n4 8 2 3 1 0 8 3 7 6\n2 0 5 4 1 8 1 0 3\n2 5 9 5 9 9 1 3\n7 4 4 4 8 0 4\n1 8 8 2 8 4\n9 6 0 0 2\n5 6 0 2\n1 6 2\n7 8\nFive\n\n\nThis pattern follows the rules below.\n\n...
[{"type": "stdin_stdout", "input": "4823108376\n2273064329\n0123456789", "output": "5\n1\n4\n"}, {"type": "stdin_stdout", "input": "4823108376\n2314825047\n0123456789", "output": "5\n4\n4\n"}, {"type": "stdin_stdout", "input": "4823108376\n1842094049\n0123456789", "output": "5\n0\n4\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConvenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely...
[{"type": "stdin_stdout", "input": "10 12\n6\n2 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 1\n1 1\n1 6\n5 6\n2\n0 3\n6 4\n0 0", "output": "6\n18\n"}, {"type": "stdin_stdout", "input": "10 12\n6\n1 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 2\n1 1\n1 5\n1 6\n2\n0 3\n6 4\n0 0", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nPresident K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one...
[{"type": "stdin_stdout", "input": "4 10\nWRWQW\nBWRXB\nRVWRW\nRWBWQ", "output": "32\n"}, {"type": "stdin_stdout", "input": "4 16\nWRWQW\nBWRXB\nRVWRW\nRWBWQ", "output": "56\n"}, {"type": "stdin_stdout", "input": "4 10\nWRWRW\nBRWWB\nWRWRW\nRWBVR", "output": "31\n"}, {"type": "stdin_stdout", "input": "4 14\nWRWWR\nBVRW...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.\n\nThe space station is made u...
[{"type": "stdin_stdout", "input": "3\n10.428063836405636 10.000 50.41258054211165 10.000\n40.000 10.67607738240928 53.01420883969367 10.791354692497457\n40.998260752412115 40.51646067399203 50.343828752057796 10.89540561727416\n2\n30.571866538226903 30.21421585553614 30.992025805702255 20.557461946050214\n40.000 40.89...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFast Forwarding\n\nMr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants t...
[{"type": "stdin_stdout", "input": "2139", "output": "21\n"}, {"type": "stdin_stdout", "input": "1374", "output": "22\n"}, {"type": "stdin_stdout", "input": "3723", "output": "23\n"}, {"type": "stdin_stdout", "input": "138", "output": "12\n"}, {"type": "stdin_stdout", "input": "149", "output": "13\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSkyscraper \"MinatoHarukas\"\n\nMr. Port plans to start a new business renting one or more floors of the new skyscraper with one giga floors, MinatoHarukas. He wants to rent as many vertically adjacent floors as possible,...
[{"type": "stdin_stdout", "input": "15\n27\n3\n5\n14453855\n142729211\n251672118\n560550970\n979553853\n999999999\n0", "output": "1 5\n2 6\n1 2\n2 2\n111119 130\n801761 178\n11923 13484\n4003866 140\n7523 37374\n163837 5994\n"}, {"type": "stdin_stdout", "input": "15\n16\n3\n3\n9699690\n237086004\n847288609\n900660121\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTraining is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.\n\nToday's training is to gain dexterity that never mistypes by carefully stacking blocks...
[{"type": "stdin_stdout", "input": "3\n10 40\n15 40\n20 30", "output": "110\n"}, {"type": "stdin_stdout", "input": "3\n10 40\n15 40\n40 30", "output": "120\n"}, {"type": "stdin_stdout", "input": "3\n10 40\n15 40\n20 32", "output": "112\n"}, {"type": "stdin_stdout", "input": "3\n10 36\n15 40\n20 32", "output": "108\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe unlucky Ikta-kun has rewritten the important character string T that he had to a different character string T'by the virus. It is known that the virus has rewritten one letter of T to a different letter. That is, T an...
[{"type": "stdin_stdout", "input": "aaaaaa\naaaaab", "output": "1\n"}, {"type": "stdin_stdout", "input": "aaaaaa\nbbaaaa", "output": "0\n"}, {"type": "stdin_stdout", "input": "aaaaaa\nbaaaaa", "output": "1\n"}, {"type": "stdin_stdout", "input": "aaaaaa\nbbaa`a", "output": "0\n"}, {"type": "stdin_stdout", "input": "aaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nGiven the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence:\n\n* $ 1 \\ leq i \\ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $...
[{"type": "stdin_stdout", "input": "5\n2 10 5 22 4", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 6 7 31 10", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n1 8 7 31 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2 10 5 22 8", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nHere is a list of strings. Let's take a break and play with shiritori. Shiritori is performed according to the following rules.\n\n1. First of all, select one of your favorite strings from the list and exclude ...
[{"type": "stdin_stdout", "input": "7\nshf\nslldr\nsea\nshells\nyb\nteh\nsaeshore", "output": "a\nb\ne\nf\nh\nr\n"}, {"type": "stdin_stdout", "input": "7\nshf\nsller\nsae\nshells\nby\nteh\nsfeshora", "output": "a\ne\nf\nh\nr\ny\n"}, {"type": "stdin_stdout", "input": "7\nshg\nsller\nsae\nshells\nby\nteh\nsfeshora", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA binary search tree can be unbalanced depending on features of data. For example, if we insert $n$ elements into a binary search tree in ascending order, the tree become a list, leading to long search times. One of strat...
[{"type": "stdin_stdout", "input": "16\ninsert 21 99\ninsert 3 80\ninsert 1 12\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 141 47\ninsert 26 6\ninsert 12 10\ninsert 6 139\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint", "output": " 1 3 6 12 14 21 26 42 80 141\n 6 3 1 21 14 12 80 26 42 141\nyes\nno\n 1 3 6 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a dynamic list $L$ of integers, perform a sequence of the following operations. $L$ has a special element called END at the end of the list and an element of $L$ is indicated by a cursor.\n\n* insert($x$): Insert $x$ ...
[{"type": "stdin_stdout", "input": "5\n0 -1\n0 0\n0 2\n0 -1\n1", "output": "-1\n2\n0\n-1\n"}, {"type": "stdin_stdout", "input": "5\n0 1\n0 0\n0 1\n0 -1\n1", "output": "-1\n1\n0\n1\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n0 0\n0 1\n0 -1\n1", "output": "-1\n1\n0\n0\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef loves palindromes. Chef initially has odd number of charachters. Chef wants to create a palindrome of maximum even length using these characters.\nFor this Chef needs to discard one character. Help Chef find the char...
[{"type": "stdin_stdout", "input": "2\n7\nacdbcba\n3\nabb", "output": "d\na\n"}, {"type": "stdin_stdout", "input": "2\n1\nacdbcaa\n3\nbba", "output": "a\na\n"}, {"type": "stdin_stdout", "input": "2\n1\nbcdacaa\n3\nbbb", "output": "b\nb\n"}, {"type": "stdin_stdout", "input": "2\n1\n`bcdaca\n3\nbba", "output": "`\na\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array d_1, d_2, ..., d_n consisting of n integer numbers.\n\nYour task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly ...
[{"type": "stdin_stdout", "input": "5\n2 3 5 4 10\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n1000000100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 15 4 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaving watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he ...
[{"type": "stdin_stdout", "input": "156161456146164104103460452045416165146141414651641564105461465156445621465146514562146145465165145145614561465145614561\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1035582652791945409199994791047369985911446143541282263853565235001365759340472951643698773718261928078951...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of all integers from l to r inclusive, l < r, (r - l + 1) ≤ 3 ⋅ 10^5 and (r - l) is always odd.\n\nYou want to split these numbers into exactly (r - l + 1)/(2) pairs in such a way that for each pair (i...
[{"type": "stdin_stdout", "input": "804212830686677670 804212830686679109\n", "output": "YES\n804212830686677670 804212830686677671\n804212830686677672 804212830686677673\n804212830686677674 804212830686677675\n804212830686677676 804212830686677677\n804212830686677678 804212830686677679\n804212830686677680 804212830686...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0, 0). Robot can perform the following four kinds of operations: \n\n * U — move from (x, y) to (x, y + 1); \n * D — move fr...
[{"type": "stdin_stdout", "input": "386\nRUDLURLUURDDLLLRLDURLRRDLDUUURLLRDLRRDLDRLDDURDURURDRLUULLDUULRULDLLLLDLUURRLRRRUDULRDDRDLDULRLDDRDDRLRLDLDULLULUDULLLDUUDURURDDLDRLUDDDDLDUDUURLUUDURRUDRLUDRLULLRLRRDLULDRRURUULLRDLDRLURDUDRLDLRLLUURLURDUUDRDURUDDLLDURURLLRRULURULRRLDLDRLLUUURURDRRRLRDRURULUDURRLRLDRUDLRRRRLLRU...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a line of n colored squares in a row, numbered from 1 to n from left to right. The i-th square initially has the color c_i.\n\nLet's say, that two squares i and j belong to the same connected component if c_...
[{"type": "stdin_stdout", "input": "93\n2805 3621 1888 921 2394 2426 3424 739 4404 1923 2043 1106 305 788 546 1396 2252 4915 1857 1833 2601 3148 1768 1079 893 4669 1939 1231 1019 4578 3202 3645 352 4730 2074 1251 736 168 1377 4630 1542 3083 222 2864 1 4838 1319 1037 4297 552 304 2638 3278 518 4563 513 4313 4620 4907 49...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...\n\nWhat the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their fr...
[{"type": "stdin_stdout", "input": "1000 843\n", "output": "157\n"}, {"type": "stdin_stdout", "input": "1000 488\n", "output": "488\n"}, {"type": "stdin_stdout", "input": "1000 733\n", "output": "267\n"}, {"type": "stdin_stdout", "input": "571 402\n", "output": "169\n"}, {"type": "stdin_stdout", "input": "543 110\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne important contest will take place on the most famous programming platform (Topforces) very soon!\n\nThe authors have a pool of n problems and should choose at most three of them into this contest. The prettiness of th...
[{"type": "stdin_stdout", "input": "1\n37\n166320 83160 41580 33264 27720 23760 20790 18480 16632 15120 13860 11880 11088 10395 9240 10676 7920 7560 6930 6160 5940 9910 5040 4752 4620 4158 3960 3780 3696 3465 3080 3024 2970 2772 2640 29 23\n", "output": "186906\n"}, {"type": "stdin_stdout", "input": "1\n37\n166320 8316...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA class of students wrote a multiple-choice test.\n\nThere are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each questio...
[{"type": "stdin_stdout", "input": "10 10\nCBBBBBBBBB\nABBBBEBBBB\nBDBBBBBBBB\nBCBBBBBBBB\nBABBBBBEBB\nEBBBBBBBBB\nBBBCBDCBBB\nBEBBEBBBBB\nBBBBBBBBBB\nBBBDBBBACB\n840 678 490 153 1118 84 256 405 468 856\n", "output": "45122\n"}, {"type": "stdin_stdout", "input": "10 10\nCBBBBBBBBB\nABBBBEBBBB\nBDBBBBBBBB\nBBBBBBBBBB\nB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUjan decided to make a new wooden roof for the house. He has n rectangular planks numbered from 1 to n. The i-th plank has size a_i × 1 (that is, the width is 1 and the height is a_i).\n\nNow, Ujan wants to make a square ...
[{"type": "stdin_stdout", "input": "10\n1\n1\n2\n2 1\n3\n3 1 2\n3\n2 2 2\n4\n4 1 4 2\n5\n5 4 3 4 1\n5\n1 2 3 4 5\n6\n3 2 1 6 2 2\n10\n4 5 2 9 6 10 3 7 1 8\n10\n1 3 2 2 2 9 10 10 9 10\n", "output": "1\n1\n2\n2\n2\n3\n3\n2\n5\n5\n"}, {"type": "stdin_stdout", "input": "10\n1\n1\n2\n2 1\n3\n3 1 2\n3\n2 2 2\n4\n4 1 4 1\n5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer array a_1, a_2, ..., a_n, where a_i represents the number of blocks at the i-th position. It is guaranteed that 1 ≤ a_i ≤ n. \n\nIn one operation you can choose a subset of indices of the given ar...
[{"type": "stdin_stdout", "input": "100\n27 23 70 25 25 28 76 32 8 16 94 5 91 13 46 83 58 18 86 16 50 48 68 41 20 15 14 53 59 58 93 40 29 42 32 73 46 31 49 80 68 80 57 88 17 60 33 8 6 64 100 6 34 35 23 58 100 3 93 59 87 67 28 14 100 13 45 16 94 95 23 21 37 35 44 52 57 28 85 74 90 2 42 37 22 9 20 32 18 69 20 76 65 51 96...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sequence a = [a_1, a_2, …, a_l] of length l has an ascent if there exists a pair of indices (i, j) such that 1 ≤ i < j ≤ l and a_i < a_j. For example, the sequence [0, 2, 0, 2, 0] has an ascent because of the pair (1, 4...
[{"type": "stdin_stdout", "input": "10\n3 62 24 39\n1 17\n1 99\n1 60\n1 64\n1 30\n2 79 29\n2 20 73\n2 85 37\n1 100\n", "output": "72\n"}, {"type": "stdin_stdout", "input": "5\n5 1 2 2 4 5\n4 -1 2 3 6\n3 3 2 1\n2 3 1\n1 0\n", "output": "22\n"}, {"type": "stdin_stdout", "input": "5\n5 1 2 3 4 5\n4 1 2 3 4\n3 3 2 1\n2 2 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a bag of size n. Also you have m boxes. The size of i-th box is a_i, where each a_i is an integer non-negative power of two.\n\nYou can divide boxes into two parts of equal size. Your goal is to fill the bag comp...
[{"type": "stdin_stdout", "input": "3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8\n", "output": "2\n-1\n0\n"}, {"type": "stdin_stdout", "input": "3\n14 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 2 8\n", "output": "3\n-1\n0\n"}, {"type": "stdin_stdout", "input": "3\n16 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou wrote down all integers from 0 to 10^n - 1, padding them with leading zeroes so their lengths are exactly n. For example, if n = 3 then you wrote out 000, 001, ..., 998, 999.\n\nA block in an integer x is a consecutiv...
[{"type": "stdin_stdout", "input": "2352\n", "output": "388795058 433322746 541969001 523323201 867893102 537695799 837561050 990678065 688882179 577079614 937069914 960273782 761665782 282484628 787581089 314410468 983373531 353249698 130693309 82500826 144964998 247781749 108001361 947489703 358119467 770902487 73956...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArthur owns a ski resort on a mountain. There are n landing spots on the mountain numbered from 1 to n from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. All tracks go towar...
[{"type": "stdin_stdout", "input": "2\n4 6\n1 2\n1 3\n2 3\n2 4\n3 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n", "output": "2\n3 4 \n4\n4 5 6 7 \n"}, {"type": "stdin_stdout", "input": "2\n4 6\n1 2\n1 3\n2 3\n2 4\n1 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n", "output": "2\n3 4\n4\n4 5 6 7\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs Gerald sets the table, Alexander sends the greeting cards, and Sergey and his twins create an army of clone snowmen, Gennady writes a New Year contest.\n\nThe New Year contest begins at 18:00 (6.00 P.M.) on December 31...
[{"type": "stdin_stdout", "input": "100\n46 353 325 357 342 31 186 689 447 377 484 297 517 92 408 336 389 651 346 464 521 670 353 577 73 477 21 84 659 180 454 386 274 425 274 8 306 131 688 313 342 144 589 277 225 520 442 704 72 376 334 200 92 180 205 602 138 286 668 39 714 447 477 684 491 38 44 186 274 614 127 5 585 56...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNezzar's favorite digit among 1,…,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,…,a_q, for each 1 ≤ i ≤ q Nezzar would like to know if a_i ...
[{"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\nA mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, a...
[{"type": "stdin_stdout", "input": "5 5\n..*..\n.....\n**...\n**...\n**...\n", "output": "\n1\n"}, {"type": "stdin_stdout", "input": "5 5\n..*..\n.....\n)*...\n**...\n**...\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5 5\n..*..\n.....\n**...\n+*...\n**...\n", "output": "1\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a pr...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1000 1100\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1000 44\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "428 23\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "332 20\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcode...
[{"type": "stdin_stdout", "input": "4\ntfggs qnehos igekv rnmr\n10\n8 ccj ccj qnehos igekv rnmr ccj igekv qnehos\n8 rnmr igekv gydhj tfggs ccj tfggs rnmr rnmr\n8 gydhj qnehos igekv ccj tfggs gydhj qnehos ccj\n8 tfggs igekv rnmr rnmr rnmr tfggs rnmr ccj\n8 jjwek gydhj gydhj tfggs igekv igekv rnmr ccj\n8 rnmr tfggs rnmr ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTrouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point C and began to terrorize the residents of the surrounding villages.\n\nA brave hero decided to put an end to the dr...
[{"type": "stdin_stdout", "input": "-1000000000 1000000000\n-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "LEFT\n"}, {"type": "stdin_stdout", "input": "-1000000000 1000001000\n-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "LEFT\n"}, {"type": "stdin_stdout", "input": "-1000000000 10000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo villages are separated by a river that flows from the north to the south. The villagers want to build a bridge across the river to make it easier to move across the villages.\n\nThe river banks can be assumed to be ve...
[{"type": "stdin_stdout", "input": "10 20 50 60\n-96 -75 32 37 42 43 44 57 61 65\n-95 -90 -86 -79 -65 -62 -47 -11 -8 -6 1 8 23 25 32 51 73 88 94 100\n138 75 132 116 49 43 96 166 96 161 146 112 195 192 201 186 251 254 220 227\n", "output": "2 6\n"}, {"type": "stdin_stdout", "input": "10 20 50 60\n-96 -75 32 37 42 43 44 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLuyi has n circles on the plane. The i-th circle is centered at (xi, yi). At the time zero circles start to grow simultaneously. In other words, the radius of each circle at time t (t > 0) is equal to t. The circles are d...
[{"type": "stdin_stdout", "input": "40\n-6259 -9662\n-871 -6148\n5078 -4522\n4269 1750\n-1343 -9160\n4862 -7033\n2241 -6648\n-144 -6317\n2776 2075\n-7110 305\n-9860 -5853\n-3450 5665\n-7267 8475\n-5509 4145\n-7696 -802\n7432 5226\n1696 6231\n7023 -1257\n5245 7871\n6738 5332\n7317 -1594\n-3728 8160\n-5608 6610\n7920 -64...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKsusha the Squirrel is standing at the beginning of a straight road, divided into n sectors. The sectors are numbered 1 to n, from left to right. Initially, Ksusha stands in sector 1. \n\nKsusha wants to walk to the end o...
[{"type": "stdin_stdout", "input": "10 3\n..........\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 1\n..........\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 4\n..........\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "10 2\n..........\n", "output": "YES\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.\n\nUnfortunately, he has just s dollars for sugar. But that's not a rea...
[{"type": "stdin_stdout", "input": "69 9\n39 15\n70 44\n90 89\n84 58\n83 97\n24 28\n90 18\n7 96\n43 86\n99 50\n77 12\n12 34\n100 19\n21 86\n55 30\n99 29\n26 92\n82 67\n78 14\n64 16\n98 12\n31 39\n36 86\n73 36\n87 29\n42 23\n58 15\n35 52\n91 56\n39 6\n88 45\n38 36\n57 12\n79 71\n40 33\n98 42\n34 36\n23 79\n69 68\n50 47\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe next \"Data Structures and Algorithms\" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.\n\nNam created...
[{"type": "stdin_stdout", "input": "100\n102 157 177 149 138 193 19 74 127 156 128 122 6 101 154 92 24 188 51 89 18 77 112 100 65 11 113 173 79 124 102 81 11 171 114 43 60 168 44 86 87 82 177 8 12 181 139 121 140 28 108 17 173 63 18 4 148 125 117 153 193 180 188 142 46 75 163 126 128 22 32 163 164 1 161 19 162 59 190 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe commanding officers decided to drop a nuclear bomb on the enemy's forces. You are ordered to determine the power of the warhead that needs to be used.\n\nThe enemy has N strategically important objects. Their position...
[{"type": "stdin_stdout", "input": "76\n35 639\n-2 0\n-1 -2\n-2 -7\n4 0\n-6 -7\n8 3\n2 4\n8 6\n6 6\n7 8\n-2 6\n9 8\n9 2\n4 8\n-5 2\n2 -3\n-5 1\n0 9\n-7 -5\n4 -3\n0 -9\n-1 5\n-9 4\n9 0\n-2 0\n5 -4\n5 4\n-7 4\n4 7\n0 5\n8 -3\n-1 -9\n4 -3\n-5 -4\n3 -1\n-6 -5\n3 4\n0 5\n1 -4\n-1 7\n-3 5\n9 -7\n7 -2\n-9 -8\n4 1\n4 9\n-6 -7\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k - 1 hassoсks (clockwise). For example, after the first minute the flea jumps to the neighbori...
[{"type": "stdin_stdout", "input": "1000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "512\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "256\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "512\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n", "output": "NO\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has n mandatory quests. To perform each of them, you need to take exactly two companions.\n...
[{"type": "stdin_stdout", "input": "25\n26668 10412 12658\n25216 11939 10247\n28514 22515 5833\n4955 19029 22405\n12552 6903 19634\n12315 1671 505\n20848 9175 6060\n12990 5827 16433\n9184 30621 25596\n31818 7826 11221\n18090 4476 30078\n30915 11014 16950\n3119 29529 21390\n775 4290 11723\n29679 14840 3566\n4491 29480 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of round brackets since Famil Door loves string of brackets of length n...
[{"type": "stdin_stdout", "input": "1980 464\n))(()()))(((((((((()))))))(()(((()((()))()()())()))()))(()))))))(())((())))()())()((())())()())))(())()(()))(()())()((((()))())()(())))))(()()(()(((((()(()()))(((()))(())))))()())(())))))())()()((())))))))((()(())))))()()(()((()((()()))(()))(())(()))()((((())()()))))))()(()...
code_stdio