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\nYou are given a string $s$ consisting of $n$ lowercase Latin letters. $n$ is even.\n\nFor each position $i$ ($1 \\le i \\le n$) in string $s$ you are required to change the letter on this position either to the previous l... | [{"type": "stdin_stdout", "input": "50\n6\nbxyxcz\n4\nzzcy\n2\nzb\n2\nyb\n6\nzzbxyx\n4\nbxzb\n4\naaca\n4\nbzyx\n4\nxaac\n2\nbb\n2\nzb\n6\ncabcbb\n6\nyxzbbb\n2\nxz\n2\ncc\n6\nazcaza\n4\nyyaa\n2\nxb\n2\nyb\n6\nzaxxxz\n4\nbyab\n4\naxxz\n2\nay\n2\nyb\n2\ncx\n4\nzyab\n6\nybcyya\n6\nxayzaz\n4\nzacx\n6\nzzyxbz\n2\ncc\n4\nbycx... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor the multiset of positive integers s=\\\\{s_1,s_2,...,s_k\\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow:\n\n * \\gcd(s) is the maximum positive integer x, such that all in... | [{"type": "stdin_stdout", "input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"type": "stdin_stdout", "input": "10\n61 1677 535 769 324 1309 1589 243 324 184\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10\n61 1677 535 769 627 1309 1589 243 324 184\n", "output": "1\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNatasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string ... | [{"type": "stdin_stdout", "input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "169\n"}, {"type": "stdin_stdout", "input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "169"}, {"type": "stdin_stdout", "input": "50 31\nahbyyoxltryqdmvenemaqnbakglgqolxnaifnqtoclnnq... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L,... | [{"type": "stdin_stdout", "input": "10\n5 4\n5 7\n-1 13\n0 9\n12 10\n4 11\n7 4\n11 10\n7 4", "output": "152\n"}, {"type": "stdin_stdout", "input": "10\n5 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4\n6 3\n7 3", "output": "187\n"}, {"type": "stdin_stdout", "input": "10\n5 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4\n6 5\n7 3", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. H... | [{"type": "stdin_stdout", "input": "2000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA country decides to build a palace.\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\nThere are N places proposed for the place. The elevation of Plac... | [{"type": "stdin_stdout", "input": "1000\n20 -20\n51765 34765 54644 24887 70030 45034 46376 88410 33772 52941 79750 44783 70874 36236 36651 16147 23251 11281 36605 69084 74679 18310 88655 92253 0 76064 82769 20419 60361 61197 51619 35110 6063 82815 99426 22379 61759 34008 31814 22642 80907 10203 11864 18291 34343 35250... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. \n\nSimply speaking, the process of taking photos can be described as follows. On the photo... | [{"type": "stdin_stdout", "input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n", "output": "90000 90000 90000 90000 90000 90000 90000 90000 90000 90000 "}, {"type": "stdin_stdout", "input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as M... | [{"type": "stdin_stdout", "input": "5\n12 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n2 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n2 -1 -1 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n4 -1 -1 -2 -2", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNeko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys... | [{"type": "stdin_stdout", "input": "1000\n", "output": "143886430\n"}, {"type": "stdin_stdout", "input": "450\n", "output": "690479399\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "742390865\n"}, {"type": "stdin_stdout", "input": "900\n", "output": "454329300\n"}, {"type": "stdin_stdout", "input": "500\n",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSimon has a prime number x and an array of non-negative integers a_1, a_2, ..., a_{n}.\n\nSimon loves fractions very much. Today he wrote out number $\\frac{1}{x^{a} 1} + \\frac{1}{x^{a_{2}}} + \\ldots + \\frac{1}{x^{a_{n... | [{"type": "stdin_stdout", "input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLike any unknown mathematician, Yuri has favourite numbers: $A$, $B$, $C$, and $D$, where $A \\leq B \\leq C \\leq D$. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides $x... | [{"type": "stdin_stdout", "input": "86565 229134 356183 486713\n", "output": "1559833368660730\n"}, {"type": "stdin_stdout", "input": "90528 225462 336895 417903\n", "output": "1043176084391535\n"}, {"type": "stdin_stdout", "input": "178561 294901 405737 476436\n", "output": "911664147520700\n"}, {"type": "stdin_stdout... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are playing a variation of game 2048. Initially you have a multiset $s$ of $n$ integers. Every integer in this multiset is a power of two. \n\nYou may perform any number (possibly, zero) operations with this multiset.... | [{"type": "stdin_stdout", "input": "6\n4\n1024 512 64 512\n1\n2048\n3\n128 512 2\n2\n4096 8\n1\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4898\n", "output": "YES\nYES\nNO\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nConstraints\n\n* 1 ≤ a, b ≤ 100\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\n... | [{"type": "stdin_stdout", "input": "-10 2", "output": "-20 -16\n"}, {"type": "stdin_stdout", "input": "-16 -2", "output": "32 -36\n"}, {"type": "stdin_stdout", "input": "-16 -1", "output": "16 -34\n"}, {"type": "stdin_stdout", "input": "-16 1", "output": "-16 -30\n"}, {"type": "stdin_stdout", "input": "4 122", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two positive integers $a$ and $b$.\n\nIn one move, you can change $a$ in the following way:\n\n Choose any positive odd integer $x$ ($x > 0$) and replace $a$ with $a+x$; choose any positive even integer $y... | [{"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 4\n7 4\n9 3\n", "output": "1\n0\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 4\n4 4\n9 3\n", "output": "1\n0\n2\n0\n1\n"}, {"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 7\n4 4\n9 3\n", "output": "1\n0\n1\n0\n1\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVlad went into his appartment house entrance, now he is on the $1$-th floor. He was going to call the elevator to go up to his apartment.\n\nThere are only two elevators in his house. Vlad knows for sure that:\n\nthe firs... | [{"type": "stdin_stdout", "input": "69\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with 3 rows and N columns. The cell at the i-th row and j-th column is denoted (i, j). Initially, each cell (i, j) contains the integer i+3j-3.\n\n<image>\n\nA grid with N=5 columns\n\nSnuke can perform the... | [{"type": "stdin_stdout", "input": "7\n21 12 1 16 14 6 10\n20 11 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"type": "stdin_stdout", "input": "7\n21 12 1 16 14 6 10\n20 12 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"type": "stdin_stdout", "input": "7\n21 12 1 16 12 6 10\n20 12 0 27 14 7 8\n19 10 3 18... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).\n\nYour task ... | [{"type": "stdin_stdout", "input": "1000000000 1000000000 286536427 579261823 230782719 575570138\n", "output": "171145067 291476754 401927786 867046892\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 623214043 753726318 970868535 929707704\n", "output": "29131465 70292296 1000000000 1000000000\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you c... | [{"type": "stdin_stdout", "input": "100\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "11\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "40\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "12\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "Yes\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInnovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!\n\nA restaurant called \"Dijkstra's Place\" has started thinking about optimizing the booking system.... | [{"type": "stdin_stdout", "input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431 425 227 147 153 170 954 757 222 759\n", "output": "6 3621\n6 2\n2 8\n9 7\n4 1\n7 10\n5 4\n"}, {"type": "stdin_stdout", "input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree with $n$ vertices. You are allowed to modify the structure of the tree through the following multi-step operation: Choose three vertices $a$, $b$, and $c$ such that $b$ is adjacent to both $a$ and $c... | [{"type": "stdin_stdout", "input": "15\n4 6\n8 4\n12 11\n7 6\n9 8\n5 1\n14 13\n6 13\n1 4\n1 2\n6 11\n10 8\n15 14\n3 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "15\n4 6\n8 4\n12 11\n7 6\n9 8\n5 1\n14 13\n6 13\n1 4\n1 2\n6 11\n10 8\n15 14\n3 1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "15\n9 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian \n\nChef is going to participate in a new quiz show: \"Who dares to be a millionaire?\"\nAccording to the rules of the game, contestants must answer N questions. ... | [{"type": "stdin_stdout", "input": "3\n5\nABCDE\nEBCDA\n1 10 34 18 78 225\n4\nCHEE\nQUIZ\n15 3 3 1 0\n8\nABBABAAB\nABABABAB\n100 100 100 100 001 001 000 000 000", "output": "34\n15\n100\n"}, {"type": "stdin_stdout", "input": "3\n5\nABCDE\nEBCDA\n1 10 34 18 63 225\n4\nCHEE\nQUIZ\n15 3 3 1 0\n8\nABBABAAB\nABABABAB\n100 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nUnary is a minimalistic Brainfuck dialect in which programs are written using only one token. \n\nBrainfuck programs use 8 commands: \"+\", \"-\", \"[\", \"]\", \"<\", \">\", \".\" and \",\" (their meaning is not importan... | [{"type": "stdin_stdout", "input": ",]+>.],,+->+>-[]][><,-]><]++<.,-[.>.<+.[.<,[-,,[<]+>]->>]>]-+-+<][].,.]+][[<,-.+][+<<-+.],,,<,.]-].-\n", "output": "859903\n"}, {"type": "stdin_stdout", "input": ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", "output": "20887... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n. \n\nThere are n directed roads in the Udayland. i-th of them goes from town i to ... | [{"type": "stdin_stdout", "input": "84\n2 50 67 79 71 45 43 40 57 20 25 8 60 47 52 10 37 23 1 28 22 26 3 42 11 63 61 68 49 32 55 18 5 24 31 70 66 27 38 41 54 12 65 51 15 34 30 35 77 74 21 62 33 16 81 14 19 48 80 73 69 78 39 6 76 46 75 72 84 29 58 59 13 17 82 9 83 4 36 56 53 7 64 44\n", "output": "428380105\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice has a cute cat. To keep her cat fit, Alice wants to design an exercising walk for her cat! \n\nInitially, Alice's cat is located in a cell $(x,y)$ of an infinite grid. According to Alice's theory, cat needs to move:... | [{"type": "stdin_stdout", "input": "6\n3 2 2 2\n0 0 -2 -2 2 2\n3 1 4 1\n0 0 -1 -1 1 1\n1 1 1 1\n1 1 1 1 1 1\n0 0 0 1\n0 0 0 0 0 1\n5 1 1 1\n0 0 -100 -100 0 100\n1 1 5 1\n0 0 -100 -100 100 0\n", "output": "Yes\nNo\nNo\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n3 2 2 2\n0 1 -2 -2 2 2\n3 1 4 1\n0 0 -1 -1 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBizon the Champion isn't just attentive, he also is very hardworking.\n\nBizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent ... | [{"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 1 2 3 4 2 3 4 5 5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so i... | [{"type": "stdin_stdout", "input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n0 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n1 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\n1 3 3\n2\n1 2\n1 3\n\n\nOutput\n\n5\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem... | [{"type": "stdin_stdout", "input": "3\n0 2 0\n-1\n1 2\n0 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 2 0\n-1\n1 2\n0 1", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1 1 0\n0\n1 2\n-1 1", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 1 1\n0\n2 1\n-1 1", "output": "3\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBarney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the... | [{"type": "stdin_stdout", "input": "85\n1 1 2 2 4 6 1 3 6 3 3 11 9 14 12 5 8 11 16 19 12 17 2 19 1 24 6 2 6 6 24 3 20 1 1 1 17 8 4 25 31 32 39 12 35 23 31 26 46 9 37 7 5 23 41 41 39 9 11 54 36 54 28 15 25 58 56 18 23 70 68 18 3 48 57 70 15 65 22 35 25 13 49 34\n", "output": "1.00000000 28.50000000 27.00000000 38.000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call beauty of an array b_1, b_2, …, b_n (n > 1) — min_{1 ≤ i < j ≤ n} |b_i - b_j|.\n\nYou're given an array a_1, a_2, … a_n and a number k. Calculate the sum of beauty over all subsequences of the array of length e... | [{"type": "stdin_stdout", "input": "52 52\n19752 66708 73109 84463 95683 96876 98503 98812 99766 99778 99913 99975 99977 99997 99997 99997 99998 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.\n\nThe game is played on the following field.\n\n<i... | [{"type": "stdin_stdout", "input": "xxo xoo xxo\nooo ooo xxx\noox oxo oxx\n\noxo oxo xxx\nxoo oxx oxo\nxxx oxx ooo\n\noxx xoo xxo\nxxx oox xox\nxxo o.o oxo\n9 6\n", "output": "xxo xoo xxo \nooo ooo xxx \noox oxo oxx \n\noxo oxo xxx \nxoo oxx oxo \nxxx oxx ooo \n\noxx xoo xxo \nxxx oox xox \nxxo o!o oxo \n\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA sequence $a = [a_1, a_2, \\ldots, a_l]$ of length $l$ has an ascent if there exists a pair of indices $(i, j)$ such that $1 \\le i < j \\le l$ and $a_i < a_j$. For example, the sequence $[0, 2, 0, 2, 0]$ has an ascent b... | [{"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": "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... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStudent Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. ... | [{"type": "stdin_stdout", "input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1010000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1010000000 498... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a frequency operation in the conversion operation of a finite number sequence. The conversion result of the sequence $ S = \\\\ {s_1, s_2, ... s_n \\\\} $ is a sequence of the same length. If the result is $ C = ... | [{"type": "stdin_stdout", "input": "10\n2 5 1 -1 3 4 27 0 -2 6\n0", "output": "2\n10 10 10 10 10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "10\n2 1 0 0 3 5 0 0 0 12\n0", "output": "3\n10 10 10 10 10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "10\n2 5 1 0 3 4 27 0 -2 10\n0", "output": "2\n8 8 8 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. \n\nTen minutes befo... | [{"type": "stdin_stdout", "input": "10 3 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 1 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 1 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n3 10\n", "output": "0\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in English, Mandarin Chinese and Russian as well. \n\nSherlock is stuck. There is a N X N grid in which some cells are empty (denoted by ‘.’), while some cells have rocks in them (denoted by ‘#’).... | [{"type": "stdin_stdout", "input": "2\n3\n#..\n..#\n#..\n3\n#.#\n#.#\n#.#", "output": "3\n0\n"}, {"type": "stdin_stdout", "input": "2\n3\n#..\n\"..\n#..\n3\n#.#\n#.#\n#.#", "output": "6\n0\n"}, {"type": "stdin_stdout", "input": "2\n3\n$..\n..#\n#..\n3\n\"-#\n#.#\n\"#.", "output": "3\n1\n"}, {"type": "stdin_stdout", "in... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer n. You have to apply m operations to it.\n\nIn a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 af... | [{"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 12\n20 136\n", "output": "764520\n12\n1015\n6\n32483\n"}, {"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 12\n38 136\n", "output": "764520\n12\n1015\n6\n46148\n"}, {"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 6\n20 136\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, a... | [{"type": "stdin_stdout", "input": "31 61 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 61 51", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 86 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "39 69 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 49 59", "output":... | 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 regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and... | [{"type": "stdin_stdout", "input": "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n()()(\n)((\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYour company was appointed to lay new asphalt on the highway of length $n$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.\n\nSkippi... | [{"type": "stdin_stdout", "input": "3\n10 1 1\n11 4 10\n1000000 1 1000100\n", "output": "10\n16\n500049499900\n"}, {"type": "stdin_stdout", "input": "3\n10 1 1\n16 4 10\n1000000 1 1000100\n", "output": "10\n18\n500049499900\n"}, {"type": "stdin_stdout", "input": "3\n10 1 1\n16 4 10\n1000001 1 1000100\n", "output": "10\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMonocarp wants to draw four line segments on a sheet of paper. He wants the $i$-th segment to have its length equal to $a_i$ ($1 \\le i \\le 4$). These segments can intersect with each other, and each segment should be ei... | [{"type": "stdin_stdout", "input": "4\n1 1 5 4\n4 16 10 4\n2 1 4 1\n100 21 54 111\n", "output": "4\n40\n2\n2100\n"}, {"type": "stdin_stdout", "input": "4\n0 5 2 4\n6 14 10 3\n2 0 5 1\n101 40 47 111\n", "output": "0\n30\n0\n4040\n"}, {"type": "stdin_stdout", "input": "4\n1 1 5 8\n4 16 10 4\n2 1 4 1\n100 21 54 111\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi is meeting up with Aoki.\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\nTakahashi will leave his house now and go straight to the place at a speed of S... | [{"type": "stdin_stdout", "input": "7202 7775 4325\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3982 4784 8417\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "2156 1932 5902\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 10000 10000\n", "output": "Yes\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIlya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer... | [{"type": "stdin_stdout", "input": "-1000000000\n", "output": "-100000000\n"}, {"type": "stdin_stdout", "input": "-1000000000\n", "output": "-100000000\n"}, {"type": "stdin_stdout", "input": "-1015555150\n", "output": "-101555510\n"}, {"type": "stdin_stdout", "input": "-1620057635\n", "output": "-162005763\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAddition is easy to calculate by hand, but if some numbers are missing, is it easy to fill in the missing numbers? For example, in the following long division, if there is a condition that the numbers 1 to 9 appear only o... | [{"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 -1 -1 -1", "output": "168"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 3 4 6", "output": "0\n"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 3 2 6", "output": "0\n"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -2 3 2 6", "output": "0\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3 3 1 2 4\n1 2\n2 3\n3 1\n\n\nOutput\n\nIMPOSSIBLE\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve ... | [{"type": "stdin_stdout", "input": "4 1 2 1 2\n1 2\n2 3\n11 0", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "8 1 2 1 2\n1 2\n2 3\n11 0", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "3 3 2 2 4\n1 2\n2 3\n3 1", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "3 3 2 1 4\n1 2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ computers in a row, all originally off, and Phoenix wants to turn all of them on. He will manually turn on computers one at a time. At any point, if computer $i-1$ and computer $i+1$ are both on, computer $i... | [{"type": "stdin_stdout", "input": "100 999999733\n", "output": "499246611\n"}, {"type": "stdin_stdout", "input": "350 999999733\n", "output": "255248393\n"}, {"type": "stdin_stdout", "input": "397 999999733\n", "output": "239189389\n"}, {"type": "stdin_stdout", "input": "398 999999733\n", "output": "875462745\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vert... | [{"type": "stdin_stdout", "input": "30\n20 2 885820291\n9 3 833676138\n21 8 969316096\n13 10 732239064\n14 12 568976928\n4 14 362005859\n4 17 46938898\n4 21 706609800\n13 4 114271135\n18 13 475446302\n20 22 582315387\n7 23 941896909\n18 7 546231774\n30 24 698675648\n30 25 13971027\n11 26 760254873\n30 27 731457744\n1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJapan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league ma... | [{"type": "stdin_stdout", "input": "6\nA 1 0 0 2 -1\nB 0 0 1 2 -1\nC 2 1 1 1 1\nD 2 0 -1 0 2\nE 2 0 0 0 0\nF 1 1 1 2 2\n4\nh 1 1 1\ng 0 2 2\nx -1 0 0\n` 0 2 2\n0", "output": "E\nD\nA\nB\nF\nC\nx\ng\n`\nh\n"}, {"type": "stdin_stdout", "input": "6\nA 1 0 0 2 -1\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 1 0 0 2\nE 2 0 -1 0 0\nF 1 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJohnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d.\n\nJohnny's truck has a ga... | [{"type": "stdin_stdout", "input": "281 12 23\n178 650197\n129 288456\n34 1664910\n43 683515\n305 957083\n103 724815\n105 308008\n252 1280706\n74 87088\n229 146026\n85 241042\n35 39127\n62 47524\n217 760274\n156 562141\n10 209057\n50 714473\n201 164128\n97 624021\n120 102709\n147 388268\n317 1546753\n190 1448117\n", "o... | 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\nWhen Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playi... | [{"type": "stdin_stdout", "input": "400\nzzzerrzrzzrozrezooreroeoeezerrzeerooereezeeererrezrororoorrzezoeerrorzrezzrzoerrzorrooerzrzeozrrorzzzzeoeereeroeozezeozoozooereoeorrzoroeoezooeerorreeorezeozeroerezoerooooeerozrrorzozeroereerozeozeoerroroereeeerzzrzeeozrezzozeoooeerzzzorozrzezrrorozezoorzzerzroeeeerorreeoezoeroe... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:\n\n* Choose an element in t... | [{"type": "stdin_stdout", "input": "8\n6\n3\n2\n1\n7\n4\n8\n5", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n6\n3\n1\n2\n5\n4\n8\n7", "output": "6\n"}, {"type": "stdin_stdout", "input": "8\n6\n3\n2\n1\n4\n7\n8\n5", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n6\n3\n2\n1\n7\n4\n5\n8", "output": "5\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn a chessboard with a width of $n$ and a height of $n$, rows are numbered from bottom to top from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. Therefore, for each cell of the chessboard, you can a... | [{"type": "stdin_stdout", "input": "1000000000000000000\n1000000000000000010 1000000000000000000\n", "output": "black\n"}, {"type": "stdin_stdout", "input": "1000000000000000000\n1100000000000000010 1000000000000000000\n", "output": "black\n"}, {"type": "stdin_stdout", "input": "1000000000000000000\n1100000000000001010... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKnights' tournaments were quite popular in the Middle Ages. A lot of boys were dreaming of becoming a knight, while a lot of girls were dreaming of marrying a knight on a white horse.\n\nIn this problem we consider one of... | [{"type": "stdin_stdout", "input": "14", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA motorcade of n trucks, driving from city «Z» to city «З», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for drivers in that tunnel. Some drive... | [{"type": "stdin_stdout", "input": "20\n7892 2 0 24\n4201 1 2 23\n3667 1 3 22\n6388 1 4 21\n2406 1 5 20\n1148 1 6 19\n3958 1 7 18\n7363 1 8 17\n9025 2 9 15\n1909 1 11 14\n73 1 12 13\n5477 2 13 11\n1869 1 15 10\n107 1 16 9\n523 1 17 8\n6589 2 18 6\n6277 2 20 4\n3881 1 22 3\n5771 1 23 2\n622 2 24 0\n", "output": "20\n1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\\\[ b = \\left( \\be... | [{"type": "stdin_stdout", "input": "3 4\n1 4 -2 1\n0 3 0 -1\n4 1 0 0\n0\n-2\n3\n0", "output": "-14\n-6\n-2\n"}, {"type": "stdin_stdout", "input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 2 0\n1\n1\n3\n-1", "output": "-32\n-1\n12\n"}, {"type": "stdin_stdout", "input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 2 0\n1\n2\n3\n-1", "output": "-25... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other... | [{"type": "stdin_stdout", "input": "9992164445234764941\n8162963574901971597\n", "output": "914600435166396672 9077564010068368269"}, {"type": "stdin_stdout", "input": "1367480970723947\n584615739735395\n", "output": "391432615494276 976048355229671"}, {"type": "stdin_stdout", "input": "339671107814\n208405902980\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty).\n\nYou may perform the following operations until both a and s are empty:\n\n Take the first element of a, push it int... | [{"type": "stdin_stdout", "input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9 12\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subseq... | [{"type": "stdin_stdout", "input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n", "output": "463\n"}, {"type": "stdin_stdout", "input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n", "output": "463\n"}, {"type": "stdin_stdout", "input": "vvovooovovvovoovoovvvvovovvvov\n", "output": "100\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStudents of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to n. Eac... | [{"type": "stdin_stdout", "input": "10\n9 10 6 8 5 3 1 7 4 2\n7 6 2 9 5 10 8 4 1 3\n", "output": "8 3 10 1 5 2 4 9 7 6 "}, {"type": "stdin_stdout", "input": "10\n2 9 1 7 6 8 5 4 10 3\n6 8 5 1 9 10 2 3 4 7\n", "output": "5 6 7 3 2 9 1 10 8 4 "}, {"type": "stdin_stdout", "input": "10\n5 9 7 1 4 10 3 6 2 8\n8 3 9 10 6 5 2... | 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\nYou are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positio... | [{"type": "stdin_stdout", "input": "5\naabbc", "output": "17\n"}, {"type": "stdin_stdout", "input": "5\nabcda", "output": "23\n"}, {"type": "stdin_stdout", "input": "5\nbdacf", "output": "31\n"}, {"type": "stdin_stdout", "input": "5\nabcaa", "output": "15\n"}, {"type": "stdin_stdout", "input": "5\nabbaa", "output": "11... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq... | [{"type": "stdin_stdout", "input": "4347\n260851 113568 146755 277208 291368 365593 306158 216020 344668 347475 275144 352224 284362 117882 195739 364750 445348 416819 269652 99635 82915 80392 51627 75388 237943 322687 343290 419290 298882 162789 250158 343046 283281 278723 215017 105840 263209 271290 119076 276553 322... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the maximum value of $n$.\n\nYou are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equ... | [{"type": "stdin_stdout", "input": "100\n2\n8\n5\n6\n5\n4\n4\n6\n12\n2\n9\n5\n10\n8\n4\n10\n9\n6\n9\n4\n5\n6\n4\n4\n7\n1\n2\n2\n5\n6\n1\n5\n10\n9\n10\n16\n3\n2\n2\n3\n2\n7\n9\n2\n9\n5\n7\n8\n1\n5\n2\n5\n1\n3\n8\n4\n7\n9\n3\n1\n7\n1\n2\n4\n7\n2\n7\n1\n1\n10\n8\n5\n7\n12\n10\n8\n1\n7\n5\n10\n7\n6\n6\n6\n7\n4\n9\n3\n4\n9\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSeveral days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.\n\nYour house has $n$ rooms. In the... | [{"type": "stdin_stdout", "input": "69\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 15\n2 6\n2 6\n2 6\n2 6\n2 6\n2 11\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 7\n2 11\n2 6\n2 6\n2 6\n2 6\n4 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTaro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other... | [{"type": "stdin_stdout", "input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\n1\n4 5\n10\n-1\n3\n11\n1\n9\n6\n0\n1\n7 4\n1\n0\n4\n0\n2\n1\n4\n4\n2\n1\n-1\n2 3\n0\n1\n2\n4\n2\n0 0", "output": "-1\n2 2\n3 0\n2 -1\n-1\n"}, {"type": "stdin_stdout", "input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.\n\nRuling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's p... | [{"type": "stdin_stdout", "input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 11\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n\n"}, {"type": "stdin_stdout", "input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a frog living in a big pond. He loves jumping between lotus leaves floating on the pond. Interestingly, these leaves have strange habits. First, a leaf will sink into the water after the frog jumps from it. Secon... | [{"type": "stdin_stdout", "input": "10 10\n.o....o...\no.oo......\n..oo..oo..\n..o.......\n..oo..oo..\n.o.o...o..\no..U.o....\noo......oo\noo........\noo..oo....", "output": "RDLLLURUUURDDLLUURRDDLULLDDRR\n"}, {"type": "stdin_stdout", "input": "10 10\n.o....o...\no.oo......\n..oo..oo..\n..o.......\n..oo..oo..\n..o...o.... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven any integer x, Aoki can do the operation below.\nOperation: Replace x with the absolute difference of x and K.\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki ... | [{"type": "stdin_stdout", "input": "999999482938498888 1000000000000000000\n", "output": "517061501112\n"}, {"type": "stdin_stdout", "input": "34439284758432890 4389039281938432\n", "output": "673029497074566\n"}, {"type": "stdin_stdout", "input": "542309233112233445 542309233112233445\n", "output": "0\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSince you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.\n\nYou are given an array a of length n and an integer c. \n\nThe value of some array b of length k is the s... | [{"type": "stdin_stdout", "input": "100 20\n9149 9142 7686 5769 1871 4565 5670 8587 663 637 3421 4267 6884 8142 7634 5748 936 316 9300 771 6906 9230 8994 9690 7155 9393 6274 3183 932 7460 1611 6122 4031 6922 5466 1499 5290 4907 4673 5665 9744 1602 9891 8260 6351 4640 9930 9756 5242 3752 82 3287 824 6897 5579 9095 883 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a sequence of digits of length $2^k$ $[a_1, a_2, \\ldots, a_{2^k}]$. We perform the following operation with it: replace pairs $(a_{2i+1}, a_{2i+2})$ with $(a_{2i+1} + a_{2i+2})\\bmod 10$ for $0\\le i<2^{k-1}$. F... | [{"type": "stdin_stdout", "input": "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n15\n16 19\n3 10\n9 9\n3 18\n6 7\n15 18\n12 19\n17 18\n12 12\n6 9\n3 10\n1 2\n2 3\n4 19\n16 16\n", "output": "1\n3\n0\n5\n0\n1\n2\n1\n0\n1\n3\n1\n1\n5\n0\n"}, {"type": "stdin_stdout", "input": "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.\n\nSerge... | [{"type": "stdin_stdout", "input": "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaaaaaaaaaaaaa\n61 91 5 43 53 81 7 96 6 9 34 78 79 12 8 63 22 76 18 46 41 56 3 20 57 21 75 73 100 94 35 69 32 4 70 95 88 44 68 10 71 98 23 89 36 62 28 51 24 30 74 55 27 80 38 48 93 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation of N numbers from 1 to N A1, A2, ……, AN is given. You can perform the operation reverse (i, j) to reverse the order of the numbers in the interval [i, j] (1 ≤ i ≤ j ≤ N) for this permutation. For example, if... | [{"type": "stdin_stdout", "input": "10\n3 -1 5 1 7 4 14 6 17 13", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n3 -1 5 1 7 4 14 6 17 8", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n2 -1 5 1 7 4 14 6 17 8", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n2 -1 5 1 7 4 12 6 17 8", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are many blue cards and red cards on the table. For each card, an integer number greater than 1 is printed on its face. The same number may be printed on several cards.\n\nA blue card and a red card can be paired wh... | [{"type": "stdin_stdout", "input": "4 3\n2 6 6 15\n2 3 5\n2 3\n4 9\n8 16 32\n4 2\n4 9 11 13\n2 7\n5 5\n2 3 5 1001 1001\n7 11 13 17 34\n10 10\n2 3 5 7 12 11 13 15 17 29\n3 11 1 22 18 22 26 30 34 38\n20 20\n314 144 903 63 137 609 44 626 75 473\n876 421 909 519 755 840 374 368 570 872\n363 650 155 265 64 26 426 391 15 421... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDuring her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.\n\nThe collection of porcelain is arranged neatly on n shelves. Within each shelf the... | [{"type": "stdin_stdout", "input": "1 68\n100 26 58 15 8 69 66 49 97 18 74 27 39 19 76 37 25 4 88 75 17 79 41 21 44 39 7 42 63 82 92 87 41 85 25 30 43 80 165 106 98 88 16 15 97 74 81 76 33 19 64 3 14 72 17 36 33 21 34 59 38 75 48 1 57 20 81 56 74 67 14 89 51 30 1 66 20 58 64 58 16 99 33 97 31 5 54 87 6 64 70 40 93 25 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a integer $n$ ($n > 0$). Find any integer $s$ which satisfies these conditions, or report that there are no such numbers:\n\nIn the decimal representation of $s$: $s > 0$, $s$ consists of $n$ digits, no ... | [{"type": "stdin_stdout", "input": "4\n7648\n1421\n37753\n53050\n", "output": "2333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and ... | [{"type": "stdin_stdout", "input": "6\nK.......\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\n..####.K\n\n.......K\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\nK.####..\n\nK.......\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\nK.####..\n\n.......K\n........\n.##..##.\n#..##... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day, Ikta, an elementary school student, received a piece of paper with mathematical formulas from his grandfather. Apparently, the grandfather will give you as much money as the answer to the formula. Ikta has only l... | [{"type": "stdin_stdout", "input": "(198876743*1-210*4-89)", "output": "3533045339395\n"}, {"type": "stdin_stdout", "input": "(198876744*1-210*4-89)", "output": "3533045357160\n"}, {"type": "stdin_stdout", "input": "(198776744*1-210*4-89)", "output": "3531268857160\n"}, {"type": "stdin_stdout", "input": "(198777744*1-2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\n$ M $ students will be tested in a classroom with $ N $ seats in a straight line. Seats are numbered $ 1 \\ dots N $ from the front, and $ 1 $ per seat can seat $ 1 $ students.\n\nNow each student is sitting in... | [{"type": "stdin_stdout", "input": "2 0\n-1 -1 0 3", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 0\n-1 2 -1 3", "output": "0\n"}, {"type": "stdin_stdout", "input": "11 2\n1 4 10 6", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 2\n0 2 4 10", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 0\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nACM countries have rivers that flow from east to west in the center. This river flows from the neighboring country in the west through the neighboring country in ACM to the neighboring country in the east, and the total l... | [{"type": "stdin_stdout", "input": "1 1 100\n50 200 20 40 0\n1\n2 4 101\n7 4 2 4 1\n19 5 1 4 0\n5\n3\n10\n1\n1 2 3\n2 1 1 1 0\n1\n3\n1 2 6\n5 16 1 1 1\n2\n3\n0 0 0", "output": "110.0000000000\n111.1500000000\n5.3333333333\n64.3333333333\n"}, {"type": "stdin_stdout", "input": "1 1 110\n50 200 20 40 0\n1\n2 4 101\n7 4 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n6\n2\n3\n1\n1\n4\n2\n\n\nOutput\n\nYes\nYes\nYes\nNo\nYes\nNo\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python cod... | [{"type": "stdin_stdout", "input": "6\n2\n3\n2\n1\n11\n2", "output": "Yes\nYes\nYes\nNo\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n2\n10\n0\n4\n4\n1", "output": "Yes\nYes\nNo\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n6\n8\n1\n2\n5\n3", "output": "Yes\nYes\nYes\nYes\nYes\nYes\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch dec... | [{"type": "stdin_stdout", "input": "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBWBBWBWB\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "BWBBBWWB\nBWBBBWWB\nBBBBBBBB\nBBBBBBBB\nBWBBBWWB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "BBBBBBBB\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt's now the season of TAKOYAKI FESTIVAL!\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\nAs is commonly known, when you eat two t... | [{"type": "stdin_stdout", "input": "50\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\n", "output": "12250000\n"}, {"type": "stdin_stdout", "input": "41\n49 91 82 7 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program s... | [{"type": "stdin_stdout", "input": "2\n2.926287414400688 0.6174638399148507 2.2117258079089996 2.51039017960215 2.2432914589132955 0.3458310450303873 3.950438914943076 1.6292131026754104\n5.957858300757107 3.314602021400227 10.473008708157936 7.081122407685485 15.460510197185764 6.858362845609268 7.533578119892425 12.1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\nPerson i gives A_i testimonies. The j-th testi... | [{"type": "stdin_stdout", "input": "15\n14\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n14\n1 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n14\n1 1\n2 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n14\n1 1\n2 1\n3 1\n5 1\n6 1\n7 1\n8 1\n9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nLet $ f (x) $ be the sum of each digit when the non-negative integer $ x $ is expressed in binary.\nGiven a positive integer $ N $, output the largest of $ f (0) $, $ f (1) $, ..., $ f (N) $.\n\n\nExample of ca... | [{"type": "stdin_stdout", "input": "10830", "output": "13\n"}, {"type": "stdin_stdout", "input": "1663", "output": "10\n"}, {"type": "stdin_stdout", "input": "2604", "output": "11\n"}, {"type": "stdin_stdout", "input": "5020", "output": "12\n"}, {"type": "stdin_stdout", "input": "170", "output": "7\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAll cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position x_{i} — a coordinate on the Ox axis. No two cities are located at a single point.\n\nLineland residents love to... | [{"type": "stdin_stdout", "input": "50\n-50000 -49459 -48875 -48456 -48411 -48096 -47901 -47500 -47150 -46808 -46687 -46679 -46337 -45747 -45604 -45194 -44752 -44242 -44231 -44122 -43636 -43274 -42916 -42881 -42386 -42095 -41830 -41618 -41145 -40897 -40534 -40007 -39761 -39389 -39104 -38909 -38630 -38561 -38364 -38255 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of positive integers $a = [a_0, a_1, \\dots, a_{n - 1}]$ ($n \\ge 2$).\n\nIn one step, the array $a$ is replaced with another array of length $n$, in which each element is the greatest common diviso... | [{"type": "stdin_stdout", "input": "1\n97\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\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n97\n1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a grid with H rows and W columns.\n\nThe square at the i-th row and j-th column contains a string S_{i,j} of length 5.\n\nThe rows are labeled with the numbers from 1 through H, and the columns are labeled with t... | [{"type": "stdin_stdout", "input": "15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake sna... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn some other world, today is December D-th.\nWrite a program that prints Christmas if D = 25, Christmas Eve if D = 24, Christmas Eve Eve if D = 23 and Christmas Eve Eve Eve if D = 22.\n\n-----Constraints-----\n - 22 \\le... | [{"type": "stdin_stdout", "input": "-1279", "output": "Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nYou are given two positive integers – A and B. You have to check whether A is divisible by all the prime divisors of B.\n\n------ Input ------ \n\nThe first l... | [{"type": "stdin_stdout", "input": "3\n120 75\n184 16\n16 18", "output": "Yes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "3\n120 75\n184 16\n16 36", "output": "Yes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "3\n120 75\n184 16\n0 11", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "3\n120 75\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.\n\nThe... | [{"type": "stdin_stdout", "input": "15\n11 22 13 24 15 26 17 28 19 30 21 2 23 4 25 6 27 8 29 10 1 12 3 14 5 16 7 18 9 20\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "15\n11 22 13 24 15 26 17 28 19 30 21 2 23 4 25 6 27 8 29 10 1 12 3 14 5 16 7 18 9 20\n", "output": "10\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a new attraction in Singapore Zoo: The Infinite Zoo.\n\nThe Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\\ldots$. There is a directed edge from vertex $u$ to vert... | [{"type": "stdin_stdout", "input": "5\n1 4\n3 12\n2 15\n6 6\n10 5\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "5\n1 4\n3 6\n1 8\n10 3\n5 5\n", "output": "YES\nYES\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n3 12\n2 6\n3 4\n3 5\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nIn the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunat... | [{"type": "stdin_stdout", "input": "1 2\n\nseY\n\nNo\n\nYes\n\nYds\n", "output": "1 1\n1 1\n1 1\n"}, {"type": "stdin_stdout", "input": "10 2\n\nYes\n\nNo\n\nYes\n\nYes\n", "output": "2 2\n"}, {"type": "stdin_stdout", "input": "1 2\n\nYes\n\nNo\n\nYer\n\nYes\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMost C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use.\n\nIn this problem we consider th... | [{"type": "stdin_stdout", "input": "5\n#define iiXEqDYeyVmIYsOaO fj/x-9-6/x*x+ 1/ 7*2-x -x+9+235*23*Ww+x-2*K+2-x/70\n#define XVgLzhoTUxoBr ( x+x/x/x*6-x)* x+K/24206-2 /5/8-x-7/Ww/K-x+6 \n#define QdfRBaJk 470551685-( 54-x)-30\n#define gEJcAGnF x+x-x+(x/x+9)/x-41-1/fj/1157561+x/x -x/26/x+K*x\n#define lO 7-1*(x*58 )-K*fj... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA connected undirected graph is called a vertex cactus, if each vertex of this graph belongs to at most one simple cycle.\n\nA simple cycle in a undirected graph is a sequence of distinct vertices v1, v2, ..., vt (t > 2),... | [{"type": "stdin_stdout", "input": "40 43\n1 2\n1 3\n1 4\n4 5\n5 6\n1 7\n5 8\n7 9\n2 10\n10 11\n11 12\n2 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 2\n3 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 3\n4 33\n33 34\n34 35\n35 36\n36 37\n37 4\n5 38\n38 39\n39 40\n40 5\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n points marked on the plane. The points are situated in such a way that they form a regular polygon (marked points are its vertices, and they are numbered in counter-clockwise order). You can draw n - 1 segment... | [{"type": "stdin_stdout", "input": "10\n0 1 1 0 -1 -2 1 0 0 0\n1 0 0 0 1 0 0 0 0 0\n0 0 1 2 1 0 1 1 0 0\n0 0 1 0 0 0 0 -1 0 0\n-1 0 -1 0 0 0 0 0 1 0\n0 0 -1 0 0 1 -1 0 0 1\n2 0 0 0 0 0 1 0 0 2\n0 -1 0 0 0 0 0 0 0 0\n0 0 0 0 0 -1 0 0 0 0\n0 1 0 -2 0 0 -1 -1 0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 a... | [{"type": "stdin_stdout", "input": "50 20365011074\n", "output": "2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49\n"}, {"type": "stdin_stdout", "input": "50 5608642004\n", "output": "1 2 4 3 5 6 8 7 9 10 11 13 12 15 14 17 16 18... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem is same as the previous one, but has larger constraints.\n\nIt was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home).... | [{"type": "stdin_stdout", "input": "25\n-10000 -10000\n-10000 -5000\n-10000 0\n-10000 5000\n-10000 10000\n-7452 -10000\n-5000 -5000\n-5000 0\n-5000 5000\n-5000 10000\n-1 -10000\n0 -5000\n0 0\n0 5000\n0 10000\n5000 -13650\n5000 -5000\n5000 0\n5000 5000\n5000 10000\n10000 -10000\n10000 -5000\n10000 0\n10000 5000\n10000 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.\n\nKirk has a binary string... | [{"type": "stdin_stdout", "input": "0111001100111011101000\n", "output": "0011001100001011101000\n"}, {"type": "stdin_stdout", "input": "0111001100111111101000\n", "output": "0011001100000011101000\n"}, {"type": "stdin_stdout", "input": "0111011100111111101000\n", "output": "0001001100000011101000\n"}, {"type": "stdin_... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider some set of distinct characters $A$ and some string $S$, consisting of exactly $n$ characters, where each character is present in $A$.\n\nYou are given an array of $m$ integers $b$ ($b_1 < b_2 < \\dots < b_m$). \... | [{"type": "stdin_stdout", "input": "1000000000 2 2\n1 500000000\n", "output": "933660593\n"}, {"type": "stdin_stdout", "input": "1000000000 2 2\n1 500000000\n", "output": "933660593\n"}, {"type": "stdin_stdout", "input": "1000000000 2 2\n2 500000000\n", "output": "811805447\n"}, {"type": "stdin_stdout", "input": "10000... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.