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\nIn your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flow...
[{"type": "stdin_stdout", "input": "1 1000000000\n1000000000000000000 1000000000", "output": "1999999999000000000"}, {"type": "stdin_stdout", "input": "3 17\n22 15\n10 10\n17 10", "output": "70\n"}, {"type": "stdin_stdout", "input": "3 17\n22 19\n10 10\n17 10", "output": "77\n"}, {"type": "stdin_stdout", "input": "3 27...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC --Misawa's rooted tree\n\nProblem Statement\n\nYou noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph s...
[{"type": "stdin_stdout", "input": "((()[1]())[2]())[5](((()[2]())[6](()[3]()))[8]()(\n(()[4]())[3](((()[2]())[1]())[8](()[4]')))", "output": "(()[6]())[8](((()[4]())[7]())[16]())\n"}, {"type": "stdin_stdout", "input": "((()[8]())[2]())[5](((()[3]())[6](()[3]()))[2]())\n(()[4]())[2](((()[2]())[1]())[8](()[3]())(", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simp...
[{"type": "stdin_stdout", "input": "3\n9\n0", "output": "Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7 15 16 28 29 45\n 3 5 8 14 17 27 30 44 46\n 4 9 13 18 26 31 43 47 60\n 10 12 19 25 32 42 48 59 61\n 11 20 24 33 41 49 58 62 71\n 21 23 34 40 50 57 63 70 72\n 22 35 39 51 56 64 69 73 78\n 36 38 52...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n)...
[{"type": "stdin_stdout", "input": "100 9\n66 71 37 41 23 38 77 11 74 13 51 26 93 56 81 17 12 70 85 37 54 100 14 99 12 83 44 16 99 65 13 48 92 32 69 33 100 57 58 88 25 45 44 85 5 41 82 15 37 18 21 45 3 68 33 9 52 64 8 73 32 41 87 99 26 26 47 24 79 93 9 44 11 34 85 26 14 61 49 38 25 65 49 81 29 82 28 23 2 64 38 13 77 68...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant...
[{"type": "stdin_stdout", "input": "4\n7 8\nAAPAAAAA\nAAAAPPPP\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP\n", "output": "2\n1\nMORTAL\n4\n"}, {"type": "stdin_stdout", "input": "4\n7 8\nAAPABAAA\nPPPPAAAA\nPPPPAAAA\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\n-----Constraints---...
[{"type": "stdin_stdout", "input": "105\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "104\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "134\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "135\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "164\n", "output": "2\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusiv...
[{"type": "stdin_stdout", "input": "1000000001000000000", "output": "999867657\n"}, {"type": "stdin_stdout", "input": "1100000001000000000", "output": "355035671\n"}, {"type": "stdin_stdout", "input": "1100000001000010000", "output": "391646023\n"}, {"type": "stdin_stdout", "input": "1100000001001010000", "output": "10...
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$ consisting of integers from $0$ to $9$. A subarray $a_l, a_{l+1}, a_{l+2}, \\dots , a_{r-1}, a_r$ is good if the sum of elements of this subarray is equal to the length of t...
[{"type": "stdin_stdout", "input": "11\n1\n0\n1\n1\n1\n2\n1\n3\n1\n4\n1\n5\n1\n6\n1\n7\n1\n8\n1\n9\n26\n11140000000090000000002111\n", "output": "0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n37\n"}, {"type": "stdin_stdout", "input": "11\n1\n0\n1\n1\n1\n2\n1\n3\n1\n4\n1\n5\n1\n6\n1\n7\n1\n8\n1\n9\n26\n11140000000090000000002111\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones a...
[{"type": "stdin_stdout", "input": "777777777\n", "output": "1022\n"}, {"type": "stdin_stdout", "input": "444444444\n", "output": "511\n"}, {"type": "stdin_stdout", "input": "477477447\n", "output": "728\n"}, {"type": "stdin_stdout", "input": "777744747\n", "output": "996\n"}, {"type": "stdin_stdout", "input": "7777777...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$, consisting of $n$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $1$ to $n$.\n\n$s[l; r]$ is a continuous substring of letters from index $l$ to $r$ of t...
[{"type": "stdin_stdout", "input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"type": "stdin_stdout", "input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"type": "stdin_stdout", "input": "4\n1\na\n6\nabbaba\n6\nabbaba\n7\nbabbabbaa\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$.\n\nHe has a rope, which he can use to pull the box. He can only pull the ...
[{"type": "stdin_stdout", "input": "5\n1 0 1000000000 1000000000\n1 1 1000000000 1000001100\n1 0 1001000000 1000000000\n1 1 1100010011 1001000000\n2 1 108856 18413\n", "output": "2000000001\n2000001100\n2001000001\n2101010011\n127268\n"}, {"type": "stdin_stdout", "input": "5\n1 0 1000000000 1000000000\n1 1 1001000000 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a permutation: an array $a = [a_1, a_2, \\ldots, a_n]$ of distinct integers from $1$ to $n$. The length of the permutation $n$ is odd.\n\nConsider the following algorithm of sorting the permutation in increasing ...
[{"type": "stdin_stdout", "input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n"}, {"type": "stdin_stdout", "input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 3 2 4 5\n", "output": "3\n5\n2\n"}, {"type": "stdin_stdout", "input": "3\n3\n2 3 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJAG-channel\n\nNathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View.\n\nLike many other electronic bulletin boards, JAG-channel is th...
[{"type": "stdin_stdout", "input": "6\nhoge\n.fuga\n..foobar\n..jagjag\n...zigzag\n.piyo\n8\njagjag\n.hogehoge\n..fugafuga\n...ponyoponyo\n....evaeva\n....pokemon\n...nowawa\n.buhihi\n8\nhello\n.goodmorning\n..howareyou\n.goodafternoon\n..letshavealunch\n.goodevening\n.goodnight\n..gotobed\n3\ncaution\n.themessagelengt...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:\n\nGiven two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (on...
[{"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"type": "stdin_stdout", "input": "30\n0111101101000100000110010001...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if t...
[{"type": "stdin_stdout", "input": "3\n33332 19151 47433\n", "output": "0\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price ...
[{"type": "stdin_stdout", "input": "4\n4 2\n6 1\n2 6\n-2 11\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "4\n4 1\n6 2\n2 5\n-1 4\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "4\n4 1\n6 2\n2 5\n-2 4\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "4\n4 1\n6 2\n2 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe new PIN is hard to remember. I was told that I shouldn't take notes, but I don't think I can remember them. Therefore, I decided to embed a numerical value in the text and make a note of the PIN. Here, the sum of all ...
[{"type": "stdin_stdout", "input": "Thereare100yenonthetable.Iam17yearsold.\n.mp6taemohogdluohsI", "output": "123\n"}, {"type": "stdin_stdout", "input": "Thergarn100yeeontgesable-Iam17ye`rsolc.\nIshptkogdhomemt5q`.", "output": "122\n"}, {"type": "stdin_stdout", "input": "Thereare100yenonthetable.Iam17ye`rsold.\n.mp6tae...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array is called beautiful if all the elements in the array are equal.\n\nYou can transform an array using the following steps any number of times: \n\n 1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ...
[{"type": "stdin_stdout", "input": "5\n0 11 12 13 14\n", "output": "\n120"}, {"type": "stdin_stdout", "input": "5\n0 12 1 13 14\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "5\n1 3 0 13 48\n", "output": "120\n"}, {"type": "stdin_stdout", "input": "5\n1 18 2 13 26\n", "output": "24\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAccording to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so t...
[{"type": "stdin_stdout", "input": "231\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a sequence $a$ with $n$ elements $1, 2, 3, \\dots, k - 1, k, k - 1, k - 2, \\dots, k - (n - k)$ ($k \\le n < 2k$).\n\nLet's call as inversion in $a$ a pair of indices $i < j$ such that $a[i] > a[j]$.\n\nSuppose, ...
[{"type": "stdin_stdout", "input": "4\n1 1\n3 3\n5 5\n5 5\n", "output": "1\n1 2 3\n1 2 3 4 5\n1 2 3 4 5\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n2 2\n5 5\n5 5\n", "output": "1\n1 2\n1 2 3 4 5\n1 2 3 4 5\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n3 2\n5 5\n5 5\n", "output": "1\n2 1\n1 2 3 4 5\n1 2 3 4 5\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke is interested in strings that satisfy the following conditions:\n\n* The length of the string is at least N.\n* The first N characters equal to the string s.\n* The last N characters equal to the string t.\n\n\n\nFi...
[{"type": "stdin_stdout", "input": "4\nexpr\nexpq", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\nexpr\nrxep", "output": "7\n"}, {"type": "stdin_stdout", "input": "4\nexpr\nepxq", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\nexpr\npexq", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\nexpr\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two sisters Alice and Betty. You have $n$ candies. You want to distribute these $n$ candies between two sisters in such a way that: Alice will get $a$ ($a > 0$) candies; Betty will get $b$ ($b > 0$) candies; ...
[{"type": "stdin_stdout", "input": "98\n710\n896\n635\n909\n528\n799\n184\n970\n731\n285\n481\n62\n829\n815\n204\n927\n48\n958\n858\n549\n722\n900\n290\n96\n414\n323\n488\n140\n494\n286\n783\n551\n896\n580\n722\n766\n841\n914\n200\n170\n384\n664\n14\n203\n582\n203\n678\n502\n677\n318\n189\n144\n97\n330\n169\n20\n492\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!\n\nThe Mayor thinks that one of the main city streets could be considerably widened on account of law...
[{"type": "stdin_stdout", "input": "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012\n24819 11529\n24166 11084\n24539 9211\n24152 9235\n", "output": "71869\n31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 \n"}, {"type": "stdin_stdout", "input": "10\n21005 10850\n27020 13372\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\nSuch being the...
[{"type": "stdin_stdout", "input": "43535 7\n5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.\n\nLesha c...
[{"type": "stdin_stdout", "input": "ggaaaawwwxxxxxxrrrrrrrrwwwwwwwwggggggggjjusszzzzqqqqqsssssssbbwwwwwwmmmmtttttttvvvvvvvvssssppppppggggsrrrrrrzzzzzzzyyyyyccccccchhhhhhhhjjrrrrhhhhhhhheeeeeeeaaaaaaaiiiiiuuuuuuuvvvvvjjjjjjjjffbbbbbbbbrrrrrllllllllggggggggooooollssvvvvvvvvvvnnnnnnnnuuuuuuuucccccyyyyyyyyyyzzzzzzzkkkkuuuu...
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 = x^{a} + y^{b}, 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 ...
[{"type": "stdin_stdout", "input": "433333986179614514 1000000000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"type": "stdin_stdout", "input": "433333986179614514 1000001000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} ...
[{"type": "stdin_stdout", "input": "20\n22 77\n13 50\n55 64\n16 52\n67 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45 106\n39 55\n31 33\n9 33\n6 72\n14 67\n56 98\n69 152\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "20\n22 77\n13 50\n55 64\n16 52\n62 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «...
[{"type": "stdin_stdout", "input": "3 5\nGACGA\nAGCAG\nAGCAG\n", "output": "AGCGA\nCTATC\nAGCGA\n"}, {"type": "stdin_stdout", "input": "3 5\nAGGAC\nGACGA\nGACGA\n", "output": "AGAGC\nCTCTA\nAGAGC\n"}, {"type": "stdin_stdout", "input": "3 5\nAGCAG\nAGCAG\nGACGA\n", "output": "AGCGA\nCTATC\nAGCGA\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.\n\n...
[{"type": "stdin_stdout", "input": "141 12 6\n66 53 86 91 12 27 5 74 79 50 33 2 100 26 2 73 16 14 50 86 75 9 66 48 19 34 25 1 22 50 63 39 38 42 98 71 76 27 80 16 74 21 36 1 32 20 65 28 68 40 41 6 0 77 65 84 0 34 60 0 42 65 2 16 25 85 35 57 74 66 26 33 39 14 0 6 2 15 87 99 47 67 75 63 72 32 93 7 5 63 35 99 89 61 18 25 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players decided to play one interesting card game.\n\nThere is a deck of $n$ cards, with values from $1$ to $n$. The values of cards are pairwise different (this means that no two different cards have equal values). A...
[{"type": "stdin_stdout", "input": "2\n2 1 1\n2\n-1\n5 2 3\n1 3\n2 11 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n2 1 1\n2\n-1\n5 2 3\n2 3\n2 2 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n2 1 1\n2\n1\n5 2 3\n2 3\n-1 6 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven a permutation of length $ N $ $ P = \\\\ {P_1, P_2, \\ ldots, P_N \\\\} $ and the integer $ K $.\nDetermine if the permutation $ P $ can be monotonically increased by repeating the following operation any...
[{"type": "stdin_stdout", "input": "0 3\n3 -1 1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 2\n6 11 1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 2\n10 2 2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 2\n10 2 2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 2\n2 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nRecently Chef has decided to make some changes in our beloved Codechef. As you know, each problem at Codechef has its memory and time limits. To make problems...
[{"type": "stdin_stdout", "input": "3\n2\n0 4\n5\n0 2 10 2 3\n3\n1 1 1", "output": "4\n11\n1\n"}, {"type": "stdin_stdout", "input": "3\n2\n2 2\n5\n0 0 11 4 3\n3\n0 3 0", "output": "2\n11\n3\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 2\n5\n1 2 12 2 3\n3\n1 0 1", "output": "2\n13\n2\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\naab\nczc\nbaa\n\n\nOutput\n\naac\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Y...
[{"type": "stdin_stdout", "input": "3\naab\nccz\nbaa", "output": "aac\n"}, {"type": "stdin_stdout", "input": "3\nbba\nzcc\nbaa", "output": "aaz\n"}, {"type": "stdin_stdout", "input": "3\nabb\nzbc\nbaa", "output": "aab\n"}, {"type": "stdin_stdout", "input": "3\nbbb\nzcd\nbaa", "output": "abc\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property:\n\n consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y ...
[{"type": "stdin_stdout", "input": "58 38\n6384 48910\n97759 90589\n28947 5031\n45169 32592\n85656 26360\n88538 42484\n44042 88351\n42837 79021\n96022 59200\n485 96735\n98000 3939\n3789 64468\n10894 58484\n26422 26618\n25515 95617\n37452 5250\n39557 66304\n79009 40610\n80703 60486\n90344 37588\n57504 61201\n62619 79797...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n - S is a palindrome.\n - Let N be the length of S. The string formed by the 1-st through ((N-1)...
[{"type": "stdin_stdout", "input": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "kszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzskokszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzsk\n", "output": "Yes\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEveryone loves a freebie. Especially students.\n\nIt is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times \"Fly, freebie, fly!\" — then flown...
[{"type": "stdin_stdout", "input": "100\n98 63 672 100 254 218 623 415 426 986 920 915 736 795 407 541 382 213 935 743 961 59 660 512 134 935 248 378 739 356 543 714 28 667 602 596 759 791 103 564 225 520 159 542 966 332 983 655 517 273 95 242 593 940 286 236 41 318 941 727 384 225 319 627 982 359 232 769 854 172 643 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria.\n\n1. first by $x$-coordinate\n2. in case of a tie, by $y$-coordinate\n\nConstraints\n\n* $1 \\leq n \\leq 1...
[{"type": "stdin_stdout", "input": "5\n-1 3\n1 15\n-1 1\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 1\n-1 3\n1 15\n"}, {"type": "stdin_stdout", "input": "5\n-1 3\n1 15\n-1 0\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 0\n-1 3\n1 15\n"}, {"type": "stdin_stdout", "input": "5\n-1 3\n1 22\n-1 0\n-1 -1\n-1 -1", "output": "-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMotorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her.\n\nKojiro wants to get to his g...
[{"type": "stdin_stdout", "input": "386 20 29 30\n1 349\n2 482\n1 112\n1 93\n2 189\n1 207\n2 35\n2 -5\n1 422\n1 442\n1 402\n2 238\n3 258\n3 54\n2 369\n2 290\n2 329\n3 74\n3 -62\n2 170\n1 462\n2 15\n2 222\n1 309\n3 150\n1 -25\n3 130\n1 271\n1 -43\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 73 35 188 223 73 215 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_...
[{"type": "stdin_stdout", "input": "25 4 4\n1 2\n3 3\n2 5\n6 7\n3 5\n4 3\n3 4\n6 7", "output": "1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "27 0 1\n0 0\n2 10\n3 -1\n1 0", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum. \n\nThe beau...
[{"type": "stdin_stdout", "input": "39\n37749932 37750076 37750391 37750488 37750607 37750812 37750978 37751835 37752173 37752254 75497669 75497829 75497852 75498044 75498061 75498155 75498198 75498341 75498382 75498465 150994988 150994989 150995009 150995019 150995024 150995030 150995031 150995069 150995072 805306369 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string \"aab\" is an anagram of the string \"aba\" and the string \"aa...
[{"type": "stdin_stdout", "input": "??fb???a??\ndeeefc\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??fb???a??\ndedefc\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??fb???a??\ndedefd\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??a???bf??\ndedefd\n", "output": "0\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nScheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows ho...
[{"type": "stdin_stdout", "input": "3\n17\n7\n20", "output": "129140160\n2184\n486784383\n"}, {"type": "stdin_stdout", "input": "3\n19\n7\n21", "output": "162261457\n2184\n460353130\n"}, {"type": "stdin_stdout", "input": "3\n12\n13\n11", "output": "531444\n1594320\n177144\n"}, {"type": "stdin_stdout", "input": "3\n17\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPermutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n ...
[{"type": "stdin_stdout", "input": "011\n", "output": "890786230\n"}, {"type": "stdin_stdout", "input": "13\n", "output": "695720788\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "150347555\n"}, {"type": "stdin_stdout", "input": "11\n", "output": "890786230\n"}, {"type": "stdin_stdout", "input": "11\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of $n$ integers $a_1$, $a_2$, ..., $a_n$. Initially $a_x = 1$, all other elements are equal to $0$.\n\nYou have to perform $m$ operations. During the $i$-th operation, you choose two indi...
[{"type": "stdin_stdout", "input": "9\n100 50 6\n1 49\n51 100\n40 60\n30 70\n20 30\n70 80\n100 1 11\n1 1\n1 1\n1 1\n2 2\n2 100\n1 4\n2 3\n3 7\n5 6\n6 100\n4 5\n1 1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n11 6 4\n6 6\n1 5\n7 11\n6 6\n3 3 2\n1 2\n2 3\n1000000000 1 1\n1 1000000000\n1000000000 1 1\n1 999999999\n1000000000 1 1\n2 10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHardutta is planning an inter college football league. He has invited n teams, including our own team from BPHC. Now, one of the organizers Ramehta was hell bent on knowing one thing : How many matches will all the teams ...
[{"type": "stdin_stdout", "input": "73\n11 46\n78 14\n79 84\n3 7\n77 94\n67 62\n2 12\n12 46\n17 21\n89 35\n68 2\n76 10\n79 19\n58 78\n6 28\n35 16\n73 34\n67 80\n70 59\n53 21\n46 97\n36 80\n32 91\n14 26\n97 92\n42 100\n84 76\n28 32\n80 63\n86 39\n10 63\n66 86\n54 50\n77 71\n87 79\n43 99\n76 87\n82 35\n28 70\n5 37\n15 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLuba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each ...
[{"type": "stdin_stdout", "input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.\n\nArtem want...
[{"type": "stdin_stdout", "input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n3 3 1000000000\n3 10 1000000000\n3 6 1000000000\n3 7 1000000000\n", "output": "0\n3\n2\n2\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exact...
[{"type": "stdin_stdout", "input": "68 74\n51 54\n3 22\n12 24\n3 27\n32 42\n36 55\n60 64\n1 4\n4 23\n11 64\n54 62\n50 56\n21 34\n27 63\n15 54\n28 61\n13 57\n39 53\n12 32\n32 40\n33 67\n55 61\n33 67\n30 37\n15 49\n27 45\n21 41\n8 42\n24 63\n40 48\n28 41\n30 67\n0 4\n7 15\n27 59\n60 62\n25 65\n30 31\n38 67\n24 43\n14 64\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letter...
[{"type": "stdin_stdout", "input": "10 10 2\nfriuxvShvg\nerslojqtgu\nzeqsmdewry\nwvhbeeyeSu\ngkofbjaavr\ntwkcdxugps\nnzlylSmafu\nstamkpxnzt\nuwxwximkrm\nmzxyboazbl\n100\nmRIfAtrLKmztpVkAmojDCiIgseBwlUilBIiyDQhqNhNAqVLLIobuCIretLdSvixNNdCiouFMXtwHZFlObCeaygmIiFBfaCirbmCa\n", "output": "19\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCity X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the numbers of the roads th...
[{"type": "stdin_stdout", "input": "9\n4 5\n2 3\n8 3\n5 6\n9 3\n4 4\n5 4\n4 7\n1 7\n8 4\n1 4\n1 5\n5 7\n7 8\n7 1\n9 9\n8 7\n7 5\n3 7\n6 6\n7 3\n5 2\n3 6\n7 4\n9 6\n5 8\n9 7\n6 3\n7 9\n1 2\n1 1\n6 2\n5 3\n7 2\n1 6\n4 1\n6 1\n8 9\n2 2\n3 9\n2 9\n7 7\n2 8\n9 4\n2 5\n8 6\n3 4\n2 1\n2 7\n6 5\n9 1\n3 3\n3 8\n5 5\n4 3\n3 1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because...
[{"type": "stdin_stdout", "input": "mmmmmmmmmmmmmmmm\n", "output": "NIE\n"}, {"type": "stdin_stdout", "input": "mmmmmmmmmmmmmmmm\n", "output": "NIE\n"}, {"type": "stdin_stdout", "input": "mmmmmmmmmmmmmmmn\n", "output": "NIE\n"}, {"type": "stdin_stdout", "input": "nnnnnnnnnnnnn\n", "output": "NIE\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is x^{k}. \n\nOutput the sum of costs over all non-empty subsets of people.\n\n\n--...
[{"type": "stdin_stdout", "input": "1000000000 5000\n", "output": "642932262\n"}, {"type": "stdin_stdout", "input": "1000000000 5000\n", "output": "642932262\n"}, {"type": "stdin_stdout", "input": "158260522 4575\n", "output": "875142289\n"}, {"type": "stdin_stdout", "input": "602436426 4445\n", "output": "582490088\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.\n\nConstraints\n\n* 0 \\leq N \\leq 10^4\n* |a_i| \\leq ...
[{"type": "stdin_stdout", "input": "0\n461740266", "output": "2\n3\n13\n1327\n1487\n"}, {"type": "stdin_stdout", "input": "0\n1326078230", "output": "2\n5\n1051\n126173\n"}, {"type": "stdin_stdout", "input": "0\n754892205", "output": "3\n5\n41\n853\n1439\n"}, {"type": "stdin_stdout", "input": "0\n732779016", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\nIn the formula A op1 B op2 C op3 D = 7, re...
[{"type": "stdin_stdout", "input": "1222\n", "output": "1+2+2+2=7\n"}, {"type": "stdin_stdout", "input": "0290\n", "output": "0-2+9+0=7\n"}, {"type": "stdin_stdout", "input": "3242\n", "output": "3+2+4-2=7\n"}, {"type": "stdin_stdout", "input": "2364", "output": "2+3+6-4=7\n"}, {"type": "stdin_stdout", "input": "1114",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmidakuji is a traditional method of lottery in Japan.\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and th...
[{"type": "stdin_stdout", "input": "100 8 8\n", "output": "467571711\n"}, {"type": "stdin_stdout", "input": "100 8 3\n", "output": "938282570\n"}, {"type": "stdin_stdout", "input": "100 8 1\n", "output": "755868507\n"}, {"type": "stdin_stdout", "input": "15 8 5\n", "output": "437760187\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher the corresp...
[{"type": "stdin_stdout", "input": "10\njrojjyqqjtrfjf\nvuwzvmwjyfvifdfddymwfuzmvvummwdfzjzdvzuvfvjiuvyzymviyyumvziyimfzfiji\nwxzwojjzqzyqlojjbrjlbqrrwqw\nqfwppnuvbgegbqgbmeqpbguwmmqhunnquepepeewubbmnenvmwhnvhunnmsqmmgfepevupewvenmwpmgspnebv\nrxqzorkizznsiirciokscrrjqqqzkfijrrkkfrqjjifczcjcnqoisorszkjxcxvqzcfczqfcrvfrs...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show th...
[{"type": "stdin_stdout", "input": "3\n576460752303423484\n576460752303423484\n576460752303423485\n", "output": "1152921504606846911\n1152921504606846911\n1152921504606846912\n"}, {"type": "stdin_stdout", "input": "3\n576460752303423484\n576460752303423484\n576460752303423485\n", "output": "1152921504606846911\n1152921...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAuthors have come up with the string $s$ consisting of $n$ lowercase Latin letters.\n\nYou are given two permutations of its indices (not necessary equal) $p$ and $q$ (both of length $n$). Recall that the permutation is t...
[{"type": "stdin_stdout", "input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"type": "stdin_stdout", "input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"type": "stdin_stdout", "input": "5 2\n5 2 4 3 1\n5 4 3 1 2\n", "output": "YES\nbbbba\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of $2n+1$ integer points on a Cartesian plane. Points are numbered from $0$ to $2n$ inclusive. Let $P_i$ be the $i$-th point. The $x$-coordinate of the point $P_i$ equals $i$. The $y$-coordinate of the...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000001 1000000000000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKostya likes the number 4 much. Of course! This number has such a lot of properties, like:\n\n- Four is the smallest composite number;\n- It is also the smallest Smith number;\n- The smallest non-cyclic group has four ele...
[{"type": "stdin_stdout", "input": "5\n794947\n1850\n2424\n119\n24", "output": "2\n0\n2\n0\n1\n"}, {"type": "stdin_stdout", "input": "5\n447474\n228\n6664\n40\n81\n", "output": "4\n0\n1\n1\n0\n"}, {"type": "stdin_stdout", "input": "5\n1167956\n340\n2424\n40\n42", "output": "0\n1\n2\n1\n1\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time.\n\nPolycarp is good at marketing...
[{"type": "stdin_stdout", "input": "30\n522692116 159\n589719489 488\n662495181 961\n915956552 470\n683572975 271\n498400137 480\n327010963 181\n200704287 367\n961198611 54\n978100746 208\n345455616 986\n106372142 876\n446972337 42\n309349333 200\n93462198 543\n167946793 318\n325598940 427\n121873339 459\n174934933 598...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: \"Fox\"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order. \n\nAfter checking some e...
[{"type": "stdin_stdout", "input": "10\npetr\negor\nendagorion\nfeferivan\nilovetanyaromanova\nkoatks\ndmitriyh\nmaratsnowbear\nbredorjaguarturnik\ncgyforever\n", "output": "aghjlopqrstuvwxyznefikdmbc\n"}, {"type": "stdin_stdout", "input": "10\npetr\negor\nendagorion\nfeferivan\nilovetanyaromanova\nkoatks\ndmitriyh\nma...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of o...
[{"type": "stdin_stdout", "input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1000000000 -1000000000\n1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWherever the destination is, whoever we meet, let's render this song together.\n\nOn a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and ...
[{"type": "stdin_stdout", "input": "20 50000 50000\n2 45955 55488\n1 19804 29337\n2 3767 90811\n2 24025 33558\n1 46985 56518\n2 21094 30627\n2 5787 15320\n1 4262 91306\n2 37231 46764\n1 18125 27658\n1 36532 12317\n1 31330 40863\n1 18992 28525\n1 29387 38920\n1 44654 54187\n2 45485 55018\n2 36850 46383\n1 44649 54182\n1...
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 som...
[{"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\nFrog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of $n$ meters depth. Now Gorf is on the bottom of the well and has a long way up.\n\nThe surface of the well's walls vary...
[{"type": "stdin_stdout", "input": "19\n1 1 3 4 5 3 5 0 0 6 3 1 10 3 13 9 1 4 2\n3 0 6 3 8 6 8 7 8 6 0 0 5 0 0 1 1 1 0\n", "output": "5\n17 15 2 1 0\n"}, {"type": "stdin_stdout", "input": "19\n1 1 3 4 5 3 5 11 0 6 5 3 10 3 13 9 1 4 17\n3 0 6 3 8 6 8 7 8 6 -1 0 5 0 0 1 1 1 0\n", "output": "3\n2 1 0\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. \n\nIvan knows some information ...
[{"type": "stdin_stdout", "input": "20\nadabacabaeabacabada 1 359\nabadabacabafabaca 1 213\nacabagabacaba 1 315\ncabaeabacabadabacab 1 268\nfabacabadabacabaeab 1 352\ncabafabacabada 1 28\nacabadabacabaea 1 67\ncabadabacabaeabacaba 1 484\nabacabadabacaba 1 209\nacabaiabacaba 1 251\nacabafabacabadabac 1 475\nabacabaeabac...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.\n\nConstraints\n\n* $2 \\leq n \\leq 100$\n*...
[{"type": "stdin_stdout", "input": "3\n-1 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 7 -1 -1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3\n-1 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 5 -1 -1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3\n0 10 1 14 9 17\n6 0 35 1 0 0\n13 4 2 7 -1 -1", "output": "Yes\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp was given an array of $a[1 \\dots n]$ of $n$ integers. He can perform the following operation with the array $a$ no more than $n$ times:\n\nPolycarp selects the index $i$ and adds the value $a_i$ to one of his ch...
[{"type": "stdin_stdout", "input": "50\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWelcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the...
[{"type": "stdin_stdout", "input": "100\nmntyyerijtaaditeyqvxstrwxoxglpaubigaggtrepaegniybvfmssawvhrgjjhwwkwuqhtyrimxvolcstyllbhlcursvgfafpts\nbsgmhsgavsbgtwiiqaigmtyjxihphxdlseeajfywugawigrjruttuykthfrvwagpcsxlxsopnarqcvetnbtvfrvlyymwoyelrlta\n", "output": "300\n67 1 100 88 1 100 93 1 100 70 1 100 46 1 100 96 1 100 88...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConnected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.\n\nAn ant stands at the root of some tree. He sees that there are n vertex...
[{"type": "stdin_stdout", "input": "51\n28 3\n42 40\n40 51\n48 20\n13 28\n18 40\n44 40\n22 5\n22 27\n45 34\n40 9\n34 46\n40 34\n22 1\n22 11\n40 7\n28 40\n40 22\n14 40\n34 30\n40 20\n47 40\n12 34\n28 23\n40 24\n40 43\n41 40\n28 15\n49 32\n40 8\n32 10\n40 50\n40 36\n40 21\n16 33\n40 38\n34 2\n28 16\n34 4\n17 34\n19 40\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.\n\nGiven two strings a and b, find the...
[{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshe...
[{"type": "stdin_stdout", "input": "3 9\n1051\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n1000\n0 0", "output": "2151\n1000\n"}, {"type": "stdin_stdout", "input": "3 9\n1051\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n1001\n0 0", "output": "2151\n1001\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The la...
[{"type": "stdin_stdout", "input": "10\n-1 2 2 0 140 11 1 1 12 5", "output": " 140 12 11 1 5 2 1 -1 0 2\n"}, {"type": "stdin_stdout", "input": "10\n0 2 2 0 140 11 1 -1 12 5", "output": " 140 12 11 0 5 2 1 -1 0 2\n"}, {"type": "stdin_stdout", "input": "10\n1 -1 0 0 15 18 1 -1 -1 2", "output": " 18 15 1 0 2 0 1 -1 -1 -1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe store sells $n$ beads. The color of each bead is described by a lowercase letter of the English alphabet (\"a\"–\"z\"). You want to buy some beads to assemble a necklace from them.\n\nA necklace is a set of beads conn...
[{"type": "stdin_stdout", "input": "1\n364 1485\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffgggggggggggggggggggggggggggggggggggggggghhhhhhh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCodeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part i...
[{"type": "stdin_stdout", "input": "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376\nopR 3752 2931\nGl -1481 -1002\nR -1111 3778\n0i9B21DC 3650 279\nQ8L2dS0 358 -3305\ng -2662 3968\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to ...
[{"type": "stdin_stdout", "input": "babbbbabbabbbababbabbbbbbabaabaababaaabbbbbabbbbaaaaabbaaabbaabaabbbbabbbababbabaaabbababaaababbbaaa\n", "output": "babababababababababababa\n"}, {"type": "stdin_stdout", "input": "aaabbbabaaabababbaaababbababbbabbbbaabaabbaaabbaaaaabbbbabbbbbaaababaabaababbbbbbabbababbbabbabbbbab\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bo...
[{"type": "stdin_stdout", "input": "99 17\n-993 -1745 -959 -989 -991 -995 -976 -997 -990 -1000 -996 -994 -999 -354 -1000 -983 -979 -1000 -989 -968 -994 -992 -962 -1593 -999 -983 -991 -979 -995 -993 -973 -999 -995 -995 -999 -993 -995 -992 -947 -1000 -999 -998 -982 -988 -757 -993 -426 -988 -980 -990 -979 -976 -995 -999 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer numbe...
[{"type": "stdin_stdout", "input": "7938986881993\n", "output": "1\n378028993\n"}, {"type": "stdin_stdout", "input": "472670214391\n", "output": "1\n23020027\n"}, {"type": "stdin_stdout", "input": "1468526771489\n", "output": "1\n613783\n"}, {"type": "stdin_stdout", "input": "1245373417369\n", "output": "1\n908209\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider creating the following number pattern.\n\n\n4 8 2 3 1 0 8 3 7 6\n2 0 5 4 1 8 1 0 3\n2 5 9 5 9 9 1 3\n7 4 4 4 8 0 4\n1 8 8 2 8 4\n9 6 0 0 2\n5 6 0 2\n1 6 2\n7 8\nFive\n\n\nThis pattern follows the rules below.\n\n...
[{"type": "stdin_stdout", "input": "4823108376\n2273064329\n0123456789", "output": "5\n1\n4\n"}, {"type": "stdin_stdout", "input": "4823108376\n2314825047\n0123456789", "output": "5\n4\n4\n"}, {"type": "stdin_stdout", "input": "4823108376\n1842094049\n0123456789", "output": "5\n0\n4\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a directed graph with N vertices numbered 1 to N and M edges.\nThe i-th edge is directed from Vertex A_i to Vertex B_i, and there are C_i coins placed along that edge.\nAdditionally, there is a button on Vertex N...
[{"type": "stdin_stdout", "input": "2500 5000 0\n1206 2272 100000\n315 2399 100000\n1186 1435 100000\n303 1569 100000\n2364 581 100000\n1683 1969 100000\n700 1088 100000\n717 410 100000\n1412 1595 100000\n2066 813 100000\n1190 949 100000\n258 2307 100000\n423 2263 100000\n671 425 100000\n1712 1110 100000\n787 1469 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given two segments s1 and s2, print the distance between them.\n\ns1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.\n\nConstraints\n\n* 1 ≤ q ≤ 1000\n* -10000 ≤ xpi, ypi ≤ 10000\n* p0 ≠ p...
[{"type": "stdin_stdout", "input": "3\n-1 -1 -1 -6 -1 1 1 1\n0 -1 18 -1 2 0 -1 2\n-11 1 2 -1 0 2 -1 0", "output": "2.0000000000\n1.0000000000\n0.5322001449\n"}, {"type": "stdin_stdout", "input": "3\n-1 -1 -1 -6 -1 1 1 1\n0 -1 18 -1 2 0 -1 2\n-11 1 3 -1 0 2 -1 0", "output": "2.0000000000\n1.0000000000\n0.4242640687\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules.\n\n* One number appears exactly once in the same column\n* A number a...
[{"type": "stdin_stdout", "input": "2\n-1 2 3 3 4 10 8 13 9\n6 5 1 7 39 9 1 2 3\n7 11 11 2 -1 3 2 5 8\n2 4 0 1 6 9 12 9 0\n0 8 7 8 9 1 2 1 4\n8 9 1 0 3 4 2 8 7\n1 4 5 8 7 8 9 1 3\n8 12 8 9 1 4 3 4 5\n12 0 2 3 4 0 13 7 0\n2 1 3 2 5 4 7 8 14\n4 5 6 7 8 9 0 1 3\n7 8 13 1 4 4 8 5 8\n2 6 4 8 6 7 8 9 1\n5 6 12 8 9 1 2 6 3\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes...
[{"type": "stdin_stdout", "input": "138 245 30\n3 5 6 8 9 13 15 16 19 20 24 25 27 29 30 32 33 34 35 36 37 38 40 42 47 51 52 53 55 56 58 59 63 66 67 68 69 72 73 74 75 77 78 80 81 82 85 86 87 89 91 93 95 96 99 100 102 104 105 108 110 111 112 117 122 124 125 128 129 131 133 136 139 144 145 146 147 148 149 151 153 155 156 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so tha...
[{"type": "stdin_stdout", "input": "80 4\n71 49 41 21 72 71 37 14 51 59 73 11 70 15 36 46 32 57 58 15 72 67 16 75 70 11 67 3 40 36 2 9 63 68 32 22 63 52 67 55 35 19 72 59 22 19 44 55 59 74 4 34 53 3 22 57 32 27 78 12 71 4 26 15 43 21 79 10 67 39 34 74 38 26 31 78 2 78 69 42\n", "output": "62\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe robot is placed in the top left corner of a grid, consisting of $n$ rows and $m$ columns, in a cell $(1, 1)$.\n\nIn one step, it can move into a cell, adjacent by a side to the current one:\n\n$(x, y) \\rightarrow (x,...
[{"type": "stdin_stdout", "input": "3\n2 3 1 3 0\n2 3 1 3 1\n5 5 3 4 1\n", "output": "3\n-1\n8\n"}, {"type": "stdin_stdout", "input": "2\n3 5 2 3 1\n5 3 3 2 1\n", "output": "-1\n-1\n"}, {"type": "stdin_stdout", "input": "2\n2 3 1 3 0\n2 3 1 3 1\n", "output": "3\n-1\n"}, {"type": "stdin_stdout", "input": "2\n3 3 2 2 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters. \n\nSuitability of string s is calculated by following metric:\n\nAny two letters can be swapped positions, th...
[{"type": "stdin_stdout", "input": "ccaaa?bc?baccbccccbca?cccab??aacccbaac?bccacc?accccaccbcbbcbc\ncbaaacccc\n", "output": "ccaaaabcabaccbccccbcaacccabaaaacccbaaczbccacczaccccaccbcbbcbc\n"}, {"type": "stdin_stdout", "input": "ccaaa?bc?baccbccccbca?cccab??aacccbaac?bccacc?accccaccbcbbcbc\ncbaaacccc\n", "output": "ccaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHarry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is ...
[{"type": "stdin_stdout", "input": "2\n10\n10\n", "output": "200\n"}, {"type": "stdin_stdout", "input": "2\n19\n10\n", "output": "380\n"}, {"type": "stdin_stdout", "input": "2\n4\n18\n", "output": "144\n"}, {"type": "stdin_stdout", "input": "2\n6\n18\n", "output": "216\n"}, {"type": "stdin_stdout", "input": "2\n6\n23\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with an...
[{"type": "stdin_stdout", "input": "95 97575868 5\n4612 1644 3613 5413 5649 2419 5416 3926 4610 4419 2796 5062 2112 1071 3790 4220 3955 2142 4638 2832 2702 2115 2045 4085 3599 2452 5495 4767 1368 2344 4625 4132 5755 5815 2581 6259 1330 4938 815 5430 1628 3108 4342 3692 2928 1941 3714 4498 4471 4842 1822 867 3395 2587 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Metropolis computer network consists of n servers, each has an encryption key in the range from 0 to 2^k - 1 assigned to it. Let c_i be the encryption key assigned to the i-th server. Additionally, m pairs of servers ...
[{"type": "stdin_stdout", "input": "10 40 10\n838 215 738 782 183 422 127 283 103 129\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 3\n3 5\n3 6\n3 7\n3 8\n3 9\n3 10\n4 5\n4 6\n4 7\n4 9\n4 10\n5 7\n5 8\n5 9\n5 10\n6 7\n6 8\n6 9\n6 10\n7 9\n7 10\n8 10\n9 10\n", "output": "1028608\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe student council has a shared document file. Every day, some members of the student council write the sequence TMT (short for Towa Maji Tenshi) in it.\n\nHowever, one day, the members somehow entered the sequence into ...
[{"type": "stdin_stdout", "input": "5\n3\nTMT\n3\nTMT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n", "output": "YES\nYES\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n", "output": "\nYES\nNO\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "5\n3\nTMT\n3\nMTT\n6\nTMT...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements...
[{"type": "stdin_stdout", "input": "56\n-157 136 457 598 -138 -586 -338 752 -566 -718 -333 -965 309 -125 -938 -188 -390 17 -75 -902 -320 163 820 -970 -525 -329 81 488 -412 978 138 344 305 -358 -273 -967 253 -665 -245 187 602 252 -825 -511 828 764 -402 278 995 541 542 549 612 -536 527 -884 225 800 160 -409 -926 -795 -32...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ people who want to participate in a boat competition. The weight of the $i$-th participant is $w_i$. Only teams consisting of two people can participate in this competition. As an organizer, you think that i...
[{"type": "stdin_stdout", "input": "4\n14\n2 6 5 9 5 8 13 14 12 5 6 14 5 2\n36\n15 22 27 14 23 36 10 17 33 21 18 22 3 4 32 24 8 19 36 22 17 11 24 10 33 4 30 6 2 17 11 16 18 1 2 20\n2\n2 2\n12\n4 9 10 6 1 9 5 8 12 9 9 12\n", "output": "3\n11\n1\n4\n"}, {"type": "stdin_stdout", "input": "4\n14\n2 6 5 9 5 8 13 14 12 5 6 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice has a string $s$. She really likes the letter \"a\". She calls a string good if strictly more than half of the characters in that string are \"a\"s. For example \"aaabb\", \"axaa\" are good strings, and \"baca\", \"...
[{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "ababababababababababababababababababababababababav\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs their story unravels, a timeless tale is told once again...\n\nShirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with ...
[{"type": "stdin_stdout", "input": "5\n7\n?R???BR\n7\n???R???\n1\n?\n1\nB\n10\n?R??RB??B?\n", "output": "BRBRBBR\nBRBRBRB\nR\nB\nBRBRRBRBBR\n"}, {"type": "stdin_stdout", "input": "5\n7\n?R???BR\n7\n???R???\n1\n?\n1\nB\n10\n?R??RB??B?\n", "output": "BRBRBBR\nBRBRBRB\nB\nB\nBRBRRBRBBR\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou want to go on a trip with a friend. However, friends who have a habit of spending money cannot easily save travel expenses. I don't know when my friends will go on a trip if they continue their current lives. So, if y...
[{"type": "stdin_stdout", "input": "10000\n1225 3150\n861 12737\n0 -1\n5000 1050\n5000 4211\n5000 412\n5000 5000\n5000 5000\n-1 -1\n5075 1951\n9143 2494\n5000 2100\n29170\n100000 000000\n100010 110000\n100000 100000\n100000 100000\n100100 100100\n100000 111000\n100000 100000\n101000 100000\n100000 100010\n100000 100000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, Norge found a string $s = s_1 s_2 \\ldots s_n$ consisting of $n$ lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string $s$. Yes, all $\\frac{n (n + ...
[{"type": "stdin_stdout", "input": "200 13\nvgfjhgkgwkftaeqejmbgildembgxdbskxfndwmcckjfkbeekxkgakmcjhclqsecpnkaigcxxhfghgegfadjktckftdhtifriemfifakygoesjfginnddjjklwiwlbjsgftwhtjdxmcadpvhaeddxwnmguwhetwbmffbmvdvuhecgjckddrbikgwkrfwfhdhqolidgkfm\na b c d e f g h i j k l m\n", "output": "578\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasha and Grisha like studying sets of positive integers.\n\nOne day Grisha has written a set A containing n different integers a_{i} on a blackboard. Now he asks Masha to create a set B containing n different integers b_...
[{"type": "stdin_stdout", "input": "1\n100\n74 14 24 45 22 9 49 78 79 20 60 1 31 91 32 39 90 5 42 57 30 58 64 68 12 11 86 8 3 38 76 17 98 26 85 92 56 65 89 66 36 87 23 67 13 48 15 47 81 73 117 50 34 93 82 44 77 69 96 100 41 19 35 16 88 27 99 40 62 95 70 18 46 21 53 59 37 6 61 71 2 4 52 28 97 25 29 51 7 33 80 83 72 10 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!\n\nA password is an array $a$ of $n$ positive integers. You apply the following...
[{"type": "stdin_stdout", "input": "80\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of round brackets since Famil Door loves string of brackets of length n...
[{"type": "stdin_stdout", "input": "1980 464\n))(()()))(((((((((()))))))(()(((()((()))()()())()))()))(()))))))(())((())))()())()((())())()())))(())()(()))(()())()((((()))())()(())))))(()()(()(((((()(()()))(((()))(())))))()())(())))))())()()((())))))))((()(())))))()()(()((()((()()))(()))(())(()))()((((())()()))))))()(()...
code_stdio