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\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, prin... | [{"type": "stdin_stdout", "input": "7\n500 1009", "output": "OK\n"}, {"type": "stdin_stdout", "input": "7\n500 1407", "output": "OK\n"}, {"type": "stdin_stdout", "input": "7\n500 2719", "output": "OK\n"}, {"type": "stdin_stdout", "input": "7\n500 1806", "output": "OK\n"}, {"type": "stdin_stdout", "input": "7\n782 1806"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \\leq A_i,B_i \\leq N).\n\nNow, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independent... | [{"type": "stdin_stdout", "input": "7\n4 7\n3 1\n2 6\n5 4\n7 1\n2 7", "output": "835937507\n"}, {"type": "stdin_stdout", "input": "7\n4 7\n3 1\n3 6\n5 4\n7 1\n2 7", "output": "679687506\n"}, {"type": "stdin_stdout", "input": "7\n4 7\n3 1\n2 6\n5 1\n7 1\n2 7", "output": "570312505\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and ... | [{"type": "stdin_stdout", "input": "7\n1 2 3 4 5 6 7", "output": "YES"}, {"type": "stdin_stdout", "input": "5\n-1 20 0 -2 0", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n-2 20 0 -2 0", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n1 20 -1 -2 0", "output": "NO\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.\nThe pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) ... | [{"type": "stdin_stdout", "input": "3\n99 1 191\n100 1 192\n99 0 192", "output": "100 0 193"}, {"type": "stdin_stdout", "input": "3\n99 1 191\n000 1 192\n99 0 192", "output": "49 0 242\n"}, {"type": "stdin_stdout", "input": "3\n99 1 191\n000 1 154\n99 0 192", "output": "68 0 223\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicogra... | [{"type": "stdin_stdout", "input": "abcdefghijklmnopqrytuvwzsx", "output": "abcdefghijklmnopqrytuvwzx\n"}, {"type": "stdin_stdout", "input": "abcpefghijklmnodqrytuvwzsx", "output": "abcpefghijklmnodqrytuvwzx\n"}, {"type": "stdin_stdout", "input": "azcdefghijklmnopqrstuvwbyx", "output": "azcdefghijklmnopqrstuvwx\n"}, {"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n* 1 \\leq N \\leq 10^9\n* N is an integer.\n\nInput\n\nInput is gi... | [{"type": "stdin_stdout", "input": "1205711547", "output": "1205686729\n"}, {"type": "stdin_stdout", "input": "1258489257", "output": "1258475625\n"}, {"type": "stdin_stdout", "input": "1044195797", "output": "1044194596\n"}, {"type": "stdin_stdout", "input": "115087508", "output": "115068529\n"}, {"type": "stdin_stdou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nb4ab97... | [{"type": "stdin_stdout", "input": "12 12", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 10", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "7 10", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "7 12", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "5 10", "output": "Yes\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi and Aoki are going to together construct a sequence of integers.\n\nFirst, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:\n\n* The length of a is N.\n* Each element ... | [{"type": "stdin_stdout", "input": "1000001000 1000000000", "output": "212353005\n"}, {"type": "stdin_stdout", "input": "1000001000 1010000000", "output": "938420542\n"}, {"type": "stdin_stdout", "input": "1000000000 1010000000", "output": "623631994\n"}, {"type": "stdin_stdout", "input": "1001000000 1010010000", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 ... | [{"type": "stdin_stdout", "input": "4\n-100 -45 -100 -100", "output": "2269\n"}, {"type": "stdin_stdout", "input": "4\n-100 -100 -100 -100", "output": "0"}, {"type": "stdin_stdout", "input": "3\n-3 -1 23", "output": "419\n"}, {"type": "stdin_stdout", "input": "3\n-3 -1 21", "output": "355\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are... | [{"type": "stdin_stdout", "input": "-10 6 6\n20 2 5\n1 10 0\n-1 10 10\n0 0 10", "output": "MISS\n"}, {"type": "stdin_stdout", "input": "-10 6 6\n20 2 5\n0 10 0\n-1 10 10\n0 0 10", "output": "MISS\n"}, {"type": "stdin_stdout", "input": "-10 6 6\n20 2 5\n0 10 0\n-1 10 14\n0 0 10", "output": "MISS\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.\n\nHer magic is activated by drawing a magic circle using some mag... | [{"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "yes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n7 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "yes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a string consisting of only numbers from 0 to 9, consider the operation of creating a new string from that string according to the following rules. Read the given string one character at a time from the left end. Go... | [{"type": "stdin_stdout", "input": "5\n28\n14\n1\n0", "output": "11131221121113122118\n311311222113111231131112132112311321322112111312211312111322212311322113212221\n"}, {"type": "stdin_stdout", "input": "5\n23\n14\n1\n0", "output": "11131221121113122113\n311311222113111231131112132112311321322112111312211312111322212... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHierarchical Democracy\n\nThe presidential election in Republic of Democratia is carried out through multiple stages as follows.\n\n1. There are exactly two presidential candidates.\n2. At the first stage, eligible voters... | [{"type": "stdin_stdout", "input": "6\n[[123][4567][89]]\n[[5][3][6][3][9]]\n[[[99][59][63][85][51]][[1539][7995][466]][[51][57][79][99][3][91][59]]]\n[[[37][95][31][77][25]][[43][5][5][5][85]][[71][3][51][89][29]][[57][94][5][69][31]][[99][59][65][73][31]]]\n[[[[9][7][3]][[3][5][7]][[7][9][5]]][[[9][9][3]][[5][9][9]][... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMany cats live on the campus of a school. Natsume's daily routine is to pet those cats. However, the cats may be capricious and go for a walk off campus.\n\nThe campus site is a rectangle with each side parallel to the x-... | [{"type": "stdin_stdout", "input": "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n41 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10", "output": "2\n2\n"}, {"type": "stdin_stdout", "input": "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n55 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10", "output": "2\n2\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\n()(()((\n))()()(()\n)())(())\n\n\nOutput\n\nYes\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite... | [{"type": "stdin_stdout", "input": "3\n()(()((\n))()()(()\n)())(())", "output": "Yes"}, {"type": "stdin_stdout", "input": "3\n()(()((\n))()(((()\n)())(())", "output": "No\n"}, {"type": "stdin_stdout", "input": "3\n()(()((\n))()(((()\n))(())()", "output": "No\n"}, {"type": "stdin_stdout", "input": "3\n()(()((\n))()(((()... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nD: Country In Distortion-\n\nstory\n\nAlice was completely bored. This is because the White Rabbit, who is always playing with him, is out to Trump Castle. (Ah, I wish I had gone out with him in this case.) Alice thought.... | [{"type": "stdin_stdout", "input": "4 4\n1 3 4\n2 3 0\n1 1 4\n3 4 2\n5\n0 10 12", "output": "100\n"}, {"type": "stdin_stdout", "input": "4 4\n1 3 4\n2 2 0\n1 1 7\n3 4 2\n5\n0 13 18", "output": "124\n"}, {"type": "stdin_stdout", "input": "4 4\n1 3 5\n2 3 0\n3 2 10\n3 4 1\n5\n8 10 6", "output": "39\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nF: MOD Rush\n\nproblem\n\nGiven a positive integer sequence A of length N and a positive integer sequence B of length M.\n\nFor all (i, j) (1 \\ leq i \\ leq N, 1 \\ leq j \\ leq M), find the remainder of A_i divided by B... | [{"type": "stdin_stdout", "input": "3 0\n11 3 9\n0 -1 24", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 0\n8 3 13\n0 -1 24", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 0\n11 3 9\n0 -2 24", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 0\n4 2 5\n1 -1 16", "output": "0\n"}, {"type": "stdin_... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRun, Twins\n\nE869120 You started running from home to school at a speed of $ P $ meters per minute.\n\nsquare1001 noticed E869120's forgotten thing $ A $ minutes after E869120 left home and chased at $ Q $ meters per min... | [{"type": "stdin_stdout", "input": "14 86\n9 1 20", "output": "119.428571428571"}, {"type": "stdin_stdout", "input": "-6 -4\n-2 -1 -5", "output": "-5.66667\n"}, {"type": "stdin_stdout", "input": "-6 -4\n-2 -2 -7", "output": "-5.33333\n"}, {"type": "stdin_stdout", "input": "20 124\n10 0 27", "output": "169.926\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:\n\n* $update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.\n* $getSum(s, t)$: print the sum of $a_s, a_{s+1... | [{"type": "stdin_stdout", "input": "10 7\n0 1 3 1\n0 0 4 -2\n1 0 5\n1 0 2\n0 1 5 0\n1 2 4\n1 0 0", "output": "-10\n-6\n0\n-2\n"}, {"type": "stdin_stdout", "input": "10 7\n0 1 2 1\n0 2 4 -2\n1 0 5\n1 0 2\n0 1 5 -1\n1 0 4\n1 0 0", "output": "-5\n-1\n-4\n0\n"}, {"type": "stdin_stdout", "input": "10 7\n0 1 3 1\n0 2 4 -2\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDid you know that the yummy golden triangle was introduced in India as early as 13th century ? By the way, I'm referring to the popular South Asian snack, Samosa. I guess its hard to code while thinking of Samosa, especia... | [{"type": "stdin_stdout", "input": "1\n4\n10 20 34 89\n4\n10 26\n7 21\n14 21\n7 35", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n4\n10 20 34 55\n4\n7 14\n7 21\n14 21\n7 35", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n4\n10 20 34 89\n4\n7 14\n7 21\n14 21\n7 35", "output": "2\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings a and b consisting of lowercase English letters, both of length n. The characters of both strings have indices from 1 to n, inclusive. \n\nYou are allowed to do the following changes: \n\n * Cho... | [{"type": "stdin_stdout", "input": "7\nabacaba\nbacabaa\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "7\nabacaba\naabacab\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "7\nabacaaa\naabacab\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\nabacaaa\naabacaa\n", "output": "4\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nXXI Berland Annual Fair is coming really soon! Traditionally fair consists of n booths, arranged in a circle. The booths are numbered 1 through n clockwise with n being adjacent to 1. The i-th booths sells some candies fo... | [{"type": "stdin_stdout", "input": "78 74\n20194 1621 21498 13827 31277 19791 6583 13579 11160 20419 26490 160 3450 12925 18134 10381 27009 28815 10209 6478 18504 15371 32608 14197 12075 13723 12612 19020 28762 11057 12891 31164 16684 13717 19933 25453 2742 4955 6814 2863 10397 15461 20616 10905 2600 20137 4681 9199 27... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThree years have passes and nothing changed. It is still raining in London, and Mr. Black has to close all the doors in his home in order to not be flooded. Once, however, Mr. Black became so nervous that he opened one do... | [{"type": "stdin_stdout", "input": "250\n1 0 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem is a version of problem D from the same contest with some additional constraints and tasks.\n\nThere are n candies in a candy box. The type of the i-th candy is a_i (1 ≤ a_i ≤ n). \n\nYou have to prepare a gi... | [{"type": "stdin_stdout", "input": "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n7 1\n7 0\n7 1\n", "output": "3 3\n3 3\n9 5\n"}, {"type": "stdin_stdout", "input": "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a_1, a_2, …, a_n.\n\nIn one operation you can choose two elements a_i and a_j (i ≠ j) and decrease each of them by one.\n\nYou need to check whether it is possible to make all the elements equal to ... | [{"type": "stdin_stdout", "input": "5\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n1000000000 1000000000 1000000000 1000000000 0000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n1000000000 1000000000 1000000000 1000000000 000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.\n\nAfter struggling and failing many times, Ujan decided to try ... | [{"type": "stdin_stdout", "input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza\nzz\n3\nabc\nbca\n16\naajjhdsjfdsfkadf\naajjhjsjfdsfkajf\n2\nix\nii\n2\noo\nqo\n2\npp\npa\n", "output": "Yes\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\n"}, {"type": "stdin_stdout", "input": "10\n11\nartiovnldnp\nart... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3... | [{"type": "stdin_stdout", "input": "250000 996140731\n", "output": "227969454\n"}, {"type": "stdin_stdout", "input": "244435 994838543\n", "output": "634651929\n"}, {"type": "stdin_stdout", "input": "200422 984828937\n", "output": "556345906\n"}, {"type": "stdin_stdout", "input": "140426 454141843\n", "output": "451934... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s. You can build new string p from s using the following operation no more than two times: \n\n 1. choose any subsequence s_{i_1}, s_{i_2}, ..., s_{i_k} where 1 ≤ i_1 < i_2 < ... < i_k ≤ |s|; \n 2... | [{"type": "stdin_stdout", "input": "1\nbbbaaaaabbabaabbbbaabbbbabbaabbaababbbbbbababbababbbaaaaaaabaababbbaababbbbababbbabbbbbabaabbaaaabaa\nbbbababbaabbbbbaabaaabaababaaaabaabbbabbababaaabba\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\nbbbaaaaabbabaabbbbaabbbbabbaabbaababbbbbbababbababbbaaaaaaabaababb... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given three integers n, k, m and m conditions (l_1, r_1, x_1), (l_2, r_2, x_2), ..., (l_m, r_m, x_m).\n\nCalculate the number of distinct arrays a, consisting of n integers such that: \n\n * 0 ≤ a_i < 2^k for eac... | [{"type": "stdin_stdout", "input": "20 10 20\n6 8 384\n6 7 385\n6 10 128\n13 14 182\n15 19 0\n19 20 468\n20 20 477\n6 8 384\n17 20 16\n2 4 205\n6 6 899\n16 20 0\n20 20 477\n12 15 6\n9 11 513\n11 11 873\n16 19 0\n15 16 15\n7 9 180\n10 10 727\n", "output": "298754800\n"}, {"type": "stdin_stdout", "input": "20 10 20\n6 8 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nJohn and his imaginary friend play a game. There are n lamps arranged in a circle. Lamps are numbered 1 through n in clockwise order, that is, lamps i and i + 1 are adjacent for any i = ... | [{"type": "stdin_stdout", "input": "1000 18\n", "output": "964 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 86 87 88 89 90 91 92 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.\n\nLet's consider that all lines in the poems consist of lowercase Latin letter... | [{"type": "stdin_stdout", "input": "7 3\nferwljzwakxedlgwl\noerwljzwakxedlgwl\nhyqombizhuhxedprb\netptjrizhuhxedprb\nurtuckar\ndkartmwramklcmi\nrurtuckar\nnurartmwramklcmi\niraziomsv\nsaziomsv\nbprapiqpayzurgij\nusyemayzurgij\nztstmeecvmkvuu\nquexlecvmkvuu\nrlhwecvmkvuu\nzecvmkvuu\niikymgbncljtub\nqiikymgbncljtub\nbcav... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected graph consisting of n vertices and n edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and m... | [{"type": "stdin_stdout", "input": "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "output": "\n6\n11\n18\n"}, {"type": "stdin_stdout", "input": "3\n3\n1 2\n2 3\n1 3\n4\n1 4\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "output": "6\n11\n18\n"}, {"type": "stdin_stdout", "input": "3\n3\n1 2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLong time ago there was a symmetric array a_1,a_2,…,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,…,a_{2n} is called symmetric if for each integer 1 ≤ i ≤ 2n, there exists an integer 1 ≤ j ≤ 2n such that a_i = ... | [{"type": "stdin_stdout", "input": "6\n2\n8 12 8 12\n2\n7 7 9 11\n2\n7 11 7 11\n1\n1 1\n4\n40 56 48 40 160 56 117 48\n6\n240 154 210 162 174 154 186 240 174 186 162 210\n", "output": "YES\nNO\nNO\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "6\n2\n8 12 8 12\n2\n7 7 9 11\n2\n0 11 7 11\n1\n1 1\n4\n40 56 48 40 160 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n<image> <image>\n\n*The two images are equivalent, feel free to use either one.\n\nInput\n\nThe input contains a single integer a (-100 ≤ a ≤ 100).\n\nOutput\n\nOutput the result – an integer number.\n\nExample\n\nInput\n... | [{"type": "stdin_stdout", "input": "-1079\n", "output": "-1164239\n"}, {"type": "stdin_stdout", "input": "-340\n", "output": "-115598\n"}, {"type": "stdin_stdout", "input": "-449\n", "output": "-201599\n"}, {"type": "stdin_stdout", "input": "-685\n", "output": "-469223\n"}, {"type": "stdin_stdout", "input": "-432\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLast summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not ... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "958220352\n"}, {"type": "stdin_stdout", "input": "972408\n", "output": "377259665\n"}, {"type": "stdin_stdout", "input": "956022\n", "output": "864671299\n"}, {"type": "stdin_stdout", "input": "941322\n", "output": "359985814\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the eleme... | [{"type": "stdin_stdout", "input": "100\n", "output": "15"}, {"type": "stdin_stdout", "input": "010\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "001\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "011\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "61\n", "output": "11"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOnce at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.\n\nAccording to the boys, linear search works as follows. The array elements in a pre-selected order are in turn comp... | [{"type": "stdin_stdout", "input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 9 2 9 2 10 9 8\n", "output": "40 59\n"}, {"type": "stdin_stdout", "input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n3 1 9 2 9 2 10 9 8\n", "output": "43 56\n"}, {"type": "stdin_stdout", "input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 6 2 9 2 10 9 8\n", "output": "42 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJoe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.\n\nJoe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty... | [{"type": "stdin_stdout", "input": "20 20\n..+#+.+++.+++#+..#++\n..####+++#..++#+.+.+\n+.+..+++..#.++++++++\n+##++..+.##..#+++.++\n++.+.+.+.++++.+++.++\n.+++++.+#+++++...+#+\n.++.#+++++++++.++.++\n...+.++++++.++#...++\n+++.+++.+....#....+.\n.++++++.+.+..++.++##\n.+..+..++#.+..++++++\n+..#+++++..+##+#++.+\n+.+#+#....+.#... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHaving written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly k time units for the lunch break.\n\nThe Rabbits have a list of n restaurants to lunch in: the i-th res... | [{"type": "stdin_stdout", "input": "2 3\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "2 4\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "2 4\n1000000000 1\n2 0\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "2 4\n1000000000 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game. \n\nRoman leaves a word for each of them. Each word consists ... | [{"type": "stdin_stdout", "input": "10\n00000000000111111110\n00000000011111111111\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "10\n00010000000111111110\n00000000011111111111\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "10\n00000000000111111111\n00000000011111111111\n", "output": "Draw... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he w... | [{"type": "stdin_stdout", "input": "2\n2 1 16 1\n4\n1 2 1 2\n", "output": "1\n4\n2\n3\n"}, {"type": "stdin_stdout", "input": "2\n2 1 16 1\n4\n2 2 0 2\n", "output": "2\n3\n3\n2\n"}, {"type": "stdin_stdout", "input": "2\n2 1 16 1\n4\n1 2 0 2\n", "output": "1\n4\n4\n1\n"}, {"type": "stdin_stdout", "input": "2\n2 1 4 3\n4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nValera is a collector. Once he wanted to expand his collection with exactly one antique item.\n\nValera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction price of the j-th object of t... | [{"type": "stdin_stdout", "input": "3 999999\n22 1000000 1000000 1250369 623205 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000100 1506663 1001000 1010000 999999 1000000 1000000 1010000 352800 999999 1000000\n14 999999 999999 1521826 1368902 999999 1000000 999999 1556972 999999 999999 418013 999999 1000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCaisa solved the problem with the sugar and now he is on the way back to home. \n\nCaisa is playing a mobile game during his path. There are (n + 1) pylons numbered from 0 to n in this game. The pylon with number 0 has ze... | [{"type": "stdin_stdout", "input": "99\n1401 2019 1748 3785 3236 3177 3443 3772 2138 1049 353 1195 310 2388 1322 88 2160 2783 435 2248 1471 706 2468 2319 3156 3506 2794 1999 1983 2519 2597 3735 537 344 3519 3772 3872 2961 3895 2010 10 247 3269 671 2986 942 758 1146 77 1545 3745 1547 2250 2565 217 1406 2070 3010 3404 40... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA monster is attacking the Cyberland!\n\nMaster Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).\n\nDuring the bat... | [{"type": "stdin_stdout", "input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 100 1\n100 100 100\n1 100 100\n", "output": "1891\n"}, {"type": "stdin_stdout", "input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.\n\nHis phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score wit... | [{"type": "stdin_stdout", "input": "77\n", "output": "seventy-seven\n"}, {"type": "stdin_stdout", "input": "73\n", "output": "seventy-three\n"}, {"type": "stdin_stdout", "input": "78\n", "output": "seventy-eight\n"}, {"type": "stdin_stdout", "input": "27\n", "output": "twenty-seven\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard. During each of the next th... | [{"type": "stdin_stdout", "input": "1000 1000 999 1000\n* * *\n", "output": "999000000000\n"}, {"type": "stdin_stdout", "input": "720 903 589 804\n* * *\n", "output": "307887168960\n"}, {"type": "stdin_stdout", "input": "573 598 1387 124\n* * *\n", "output": "58932376152\n"}, {"type": "stdin_stdout", "input": "739 903 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it... | [{"type": "stdin_stdout", "input": "10010 1000000000 999999999 1000000000 1\n", "output": "1.0000000009999002\n"}, {"type": "stdin_stdout", "input": "10000 1000000000 999999999 1000000000 10000\n", "output": "1.000000000"}, {"type": "stdin_stdout", "input": "10010 1000000000 1 1000000000 10000\n", "output": "2.99999999... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not bo... | [{"type": "stdin_stdout", "input": "100000 100000 10000\n", "output": "308343288\n"}, {"type": "stdin_stdout", "input": "100000 100000 1000\n", "output": "402115033\n"}, {"type": "stdin_stdout", "input": "100000 100000 1001\n", "output": "500272705\n"}, {"type": "stdin_stdout", "input": "100000 100000 100\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains ai balls, all of which have color i. You have to write a program that will divide all balls into sets such that:\n\n *... | [{"type": "stdin_stdout", "input": "200\n1 2 4 10 5 8 1 10 9 10 1 9 5 5 3 10 4 7 7 1 5 10 1 6 7 3 9 3 5 8 8 9 7 3 1 5 6 7 3 3 1 4 9 2 8 7 2 10 2 1 10 9 6 1 9 5 3 5 9 3 3 2 4 9 5 9 4 8 5 6 10 1 3 10 8 6 10 10 4 6 8 4 10 7 5 2 6 6 8 8 8 10 3 2 4 5 10 2 2 10 4 5 3 1 8 10 8 5 6 4 9 10 8 10 8 6 3 1 6 4 7 4 10 10 6 7 1 1 2 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nUnlucky year in Berland is such a year that its number n can be represented as n = xa + yb, where a and b are non-negative integer numbers. \n\nFor example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 20 +... | [{"type": "stdin_stdout", "input": "433333986179614514 1000001000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"type": "stdin_stdout", "input": "239838434825939759 805278168279318096 202337849919104640 1225406646213503725\n", "output": "565439733453378336\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.\n\nAt first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds ai can... | [{"type": "stdin_stdout", "input": "100 456\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, numbered from 1 to 2N. The tourn... | [{"type": "stdin_stdout", "input": "3\n0 0 100 0 100 0 0 0\n100 0 100 0 0 0 100 100\n0 0 0 100 100 0 0 0\n100 100 0 0 0 0 100 100\n0 100 0 100 0 0 100 0\n100 100 100 100 100 0 0 0\n100 0 100 0 0 100 0 0\n100 0 100 0 100 100 100 0\n", "output": "12.00000000000000"}, {"type": "stdin_stdout", "input": "3\n0 53 31 33 2 34 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.\n\nThere are n stations in the subway. It was built according to the Bertown ... | [{"type": "stdin_stdout", "input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer m.\n\nLet M = 2m - 1.\n\nYou are also given a set of n integers denoted as the set T. The integers will be provided in base 2 as n binary strings of length m.\n\nA set of integers S is called \"go... | [{"type": "stdin_stdout", "input": "30 10\n001000000011000111000010010000\n000001100001010000000000000100\n000110100010100000000000101000\n110000010000000001000000000000\n100001000000000010010101000101\n001001000000000100000000110000\n000000010000100000001000000000\n001000010001000000001000000010\n000000110000000001001... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th w... | [{"type": "stdin_stdout", "input": "15\n18 6 18 21 14 20 13 9 18 20 28 13 19 25 21\n", "output": "10 -1 8 8 6 6 0 -1 2 2 3 -1 -1 0 -1 "}, {"type": "stdin_stdout", "input": "15\n14 4 5 12 6 19 14 19 12 22 23 17 14 21 27\n", "output": "7 -1 -1 0 -1 6 1 4 -1 3 2 0 -1 -1 -1 "}, {"type": "stdin_stdout", "input": "15\n14 4 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of ... | [{"type": "stdin_stdout", "input": "24\n19 14\n8 15\n13 4\n18 16\n1 17\n10 3\n22 21\n10 14\n6 11\n9 12\n15 22\n11 3\n21 7\n2 12\n7 4\n4 19\n16 9\n24 17\n5 15\n8 2\n23 10\n20 12\n18 24\n", "output": "1 20 21 22 23 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24\n"}, {"type": "stdin_stdout", "input": "24\n19 14\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPaul was the most famous character in Tekken-3. Of course he went to college and stuff. In one of the exams he wasn't able to answer a question which asked to check if a tuple of 3 non negative integers constituted a Prim... | [{"type": "stdin_stdout", "input": "100\n130 0 130\n8938 6200 6439\n1059 816 676\n2421 621 2340\n9530 7280 6150\n9997 9228 3845\n68 60 32\n1412 0 1412\n9 0 9\n769 600 481\n3740 1760 3300\n91 84 35\n156 144 60\n1525 1365 681\n5 4 3\n400 384 113\n1844 1520 1044\n3256 0 3256\n1586 864 1330\n710 0 710\n10 0 10\n6 -1 6\n13 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEd, Edd and Eddy are given an art homework. They have to prepare a banner and print a single line of text on it. They can print any text they want. Ed has decided the text that he wants to put on his banner. Lets call i... | [{"type": "stdin_stdout", "input": "5\nkelio\nhi olldg ii\nged\ncba eed\njwaa\npxthon\nd\ncplusplus\nhellohi\nhellotherdhi\n\nS@NPNE", "output": "not possible\nnot possible\nnot possible\nnot possible\nnot possible\n"}, {"type": "stdin_stdout", "input": "5\nkelio\nhi olldg ii\nged\ncba eed\njwaa\npxthon\nd\nsulpsulpc\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMilly loves to eat chocolates. She buys only those food items which contain some amount or percentage of chocolate in it. She has purchased N such food items and now she is planning to make a new food item by her own. Sh... | [{"type": "stdin_stdout", "input": "5\n332\n2 63 41 84 96 4 62 52 38 36 89 99 82 72 50 100 26 34 57 54 38 62 57 39 94 4 87 34 89 38 59 64 27 67 16 28 92 28 66 58 13 82 47 94 70 60 91 72 37 90 9 75 79 50 37 30 20 11 83 51 40 95 28 70 71 9 24 44 88 94 91 81 17 11 44 2 6 20 3 59 76 4 58 88 60 9 6 43 89 41 94 29 85 56 40 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou want to repaint your house entirely for an upcoming occasion. The total area of your house is D units. There are a total of N workers. The i^th worker has his available time Ti, hiring cost Xi and speed Yi. This means... | [{"type": "stdin_stdout", "input": "3 3\n1 -1 1\n4 2 -1\n6 2 5\n\nSAMPLE", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 4\n0 -2 2\n4 3 -1\n6 2 6\n\nSAMPLE", "output": "-2\n"}, {"type": "stdin_stdout", "input": "3 3\n1 -1 1\n4 3 -1\n6 2 5\n\nSAMPLE", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 3\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.\n\nThe type of i-th query is represented by T_i.\n\n* T_i=1: You are given two integers X_i,V_i. Replace the value of A_... | [{"type": "stdin_stdout", "input": "5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0", "output": "3\n3\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 5\n1 2 1 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0", "output": "2\n6\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 5\n1 2 1 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 2 0", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem:\n\n* We will make a sequenc... | [{"type": "stdin_stdout", "input": "10\n1 2 4 2 11 1 7 11 0 4\n1 3\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n2\n2\n4\n2\n3\n2\n2\n3\n"}, {"type": "stdin_stdout", "input": "10\n1 2 4 0 12 1 7 11 0 4\n1 5\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n3\n3\n2\n2\n2\n2\n2\n3\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence of N \\times K integers: X=(X_0,X_1,\\cdots,X_{N \\times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\\cdots,A_{N-1}). For each pair i, j (0 \\leq i \\leq K-1,\\ 0 ... | [{"type": "stdin_stdout", "input": "11 97\n0 1 8 2 5 4 2 6 2 3 5", "output": "0 1 8 6 2 3 5\n"}, {"type": "stdin_stdout", "input": "11 47\n0 1 0 3 10 5 1 36 2 2 0", "output": "10 5 1 36 0\n"}, {"type": "stdin_stdout", "input": "11 101\n0 2 4 1 5 4 4 6 0 3 5", "output": "2 4 6 0 3 5\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA museum exhibits N jewels, Jewel 1, 2, ..., N. The coordinates of Jewel i are (x_i, y_i) (the museum can be regarded as a two-dimensional plane), and the value of that jewel is v_i.\n\nSnuke the thief will steal some of ... | [{"type": "stdin_stdout", "input": "10\n66 38 71040136000\n65 77 74799603000\n80 53 172413930453\n24 34 24931901000\n51 78 49867703000\n52 71 46108236000\n46 119 74799603000\n56 66 93122668000\n32 51 74374554736\n33 26 70912345000\n21\nL 69 1\nL 7 0\nU 47 4\nR 92 0\nR 91 1\nD 53 2\nR 65 3\nD 13 0\nU 63 3\nL 68 3\nD 47 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi is a user of a site that hosts programming contests.\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\n* Let... | [{"type": "stdin_stdout", "input": "4500\n-140", "output": "-4780\n"}, {"type": "stdin_stdout", "input": "4500\n-148", "output": "-4796\n"}, {"type": "stdin_stdout", "input": "4500\n-237", "output": "-4974\n"}, {"type": "stdin_stdout", "input": "2002\n416", "output": "-1170\n"}, {"type": "stdin_stdout", "input": "2002\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\n\nSome of ... | [{"type": "stdin_stdout", "input": "10 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo", "output": "5"}, {"type": "stdin_stdout", "input": "9 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n...... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct.\n... | [{"type": "stdin_stdout", "input": "3\n3\n4\n18\n11\n0\n10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3\n4\n18\n20\n0\n10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3\n10\n8\n7\n0\n10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n3\n10\n9\n7\n0\n10", "output": "1\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at leas... | [{"type": "stdin_stdout", "input": "1001 8\n1 0 4 5 6 7 15 11", "output": "2222\n"}, {"type": "stdin_stdout", "input": "1001 8\n1 3 2 5 6 7 15 9", "output": "4000\n"}, {"type": "stdin_stdout", "input": "1001 8\n1 3 4 5 6 7 8 9", "output": "2000\n"}, {"type": "stdin_stdout", "input": "1000 8\n2 3 4 5 6 7 8 9", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nI decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time.\n\nOne day, when I was water... | [{"type": "stdin_stdout", "input": "5\n1 2 3 11 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "11\n1\n12\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 14 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "14\n1\n12\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 25 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nGiven a sequence of n integers a1, a2, ..., an and a positive integer k (1 ≤ k ≤ n), then the sum of k consecutive integers Si = ai + ai + Create a program that outputs the maximum value of 1 + ... + ai + k-1 (... | [{"type": "stdin_stdout", "input": "5 1\n-1\n18\n-4\n17\n2\n0 0", "output": "18\n"}, {"type": "stdin_stdout", "input": "5 1\n-1\n3\n-4\n30\n2\n0 0", "output": "30\n"}, {"type": "stdin_stdout", "input": "5 3\n2\n13\n-3\n27\n1\n0 0", "output": "37\n"}, {"type": "stdin_stdout", "input": "5 1\n2\n10\n-4\n14\n2\n0 0", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhen naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in gen... | [{"type": "stdin_stdout", "input": "get^user_name L\ngetTserNbme U\nemaNresUteG D\nEndOfInput X", "output": "get^userName\nGetTserNbme\nema_nres_ute_g\n"}, {"type": "stdin_stdout", "input": "get^user_name L\nembNresTteg U\nemaNresUteG D\nEndOfInput X", "output": "get^userName\nEmbNresTteg\nema_nres_ute_g\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nChain Disappearance Puzzle\n\nWe are playing a puzzle. An upright board with H rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed... | [{"type": "stdin_stdout", "input": "1\n6 9 9 9 9\n5\n3 9 6 0 12\n5 6 6 9 9\n4 6 3 10 15\n3 2 2 14 9\n2 2 1 1 1\n10\n3 10 6 5 6\n2 4 1 8 3\n6 2 7 9 2\n8 7 7 6 1\n7 9 6 4 9\n8 9 1 1 10\n5 6 1 8 0\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n4 4 1 6 12\n3\n2 2 4 7 4\n6 5 7 7 7\n8 8 2 9 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ... | [{"type": "stdin_stdout", "input": "5 4\n(Folmow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are a teacher at a cram school for elementary school pupils.\n\nOne day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everyth... | [{"type": "stdin_stdout", "input": "2 6\n1 16\n3 9\n2 334\n34 79\n0 0", "output": "0 1\n4 0\n0 1\n0 166\n0 13\n"}, {"type": "stdin_stdout", "input": "3 8\n1 5\n3 10\n2 218\n36 198\n0 0", "output": "3 0\n1 0\n1 0\n0 108\n0 2\n"}, {"type": "stdin_stdout", "input": "2 6\n1 16\n3 15\n2 200\n34 62\n0 0", "output": "0 1\n4 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn angel lives in the clouds above the city where Natsume lives. The angel, like Natsume, loves cats and often comes down to the ground to play with cats. To get down to the ground, the angel made a long, long staircase l... | [{"type": "stdin_stdout", "input": "4\n6 4\nC E D# E G A\nC E F G\n6 4\nC E D# F G A\nD D# F G\n3 6\nC D D\nD# B D B D# C#\n0 12\nB B B B B B F F\nC A B B B B B B", "output": "Yes\nNo\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "4\n6 4\nC E D# E G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\ncoastline\n\nWaves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ... | [{"type": "stdin_stdout", "input": "5 2 3\n3\n2\n1\n2\n6\n3 100 100\n5\n3\n4\n20 2 8\n3\n2\n10\n1\n14\n1\n1\n4\n2\n2\n16\n1\n8\n8\n2\n6\n3\n8\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n-1\n0 0 0", "output": "2\n0\n11\n5\n"}, {"type": "stdin_stdout", "input": "5 2 3\n3\n2\n1\n2\n6\n3 110 100\n5\n3\n4\n20 2 3\n3\n2\n10\n1\n14\n1\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nC: Short-circuit evaluation\n\nproblem\n\nNaodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF.\n\n\n<formula> :: = <or-expr>\n<or-... | [{"type": "stdin_stdout", "input": "?&?&?|?|?&?", "output": "3 2\n"}, {"type": "stdin_stdout", "input": "?|?&?|?&?&?", "output": "3 1\n"}, {"type": "stdin_stdout", "input": "?&?&?|?&?|?", "output": "3 3\n"}, {"type": "stdin_stdout", "input": "?&?|?|?&?&?", "output": "3 2\n"}, {"type": "stdin_stdout", "input": "?|?|?&?&... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a set of $N$ axis-aligned rectangles in the plane, find the area of regions which are covered by at least one rectangle.\n\nConstraints\n\n* $ 1 \\leq N \\leq 2000 $\n* $ −10^9 \\leq x1_i < x2_i\\leq 10^9 $\n* $ −10... | [{"type": "stdin_stdout", "input": "4\n0 0 3 1\n-1 0 1 3\n-1 2 4 3\n3 0 3 3", "output": "11\n"}, {"type": "stdin_stdout", "input": "4\n0 0 3 1\n-1 0 1 3\n-1 0 4 3\n2 0 3 2", "output": "15\n"}, {"type": "stdin_stdout", "input": "4\n0 0 3 2\n-1 0 1 3\n-1 0 8 3\n2 0 3 2", "output": "27\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is an array with n elements a1, a2, ..., an and the number x.\n\nIn one operation you can select some i (1 ≤ i ≤ n) and replace element ai with ai & x, where & denotes the [bitwise and](https://en.wikipedia.org/wiki... | [{"type": "stdin_stdout", "input": "5 119899\n60825 99853 69251 68402 1266\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 65537\n60825 99853 69251 68402 1266\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 132\n10060 81912 13624 40413 19012\n", "output": "2\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou invited n guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles. \n\nYour guests happen to be a li... | [{"type": "stdin_stdout", "input": "10\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n", "output": "10000000010\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVova has won n trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row.\n\nThe beauty of the arrangement is the length of the longest subsegment consisting of golden ... | [{"type": "stdin_stdout", "input": "300\nSSGSGSSSGSGSSSSGGSGSSGGSGSGGSSSGSSGSGGSSGGSGSSGGSGGSSGSSSGSGSGSSGSGGSSSGSSGSSGGGGSSGSSGSSGSGGSSSSGGGGSSGSSSSSSSSGSSSSGSGSSSSSSSSGSGSSSSGSSGGSSGSGSSSSSSGSGSSSGGSSGSGSSGSSSSSSGGGSSSGSGSGSGGSGGGSSGSGSSSGSSGGSSGSSGGGGSGSSGSSSSGGSSSSGGSGSSSSSSGSSSGGGSGSGGSSGSSSSSSGGSSSGSSSSGGGSSGSSSG... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to a_i.\n\nLet's denote the function g(x, y) as the greatest common divisor of the numbers written on the ... | [{"type": "stdin_stdout", "input": "3\n1601 1601 1601\n1 2\n2 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1601 2970 1601\n1 2\n2 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1601 1572 1601\n1 2\n2 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1883 1601 1601\n1 2\n2 3\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the la... | [{"type": "stdin_stdout", "input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "lioslialapetrpetr... | 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\nYour program fails again. This time it gets \"Wrong answer on test 233\"\n\n.\n\nThis is the easier version of the problem. In this version 1 ≤ n ≤ 2000. You can hack this problem only if you solve and lock both problems.... | [{"type": "stdin_stdout", "input": "98 102\n79 30 51 48 80 91 32 16 39 54 79 17 48 24 8 66 9 94 45 14 85 82 54 89 44 92 26 62 47 5 75 33 102 24 63 39 91 31 33 55 81 63 81 87 26 19 41 108 46 56 91 97 67 30 94 81 40 5 22 8 23 34 5 77 43 66 67 15 7 154 26 22 19 71 26 82 69 52 40 4 98 27 63 74 68 74 55 75 25 51 18 100 22 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu)\n\n[KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives)\n\nWith a new body, our idol Aroma White (or should we call her Kaori Mi... | [{"type": "stdin_stdout", "input": "10000000000000000 10000000000000000 100 100 10000000000000000 10000000000000000\n10000000000000000 10000000000000000 10000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3449558549195209 933961699330867 25 92 2448338832051825 8082390281981957\n7818990402072641 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSuppose you are performing the following algorithm. There is an array v_1, v_2, ..., v_n filled with zeroes at start. The following operation is applied to the array several times — at i-th step (0-indexed) you can: \n\n ... | [{"type": "stdin_stdout", "input": "1\n30 2\n16777216 33554432 67108864 134217728 268435456 536870912 1073741824 2147483648 4294967296 8589934592 17179869184 34359738368 68719476736 137438953472 274877906944 549755813888 1099511627776 2199023255552 4398046511104 8796093022208 17592186044416 35184372088832 7036874417766... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYoung wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possibl... | [{"type": "stdin_stdout", "input": "2\n3\n1 1 1\n5\n2 3 1 2 2\n", "output": "3\n2\n\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 1 1\n5\n2 3 1 2 4\n", "output": "3\n2\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 1 1\n5\n2 3 1 1 2\n", "output": "3\n3\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 2 2\n5\n2 3 1 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile playing yet another strategy game, Mans has recruited n [Swedish heroes](https://www.youtube.com/watch?v=5sGOwFVUU0I), whose powers which can be represented as an array a.\n\nUnfortunately, not all of those mighty h... | [{"type": "stdin_stdout", "input": "11\n559227829 -118401759 491756598 -50857099 491152214 -500410377 141179566 -723654625 144131087 -460846619 791017750\n", "output": "4088562193\n"}, {"type": "stdin_stdout", "input": "11\n559227829 -118401759 491756598 -26772290 491152214 -500410377 141179566 -723654625 144131087 -46... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting t... | [{"type": "stdin_stdout", "input": "1000 1000\n", "output": "500000\n"}, {"type": "stdin_stdout", "input": "999 1000\n", "output": "499500\n"}, {"type": "stdin_stdout", "input": "1000 997\n", "output": "498500\n"}, {"type": "stdin_stdout", "input": "997 1000\n", "output": "498500\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a trampoline park with n trampolines in a line. The i-th of which has strength S_i.\n\nPekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice. \n\nIf at ... | [{"type": "stdin_stdout", "input": "3\n7\n1 2 10 2 2 2 2\n2\n2 1\n5\n1 1 1 2 1\n", "output": "10\n1\n1\n"}, {"type": "stdin_stdout", "input": "3\n7\n2 4 3 2 2 13 2\n2\n3 3\n5\n1 1 1 1 2\n", "output": "13\n4\n1\n"}, {"type": "stdin_stdout", "input": "3\n7\n3 4 3 2 2 24 2\n2\n3 3\n5\n1 1 1 1 2\n", "output": "24\n4\n1\n"}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given 2 arrays a and b, both of size n. You can swap two elements in b at most once (or leave it as it is), and you are required to minimize the value $$$∑_{i}|a_{i}-b_{i}|.$$$\n\nFind the minimum possible value o... | [{"type": "stdin_stdout", "input": "56\n902 939 451 62 914 396 59 694 724 798 850 498 327 678 543 203 879 284 795 646 575 817 4 129 49 877 452 430 720 242 37 973 532 487 34 798 234 93 135 310 242 44 159 921 721 701 475 952 244 269 949 170 437 952 299 485\n828 750 266 900 991 302 872 874 141 258 671 726 702 513 35 295 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne must train much to do well on wizardry contests. So, there are numerous wizardry schools and magic fees.\n\nOne of such magic schools consists of n tours. A winner of each tour gets a huge prize. The school is organis... | [{"type": "stdin_stdout", "input": "86 81 36\n84 44 92 12 39 24 70 73 17 43 50 59 9 89 87 67 80 35 7 49 6 23 1 19 2 70 40 84 4 28 18 60 13 97 3 76 69 5 13 26 55 27 21 62 17 3 6 40 55 69 16 56 13 55 20 72 35 13 38 24 14 73 73 92 75 46 92 39 22 86 3 70 12 95 48 40 37 69 4 83 42 9 4 63 66 56\n16 5 2 16 -1 21 11 -1 1 48 -1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:\n\n<image>\n\nFind the sum modulo 1073741824 (230).\n\nInput\n\nTh... | [{"type": "stdin_stdout", "input": "100 100 100\n", "output": "51103588"}, {"type": "stdin_stdout", "input": "98 34 100\n", "output": "13589991\n"}, {"type": "stdin_stdout", "input": "41 82 100\n", "output": "13808108\n"}, {"type": "stdin_stdout", "input": "39 90 100\n", "output": "14574419\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weig... | [{"type": "stdin_stdout", "input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"type": "stdin_stdout", "input": "2 110 100 10000 10000\n100 100\n", "output": "21000\n"}, {"type": "stdin_stdout", "input": "2 110 100 10000 11101\n100 000\n", "output": "11000\n"}, {"type": "stdin_stdout", "input": "2 110 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMany countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to S... | [{"type": "stdin_stdout", "input": "8 704 99 110\n", "output": "ACACACACACACACACACACBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA\nACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACBBBBBBBBBBBBBA\n"}, {"type": "stdin_stdout", "input": "8 66... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties:\n\n * the upper half of mat... | [{"type": "stdin_stdout", "input": "8 20\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnfisa the monkey learns to type. She is yet unfamiliar with the \"space\" key and can only type in lower-case Latin letters. Having typed for a fairly long line, Anfisa understood that it would be great to divide what sh... | [{"type": "stdin_stdout", "input": "200 1 200\nlycjpjrpkgxrkfvutlcwglghxadttpihmlpphwfttegfpimjxintjdxgqfhzrmxfcfojnxruhyfynlzgpxjeobjyxarsfxaqeogxfzvdlwsimupkwujudtfenryulzvsiazneyibqtweeuxpzrbumqqswjasliyjnnzfzuvthhzcsgfljikkajqkpjftztrzpjneaxqg\n", "output": "l\ny\nc\nj\np\nj\nr\np\nk\ng\nx\nr\nk\nf\nv\nu\nt\nl\nc\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLast week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by <image>. A Modular Equation, as Hamed's tea... | [{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "infinity"}, {"type": "stdin_stdout", "input": "1000000000 1000001000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1204165230 1287214915\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1000000000 1010001000\n", "output": "0\n"}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \n\nHe has n dollars. Ho... | [{"type": "stdin_stdout", "input": "1000 61465564 1000\n", "output": "439034436\n"}, {"type": "stdin_stdout", "input": "859 453892 543\n", "output": "126416972\n"}, {"type": "stdin_stdout", "input": "859 453892 889\n", "output": "339370803\n"}, {"type": "stdin_stdout", "input": "859 267939 889\n", "output": "339556756\... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.