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 an array a of length n that consists of zeros and ones.\n\nYou can perform the following operation multiple times. The operation consists of two steps: \n\n 1. Choose three integers 1 ≀ x < y < z ≀ n, that ...
[{"type": "stdin_stdout", "input": "125\n1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n", "output": "YES\n23\n120 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn ant moves on the real line with constant speed of $1$ unit per second. It starts at $0$ and always moves to the right (so its position increases by $1$ each second).\n\nThere are $n$ portals, the $i$-th of which is loc...
[{"type": "stdin_stdout", "input": "5\n370534603 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n1000000000 500000000 0\n", "output": "444580501\n"}, {"type": "stdin_stdout", "input": "5\n370534603 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n101000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe full exploration sister is a very talented woman. Your sister can easily count the number of routes in a grid pattern if it is in the thousands. You and your exploration sister are now in a room lined with hexagonal t...
[{"type": "stdin_stdout", "input": "-2 1 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n2 5", "output": "-1\n"}, {"type": "stdin_stdout", "input": "-2 1 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n3 5", "output": "-1\n"}, {"type": "stdin_stdout", "input": "-2 0 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n3 5", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKsusha is a beginner coder. Today she starts studying arrays. She has array a_1, a_2, ..., a_{n}, consisting of n positive integers.\n\nHer university teacher gave her a task. Find such number in the array, that all array...
[{"type": "stdin_stdout", "input": "5\n506904227 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5\n506904227 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5\n238711016 214303304 136194869 838256937 183952885\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSomeone gave Alyona an array containing n positive integers a_1, a_2, ..., a_{n}. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than t...
[{"type": "stdin_stdout", "input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 10000000 10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possi...
[{"type": "stdin_stdout", "input": "53684795681792590016697187295561462737810600000146840941336328677293748561247888801665863139922929397968535048060292988802347668853531069156825523164438370977880256909710958836918627008217572514193873141535365258436916984535972865113877338591947508645026570682995314540038481160747606...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile playing with geometric figures Alex has accidentally invented a concept of a $n$-th order rhombus in a cell grid.\n\nA $1$-st order rhombus is just a square $1 \\times 1$ (i.e just a cell).\n\nA $n$-th order rhombus...
[{"type": "stdin_stdout", "input": "100\n", "output": "19801\n"}, {"type": "stdin_stdout", "input": "100\n", "output": "19801"}, {"type": "stdin_stdout", "input": "72\n", "output": "10225\n"}, {"type": "stdin_stdout", "input": "94\n", "output": "17485\n"}, {"type": "stdin_stdout", "input": "77\n", "output": "11705\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTired of boring office work, Denis decided to open a fast food restaurant.\n\nOn the first day he made $a$ portions of dumplings, $b$ portions of cranberry juice and $c$ pancakes with condensed milk.\n\nThe peculiarity of...
[{"type": "stdin_stdout", "input": "7\n1 4 1\n0 0 0\n16 0 1\n2 2 2\n2 3 2\n3 2 2\n0 4 4\n", "output": "3\n0\n2\n4\n5\n5\n3\n"}, {"type": "stdin_stdout", "input": "7\n0 1 1\n0 0 0\n11 1 1\n2 2 4\n3 3 3\n4 2 3\n0 6 1\n", "output": "2\n0\n3\n5\n6\n5\n2\n"}, {"type": "stdin_stdout", "input": "7\n1 2 1\n0 0 0\n16 1 1\n2 2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\nEach of the airplanes flies at a constant speed of 0.1 per second...
[{"type": "stdin_stdout", "input": "8\n285 224 U\n130 175 R\n111 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"type": "stdin_stdout", "input": "8\n285 224 U\n130 175 R\n101 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShell Sort\n\nShell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$.\n\n\n1 insertionSort(A, n, g)\n2 for i = g to n-1\n3 v = A[i]\n4 j = i - g\n5 while j ...
[{"type": "stdin_stdout", "input": "5\n10\n1\n5\n9\n1", "output": "2\n4 1\n1\n1\n1\n5\n9\n10\n"}, {"type": "stdin_stdout", "input": "5\n10\n1\n5\n7\n1", "output": "2\n4 1\n1\n1\n1\n5\n7\n10\n"}, {"type": "stdin_stdout", "input": "5\n6\n1\n10\n7\n1", "output": "2\n4 1\n4\n1\n1\n6\n7\n10\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp is playing a computer game. In this game, his character fights different monsters.\n\nA fight between a character and a monster goes as follows. Suppose the character initially has health $h_C$ and attack $d_C$; ...
[{"type": "stdin_stdout", "input": "2\n1000000000000000 1\n1000000000000000 200000\n0 1 1\n1000000000000000 200000\n1000000000000000 1\n0 1 1\n", "output": "NO\nYES\n"}, {"type": "stdin_stdout", "input": "2\n1000000000000000 1\n1000000000000000 1000000000\n1000 10000 10000000000\n9 2\n16 4\n0 10 10\n", "output": "NO\nN...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≀ i ≀ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' ...
[{"type": "stdin_stdout", "input": "50 5\n232 6 17 6 21 26 27 36 41 88 665 56 61 66 71 76 602 86 28 712 101 106 111 116 121 126 131 136 141 146 151 156 161 166 755 176 181 186 191 196 201 206 211 216 5 226 172 236 241 246\n", "output": "12\n- 1 231\n- 3 6\n+ 4 10\n+ 7 4\n- 10 42\n- 11 614\n- 17 521\n+ 19 63\n- 20 616\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publica...
[{"type": "stdin_stdout", "input": "40\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 6 4 4 12 5 4 11 8 1 2 8 11 19 18 4\n52258 5648 46847 9200 101064 79328 64407 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three strings A, B and C. Check whether they form a word chain.\nMore formally, determine whether both of the following are true:\n - The last character in A and the initial character in B are the same.\n - ...
[{"type": "stdin_stdout", "input": "aaaaaaaaab aaaaaaaaaa aaaaaaaaab\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "baaaa`aaaa aabaaaaaaa aaaaa`aaab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "baaaaaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "baaabaaa`` `a...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHarry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length l. Two opponents simultaneously charge a deadly spell in the enem...
[{"type": "stdin_stdout", "input": "1000\n148\n500\n", "output": "228.39506172839506\n"}, {"type": "stdin_stdout", "input": "425\n458\n118\n", "output": "337.93402777777777\n"}, {"type": "stdin_stdout", "input": "496\n326\n429\n", "output": "214.16688741721853\n"}, {"type": "stdin_stdout", "input": "745\n152\n417\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decid...
[{"type": "stdin_stdout", "input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n18 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOur Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert. \n\nOn the day of the party, the Chef w...
[{"type": "stdin_stdout", "input": "4\n38\n13\n31\n2", "output": "17\n12\n30\n1\n"}, {"type": "stdin_stdout", "input": "4\n38\n13\n16\n2", "output": "17\n12\n0\n1\n"}, {"type": "stdin_stdout", "input": "4\n131\n14\n1\n4", "output": "130\n5\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n19\n13\n16\n2", "output": "18\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "10\n4 7 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 1310915575\n8 10 838073755\n5 10 547050646\n2 1 12607780\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n4 7 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 131091...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThe island where JOI lives has been invaded by zombies. JOI decided to escape to the shelter, which is set as the safest shelter on the island.\n\nThe island where JOI lives consists of N towns from town 1 to t...
[{"type": "stdin_stdout", "input": "13 21 1 1\n1001 6000\n11\n4 2\n3 7\n2 4\n8 8\n8 4\n2 10\n3 4\n6 7\n7 10\n10 11\n5 9\n11 10\n3 6\n4 5\n1 6\n13 12\n6 7\n8 11\n6 13\n7 8\n2 12", "output": "1001\n"}, {"type": "stdin_stdout", "input": "13 21 1 1\n1010 10247\n7\n1 2\n3 7\n2 4\n5 8\n8 9\n2 5\n3 4\n4 7\n9 10\n10 11\n9 9\n7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya decided to go to the grocery store. He found in his wallet $a$ coins of $1$ burle and $b$ coins of $2$ burles. He does not yet know the total cost of all goods, so help him find out $s$ ($s > 0$): the minimum positi...
[{"type": "stdin_stdout", "input": "7\n1 1\n4 0\n0 2\n0 0\n2314 2374\n0 0\n1 1\n", "output": "4\n5\n1\n1\n7063\n1\n4\n"}, {"type": "stdin_stdout", "input": "5\n1 1\n4 0\n0 2\n0 0\n2314 2374\n", "output": "4\n5\n1\n1\n7063\n"}, {"type": "stdin_stdout", "input": "1\n1123112 1221133\n", "output": "3565379\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n - YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), ...
[{"type": "stdin_stdout", "input": "0112\n", "output": "AMBIGUOUS\n"}, {"type": "stdin_stdout", "input": "0101\n", "output": "AMBIGUOUS\n"}, {"type": "stdin_stdout", "input": "1211", "output": "AMBIGUOUS\n"}, {"type": "stdin_stdout", "input": "1204", "output": "AMBIGUOUS\n"}, {"type": "stdin_stdout", "input": "0112", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nRupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A_{1}, A_{2}, ..., A_{N} respectively to store it. But as ...
[{"type": "stdin_stdout", "input": "2\n-1\n3 111\n-1\n9", "output": "113\n2\n"}, {"type": "stdin_stdout", "input": "2\n-1\n3 101\n-1\n9", "output": "103\n2\n"}, {"type": "stdin_stdout", "input": "2\n-2\n2 25\n-2\n16", "output": "27\n2\n"}, {"type": "stdin_stdout", "input": "2\n-1\n3 12\n-1\n9", "output": "14\n2\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAccording to a new ISO standard, a flag of every country should have a chequered field n Γ— m, each square should be of one of 10 colours, and the flag should be Β«stripedΒ»: each horizontal row of the flag should contain sq...
[{"type": "stdin_stdout", "input": "20 19\n1111111111111111111\n8247715032316286876\n0000001000000000000\n4784876473600342372\n1111111111111111111\n2222222222222222222\n4444444444444444444\n5555555555555555555\n0000000000000000010\n4444444444444444444\n0000000000000000000\n5555555555555555555\n11500026576261848309\n999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen you play the game of thrones, you win, or you die. There is no middle ground.\n\nCersei Lannister, A Game of Thrones by George R. R. Martin\n\nThere are n nobles, numbered from 1 to n. Noble i has a power of i. There...
[{"type": "stdin_stdout", "input": "20 53\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 20\n2 3\n2 6\n2 16\n2 17\n3 6\n3 18\n3 20\n4 6\n4 7\n4 8\n4 18\n4 14\n4 18\n5 11\n5 16\n5 17\n2 18\n5 19\n6 8\n6 13\n7 8\n7 10\n7 15\n7 17\n14 18\n8 15\n8 16\n4 10\n17 15\n10 11\n10 17\n10 20\n11 15\n11 17\n12 14\n12 15\n12 16\n16 19\n14 16\n14 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given strings $S$ and $T$, consisting of lowercase English letters. It is guaranteed that $T$ is a permutation of the string abc.\n\nFind string $S'$, the lexicographically smallest permutation of $S$ such that $T...
[{"type": "stdin_stdout", "input": "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabc\nac\nabc\n", "output": "aaaacbb\nabccc\nbcdis\naaaaacbbdrr\ndddddddddddd\nbbc\nac\n"}, {"type": "stdin_stdout", "input": "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCreate a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface ...
[{"type": "stdin_stdout", "input": "35.997652258458864 139.77 51.15 361.449066466584\n1.6512558665331527 105.35573273382599 41.78 272.61282853754\n51.62303215206055 360.59086045680647 -34.03891385785915 302.61951676416413\n-1 -1 -1 -1", "output": "9516\n15035\n11082\n"}, {"type": "stdin_stdout", "input": "36.4199056430...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova promised himself that he would never play computer games... But recently Firestorm β€” a well-known game developing company β€” published their newest game, World of Farcraft, and it became really popular. Of course, Vov...
[{"type": "stdin_stdout", "input": "10 5\n1 6 2 11 3 8 4 9 5 10\n1 2\n3 5\n5 6\n7 10\n9 10\n", "output": "27\n"}, {"type": "stdin_stdout", "input": "10 3\n1 6 2 27 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n", "output": "45\n"}, {"type": "stdin_stdout", "input": "10 3\n1 6 2 17 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained ...
[{"type": "stdin_stdout", "input": "17\n15 4 3 6 5 11 8 8 9 10 15 12 13 14 17 16 17\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "17\n16 4 3 6 7 6 10 8 9 10 11 12 13 14 15 16 17\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "17\n9 4 3 6 7 6 10 8 9 10 11 12 13 14 15 16 17\n", "output": "8\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet x be a string of length at least 1.\nWe will call x a good string, if for any string y and any integer k (k \\geq 2), the string obtained by concatenating k copies of y is different from x.\nFor example, a, bbc and cd...
[{"type": "stdin_stdout", "input": "bcbc\n", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "aab\n", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "ddd\n", "output": "3\n1\n"}, {"type": "stdin_stdout", "input": "adad", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "bbcc", "output": "1\n1\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya got an integer array $a_1, a_2, \\dots, a_n$. The array can contain both positive and negative integers, but Kolya doesn't like $0$, so the array doesn't contain any zeros.\n\nKolya doesn't like that the sum of some...
[{"type": "stdin_stdout", "input": "100\n-6 2 8 -9 -9 3 -3 -2 7 3 2 -2 -9 -7 -10 -9 10 4 5 -9 8 -5 7 -2 6 -2 4 4 -2 -5 6 4 8 -8 9 7 -4 2 -3 7 4 -10 -7 -4 8 2 10 -8 -3 -8 -5 -5 -10 -6 -8 -5 7 -1 7 -5 9 10 3 5 10 -7 -3 -7 1 -5 -8 5 1 -1 4 10 2 6 -4 9 3 10 -5 -10 -10 -2 1 9 10 1 10 2 8 -3 -3 -1 7 -5 8 -4\n", "output": "11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in som...
[{"type": "stdin_stdout", "input": "41 4\n24 15 17 35 13 41 4 14 23 5 8 16 21 18 30 36 6 22 11 29 26 1 40 31 7 3 32 10 28 38 12 20 39 37 34 19 33 27 2 25 9\n22 13 25 24 38 35 29 12 15 8 11 37 3 19 4 23 18 32 30 40 36 21 16 34 27 9 5 41 39 2 14 17 31 33 26 7 1 10 20 6 28\n31 27 39 16 22 12 13 32 6 10 19 29 37 7 18 33 24...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAll cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowe...
[{"type": "stdin_stdout", "input": "100 67\n66 12 2 49 62 63 59 14 13 26 15 25 22 16 33 17 15 14 13 33 9 10 53 28 17 27 18 39 35 64 1 59 33 24 66 64 4 2 4 5 22 9 52 36 44 57 62 3 52 21 62 55 25 2 65 18 20 40 8 30 27 28 47 19 67 67 42 6 53 17 36 38 57 37 45 13 58 12 31 24 15 67 9 18 56 20 34 8 20 31 13 19 42 12 16 15 54...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA palindrome is a string that reads the same backward as forward. For example, the strings \"z\", \"aaa\", \"aba\", and \"abccba\" are palindromes, but \"codeforces\" and \"ab\" are not. You hate palindromes because they ...
[{"type": "stdin_stdout", "input": "6\ncbabc\nab\nzza\nba\na\nnutforajaroftuna\n", "output": "\nYES\ncbabac\nYES\naab\nYES\nzaza\nYES\nbaa\nNO\nYES\nnutforajarofatuna\n"}, {"type": "stdin_stdout", "input": "6\ncbabc\nab\nzza\nba\na\nnutforajaroftuna\n", "output": "YES\ncbabca\nYES\naab\nYES\nzzaa\nYES\nbaa\nNO\nYES\nnu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..\n\nThere is a glob pattern in...
[{"type": "stdin_stdout", "input": "k\n*\n89\nb\ncbbbc\ncabac\nbccbb\nccc\ncabaa\nabbaa\nccbaa\nccccb\ncabbb\nbbcbc\nbac\naaac\nabb\nbcbb\ncb\nbacc\nbbaba\nb\nacc\nbaac\naaba\nbcbba\nbaa\nbc\naaccb\nb\nab\nc\nbbbb\nabbcb\nacbb\ncba\nc\nbac\nc\nac\ncc\nb\nbbc\nbaab\nc\nbbc\nab\nb\nc\naa\naab\nab\naccbc\nacbaa\na\nccc\nc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFrom \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defec...
[{"type": "stdin_stdout", "input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"type": "stdin_stdout", "input": "10\n5 20 18 1 12 17 22 20 26 4\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"type": "stdin_stdout", "input": "10\n5 20 18 1 12 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer sequence of length N: A_1, A_2, \\cdots, A_N.\nAn integer sequence X, which is also of length N, will be chosen randomly by independently choosing X_i from a uniform distribution on the integers 1, 2, ...
[{"type": "stdin_stdout", "input": "6\n680824625 680824626 680824626 680824624 680824626 680824624\n", "output": "655804632\n"}, {"type": "stdin_stdout", "input": "6\n612348318 612348320 612348320 612348319 612348318 612348317\n", "output": "110656261\n"}, {"type": "stdin_stdout", "input": "6\n101617840 101617840 10161...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down ...
[{"type": "stdin_stdout", "input": "50 25\n199970 199997 199998 199988 199999 199981 200000 199990 199974 199985 199932 200000 199966 199999 199999 199951 199983 199975 199974 199996 199974 199992 199979 199995 199955 199989 199960 199975 199983 199990 199950 199952 199999 199999 199962 199939 199979 199977 199962 1999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe courier charges for a courier company are set according to size and weight as shown in the table below.\n\nA size | B size | C size | D size | E size | F size\n--- | --- | --- | --- | --- | --- | ---\nSize | 60 cm or ...
[{"type": "stdin_stdout", "input": "2\n86 25 5 5\n135 60 10 30\n3\n10 8 25 24\n5 16 13 9\n30 30 30 14\n0", "output": "1200\n3800\n"}, {"type": "stdin_stdout", "input": "2\n51 0 5 15\n107 60 3 30\n3\n10 15 25 47\n2 12 12 3\n30 30 11 11\n0", "output": "1200\n2000\n"}, {"type": "stdin_stdout", "input": "2\n50 34 5 5\n80 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.\n...
[{"type": "stdin_stdout", "input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n100 1000 1000 1000 1000\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "5\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the d...
[{"type": "stdin_stdout", "input": "10\n10\n6 2 1 1 1 10 10 2 10 5\n8\n1 3 1 1 4 5 4 4\n9\n14 6 9 9 2 8 7 2 2\n10\n9 4 3 3 5 4 3 10 4 5\n9\n7 5 1 7 5 5 5 5 6\n8\n8 8 4 4 7 6 2 8\n10\n6 8 1 6 8 8 5 6 8 4\n10\n5 5 5 8 3 4 3 3 10 10\n8\n1 1 3 6 6 7 1 2\n8\n4 1 3 5 3 1 3 3\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\nY...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straig...
[{"type": "stdin_stdout", "input": "33 23 17 2\n1 1 2 2 2 3 3 3 3 3 3 4 4 4 4 4 5 5 5 6 6 7 7 7 8 8 8 8 8 9 9 10 10\n1 1 3 3 4 4 4 5 5 6 6 6 7 8 8 8 8 8 8 9 9 10 10\n", "output": "23\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n12 10\n13 11\n14 12\n17 13\n20 14\n21 15\n22 16\n23 17\n24 18\n25 19\n26 20\n27 21\n28 22\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some other world, today is the day before Christmas Eve.\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\nHe has a discoun...
[{"type": "stdin_stdout", "input": "10\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n", "output": "95000\n"}, {"type": "stdin_stdout", "input": "10\n8830\n106\n9248\n6388\n3562\n7160\n8452\n3486\n5802\n9228\n", "output": "57638\n"}, {"type": "stdin_stdout", "input": "9\n6126\n5482\n9198\n9274\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:\n\n b is lexicographically greater than or equal to a. b_{i} β‰₯ 2. b is pairwise coprime: for every 1 ...
[{"type": "stdin_stdout", "input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"type": "stdin_stdout", "input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"type": "stdin_stdout", "input": "10\n5 3 4 2 3 3 3 4 2 5\n", "output": "5 3 4 7 11 13 17 19 23 29\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: \n\nYou are given two integers d, m, find the number of arrays a, satisfying the following constraints:\n\n * Th...
[{"type": "stdin_stdout", "input": "10\n1 1100000000\n2 1587398050\n4 99999998\n4 9999997\n5 999996\n10 99995\n9 9994\n8 1104\n12 92\n19 1\n", "output": "1\n3\n11\n11\n17\n119\n89\n59\n87\n0\n"}, {"type": "stdin_stdout", "input": "10\n1 1100000000\n2 1587398050\n3 99999998\n4 9999997\n5 999996\n18 99995\n9 9994\n8 1104...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWelcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and i...
[{"type": "stdin_stdout", "input": "30 20\n55 0\n32 18\n2 23\n43 21\n34 10\n20 -13", "output": "10\n55\n14\n-21\n22\n24\n33\n"}, {"type": "stdin_stdout", "input": "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n10 -10", "output": "11\n19\n1\n-16\n1\n13\n20\n"}, {"type": "stdin_stdout", "input": "30 19\n39 20\n19 18\n4 20\n22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix.\n\nThe dot product of two integer number vectors x and y of size n is the sum of the produc...
[{"type": "stdin_stdout", "input": "5\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n7\n3\n2 4\n1 3\n3\n2 5\n1 2\n3\n", "output": "111\n"}, {"type": "stdin_stdout", "input": "5\n1 0 1 1 1\n0 1 0 1 0\n1 0 1 1 1\n0 1 0 1 0\n1 0 1 0 0\n7\n3\n2 4\n1 3\n3\n2 5\n1 1\n3\n", "output": "000\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one.\n\nWhen typing a character, inste...
[{"type": "stdin_stdout", "input": "10\npaxghjnihn\nhn\nhdmevxvn\nn\nazdfhfxem\nxem\neowhldode\ndode\nwlclsnht\nct\nbpflheocamv\nv\nflejfh\nhixqqbnikthccagc\ndugt\neebmbpykcsmi\noivgrzwppny\nzhfyiuu\nebkqjcbcwviqkojnzyruwygtbvwws\nbofzr\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down ...
[{"type": "stdin_stdout", "input": "50 25\n199970 199997 199998 199988 199999 199981 200000 199990 199974 199985 199932 200000 199966 199999 199999 199951 199983 199975 199974 199996 199974 199992 199979 199995 199955 199989 199960 199975 199983 199990 199950 199952 199999 199999 199962 199939 199979 199977 199962 1999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSquirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good.\n\nNow she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called go...
[{"type": "stdin_stdout", "input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 354 380 406 418 428 438 442 482 532 536 544 546 554 596 626 642 682 684 704 714 792 804 820 862 880 906 946 954 966 970\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "49\n10 34 58 72 126 166 176 18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a_1, a_2, \\dots , a_n$, which is sorted in non-decreasing order ($a_i \\le a_{i + 1})$. \n\nFind three indices $i$, $j$, $k$ such that $1 \\le i < j < k \\le n$ and it is impossible to construct a...
[{"type": "stdin_stdout", "input": "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\n"}, {"type": "stdin_stdout", "input": "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\n"}, {"type": "stdin_stdout", "input": "3\n7\n4 6 11 11 15 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the harder version of the problem. In this version, $1 \\le n, m \\le 2\\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nYou are gi...
[{"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.\n\nA Bitlandish string is a string made only of characters \"0\" and...
[{"type": "stdin_stdout", "input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\nOn this sequence, Snuke can perform the following operation:\n - Choose K consecutive elements in the sequen...
[{"type": "stdin_stdout", "input": "7635 1737\n1 4336 5028 2246 3376 4632 3484 5018 6851 5712 6421 1045 4582 6443 5762 2211 5622 2385 1213 6493 6742 4499 7581 6655 2974 2212 2861 4283 5757 1316 4008 2602 5971 4098 5433 1398 4622 7224 93 4338 1998 1188 853 2588 2210 7123 3903 1360 1308 3213 3437 2333 6285 2126 3228 2323...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the com...
[{"type": "stdin_stdout", "input": "3 300\n100 46 150\n100 50 150\n101 50 148\n3 300\n110 50 150\n100 50 150\n200 50 150\n9 18\n5 1 1\n3 1 1\n3 1 1\n4 100 1\n5 100 1\n5 100 1\n10 5 5\n10 5 5\n2 7 1000\n10 18\n1 2 6\n2 3 1\n3 4 5\n4 5 6\n5 6 7\n6 7 8\n7 8 9\n12 9 10\n9 10 11\n18 11 12\n0 0", "output": "2\n3\n5\n10\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new dog show on TV is starting next week. On the show dogs are required to demonstrate bottomless stomach, strategic thinking and self-preservation instinct. You and your dog are invited to compete with other participan...
[{"type": "stdin_stdout", "input": "100 154\n132 88 72 98 184 47 176 56 68 168 137 88 188 140 198 18 162 139 94 133 90 91 37 156 196 28 186 1 51 47 4 92 18 51 37 121 86 195 153 195 183 191 15 24 104 174 94 83 102 61 131 40 149 46 22 112 13 136 133 177 3 175 160 152 172 48 44 174 77 100 155 157 167 174 64 109 118 194 12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers $n$ and $m$. You have to construct the array $a$ of length $n$ consisting of non-negative integers (i.e. integers greater than or equal to zero) such that the sum of elements of this array is ex...
[{"type": "stdin_stdout", "input": "5\n1 100\n2 -1\n5 5\n2 1000000000\n1000100000 1000000000\n", "output": "0\n-1\n10\n1000000000\n2000000000\n"}, {"type": "stdin_stdout", "input": "5\n1 100\n2 2\n5 5\n2 1000000000\n1000000000 1000000000\n", "output": "0\n2\n10\n1000000000\n2000000000\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the ful...
[{"type": "stdin_stdout", "input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"type": "stdin_stdout", "input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"type": "stdin_stdout", "input": "asdfghkkli ware\n", "output": "asdfghkkliw\n"}, {"type": "stdin_stdout", "input": "ilkkhgfdsa ware\n", "output": "ilkk...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\nYou are given ...
[{"type": "stdin_stdout", "input": "200000 10\n195313 197047\n198503 199144\n199910 200000\n193793 195312\n186922 193792\n199860 199909\n199145 199570\n197048 198502\n1 186921\n199571 199859\n", "output": "946746535\n"}, {"type": "stdin_stdout", "input": "199993 10\n23896 23905\n92651 92660\n184931 184940\n101332 10134...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequen...
[{"type": "stdin_stdout", "input": "1989 1986\n84234 80908 59749 63761 63761 49034 63761 64697 84234 84234 64697 64697 49034 80908 80908 63761 66200 59749 59749 80908 84234 63761 80908 80908 66200 92283 84234 63761 80908 63761 92283 59749 49034 78052 53613 49034 92283 80908 53613 59749 49034 49034 59749 80908 66200 809...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\nDetermine whether N is a multiple of 9.\n\n-----Constraints-----\n - 0 \\leq N < 10^{200000}\n -...
[{"type": "stdin_stdout", "input": "33813819154164361588118768953262516554574111032083043031384286303065210509562262038973079975476396016546146039303789823110933080134565927492314604458575884820133400398416950126075966048913496870281342656762187821939147033106717650124502612019109078419691362651717290499399798948652832...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGenos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color c_{i}. The goal of the game is to destroy all the gemstones in the line as quickly as possible.\...
[{"type": "stdin_stdout", "input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 24 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 18 19 17 29 11 20 29 24\n", "output": "25\n"}, {"type": "stdin_stdout", "input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 24 28 19 19 22 30 28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit...
[{"type": "stdin_stdout", "input": "24 24\n25 69 103 18 40 8 78 14 14 10 27 61 75 140 10 69 80 71 102 8 91 14 15 10\nswtcofrcpeys{ydwkrg\nszyd\ndyzsyep\nrcpeyszydwkrgfj\nfgrkwdyzsyfp\ndwyz\nsmzginydyrtua\nj\nk\ntzwsw\ngfj\nmsplnqossy\ninydyrtuatzw\ninxdy\nlpsmzginydyrtuatzwswtcofrcpeyszy\nyssoqnlpsm\npeyszyd\nysosqnlps...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 Γ— 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid ...
[{"type": "stdin_stdout", "input": "AB\nXC\nXB\nAC\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "AB\nXC\nAX\nCB\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "CB\nAX\nXA\nBC\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "CB\nAX\nCX\nAB\n", "output": "YES\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThink of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are...
[{"type": "stdin_stdout", "input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75\n1 54\n10\n36 97\n41 1\n1 87\n39 23\n27 44\n73 97\n1 1\n6 26\n48 3\n5 69\n", "output": "108\n4\n"}, {"type": "stdin_stdout", "input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start i...
[{"type": "stdin_stdout", "input": "100 3 4\n644\n861\n478\n250\n560\n998\n141\n162\n386\n778\n123\n811\n602\n533\n391\n515\n898\n215\n965\n556\n446\n883\n256\n195\n573\n889\n515\n240\n179\n339\n258\n593\n930\n730\n735\n949\n522\n067\n549\n366\n452\n405\n473\n188\n488\n994\n000\n046\n930\n217\n897\n580\n509\n032\n343\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≀i≀N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_iβ‰ i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair i...
[{"type": "stdin_stdout", "input": "5\n5 5 5 -1 2", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n5 5 5 -2 2", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n3 5 5 -1 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n5 5 5 -1 1", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n3 3 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.\n\nThe current state of ...
[{"type": "stdin_stdout", "input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "20\n10 1 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the following strings are diverse: \"fced\", \"xyz\", \"r\" and \"dabcef\". ...
[{"type": "stdin_stdout", "input": "69\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\nabc\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree.\n\nYou have a map of that network, so for...
[{"type": "stdin_stdout", "input": "10\n9 4\n5 7\n2 1\n3 4\n2 10\n6 3\n2 5\n1 3\n4 8\n8\n6 8 3\n10 5 3\n2 10 3\n3 5 2\n8 4 3\n1 9 3\n9 5 2\n3 10 2\n", "output": "3 1 2 3 3 3 3 3 3 \n"}, {"type": "stdin_stdout", "input": "10\n3 6\n3 2\n4 1\n1 10\n3 8\n5 2\n6 7\n2 1\n6 9\n7\n9 10 3\n5 7 1\n9 10 3\n7 4 1\n3 10 4\n3 6 4\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the edit distance between given two words s1 and s2.\n\nThe disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:\n\n* inse...
[{"type": "stdin_stdout", "input": "icpc\nipcc", "output": "2\n"}, {"type": "stdin_stdout", "input": "icpb\ncbio", "output": "4\n"}, {"type": "stdin_stdout", "input": "cpci\nipcc", "output": "2\n"}, {"type": "stdin_stdout", "input": "cpci\nccpi", "output": "2\n"}, {"type": "stdin_stdout", "input": "icpc\nccpi", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThere are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called \"U & U\". \"U & U\" has a common score fo...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000010000000", "output": "4\n"}, {"type": "stdin_stdout", "input": "1000000001000000000 1000000000010000000", "output": "2\n"}, {"type": "stdin_stdout", "input": "1000001001000000000 1000000000010000000", "output": "2\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is the hard version of the problem. The only difference is that in this version $1 \\le n \\le 300$.\n\nIn the cinema seats can be represented as the table with $n$ rows and $m$ columns. The rows are numbered with inte...
[{"type": "stdin_stdout", "input": "7\n1 2\n1 1\n3 2\n1 1 2 2 4 6\n3 3\n3 4 4 1 1 1 1 1 5\n2 2\n2 1 2 1\n4 2\n50 50 50 50 3 50 56 50\n4 2\n6 6 6 10 2 2 9 6\n2 9\n1 3 2 3 3 6 1 1 3 2 3 1 1 6 3 1 1 3\n", "output": "0\n1\n2\n0\n0\n0\n12\n"}, {"type": "stdin_stdout", "input": "7\n1 2\n1 1\n3 2\n1 1 2 4 4 6\n3 3\n3 4 4 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons β€” 8 blocks in total, each block has four hexadecimal digits. Her...
[{"type": "stdin_stdout", "input": "20\n0:0:9e39:9:b21:c9b:c:0\n0:0:0:0:0:a27:6b:cb0a\n2:7:4d:b:0:3:2:f401\n17:2dc6::0:89e3:0:dc:0\nca:4:0:0:d6:b999:e:0\n4af:553:b29:dd7:2:5b:0:7\n0:c981:8f:a4d:0:d4:0:f61\n0:0:1:0:dc33:0:1964:0\n84:da:0:6d6:0ecc:1:f:0\n4:fb:4d37:0:8c:4:4a52:24\nc:e:a:0:0:0:e:0\n0:3761:72ed:b7:3b0:ff7:f...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers ...
[{"type": "stdin_stdout", "input": "680 871 347 800\n10 100\n872 156 571 136 703 201 832 213 15 333\n465 435 870 173 660 237 694 594 423 405 27 866 325 490 255 989 128 345 278 125 708 210 771 848 961 448 871 190 745 343 532 174 103 999 874 221 252 500 886 129 185 208 137 425 758 34 696 15 198 981 91 50 545 885 194 583 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game.\n\nThe game works as f...
[{"type": "stdin_stdout", "input": "21 2\n1 2\n2 3\n2 4\n4 5\n10 6\n6 7\n13 8\n8 9\n1 10\n3 11\n11 12\n12 13\n3 15\n14 15\n20 16\n14 17\n14 18\n14 19\n14 20\n17 21\n", "output": "-70\n"}, {"type": "stdin_stdout", "input": "21 1\n1 2\n2 3\n2 4\n4 5\n10 6\n6 7\n14 8\n8 9\n9 10\n3 11\n11 12\n12 13\n5 14\n14 15\n14 16\n14 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA card pyramid of height $1$ is constructed by resting two cards against each other. For $h>1$, a card pyramid of height $h$ is constructed by placing a card pyramid of height $h-1$ onto a base. A base consists of $h$ pyr...
[{"type": "stdin_stdout", "input": "50\n11833308\n5211498\n64660\n9077929\n2699416\n2432035\n234901\n1337830\n8457191\n10523566\n5722429\n5452712\n5511654\n8587879\n348160\n3141182\n2661936\n395300\n6950223\n2119926\n4407089\n3559060\n10228325\n5752720\n1607500\n647047\n8904557\n1954681\n698061\n9852830\n1972893\n13760...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWilliam arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies.\n\nTh...
[{"type": "stdin_stdout", "input": "10 8\n1 2\n2 3\n3 4\n1 4\n6 7\n8 9\n8 10\n1 4\n", "output": "1\n2\n3\n4\n5\n5\n6\n8\n"}, {"type": "stdin_stdout", "input": "7 6\n1 2\n3 4\n2 4\n7 6\n6 5\n1 7\n", "output": "1\n1\n3\n3\n3\n6\n"}, {"type": "stdin_stdout", "input": "4 3\n2 1\n4 1\n1 2\n", "output": "1\n2\n3\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N integers A_1, A_2, ..., A_N.\nThere are \\frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-...
[{"type": "stdin_stdout", "input": "30 413\n-170202098 -268409015 537203564 983211703 11883920 -443999067 -286607651 -159124657 -358352725 526800997 -1907718835 648738515 -1273635706 -1268616353 37909651 -1 1196187672 -20098238 0 -948955241 1 -214720580 287839163 -18897162 694477644 0 -425610555 158912296 842295515 0",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a long journey, the super-space-time immigrant ship carrying you finally discovered a planet that seems to be habitable. The planet, named JOI, is a harsh planet with three types of terrain, \"Jungle,\" \"Ocean,\" a...
[{"type": "stdin_stdout", "input": "4 7\n4\nJIOJOIJ\nIJIOJOO\nJOIJOOI\nOOJJIJO\n5 7 0 7\n2 2 3 0\n2 3 2 2\n1 1 0 7", "output": "-1 -2 -1\n-1 0 -1\n0 0 0\n0 0 0\n"}, {"type": "stdin_stdout", "input": "4 7\n4\nJIOJOIJ\nIJIOJOO\nJOIJOOI\nOOJJIJO\n5 2 0 7\n2 2 2 0\n2 3 2 2\n1 1 0 7", "output": "-8 -10 -6\n0 0 -1\n0 0 0\n0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJoisino is working as a receptionist at a theater.\nThe theater has 100000 seats, numbered from 1 to 100000.\nAccording to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seat...
[{"type": "stdin_stdout", "input": "2\n151 -2\n0 4", "output": "-147\n"}, {"type": "stdin_stdout", "input": "2\n276 -2\n0 4", "output": "-272\n"}, {"type": "stdin_stdout", "input": "2\n276 -1\n0 4", "output": "-271\n"}, {"type": "stdin_stdout", "input": "2\n276 -1\n0 7", "output": "-268\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a beautiful garden of stones in Innopolis.\n\nIts most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.\n\nEJOI participants have visited this place twice. \n\nWhen they first visited it, th...
[{"type": "stdin_stdout", "input": "50\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\n1000 1000 1000 1000 1000 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\n* Choose two stones painted in the same color. Repaint a...
[{"type": "stdin_stdout", "input": "7\n1\n2\n10\n2\n1\n6\n2", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\n1\n2\n1\n2\n3\n3\n2", "output": "6\n"}, {"type": "stdin_stdout", "input": "7\n1\n3\n1\n2\n1\n3\n2", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n1\n3\n1\n2\n4\n3\n2", "output": "5\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEugeny has array a = a_1, a_2, ..., a_{n}, consisting of n integers. Each integer a_{i} equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers l_{i}, r_{i} (1 ≀ l_{i} ≀ r_{i} ≀ n). ...
[{"type": "stdin_stdout", "input": "10 10\n-1 1 -1 1 -1 -1 -1 -1 -1 -1\n6 10\n4 5\n3 6\n2 3\n3 5\n4 5\n3 4\n1 7\n1 1\n1 1\n", "output": "0\n1\n1\n1\n0\n1\n1\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "10 10\n-1 1 -1 1 -1 -1 -1 -1 -1 -1\n6 13\n4 5\n3 6\n2 3\n0 5\n4 5\n3 4\n1 4\n1 1\n1 1\n", "output": "0\n1\n1\n1\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Russian also. \nChef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him ...
[{"type": "stdin_stdout", "input": "4\n20 -1 -2 -4", "output": "4\n"}, {"type": "stdin_stdout", "input": "4\n0 -2 6 10", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n1 -2 6 10", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n2 -2 6 10", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n4 -2 6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.\n\nYou are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you...
[{"type": "stdin_stdout", "input": "128982\n", "output": "17 16 15 14 13 11 10 9 8 7 5 3 2\n"}, {"type": "stdin_stdout", "input": "97205\n", "output": "17 15 14 13 12 10 9 8 6 5 3 1 \n"}, {"type": "stdin_stdout", "input": "97205\n", "output": "17 15 14 13 12 10 9 8 6 5 3 1\n"}, {"type": "stdin_stdout", "input": "32698\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".\n\nThe test consists of n questio...
[{"type": "stdin_stdout", "input": "50\n515844718 503470143 928669067 209884122 322869098 241621928 844696197 105586164 552680307 968792756 135928721 842094825 298782438 829020472 791637138 285482545 811025527 428952878 887796419 11883658 546401594 6272027 100292274 308219869 372132044 955814846 644008184 521195760 919...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ strings $s_1, s_2, \\ldots, s_n$ consisting of lowercase Latin letters.\n\nIn one operation you can remove a character from a string $s_i$ and insert it to an arbitrary position in a string $s_j$ ($j$ ma...
[{"type": "stdin_stdout", "input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNaman has two binary strings $s$ and $t$ of length $n$ (a binary string is a string which only consists of the characters \"0\" and \"1\"). He wants to convert $s$ into $t$ using the following operation as few times as po...
[{"type": "stdin_stdout", "input": "12\n011001010101\n111001010101\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "12\n011101010101\n101001010101\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "12\n011001010101\n111001010101\n", "output": "-1"}, {"type": "stdin_stdout", "input": "12\n011101010101\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLeha is planning his journey from Moscow to Saratov. He hates trains, so he has decided to get from one city to another by car.\n\nThe path from Moscow to Saratov can be represented as a straight line (well, it's not that...
[{"type": "stdin_stdout", "input": "100\n3 3 3 4 7 8 8 8 9 9 10 12 12 13 14 14 15 15 16 17 17 20 21 21 22 22 23 25 29 31 36 37 37 38 39 40 41 41 41 42 43 44 45 46 46 47 47 49 49 49 51 52 52 53 54 55 59 59 59 60 62 63 63 64 66 69 70 71 71 72 74 76 76 77 77 78 78 79 80 81 81 82 82 84 85 86 87 87 87 89 91 92 92 92 92 97 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b. \n\nEach of the friends can move by one along the line in any directi...
[{"type": "stdin_stdout", "input": "864\n179\n", "output": "117649\n"}, {"type": "stdin_stdout", "input": "967\n102\n", "output": "187489\n"}, {"type": "stdin_stdout", "input": "967\n142\n", "output": "170569\n"}, {"type": "stdin_stdout", "input": "967\n282\n", "output": "117649\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are integer sequence of length N, A = (A_1, A_2, \\cdots, A_N), and an integer K.\nFor each X such that 1 \\le X \\le K, find the following value:\n\\left(\\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} (A_L+A_R)...
[{"type": "stdin_stdout", "input": "192 275\n426 445 272 81 447 129 497 202 275 325 482 284 417 156 432 402 228 37 357 239 418 211 179 6 340 68 368 16 440 263 93 449 491 310 355 68 431 80 257 218 434 328 176 355 221 80 422 45 11 67 467 174 191 4 335 34 465 480 221 395 1 152 325 231 302 153 396 22 489 399 107 466 432 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe problem statement looms below, filling you with determination.\n\nConsider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the ...
[{"type": "stdin_stdout", "input": "3 3\nXX.\n...\n.XX\n10\n1 3\n1 3\n1 2\n1 2\n3 3\n1 3\n2 3\n3 3\n2 3\n2 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "3 3\n..X\nX.X\n..X\n10\n2 3\n2 2\n3 3\n1 3\n1 1\n3 3\n3 3\n1 1\n1 2\n1 1\n", "output": "YES\nYES\nYES\nYES\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ beautiful skyscrapers in New York, the height of the $i$-th one is $h_i$. Today some villains have set on fire first $n - 1$ of them, and now the only safety building is $n$-th skyscraper.\n\nLet's call a ju...
[{"type": "stdin_stdout", "input": "8\n7 2 5 5 1 2 5 2\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n7 2 5 5 1 2 2 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n7 2 5 5 2 2 5 2\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n4 3 5 5 1 2 5 2\n", "output": "4\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce a Mathematician was trapped by military people during a world war with his forty colleagues. The colleagues were without any weapons, only the mathematician had a knife. And with no weapons they were not able to figh...
[{"type": "stdin_stdout", "input": "934\n48171068\n63138680\n25597136\n5610719\n22559303\n19374620\n52609147\n76485130\n4119341\n84687324\n74124384\n29214349\n76525070\n27296334\n62086857\n7062292\n70121510\n32711240\n40766945\n75911566\n64205975\n68575226\n83591193\n54443307\n63540837\n4289505\n8767969\n70478582\n7243...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they star...
[{"type": "stdin_stdout", "input": "100\n4 3\n3 4\n5 1\n2 5\n5 3\n1 5\n6 3\n2 4\n5 2\n2 6\n5 2\n1 5\n6 3\n1 5\n6 3\n3 4\n5 2\n1 5\n6 1\n1 5\n4 2\n3 5\n6 3\n2 6\n6 3\n1 4\n6 2\n3 4\n4 1\n3 6\n5 1\n2 4\n5 1\n3 4\n6 2\n3 5\n4 1\n2 6\n4 3\n2 6\n5 2\n3 6\n6 2\n3 5\n4 3\n1 5\n5 3\n3 6\n4 2\n3 4\n6 1\n3 4\n5 2\n2 6\n5 2\n2 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be...
[{"type": "stdin_stdout", "input": "69\n1034 414 632 614 62 855 915 385 1098 8 462 1750 1227 960 450 25 1307 578 37 262 482 1143 844 696 1004 1008 70 1137 509 1217 561 557 192 513 792 794 1335 1201 1290 543 698 55 119 536 1088 162 1074 676 246 457 662 595 1054 1252 778 165 703 1222 326 158 145 272 729 381 1087 1261 717...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Kingdom of Kremland is a tree (a connected undirected graph without cycles) consisting of $n$ vertices. Each vertex $i$ has its own value $a_i$. All vertices are connected in series by edges. Formally, for every $1 \\...
[{"type": "stdin_stdout", "input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37 22 31 4 3 27 23 21 21 26 39 20 8\n", "output": "6926\n"}, {"type": "stdin_stdout", "input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fo...
[{"type": "stdin_stdout", "input": "110 5\n111 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 109 90\n-110 159 10 3\n26 11\n15 -1 5 2\n25 0 5 1\n35 0 5 1\n118 0 5 1\n55 0 5 1\n65 0 5 1\n149 -1 5 1\n169 0 1 1\n90 0 5 1\n-19 -1 5 20\n-30 0 500 5\n0 0", "output": "1\n4\n"}, {"type": "stdin_stdout", "input": "100 5\n111 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is sad β€” New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.\n\nThe local store introduced a new service thi...
[{"type": "stdin_stdout", "input": "11\n1000000000 500000000 500000000\n1000000000 500000000 499999999\n1000000000 499999999 499999999\n500000000 1000000000 500000000\n500000000 1000000000 499999999\n499999999 1000000000 499999999\n500000000 500000000 1000000000\n500000000 499999999 1000000000\n499999999 499999999 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n points on a straight line, and the i-th point among them is located at x_{i}. All these coordinates are distinct.\n\nDetermine the number m β€” the smallest number of points you should add on the line to make th...
[{"type": "stdin_stdout", "input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505\n", "output": "156311685\n"}, {"type": "stdin_stdout", "input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505...
code_stdio